mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Remove support for multiple channels.
This commit is contained in:
@@ -66,12 +66,11 @@ static inline bool CheckStatus(JNIEnv *env, CS_Status status,
|
||||
|
||||
static jobject MakeJObject(JNIEnv *env, const cs::USBCameraInfo &info) {
|
||||
static jmethodID constructor = env->GetMethodID(
|
||||
usbCameraInfoCls, "<init>", "(ILjava/lang/String;Ljava/lang/String;I)V");
|
||||
usbCameraInfoCls, "<init>", "(ILjava/lang/String;Ljava/lang/String;)V");
|
||||
JLocal<jstring> path(env, MakeJString(env, info.path));
|
||||
JLocal<jstring> name(env, MakeJString(env, info.name));
|
||||
return env->NewObject(usbCameraInfoCls, constructor,
|
||||
static_cast<jint>(info.dev), path.obj(), name.obj(),
|
||||
static_cast<jint>(info.channels));
|
||||
static_cast<jint>(info.dev), path.obj(), name.obj());
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
@@ -303,13 +302,13 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_createHTTPSourc
|
||||
/*
|
||||
* Class: edu_wpi_cameraserver_CameraServerJNI
|
||||
* Method: createCvSource
|
||||
* Signature: (Ljava/lang/String;I)I
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_createCvSource
|
||||
(JNIEnv *env, jclass, jstring name, jint numChannels)
|
||||
(JNIEnv *env, jclass, jstring name)
|
||||
{
|
||||
CS_Status status;
|
||||
auto val = cs::CreateCvSource(JStringRef{env, name}, numChannels, &status);
|
||||
auto val = cs::CreateCvSource(JStringRef{env, name}, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -358,20 +357,6 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_getSourceLastF
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cameraserver_CameraServerJNI
|
||||
* Method: getSourceNumChannels
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_getSourceNumChannels
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
{
|
||||
CS_Status status;
|
||||
auto val = cs::GetSourceNumChannels(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cameraserver_CameraServerJNI
|
||||
* Method: isSourceConnected
|
||||
@@ -442,19 +427,6 @@ JNIEXPORT void JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_releaseSource
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cameraserver_CameraServerJNI
|
||||
* Method: notifySourceFrame
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_notifySourceFrame
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
{
|
||||
CS_Status status;
|
||||
cs::NotifySourceFrame(source, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cameraserver_CameraServerJNI
|
||||
* Method: notifySourceError
|
||||
@@ -651,33 +623,6 @@ JNIEXPORT void JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_releaseSink
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cameraserver_CameraServerJNI
|
||||
* Method: setSinkSourceChannel
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_setSinkSourceChannel
|
||||
(JNIEnv *env, jclass, jint sink, jint channel)
|
||||
{
|
||||
CS_Status status;
|
||||
cs::SetSinkSourceChannel(sink, channel, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cameraserver_CameraServerJNI
|
||||
* Method: sinkWaitForFrame
|
||||
* Signature: (I)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_sinkWaitForFrame
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status;
|
||||
auto val = cs::SinkWaitForFrame(sink, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cameraserver_CameraServerJNI
|
||||
* Method: getSinkError
|
||||
|
||||
@@ -95,7 +95,7 @@ public class CameraServerJNI {
|
||||
public static native int createUSBSourceDev(String name, int dev);
|
||||
public static native int createUSBSourcePath(String name, String path);
|
||||
public static native int createHTTPSource(String name, String url);
|
||||
public static native int createCvSource(String name, int numChannels);
|
||||
public static native int createCvSource(String name);
|
||||
|
||||
//
|
||||
// Source Functions
|
||||
@@ -103,7 +103,6 @@ public class CameraServerJNI {
|
||||
public static native String getSourceName(int source);
|
||||
public static native String getSourceDescription(int source);
|
||||
public static native long getSourceLastFrameTime(int source);
|
||||
public static native int getSourceNumChannels(int source);
|
||||
public static native boolean isSourceConnected(int source);
|
||||
public static native int getSourceProperty(int source, String name);
|
||||
public static native int[] enumerateSourceProperties(int source);
|
||||
@@ -113,8 +112,6 @@ public class CameraServerJNI {
|
||||
//
|
||||
// OpenCV Source Functions
|
||||
//
|
||||
//public static native void putSourceImage(int source, int channel, CvMat image);
|
||||
public static native void notifySourceFrame(int source);
|
||||
//public static native void putSourceFrame(int source, CvMat image);
|
||||
public static native void notifySourceError(int source, String msg);
|
||||
public static native void setSourceConnected(int source, boolean connected);
|
||||
@@ -145,16 +142,9 @@ public class CameraServerJNI {
|
||||
public static native int copySink(int sink);
|
||||
public static native void releaseSink(int sink);
|
||||
|
||||
//
|
||||
// Server Sink (e.g. HTTP) Functions
|
||||
//
|
||||
public static native void setSinkSourceChannel(int sink, int channel);
|
||||
|
||||
//
|
||||
// OpenCV Sink Functions
|
||||
//
|
||||
public static native long sinkWaitForFrame(int sink);
|
||||
//public static native int getSinkImage(int sink, CvMat image);
|
||||
//public static native int grabSinkFrame(int sink, CvMat image);
|
||||
public static native String getSinkError(int sink);
|
||||
public static native void setSinkEnabled(int sink, boolean enabled);
|
||||
|
||||
@@ -30,22 +30,7 @@ public class CvSink extends VideoSink {
|
||||
// super(CameraServerJNI.createCvSinkCallback(name, processFrame));
|
||||
//}
|
||||
|
||||
/// Wait for the next frame. This is a blocking call.
|
||||
/// @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
/// message).
|
||||
public long waitForFrame() {
|
||||
return CameraServerJNI.sinkWaitForFrame(m_handle);
|
||||
}
|
||||
|
||||
/// Get an OpenCV image from the specified channel.
|
||||
/// @return False if image could not be obtained for some reason (e.g.
|
||||
/// channel out of range)
|
||||
//public boolean getImage(int channel, CvMat image) {
|
||||
// return CameraServerJNI.getSinkImage(m_handle, channel, image);
|
||||
//}
|
||||
|
||||
/// Wait for the next frame and get the image from channel 0. Equivalent
|
||||
/// to calling WaitForFrame() followed by GetImage(0, image).
|
||||
/// 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) {
|
||||
|
||||
@@ -9,33 +9,13 @@ package edu.wpi.cameraserver;
|
||||
|
||||
/// A source that represents a video camera.
|
||||
public class CvSource extends VideoSource {
|
||||
/// Create an OpenCV source with a single channel.
|
||||
/// @param name Source name (arbitrary unique identifier)
|
||||
public CvSource(String name) {
|
||||
super(CameraServerJNI.createCvSource(name, 1));
|
||||
}
|
||||
|
||||
/// Create an OpenCV source.
|
||||
/// @param name Source name (arbitrary unique identifier)
|
||||
/// @param numChannels Number of channels
|
||||
public CvSource(String name, int numChannels) {
|
||||
super(CameraServerJNI.createCvSource(name, numChannels));
|
||||
public CvSource(String name) {
|
||||
super(CameraServerJNI.createCvSource(name));
|
||||
}
|
||||
|
||||
/// Put an OpenCV image onto the specified channel.
|
||||
/// @param channel Channel number (range 0 to nChannels-1)
|
||||
/// @param image OpenCV image
|
||||
//public void putImage(int channel, Mat image);
|
||||
|
||||
/// Signal sinks connected to this source that all new channel images have
|
||||
/// been put to the stream and are ready to be read.
|
||||
public void notifyFrame() {
|
||||
CameraServerJNI.notifySourceFrame(m_handle);
|
||||
}
|
||||
|
||||
/// Put an OpenCV image onto channel 0 and notify sinks.
|
||||
/// This is identical in behavior to calling PutImage(0, image) followed by
|
||||
/// NotifyFrame().
|
||||
/// Put an OpenCV image and notify sinks.
|
||||
/// @param image OpenCV image
|
||||
//public void putFrame(Mat image);
|
||||
|
||||
|
||||
@@ -23,12 +23,4 @@ public class HTTPSink extends VideoSink {
|
||||
public HTTPSink(String name, int port) {
|
||||
this(name, "", port);
|
||||
}
|
||||
|
||||
/// Set what video channel should be served.
|
||||
/// MJPEG-HTTP can only serve a single channel of video.
|
||||
/// By default, channel 0 is served.
|
||||
/// @param channel video channel to serve to clients
|
||||
public void setSourceChannel(int channel) {
|
||||
CameraServerJNI.setSinkSourceChannel(m_handle, channel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,10 @@ package edu.wpi.cameraserver;
|
||||
|
||||
/// USB camera information
|
||||
public class USBCameraInfo {
|
||||
public USBCameraInfo(int dev, String path, String name, int channels) {
|
||||
public USBCameraInfo(int dev, String path, String name) {
|
||||
this.dev = dev;
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.channels = channels;
|
||||
}
|
||||
|
||||
/// Device number (e.g. N in '/dev/videoN' on Linux)
|
||||
@@ -22,7 +21,4 @@ public class USBCameraInfo {
|
||||
public String path;
|
||||
/// Vendor/model name of the camera as provided by the USB driver
|
||||
public String name;
|
||||
/// Number of channels the camera provides (usually 1, but some cameras such
|
||||
/// as stereo or depth cameras may provide multiple channels).
|
||||
public int channels;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,6 @@ public class VideoSource {
|
||||
return CameraServerJNI.getSourceLastFrameTime(m_handle);
|
||||
}
|
||||
|
||||
/// Get the number of channels this source provides.
|
||||
public int getNumChannels() {
|
||||
return CameraServerJNI.getSourceNumChannels(m_handle);
|
||||
}
|
||||
|
||||
/// Is the source currently connected to whatever is providing the images?
|
||||
public boolean isConnected() {
|
||||
return CameraServerJNI.isSourceConnected(m_handle);
|
||||
|
||||
Reference in New Issue
Block a user