Use Javadoc formatting for Java comments. (#66)

This commit is contained in:
Peter Johnson
2017-03-11 21:56:14 -08:00
committed by GitHub
parent b484cbba7c
commit 59133a7d93
14 changed files with 366 additions and 191 deletions

View File

@@ -7,7 +7,9 @@
package edu.wpi.cscore;
/// A source that represents an Axis IP camera.
/**
* A source that represents an Axis IP camera.
*/
public class AxisCamera extends HttpCamera {
private static String hostToUrl(String host) {
return "http://" + host + "/mjpg/video.mjpg";
@@ -21,16 +23,20 @@ public class AxisCamera extends HttpCamera {
return urls;
}
/// Create a source for an Axis IP camera.
/// @param name Source name (arbitrary unique identifier)
/// @param host Camera host IP or DNS name (e.g. "10.x.y.11")
/**
* Create a source for an Axis IP camera.
* @param name Source name (arbitrary unique identifier)
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
*/
public AxisCamera(String name, String host) {
super(name, hostToUrl(host), HttpCameraKind.kAxis);
}
/// Create a source for an Axis IP camera.
/// @param name Source name (arbitrary unique identifier)
/// @param hosts Array of Camera host IPs/DNS names
/**
* Create a source for an Axis IP camera.
* @param name Source name (arbitrary unique identifier)
* @param hosts Array of Camera host IPs/DNS names
*/
public AxisCamera(String name, String[] hosts) {
super(name, hostToUrl(hosts), HttpCameraKind.kAxis);
}

View File

@@ -9,12 +9,16 @@ package edu.wpi.cscore;
import org.opencv.core.Mat;
/// A sink for user code to accept video frames as OpenCV images.
/**
* A sink for user code to accept video frames as OpenCV images.
*/
public class CvSink extends VideoSink {
/// Create a sink for accepting OpenCV images.
/// WaitForFrame() must be called on the created sink to get each new
/// image.
/// @param name Source name (arbitrary unique identifier)
/**
* Create a sink for accepting OpenCV images.
* WaitForFrame() must be called on the created sink to get each new
* image.
* @param name Source name (arbitrary unique identifier)
*/
public CvSink(String name) {
super(CameraServerJNI.createCvSink(name));
}
@@ -32,48 +36,60 @@ public class CvSink extends VideoSink {
// super(CameraServerJNI.createCvSinkCallback(name, processFrame));
//}
/// Set sink description.
/// @param description Description
/**
* Set sink description.
* @param description Description
*/
public void setDescription(String description) {
CameraServerJNI.setSinkDescription(m_handle, description);
}
/// Wait for the next frame and get the image.
/// Times out (returning 0) after 0.225 seconds.
/// The provided image will have three 3-bit channels stored in BGR order.
/// @return Frame time, or 0 on error (call GetError() to obtain the error
/// message);
/**
* Wait for the next frame and get the image.
* Times out (returning 0) after 0.225 seconds.
* The provided image will have three 3-bit channels stored in BGR order.
* @return Frame time, or 0 on error (call GetError() to obtain the error
* message)
*/
public long grabFrame(Mat image) {
return grabFrame(image, 0.225);
}
/// Wait for the next frame and get the image.
/// Times out (returning 0) after timeout seconds.
/// The provided image will have three 3-bit channels stored in BGR order.
/// @return Frame time, or 0 on error (call GetError() to obtain the error
/// message);
/**
* Wait for the next frame and get the image.
* Times out (returning 0) after timeout seconds.
* The provided image will have three 3-bit channels stored in BGR order.
* @return Frame time, or 0 on error (call GetError() to obtain the error
* message)
*/
public long grabFrame(Mat image, double timeout) {
return CameraServerJNI.grabSinkFrameTimeout(m_handle, image.nativeObj, timeout);
}
/// Wait for the next frame and get the image. May block forever.
/// The provided image will have three 3-bit channels stored in BGR order.
/// @return Frame time, or 0 on error (call GetError() to obtain the error
/// message);
/**
* Wait for the next frame and get the image. May block forever.
* The provided image will have three 3-bit channels stored in BGR order.
* @return Frame time, or 0 on error (call GetError() to obtain the error
* message)
*/
public long grabFrameNoTimeout(Mat image) {
return CameraServerJNI.grabSinkFrame(m_handle, image.nativeObj);
}
/// Get error string. Call this if WaitForFrame() returns 0 to determine
/// what the error is.
/**
* Get error string. Call this if WaitForFrame() returns 0 to determine
* what the error is.
*/
public String getError() {
return CameraServerJNI.getSinkError(m_handle);
}
/// Enable or disable getting new frames.
/// Disabling will cause processFrame (for callback-based CvSinks) to not
/// be called and WaitForFrame() to not return. This can be used to save
/// processor resources when frames are not needed.
/**
* Enable or disable getting new frames.
* Disabling will cause processFrame (for callback-based CvSinks) to not
* be called and WaitForFrame() to not return. This can be used to save
* processor resources when frames are not needed.
*/
public void setEnabled(boolean enabled) {
CameraServerJNI.setSinkEnabled(m_handle, enabled);
}

View File

@@ -9,61 +9,77 @@ package edu.wpi.cscore;
import org.opencv.core.Mat;
/// A source that represents a video camera.
/**
* A source that represents a video camera.
*/
public class CvSource extends VideoSource {
/// Create an OpenCV source.
/// @param name Source name (arbitrary unique identifier)
/// @param mode Video mode being generated
/**
* Create an OpenCV source.
* @param name Source name (arbitrary unique identifier)
* @param mode Video mode being generated
*/
public CvSource(String name, VideoMode mode) {
super(CameraServerJNI.createCvSource(name, mode.pixelFormat.getValue(), mode.width, mode.height, mode.fps));
}
/// Create an OpenCV source.
/// @param name Source name (arbitrary unique identifier)
/// @param pixelFormat Pixel format
/// @param width width
/// @param height height
/// @param fps fps
/**
* Create an OpenCV source.
* @param name Source name (arbitrary unique identifier)
* @param pixelFormat Pixel format
* @param width width
* @param height height
* @param fps fps
*/
public CvSource(String name, VideoMode.PixelFormat pixelFormat, int width, int height, int fps) {
super(CameraServerJNI.createCvSource(name, pixelFormat.getValue(), width, height, fps));
}
/// Put an OpenCV image and notify sinks.
/// Only 8-bit single-channel or 3-channel (with BGR channel order) images
/// are supported. If the format, depth or channel order is different, use
/// Mat.convertTo() and/or cvtColor() to convert it first.
/// @param image OpenCV image
/**
* Put an OpenCV image and notify sinks.
* Only 8-bit single-channel or 3-channel (with BGR channel order) images
* are supported. If the format, depth or channel order is different, use
* Mat.convertTo() and/or cvtColor() to convert it first.
* @param image OpenCV 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.
/**
* Signal sinks that an error has occurred. This should be called instead
* of NotifyFrame when an error occurs.
*/
public void notifyError(String msg) {
CameraServerJNI.notifySourceError(m_handle, msg);
}
/// Set source connection status. Defaults to true.
/// @param connected True for connected, false for disconnected
/**
* Set source connection status. Defaults to true.
* @param connected True for connected, false for disconnected
*/
public void setConnected(boolean connected) {
CameraServerJNI.setSourceConnected(m_handle, connected);
}
/// Set source description.
/// @param description Description
/**
* Set source description.
* @param description Description
*/
public void setDescription(String description) {
CameraServerJNI.setSourceDescription(m_handle, description);
}
/// Create a property.
/// @param name Property name
/// @param kind Property kind
/// @param minimum Minimum value
/// @param maximum Maximum value
/// @param step Step value
/// @param defaultValue Default value
/// @param value Current value
/// @return Property
/**
* Create a property.
* @param name Property name
* @param kind Property kind
* @param minimum Minimum value
* @param maximum Maximum value
* @param step Step value
* @param defaultValue Default value
* @param value Current value
* @return Property
*/
public VideoProperty createProperty(String name, VideoProperty.Kind kind, int minimum, int maximum, int step, int defaultValue, int value) {
return new VideoProperty(
CameraServerJNI.createSourceProperty(m_handle, name, kind.getValue(), minimum, maximum, step, defaultValue, value));
@@ -84,9 +100,11 @@ public class CvSource extends VideoSource {
// std::function<void(VideoProperty property)>
// onChange);
/// Configure enum property choices.
/// @param property Property
/// @param choices Choices
/**
* Configure enum property choices.
* @param property Property
* @param choices Choices
*/
public void SetEnumPropertyChoices(VideoProperty property, String[] choices) {
CameraServerJNI.setSourceEnumPropertyChoices(m_handle, property.m_handle, choices);
}

View File

@@ -7,7 +7,9 @@
package edu.wpi.cscore;
/// A source that represents a MJPEG-over-HTTP (IP) camera.
/**
* A source that represents a MJPEG-over-HTTP (IP) camera.
*/
public class HttpCamera extends VideoCamera {
public enum HttpCameraKind {
kUnknown(0), kMJPGStreamer(1), kCSCore(2), kAxis(3);
@@ -31,49 +33,63 @@ public class HttpCamera extends VideoCamera {
}
}
/// Create a source for a MJPEG-over-HTTP (IP) camera.
/// @param name Source name (arbitrary unique identifier)
/// @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
/**
* Create a source for a MJPEG-over-HTTP (IP) camera.
* @param name Source name (arbitrary unique identifier)
* @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
*/
public HttpCamera(String name, String url) {
super(CameraServerJNI.createHttpCamera(name, url, HttpCameraKind.kUnknown.getValue()));
}
/// Create a source for a MJPEG-over-HTTP (IP) camera.
/// @param name Source name (arbitrary unique identifier)
/// @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
/// @param kind Camera kind (e.g. kAxis)
/**
* Create a source for a MJPEG-over-HTTP (IP) camera.
* @param name Source name (arbitrary unique identifier)
* @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
* @param kind Camera kind (e.g. kAxis)
*/
public HttpCamera(String name, String url, HttpCameraKind kind) {
super(CameraServerJNI.createHttpCamera(name, url, kind.getValue()));
}
/// Create a source for a MJPEG-over-HTTP (IP) camera.
/// @param name Source name (arbitrary unique identifier)
/// @param urls Array of Camera URLs
/**
* Create a source for a MJPEG-over-HTTP (IP) camera.
* @param name Source name (arbitrary unique identifier)
* @param urls Array of Camera URLs
*/
public HttpCamera(String name, String[] urls) {
super(CameraServerJNI.createHttpCameraMulti(name, urls, HttpCameraKind.kUnknown.getValue()));
}
/// Create a source for a MJPEG-over-HTTP (IP) camera.
/// @param name Source name (arbitrary unique identifier)
/// @param urls Array of Camera URLs
/// @param kind Camera kind (e.g. kAxis)
/**
* Create a source for a MJPEG-over-HTTP (IP) camera.
* @param name Source name (arbitrary unique identifier)
* @param urls Array of Camera URLs
* @param kind Camera kind (e.g. kAxis)
*/
public HttpCamera(String name, String[] urls, HttpCameraKind kind) {
super(CameraServerJNI.createHttpCameraMulti(name, urls, kind.getValue()));
}
/// Get the kind of HTTP camera.
/// Autodetection can result in returning a different value than the camera
/// was created with.
/**
* Get the kind of HTTP camera.
* Autodetection can result in returning a different value than the camera
* was created with.
*/
public HttpCameraKind getHttpCameraKind() {
return getHttpCameraKindFromInt(CameraServerJNI.getHttpCameraKind(m_handle));
}
/// Change the URLs used to connect to the camera.
/**
* Change the URLs used to connect to the camera.
*/
public void setUrls(String[] urls) {
CameraServerJNI.setHttpCameraUrls(m_handle, urls);
}
/// Get the URLs used to connect to the camera.
/**
* Get the URLs used to connect to the camera.
*/
public String[] getUrls() {
return CameraServerJNI.getHttpCameraUrls(m_handle);
}

View File

@@ -7,29 +7,39 @@
package edu.wpi.cscore;
/// A sink that acts as a MJPEG-over-HTTP network server.
/**
* A sink that acts as a MJPEG-over-HTTP network server.
*/
public class MjpegServer extends VideoSink {
/// Create a MJPEG-over-HTTP server sink.
/// @param name Sink name (arbitrary unique identifier)
/// @param listenAddress TCP listen address (empty string for all addresses)
/// @param port TCP port number
/**
* Create a MJPEG-over-HTTP server sink.
* @param name Sink name (arbitrary unique identifier)
* @param listenAddress TCP listen address (empty string for all addresses)
* @param port TCP port number
*/
public MjpegServer(String name, String listenAddress, int port) {
super(CameraServerJNI.createMjpegServer(name, listenAddress, port));
}
/// Create a MJPEG-over-HTTP server sink.
/// @param name Sink name (arbitrary unique identifier)
/// @param port TCP port number
/**
* Create a MJPEG-over-HTTP server sink.
* @param name Sink name (arbitrary unique identifier)
* @param port TCP port number
*/
public MjpegServer(String name, int port) {
this(name, "", port);
}
/// Get the listen address of the server.
/**
* Get the listen address of the server.
*/
public String getListenAddress() {
return CameraServerJNI.getMjpegServerListenAddress(m_handle);
}
/// Get the port number of the server.
/**
* Get the port number of the server.
*/
public int getPort() {
return CameraServerJNI.getMjpegServerPort(m_handle);
}

View File

@@ -7,29 +7,39 @@
package edu.wpi.cscore;
/// A source that represents a USB camera.
/**
* A source that represents a USB camera.
*/
public class UsbCamera extends VideoCamera {
/// Create a source for a USB camera based on device number.
/// @param name Source name (arbitrary unique identifier)
/// @param dev Device number (e.g. 0 for /dev/video0)
/**
* Create a source for a USB camera based on device number.
* @param name Source name (arbitrary unique identifier)
* @param dev Device number (e.g. 0 for /dev/video0)
*/
public UsbCamera(String name, int dev) {
super(CameraServerJNI.createUsbCameraDev(name, dev));
}
/// Create a source for a USB camera based on device path.
/// @param name Source name (arbitrary unique identifier)
/// @param path Path to device (e.g. "/dev/video0" on Linux)
/**
* Create a source for a USB camera based on device path.
* @param name Source name (arbitrary unique identifier)
* @param path Path to device (e.g. "/dev/video0" on Linux)
*/
public UsbCamera(String name, String path) {
super(CameraServerJNI.createUsbCameraPath(name, path));
}
/// Enumerate USB cameras on the local system.
/// @return Vector of USB camera information (one for each camera)
/**
* Enumerate USB cameras on the local system.
* @return Vector of USB camera information (one for each camera)
*/
public static UsbCameraInfo[] enumerateUsbCameras() {
return CameraServerJNI.enumerateUsbCameras();
}
/// Get the path to the device.
/**
* Get the path to the device.
*/
public String getPath() {
return CameraServerJNI.getUsbCameraPath(m_handle);
}

View File

@@ -7,7 +7,9 @@
package edu.wpi.cscore;
/// USB camera information
/**
* USB camera information
*/
public class UsbCameraInfo {
public UsbCameraInfo(int dev, String path, String name) {
this.dev = dev;
@@ -15,10 +17,18 @@ public class UsbCameraInfo {
this.name = name;
}
/// Device number (e.g. N in '/dev/videoN' on Linux)
/**
* Device number (e.g. N in '/dev/videoN' on Linux)
*/
public int dev;
/// Path to device if available (e.g. '/dev/video0' on Linux)
/**
* Path to device if available (e.g. '/dev/video0' on Linux)
*/
public String path;
/// Vendor/model name of the camera as provided by the USB driver
/**
* Vendor/model name of the camera as provided by the USB driver
*/
public String name;
}

View File

@@ -7,7 +7,9 @@
package edu.wpi.cscore;
/// A source that represents a video camera.
/**
* A source that represents a video camera.
*/
public class VideoCamera extends VideoSource {
public class WhiteBalance {
public static final int kFixedIndoor = 3000;
@@ -21,42 +23,58 @@ public class VideoCamera extends VideoSource {
super(handle);
}
/// Set the brightness, as a percentage (0-100).
/**
* Set the brightness, as a percentage (0-100).
*/
public synchronized void setBrightness(int brightness) {
CameraServerJNI.setCameraBrightness(m_handle, brightness);
}
/// Get the brightness, as a percentage (0-100).
/**
* Get the brightness, as a percentage (0-100).
*/
public synchronized int getBrightness() {
return CameraServerJNI.getCameraBrightness(m_handle);
}
/// Set the white balance to auto.
/**
* Set the white balance to auto.
*/
public synchronized void setWhiteBalanceAuto() {
CameraServerJNI.setCameraWhiteBalanceAuto(m_handle);
}
/// Set the white balance to hold current.
/**
* Set the white balance to hold current.
*/
public synchronized void setWhiteBalanceHoldCurrent() {
CameraServerJNI.setCameraWhiteBalanceHoldCurrent(m_handle);
}
/// Set the white balance to manual, with specified color temperature.
/**
* Set the white balance to manual, with specified color temperature.
*/
public synchronized void setWhiteBalanceManual(int value) {
CameraServerJNI.setCameraWhiteBalanceManual(m_handle, value);
}
/// Set the exposure to auto aperture.
/**
* Set the exposure to auto aperture.
*/
public synchronized void setExposureAuto() {
CameraServerJNI.setCameraExposureAuto(m_handle);
}
/// Set the exposure to hold current.
/**
* Set the exposure to hold current.
*/
public synchronized void setExposureHoldCurrent() {
CameraServerJNI.setCameraExposureHoldCurrent(m_handle);
}
/// Set the exposure to manual, as a percentage (0-100).
/**
* Set the exposure to manual, as a percentage (0-100).
*/
public synchronized void setExposureManual(int value) {
CameraServerJNI.setCameraExposureManual(m_handle, value);
}

View File

@@ -7,7 +7,9 @@
package edu.wpi.cscore;
/// Video event
/**
* Video event
*/
public class VideoEvent {
public enum Kind {
kUnknown(0x0000),

View File

@@ -7,7 +7,9 @@
package edu.wpi.cscore;
/// An exception raised by the camera server.
/**
* An exception raised by the camera server.
*/
public class VideoException extends RuntimeException {
public VideoException(String msg) {
super(msg);

View File

@@ -9,14 +9,18 @@ package edu.wpi.cscore;
import java.util.function.Consumer;
/// An event listener. This calls back to a desigated callback function when
/// an event matching the specified mask is generated by the library.
/**
* An event listener. This calls back to a desigated callback function when
* an event matching the specified mask is generated by the library.
*/
public class VideoListener {
/// Create an event listener.
/// @param listener Listener function
/// @param eventMask Bitmask of VideoEvent.Type values
/// @param immediateNotify Whether callback should be immediately called with
/// a representative set of events for the current library state.
/**
* Create an event listener.
* @param listener Listener function
* @param eventMask Bitmask of VideoEvent.Type values
* @param immediateNotify Whether callback should be immediately called with
* a representative set of events for the current library state.
*/
public VideoListener(Consumer<VideoEvent> listener, int eventMask,
boolean immediateNotify) {
m_handle = CameraServerJNI.addListener(listener, eventMask, immediateNotify);

View File

@@ -7,7 +7,9 @@
package edu.wpi.cscore;
/// Video mode
/**
* Video mode
*/
public class VideoMode {
public enum PixelFormat {
kUnknown(0), kMJPEG(1), kYUYV(2), kRGB565(3), kBGR(4), kGray(5);
@@ -41,12 +43,23 @@ public class VideoMode {
this.fps = fps;
}
/// Pixel format
/**
* Pixel format
*/
public PixelFormat pixelFormat;
/// Width in pixels
/**
* Width in pixels
*/
public int width;
/// Height in pixels
/**
* Height in pixels
*/
public int height;
/// Frames per second
/**
* Frames per second
*/
public int fps;
}

View File

@@ -7,9 +7,11 @@
package edu.wpi.cscore;
/// A source for video that provides a sequence of frames. Each frame may
/// consist of multiple images (e.g. from a stereo or depth camera); these
/// are called channels.
/**
* A source for video that provides a sequence of frames. Each frame may
* consist of multiple images (e.g. from a stereo or depth camera); these
* are called channels.
*/
public class VideoSink {
public enum Kind {
kUnknown(0), kMjpeg(2), kCv(4);
@@ -63,26 +65,34 @@ public class VideoSink {
return m_handle;
}
/// Get the kind of the sink.
/**
* Get the kind of the sink.
*/
public Kind getKind() {
return getKindFromInt(CameraServerJNI.getSinkKind(m_handle));
}
/// Get the name of the sink. The name is an arbitrary identifier
/// provided when the sink is created, and should be unique.
/**
* Get the name of the sink. The name is an arbitrary identifier
* provided when the sink is created, and should be unique.
*/
public String getName() {
return CameraServerJNI.getSinkName(m_handle);
}
/// Get the sink description. This is sink-kind specific.
/**
* Get the sink description. This is sink-kind specific.
*/
public String getDescription() {
return CameraServerJNI.getSinkDescription(m_handle);
}
/// Configure which source should provide frames to this sink. Each sink
/// can accept frames from only a single source, but a single source can
/// provide frames to multiple clients.
/// @param source Source
/**
* Configure which source should provide frames to this sink. Each sink
* can accept frames from only a single source, but a single source can
* provide frames to multiple clients.
* @param source Source
*/
public void setSource(VideoSource source) {
if (source == null) {
CameraServerJNI.setSinkSource(m_handle, 0);
@@ -91,25 +101,31 @@ public class VideoSink {
}
}
/// Get the connected source.
/// @return Connected source; nullptr if no source connected.
/**
* Get the connected source.
* @return Connected source; nullptr if no source connected.
*/
public VideoSource getSource() {
// While VideoSource.free() will call releaseSource(), getSinkSource()
// increments the internal reference count so this is okay to do.
return new VideoSource(CameraServerJNI.getSinkSource(m_handle));
}
/// Get a property of the associated source.
/// @param name Property name
/// @return Property (kind Property::kNone if no property with
/// the given name exists or no source connected)
/**
* Get a property of the associated source.
* @param name Property name
* @return Property (kind Property::kNone if no property with
* the given name exists or no source connected)
*/
public VideoProperty getSourceProperty(String name) {
return new VideoProperty(
CameraServerJNI.getSinkSourceProperty(m_handle, name));
}
/// Enumerate all existing sinks.
/// @return Vector of sinks.
/**
* Enumerate all existing sinks.
* @return Vector of sinks.
*/
public static VideoSink[] enumerateSinks() {
int[] handles = CameraServerJNI.enumerateSinks();
VideoSink[] rv = new VideoSink[handles.length];

View File

@@ -7,9 +7,11 @@
package edu.wpi.cscore;
/// A source for video that provides a sequence of frames. Each frame may
/// consist of multiple images (e.g. from a stereo or depth camera); these
/// are called channels.
/**
* A source for video that provides a sequence of frames. Each frame may
* consist of multiple images (e.g. from a stereo or depth camera); these
* are called channels.
*/
public class VideoSource {
public enum Kind {
kUnknown(0), kUsb(1), kHttp(2), kCv(4);
@@ -64,41 +66,55 @@ public class VideoSource {
return m_handle;
}
/// Get the kind of the source.
/**
* Get the kind of the source.
*/
public Kind getKind() {
return getKindFromInt(CameraServerJNI.getSourceKind(m_handle));
}
/// Get the name of the source. The name is an arbitrary identifier
/// provided when the source is created, and should be unique.
/**
* Get the name of the source. The name is an arbitrary identifier
* provided when the source is created, and should be unique.
*/
public String getName() {
return CameraServerJNI.getSourceName(m_handle);
}
/// Get the source description. This is source-kind specific.
/**
* Get the source description. This is source-kind specific.
*/
public String getDescription() {
return CameraServerJNI.getSourceDescription(m_handle);
}
/// Get the last time a frame was captured.
/**
* Get the last time a frame was captured.
*/
public long getLastFrameTime() {
return CameraServerJNI.getSourceLastFrameTime(m_handle);
}
/// Is the source currently connected to whatever is providing the images?
/**
* Is the source currently connected to whatever is providing the images?
*/
public boolean isConnected() {
return CameraServerJNI.isSourceConnected(m_handle);
}
/// Get a property.
/// @param name Property name
/// @return Property contents (of kind Property::kNone if no property with
/// the given name exists)
/**
* Get a property.
* @param name Property name
* @return Property contents (of kind Property::kNone if no property with
* the given name exists)
*/
public VideoProperty getProperty(String name) {
return new VideoProperty(CameraServerJNI.getSourceProperty(m_handle, name));
}
/// Enumerate all properties of this source.
/**
* Enumerate all properties of this source.
*/
public VideoProperty[] enumerateProperties() {
int[] handles = CameraServerJNI.enumerateSourceProperties(m_handle);
VideoProperty[] rv = new VideoProperty[handles.length];
@@ -108,56 +124,72 @@ public class VideoSource {
return rv;
}
/// Get the current video mode.
/**
* Get the current video mode.
*/
public VideoMode getVideoMode() {
return CameraServerJNI.getSourceVideoMode(m_handle);
}
/// Set the video mode.
/// @param mode Video mode
/**
* Set the video mode.
* @param mode Video mode
*/
public boolean setVideoMode(VideoMode mode) {
return CameraServerJNI.setSourceVideoMode(m_handle, mode.pixelFormat.getValue(), mode.width, mode.height, mode.fps);
}
/// Set the video mode.
/// @param pixelFormat desired pixel format
/// @param width desired width
/// @param height desired height
/// @param fps desired FPS
/// @return True if set successfully
/**
* Set the video mode.
* @param pixelFormat desired pixel format
* @param width desired width
* @param height desired height
* @param fps desired FPS
* @return True if set successfully
*/
public boolean setVideoMode(VideoMode.PixelFormat pixelFormat, int width, int height, int fps) {
return CameraServerJNI.setSourceVideoMode(m_handle, pixelFormat.getValue(), width, height, fps);
}
/// Set the pixel format.
/// @param pixelFormat desired pixel format
/// @return True if set successfully
/**
* Set the pixel format.
* @param pixelFormat desired pixel format
* @return True if set successfully
*/
public boolean setPixelFormat(VideoMode.PixelFormat pixelFormat) {
return CameraServerJNI.setSourcePixelFormat(m_handle, pixelFormat.getValue());
}
/// Set the resolution.
/// @param width desired width
/// @param height desired height
/// @return True if set successfully
/**
* Set the resolution.
* @param width desired width
* @param height desired height
* @return True if set successfully
*/
public boolean setResolution(int width, int height) {
return CameraServerJNI.setSourceResolution(m_handle, width, height);
}
/// Set the frames per second (FPS).
/// @param fps desired FPS
/// @return True if set successfully
/**
* Set the frames per second (FPS).
* @param fps desired FPS
* @return True if set successfully
*/
public boolean setFPS(int fps) {
return CameraServerJNI.setSourceFPS(m_handle, fps);
}
/// Enumerate all known video modes for this source.
/**
* Enumerate all known video modes for this source.
*/
public VideoMode[] enumerateVideoModes() {
return CameraServerJNI.enumerateSourceVideoModes(m_handle);
}
/// Enumerate all sinks connected to this source.
/// @return Vector of sinks.
/**
* Enumerate all sinks connected to this source.
* @return Vector of sinks.
*/
public VideoSink[] enumerateSinks() {
int[] handles = CameraServerJNI.enumerateSourceSinks(m_handle);
VideoSink[] rv = new VideoSink[handles.length];
@@ -167,8 +199,10 @@ public class VideoSource {
return rv;
}
/// Enumerate all existing sources.
/// @return Vector of sources.
/**
* Enumerate all existing sources.
* @return Vector of sources.
*/
public static VideoSource[] enumerateSources() {
int[] handles = CameraServerJNI.enumerateSources();
VideoSource[] rv = new VideoSource[handles.length];