Add support for OpenCV to Java wrappers.

This commit is contained in:
Peter Johnson
2016-10-21 14:50:24 -07:00
parent 6641612de5
commit 017ec83ce3
5 changed files with 47 additions and 7 deletions

View File

@@ -116,7 +116,7 @@ public class CameraServerJNI {
//
// OpenCV Source Functions
//
//public static native void putSourceFrame(int source, CvMat image);
public static native void putSourceFrame(int source, long imageNativeObj);
public static native void notifySourceError(int source, String msg);
public static native void setSourceConnected(int source, boolean connected);
public static native int createSourceProperty(int source, String name, int type);
@@ -149,7 +149,7 @@ public class CameraServerJNI {
//
// OpenCV Sink Functions
//
//public static native int grabSinkFrame(int sink, CvMat image);
public static native long grabSinkFrame(int sink, long imageNativeObj);
public static native String getSinkError(int sink);
public static native void setSinkEnabled(int sink, boolean enabled);

View File

@@ -7,6 +7,8 @@
package edu.wpi.cameraserver;
import org.opencv.core.Mat;
/// A sink for user code to accept video frames as OpenCV images.
public class CvSink extends VideoSink {
/// Create a sink for accepting OpenCV images.
@@ -33,9 +35,9 @@ public class CvSink extends VideoSink {
/// Wait for the next frame and get the image.
/// @return Frame time, or 0 on error (call GetError() to obtain the error
/// message);
//public long grabFrame(CvMat image) {
// return CameraServerJNI.grabSinkFrame(m_handle, image);
//}
public long grabFrame(Mat image) {
return CameraServerJNI.grabSinkFrame(m_handle, image.nativeObj);
}
/// Get error string. Call this if WaitForFrame() returns 0 to determine
/// what the error is.

View File

@@ -7,6 +7,8 @@
package edu.wpi.cameraserver;
import org.opencv.core.Mat;
/// A source that represents a video camera.
public class CvSource extends VideoSource {
/// Create an OpenCV source.
@@ -28,7 +30,9 @@ public class CvSource extends VideoSource {
/// Put an OpenCV image and notify sinks.
/// @param image OpenCV image
//public void putFrame(Mat image);
public void putFrame(Mat image) {
CameraServerJNI.putSourceFrame(m_handle, image.nativeObj);
}
/// Signal sinks that an error has occurred. This should be called instead
/// of NotifyFrame when an error occurs.