Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV 4.5.1 with CUDA support #976

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/core.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ dependencies {
api(project(":annotation"))
annotationProcessor(project(":annotation"))
api(group = "com.google.code.findbugs", name = "jsr305", version = "3.0.1")
api(group = "org.bytedeco", name = "javacv", version = "1.3")
api(group = "org.bytedeco.javacpp-presets", name = "opencv", version = "3.4.3-1.4.3")
api(group = "org.bytedeco.javacpp-presets", name = "opencv", version = "3.4.3-1.4.3", classifier = if (withCuda) "$os-gpu" else os)
api(group = "org.bytedeco", name = "javacv", version = "1.5.5")
api(group = "org.bytedeco", name = "opencv-platform", version = "4.5.1-1.5.5")
api(group = "org.bytedeco", name = "opencv-platform-gpu", version = "4.5.1-1.5.5")
api(group = "org.bytedeco.javacpp-presets", name = "videoinput", version = "0.200-1.1", classifier = os)
api(group = "org.bytedeco.javacpp-presets", name = "ffmpeg", version = "0.200-1.3", classifier = os)
api(group = "org.bytedeco.javacpp-presets", name = "ffmpeg", version = "4.1-1.4.4", classifier = os)
api(group = "org.python", name = "jython", version = "2.7.0")
api(group = "com.thoughtworks.xstream", name = "xstream", version = "1.4.10")
api(group = "org.apache.commons", name = "commons-lang3", version = "3.5")
Expand Down
Binary file removed core/libs/opencv-3.0.0-1.1-linux-frc.jar
Binary file not shown.
40 changes: 20 additions & 20 deletions core/src/main/java/edu/wpi/grip/core/MatWrapper.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
package edu.wpi.grip.core;

import org.bytedeco.javacpp.opencv_core;
import org.bytedeco.javacpp.opencv_core.GpuMat;
import org.bytedeco.javacpp.opencv_core.Mat;
import org.bytedeco.javacpp.opencv_core.Size;
import org.bytedeco.opencv.opencv_core.Scalar;
import org.bytedeco.opencv.opencv_core.GpuMat;
import org.bytedeco.opencv.opencv_core.Mat;
import org.bytedeco.opencv.opencv_core.Size;

import java.util.Objects;
import java.util.function.Function;

import static org.bytedeco.javacpp.opencv_core.CV_16S;
import static org.bytedeco.javacpp.opencv_core.CV_16U;
import static org.bytedeco.javacpp.opencv_core.CV_32F;
import static org.bytedeco.javacpp.opencv_core.CV_32S;
import static org.bytedeco.javacpp.opencv_core.CV_64F;
import static org.bytedeco.javacpp.opencv_core.CV_8S;
import static org.bytedeco.javacpp.opencv_core.CV_8U;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_16S;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_16U;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_1U;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_32F;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_32S;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_64F;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_8S;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_8U;
import static org.bytedeco.opencv.global.opencv_core.CV_16S;
import static org.bytedeco.opencv.global.opencv_core.CV_16U;
import static org.bytedeco.opencv.global.opencv_core.CV_32F;
import static org.bytedeco.opencv.global.opencv_core.CV_32S;
import static org.bytedeco.opencv.global.opencv_core.CV_64F;
import static org.bytedeco.opencv.global.opencv_core.CV_8S;
import static org.bytedeco.opencv.global.opencv_core.CV_8U;
import static org.bytedeco.opencv.global.opencv_core.IPL_DEPTH_16S;
import static org.bytedeco.opencv.global.opencv_core.IPL_DEPTH_16U;
import static org.bytedeco.opencv.global.opencv_core.IPL_DEPTH_1U;
import static org.bytedeco.opencv.global.opencv_core.IPL_DEPTH_32F;
import static org.bytedeco.opencv.global.opencv_core.IPL_DEPTH_32S;
import static org.bytedeco.opencv.global.opencv_core.IPL_DEPTH_64F;
import static org.bytedeco.opencv.global.opencv_core.IPL_DEPTH_8S;
import static org.bytedeco.opencv.global.opencv_core.IPL_DEPTH_8U;

/**
* Wraps a GPU mat and a CPU mat and allows device memory and host memory
Expand Down Expand Up @@ -370,7 +370,7 @@ public void create(int rows, int cols, int type) {
*
* @param value Assigned scalar converted to the actual array type.
*/
public MatWrapper put(opencv_core.Scalar value) {
public MatWrapper put(Scalar value) {
if (isCpu()) {
cpuMat.put(value);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.wpi.grip.core.cuda;

import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.opencv_cudaarithm;
import org.bytedeco.opencv.global.opencv_cudaarithm;

/**
* Checks if CUDA is available by attempting to load one of the OpenCV CUDA class' JNI. If the JNI
Expand Down
75 changes: 38 additions & 37 deletions core/src/main/java/edu/wpi/grip/core/operations/CVOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,44 @@
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;

import org.bytedeco.javacpp.opencv_core.Point;
import org.bytedeco.javacpp.opencv_core.Scalar;
import org.bytedeco.javacpp.opencv_core.Size;
import org.bytedeco.javacpp.opencv_cudaarithm;
import org.bytedeco.javacpp.opencv_cudafilters.Filter;
import org.bytedeco.javacpp.opencv_cudaimgproc;
import org.bytedeco.javacpp.opencv_imgproc;

import static org.bytedeco.javacpp.opencv_core.absdiff;
import static org.bytedeco.javacpp.opencv_core.add;
import static org.bytedeco.javacpp.opencv_core.addWeighted;
import static org.bytedeco.javacpp.opencv_core.bitwise_and;
import static org.bytedeco.javacpp.opencv_core.bitwise_not;
import static org.bytedeco.javacpp.opencv_core.bitwise_or;
import static org.bytedeco.javacpp.opencv_core.bitwise_xor;
import static org.bytedeco.javacpp.opencv_core.compare;
import static org.bytedeco.javacpp.opencv_core.divide;
import static org.bytedeco.javacpp.opencv_core.extractChannel;
import static org.bytedeco.javacpp.opencv_core.flip;
import static org.bytedeco.javacpp.opencv_core.max;
import static org.bytedeco.javacpp.opencv_core.min;
import static org.bytedeco.javacpp.opencv_core.multiply;
import static org.bytedeco.javacpp.opencv_core.scaleAdd;
import static org.bytedeco.javacpp.opencv_core.subtract;
import static org.bytedeco.javacpp.opencv_core.transpose;
import static org.bytedeco.javacpp.opencv_cudafilters.createSobelFilter;
import static org.bytedeco.javacpp.opencv_imgproc.GaussianBlur;
import static org.bytedeco.javacpp.opencv_imgproc.Laplacian;
import static org.bytedeco.javacpp.opencv_imgproc.Sobel;
import static org.bytedeco.javacpp.opencv_imgproc.adaptiveThreshold;
import static org.bytedeco.javacpp.opencv_imgproc.applyColorMap;
import static org.bytedeco.javacpp.opencv_imgproc.cvtColor;
import static org.bytedeco.javacpp.opencv_imgproc.dilate;
import static org.bytedeco.javacpp.opencv_imgproc.medianBlur;
import static org.bytedeco.javacpp.opencv_imgproc.rectangle;
import static org.bytedeco.javacpp.opencv_imgproc.resize;
import static org.bytedeco.javacpp.opencv_imgproc.threshold;
import org.bytedeco.opencv.opencv_core.Point;
import org.bytedeco.opencv.opencv_core.Scalar;
import org.bytedeco.opencv.opencv_core.Size;
import org.bytedeco.opencv.global.opencv_cudaarithm;
import org.bytedeco.opencv.opencv_cudafilters.Filter;
import org.bytedeco.opencv.global.opencv_cudaimgproc;
import org.bytedeco.opencv.global.opencv_imgproc;

import static org.bytedeco.opencv.global.opencv_core.*;
//import static org.bytedeco.opencv.opencv_core.absdiff;
//import static org.bytedeco.opencv.opencv_core.add;
//import static org.bytedeco.opencv.opencv_core.addWeighted;
//import static org.bytedeco.opencv.opencv_core.bitwise_and;
//import static org.bytedeco.opencv.opencv_core.bitwise_not;
//import static org.bytedeco.opencv.opencv_core.bitwise_or;
//import static org.bytedeco.opencv.opencv_core.bitwise_xor;
//import static org.bytedeco.opencv.opencv_core.compare;
//import static org.bytedeco.opencv.opencv_core.divide;
//import static org.bytedeco.opencv.opencv_core.extractChannel;
//import static org.bytedeco.opencv.opencv_core.flip;
//import static org.bytedeco.opencv.opencv_core.max;
//import static org.bytedeco.opencv.opencv_core.min;
//import static org.bytedeco.opencv.opencv_core.multiply;
//import static org.bytedeco.opencv.opencv_core.scaleAdd;
//import static org.bytedeco.opencv.opencv_core.subtract;
//import static org.bytedeco.opencv.opencv_core.transpose;
//import static org.bytedeco.opencv.opencv_cudafilters.createSobelFilter;
//import static org.bytedeco.opencv.opencv_imgproc.GaussianBlur;
//import static org.bytedeco.opencv.opencv_imgproc.Laplacian;
//import static org.bytedeco.opencv.opencv_imgproc.Sobel;
//import static org.bytedeco.opencv.opencv_imgproc.adaptiveThreshold;
//import static org.bytedeco.opencv.opencv_imgproc.applyColorMap;
//import static org.bytedeco.opencv.opencv_imgproc.cvtColor;
//import static org.bytedeco.opencv.opencv_imgproc.dilate;
//import static org.bytedeco.opencv.opencv_imgproc.medianBlur;
//import static org.bytedeco.opencv.opencv_imgproc.rectangle;
//import static org.bytedeco.opencv.opencv_imgproc.resize;
//import static org.bytedeco.opencv.opencv_imgproc.threshold;
GrantPerkins marked this conversation as resolved.
Show resolved Hide resolved

/**
* A list of all of the raw opencv operations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import edu.wpi.grip.core.sockets.SocketHint;
import edu.wpi.grip.core.sockets.SocketHints;

import org.bytedeco.javacpp.opencv_core.GpuMat;
import org.bytedeco.javacpp.opencv_core.Mat;
import org.bytedeco.opencv.opencv_core.GpuMat;
import org.bytedeco.opencv.opencv_core.Mat;

/**
* A partial implementation of Operation that has the option to use CUDA acceleration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;

import org.bytedeco.javacpp.opencv_core.GpuMat;
import org.bytedeco.javacpp.opencv_cudaimgproc;
import org.bytedeco.opencv.opencv_core.GpuMat;
import org.bytedeco.opencv.global.opencv_cudaimgproc;

import java.util.List;

import static org.bytedeco.javacpp.opencv_core.CV_8UC3;
import static org.bytedeco.javacpp.opencv_core.CV_8UC4;
import static org.bytedeco.javacpp.opencv_core.Size;
import static org.bytedeco.javacpp.opencv_cudafilters.Filter;
import static org.bytedeco.javacpp.opencv_cudafilters.createGaussianFilter;
import static org.bytedeco.javacpp.opencv_imgproc.CV_BGR2BGRA;
import static org.bytedeco.javacpp.opencv_imgproc.CV_BGRA2BGR;
import static org.bytedeco.javacpp.opencv_imgproc.GaussianBlur;
import static org.bytedeco.javacpp.opencv_imgproc.bilateralFilter;
import static org.bytedeco.javacpp.opencv_imgproc.blur;
import static org.bytedeco.javacpp.opencv_imgproc.medianBlur;
import static org.bytedeco.opencv.global.opencv_core.CV_8UC3;
import static org.bytedeco.opencv.global.opencv_core.CV_8UC4;
import org.bytedeco.opencv.opencv_core.Size;
import org.bytedeco.opencv.opencv_cudafilters.Filter;
import static org.bytedeco.opencv.global.opencv_cudafilters.createGaussianFilter;
import static org.bytedeco.opencv.global.opencv_imgproc.CV_BGR2BGRA;
import static org.bytedeco.opencv.global.opencv_imgproc.CV_BGRA2BGR;
import static org.bytedeco.opencv.global.opencv_imgproc.GaussianBlur;
import static org.bytedeco.opencv.global.opencv_imgproc.bilateralFilter;
import static org.bytedeco.opencv.global.opencv_imgproc.blur;
import static org.bytedeco.opencv.global.opencv_imgproc.medianBlur;

/**
* An {@link Operation} that softens an image using one of several different filters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import org.bytedeco.javacpp.opencv_cudaimgproc.CannyEdgeDetector;
import org.bytedeco.opencv.opencv_cudaimgproc.CannyEdgeDetector;

import java.util.List;

import static org.bytedeco.javacpp.opencv_cudaimgproc.createCannyEdgeDetector;
import static org.bytedeco.javacpp.opencv_imgproc.Canny;
import static org.bytedeco.opencv.global.opencv_cudaimgproc.createCannyEdgeDetector;
import static org.bytedeco.opencv.global.opencv_imgproc.Canny;

/**
* An operation that performs canny edge detection on an image.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;

import org.bytedeco.javacpp.opencv_core.Mat;
import org.bytedeco.javacpp.opencv_core.Rect;
import org.bytedeco.javacpp.opencv_core.RectVector;
import org.bytedeco.javacpp.opencv_core.Size;
import org.bytedeco.javacpp.opencv_objdetect.CascadeClassifier;
import org.bytedeco.opencv.opencv_core.Mat;
import org.bytedeco.opencv.opencv_core.Rect;
import org.bytedeco.opencv.opencv_core.RectVector;
import org.bytedeco.opencv.opencv_core.Size;
import org.bytedeco.opencv.opencv_objdetect.CascadeClassifier;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import java.util.List;
import java.util.Optional;

import static org.bytedeco.javacpp.opencv_core.Mat;
import static org.bytedeco.javacpp.opencv_core.MatVector;
import static org.bytedeco.javacpp.opencv_core.Rect;
import static org.bytedeco.javacpp.opencv_imgproc.boundingRect;
import static org.bytedeco.javacpp.opencv_imgproc.contourArea;
import static org.bytedeco.javacpp.opencv_imgproc.convexHull;
import org.bytedeco.opencv.opencv_core.Mat;
import org.bytedeco.opencv.opencv_core.MatVector;
import org.bytedeco.opencv.opencv_core.Rect;
import static org.bytedeco.opencv.global.opencv_imgproc.boundingRect;
import static org.bytedeco.opencv.global.opencv_imgproc.contourArea;
import static org.bytedeco.opencv.global.opencv_imgproc.convexHull;

/**
* The output of {@link FindContoursOperation}. This stores a list of contours (which is basically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import java.util.List;

import static org.bytedeco.javacpp.opencv_core.MatVector;
import static org.bytedeco.javacpp.opencv_imgproc.convexHull;
import org.bytedeco.opencv.opencv_core.MatVector;
import static org.bytedeco.opencv.global.opencv_imgproc.convexHull;

/**
* An {@link Operation} that finds the convex hull of each of a list of contours. This can help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.List;

import static org.bytedeco.javacpp.opencv_core.Rect;
import org.bytedeco.opencv.opencv_core.Rect;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;

import org.bytedeco.javacpp.opencv_cudaimgproc;
import org.bytedeco.opencv.global.opencv_cudaimgproc;

import java.util.List;

import static org.bytedeco.javacpp.opencv_imgproc.COLOR_BGR2GRAY;
import static org.bytedeco.javacpp.opencv_imgproc.COLOR_BGRA2GRAY;
import static org.bytedeco.javacpp.opencv_imgproc.cvtColor;
import static org.bytedeco.opencv.global.opencv_imgproc.COLOR_BGR2GRAY;
import static org.bytedeco.opencv.global.opencv_imgproc.COLOR_BGRA2GRAY;
import static org.bytedeco.opencv.global.opencv_imgproc.cvtColor;

/**
* An {@link Operation} that converts a color image into shades of gray.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;

import org.bytedeco.javacpp.opencv_core.Mat;
import org.bytedeco.opencv.opencv_core.Mat;

import java.util.List;

import static org.bytedeco.javacpp.opencv_core.CV_8U;
import static org.bytedeco.javacpp.opencv_imgproc.CV_DIST_C;
import static org.bytedeco.javacpp.opencv_imgproc.CV_DIST_L1;
import static org.bytedeco.javacpp.opencv_imgproc.CV_DIST_L2;
import static org.bytedeco.javacpp.opencv_imgproc.distanceTransform;
import static org.bytedeco.opencv.global.opencv_core.CV_8U;
import static org.bytedeco.opencv.global.opencv_imgproc.CV_DIST_C;
import static org.bytedeco.opencv.global.opencv_imgproc.CV_DIST_L1;
import static org.bytedeco.opencv.global.opencv_imgproc.CV_DIST_L2;
import static org.bytedeco.opencv.global.opencv_imgproc.distanceTransform;

/**
* GRIP {@link Operation} for {@link org.bytedeco.javacpp.opencv_imgproc#distanceTransform}.
* GRIP {@link Operation} for {@link org.bytedeco.opencv.global.opencv_imgproc#distanceTransform}.
*/
@Description(name = "Distance Transform",
summary = "Sets the values of pixels in a binary image to their distance to"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

import java.util.List;

import static org.bytedeco.javacpp.opencv_core.Mat;
import static org.bytedeco.javacpp.opencv_core.MatVector;
import static org.bytedeco.javacpp.opencv_core.Rect;
import static org.bytedeco.javacpp.opencv_imgproc.arcLength;
import static org.bytedeco.javacpp.opencv_imgproc.boundingRect;
import static org.bytedeco.javacpp.opencv_imgproc.contourArea;
import static org.bytedeco.javacpp.opencv_imgproc.convexHull;
import org.bytedeco.opencv.opencv_core.Mat;
import org.bytedeco.opencv.opencv_core.MatVector;
import org.bytedeco.opencv.opencv_core.Rect;
import static org.bytedeco.opencv.global.opencv_imgproc.arcLength;
import static org.bytedeco.opencv.global.opencv_imgproc.boundingRect;
import static org.bytedeco.opencv.global.opencv_imgproc.contourArea;
import static org.bytedeco.opencv.global.opencv_imgproc.convexHull;

/**
* An {@link Operation} that takes in a list of contours and outputs a list of any contours in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import java.util.ArrayList;
import java.util.List;

import static org.bytedeco.javacpp.opencv_core.KeyPoint;
import static org.bytedeco.javacpp.opencv_core.KeyPointVector;
import static org.bytedeco.javacpp.opencv_core.Mat;
import static org.bytedeco.javacpp.opencv_features2d.SimpleBlobDetector;
import org.bytedeco.opencv.opencv_core.KeyPoint;
import org.bytedeco.opencv.opencv_core.KeyPointVector;
import org.bytedeco.opencv.opencv_core.Mat;
import org.bytedeco.opencv.opencv_features2d.SimpleBlobDetector;

/**
* Find groups of similar pixels in a color or grayscale image.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

import java.util.List;

import static org.bytedeco.javacpp.opencv_core.Mat;
import static org.bytedeco.javacpp.opencv_core.MatVector;
import static org.bytedeco.javacpp.opencv_imgproc.CV_CHAIN_APPROX_TC89_KCOS;
import static org.bytedeco.javacpp.opencv_imgproc.CV_RETR_EXTERNAL;
import static org.bytedeco.javacpp.opencv_imgproc.CV_RETR_LIST;
import static org.bytedeco.javacpp.opencv_imgproc.findContours;
import org.bytedeco.opencv.opencv_core.Mat;
import org.bytedeco.opencv.opencv_core.MatVector;
import static org.bytedeco.opencv.global.opencv_imgproc.CV_CHAIN_APPROX_TC89_KCOS;
import static org.bytedeco.opencv.global.opencv_imgproc.CV_RETR_EXTERNAL;
import static org.bytedeco.opencv.global.opencv_imgproc.CV_RETR_LIST;
import static org.bytedeco.opencv.global.opencv_imgproc.findContours;

/**
* An {@link Operation} that, given a binary image, produces a list of contours of all of the shapes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import java.util.ArrayList;
import java.util.List;

import static org.bytedeco.javacpp.opencv_core.Mat;
import static org.bytedeco.javacpp.opencv_imgproc.COLOR_BGR2GRAY;
import static org.bytedeco.javacpp.opencv_imgproc.LineSegmentDetector;
import static org.bytedeco.javacpp.opencv_imgproc.cvtColor;
import org.bytedeco.opencv.opencv_core.Mat;
import static org.bytedeco.opencv.global.opencv_imgproc.COLOR_BGR2GRAY;
import org.bytedeco.opencv.opencv_imgproc.LineSegmentDetector;
import static org.bytedeco.opencv.global.opencv_imgproc.cvtColor;

/**
* Find line segments in a color or grayscale image.
Expand Down
Loading