Package edu.wpi.first.cscore
Class CameraServerJNI
java.lang.Object
edu.wpi.first.cscore.CameraServerJNI
CameraServer JNI.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSets whether JNI should be loaded in the static block.static interfaceLogger functional interface.static enumTelemetry kind. -
Method Summary
Modifier and TypeMethodDescriptionstatic intaddListener(Consumer<VideoEvent> listener, int eventMask, boolean immediateNotify) Adds listener.static intaddPolledListener(int poller, int eventMask, boolean immediateNotify) Add polled listener.static voidcancelPollListener(int poller) Cancels poll listener.static intcopySink(int sink) Copies sink.static intcopySource(int source) Copies source.static intcreateHttpCamera(String name, String url, int kind) Creates an HTTP camera.static intcreateHttpCameraMulti(String name, String[] urls, int kind) Creates an HTTP camera from multiple URLs.static intCreates listener poller.static intcreateMjpegServer(String name, String listenAddress, int port) Creates an MJPEG server.static intcreateRawSink(String name, boolean isCv) Creates a raw sink.static intcreateRawSource(String name, boolean isCv, int pixelFormat, int width, int height, int fps) Creates a raw source.static intcreateSourceProperty(int source, String name, int kind, int minimum, int maximum, int step, int defaultValue, int value) Creates a source property.static intcreateUsbCameraDev(String name, int dev) Creates a new USB camera by device.static intcreateUsbCameraPath(String name, String path) Creates a new USB camera by path.static voiddestroyListenerPoller(int poller) Destroys listener poller.static int[]enumerateSinkProperties(int sink) Returns list of sink property handles.static int[]Returns list of sinks.static int[]enumerateSourceProperties(int source) Returns list of source property handles.static int[]Returns list of sources.static int[]enumerateSourceSinks(int source) Returns list of source sinks.static VideoMode[]enumerateSourceVideoModes(int source) Returns list of source's supported video modes.static UsbCameraInfo[]Returns list of USB cameras.static voidForce load the library.static intgetCameraBrightness(int source) Returns camera brightness.static String[]getEnumPropertyChoices(int property) Returns enum of possible property value strings.static StringReturns hostname.static intgetHttpCameraKind(int source) Returns HTTP camera kind.static String[]getHttpCameraUrls(int source) Returns HTTP camera URLs.static StringgetMjpegServerListenAddress(int sink) Returns MJPEG server listen address.static intgetMjpegServerPort(int sink) Returns MJPEG server port.static String[]Returns list of network interfaces.static intgetProperty(int property) Returns property value.static intgetPropertyDefault(int property) Returns property default value.static intgetPropertyKind(int property) Returns property kind.static intgetPropertyMax(int property) Returns property maximum.static intgetPropertyMin(int property) Returns property minimum.static StringgetPropertyName(int property) Returns property name.static intgetPropertyStep(int property) Returns property step.static StringgetSinkConfigJson(int sink) Returns sink configuration JSON.static StringgetSinkDescription(int sink) Returns sink description.static StringgetSinkError(int sink) Returns sink error message.static intgetSinkKind(int sink) Returns sink kind.static StringgetSinkName(int sink) Returns sink name.static intgetSinkProperty(int sink, String name) Returns sink property.static intgetSinkSource(int sink) Returns sink source.static intgetSinkSourceProperty(int sink, String name) Returns sink source property.static StringgetSourceConfigJson(int source) Returns source configuration JSON.static StringgetSourceDescription(int source) Returns source description.static intgetSourceKind(int source) Returns source kind.static longgetSourceLastFrameTime(int source) Returns source's last frame time.static StringgetSourceName(int source) Returns source name.static intgetSourceProperty(int source, String name) Returns source property.static VideoModegetSourceVideoMode(int source) Returns source video mode.static StringgetStringProperty(int property) Returns property value as a string.static doublegetTelemetryAverageValue(int handle, int kind) Returns telemetry average value.static doublegetTelemetryAverageValue(int handle, CameraServerJNI.TelemetryKind kind) Returns telemetry average value.static doubleReturns telemetry elapsed time.static longgetTelemetryValue(int handle, int kind) Returns telemetry value.static longgetTelemetryValue(int handle, CameraServerJNI.TelemetryKind kind) Returns telemetry value.static UsbCameraInfogetUsbCameraInfo(int source) Returns USB camera info.static StringgetUsbCameraPath(int source) Returns USB camera path.static longgrabRawSinkFrame(int sink, RawFrame frame, long nativeObj) Returns raw sink frame.static longgrabRawSinkFrameTimeout(int sink, RawFrame frame, long nativeObj, double timeout) Returns raw sink frame timeout.static booleanisSourceConnected(int source) Returns true if source is connected.static booleanisSourceEnabled(int source) Returns true if source is enabled.static voidnotifySourceError(int source, String msg) Notify source error.static VideoEvent[]pollListener(int poller) Polls listener.static VideoEvent[]pollListenerTimeout(int poller, double timeout) Polls listener with timeout.static voidputRawSourceFrame(int source, long frame) Puts raw frame into source.static voidputRawSourceFrameBB(int source, ByteBuffer data, int size, int width, int height, int stride, int pixelFormat) Puts raw frame into source.static voidputRawSourceFrameData(int source, long data, int size, int width, int height, int stride, int pixelFormat) Puts raw frame into source.static voidreleaseSink(int sink) Releases sink.static voidreleaseSource(int source) Releases source.static voidremoveListener(int handle) Removes listener.static voidRuns main run loop.static intrunMainRunLoopTimeout(double timeoutSeconds) Runs main run loop with timeout.static voidsetCameraBrightness(int source, int brightness) Sets camera brightness.static voidsetCameraExposureAuto(int source) Sets camera exposure to auto.static voidsetCameraExposureHoldCurrent(int source) Sets camera exposure to "hold current".static voidsetCameraExposureManual(int source, int value) Sets camera exposure to the given value.static voidsetCameraWhiteBalanceAuto(int source) Sets camera white balance to auto.static voidsetCameraWhiteBalanceHoldCurrent(int source) Sets camera white balance to "hold current".static voidsetCameraWhiteBalanceManual(int source, int value) Sets camera white balance to the given value.static voidsetHttpCameraUrls(int source, String[] urls) Sets HTTP camera URLs.static voidsetLogger(CameraServerJNI.LoggerFunction func, int minLevel) Sets logger.static voidsetProperty(int property, int value) Sets property value.static booleansetSinkConfigJson(int sink, String config) Sets sink configuration JSON.static voidsetSinkDescription(int sink, String description) Sets sink description.static voidsetSinkEnabled(int sink, boolean enabled) Sets sink enable.static voidsetSinkSource(int sink, int source) Sets sink source.static booleansetSourceConfigJson(int source, String config) Sets source configuration JSON.static voidsetSourceConnected(int source, boolean connected) Sets whether source is connected.static voidsetSourceConnectionStrategy(int source, int strategy) Sets source connection strategy.static voidsetSourceDescription(int source, String description) Sets source description.static voidsetSourceEnumPropertyChoices(int source, int property, String[] choices) Sets list of possible property values.static booleansetSourceFPS(int source, int fps) Sets source FPS.static booleansetSourcePixelFormat(int source, int pixelFormat) Sets source pixel format.static booleansetSourceResolution(int source, int width, int height) Sets source resolution.static booleansetSourceVideoMode(int source, int pixelFormat, int width, int height, int fps) Sets source video mode.static voidsetStringProperty(int property, String value) Sets property value to a string.static voidsetTelemetryPeriod(double seconds) Sets telemetry period.static voidsetUsbCameraPath(int source, String path) Sets USB camera path.static voidStops main run loop.
-
Method Details
-
forceLoad
Force load the library.- Throws:
IOException- if library load failed
-
getPropertyKind
Returns property kind.- Parameters:
property- Property handle.- Returns:
- Property kind.
-
getPropertyName
Returns property name.- Parameters:
property- Property handle.- Returns:
- Property name.
-
getProperty
Returns property value.- Parameters:
property- Property handle.- Returns:
- Property value.
-
setProperty
Sets property value.- Parameters:
property- Property handle.value- Property value.
-
getPropertyMin
Returns property minimum.- Parameters:
property- Property handle.- Returns:
- Property minimum.
-
getPropertyMax
Returns property maximum.- Parameters:
property- Property handle.- Returns:
- Property maximum.
-
getPropertyStep
Returns property step.- Parameters:
property- Property handle.- Returns:
- Property step.
-
getPropertyDefault
Returns property default value.- Parameters:
property- Property handle.- Returns:
- Property default value.
-
getStringProperty
Returns property value as a string.- Parameters:
property- Property handle.- Returns:
- Property value as a string.
-
setStringProperty
Sets property value to a string.- Parameters:
property- Property handle.value- Property value string.
-
getEnumPropertyChoices
Returns enum of possible property value strings.- Parameters:
property- Property handle.- Returns:
- Enum of possible property value strings.
-
createUsbCameraDev
Creates a new USB camera by device.- Parameters:
name- USB camera name.dev- USB camera device number.- Returns:
- USB camera handle.
-
createUsbCameraPath
Creates a new USB camera by path.- Parameters:
name- USB camera name.path- USB camera path.- Returns:
- USB camera handle.
-
createHttpCamera
Creates an HTTP camera.- Parameters:
name- HTTP camera name.url- HTTP camera stream URL.kind- HTTP camera kind.- Returns:
- HTTP camera handle.
-
createHttpCameraMulti
Creates an HTTP camera from multiple URLs.- Parameters:
name- HTTP camera name.urls- HTTP camera stream URLs.kind- HTTP camera kind.- Returns:
- HTTP camera handle.
-
createRawSource
public static int createRawSource(String name, boolean isCv, int pixelFormat, int width, int height, int fps) Creates a raw source.- Parameters:
name- Source name.isCv- true for a Cv source.pixelFormat- Pixel format.width- Image width.height- Image height.fps- Source frames per second.- Returns:
- Raw source handle.
-
getSourceKind
Returns source kind.- Parameters:
source- Source handle.- Returns:
- Source kind.
-
getSourceName
Returns source name.- Parameters:
source- Source handle.- Returns:
- Source name.
-
getSourceDescription
Returns source description.- Parameters:
source- Source handle.- Returns:
- Source description.
-
getSourceLastFrameTime
Returns source's last frame time.- Parameters:
source- Source handle.- Returns:
- Source's last frame time.
-
setSourceConnectionStrategy
Sets source connection strategy.- Parameters:
source- Source handle.strategy- Connection strategy.
-
isSourceConnected
Returns true if source is connected.- Parameters:
source- Source handle.- Returns:
- True if source is connected.
-
isSourceEnabled
Returns true if source is enabled.- Parameters:
source- Source handle.- Returns:
- True if source is enabled.
-
getSourceProperty
Returns source property.- Parameters:
source- Source handle.name- Source property name.- Returns:
- Source property.
-
enumerateSourceProperties
Returns list of source property handles.- Parameters:
source- Source handle.- Returns:
- List of source property handles.
-
getSourceVideoMode
Returns source video mode.- Parameters:
source- Source handle.- Returns:
- Source video mode.
-
setSourceVideoMode
public static boolean setSourceVideoMode(int source, int pixelFormat, int width, int height, int fps) Sets source video mode.- Parameters:
source- Source handle.pixelFormat- Pixel format.width- Image width.height- Image height.fps- Source frames per second.- Returns:
- True if set succeeded.
-
setSourcePixelFormat
Sets source pixel format.- Parameters:
source- Source handle.pixelFormat- Source pixel format.- Returns:
- True if set succeeded.
-
setSourceResolution
Sets source resolution.- Parameters:
source- Source handle.width- Image width.height- Image height.- Returns:
- True if set succeeded.
-
setSourceFPS
Sets source FPS.- Parameters:
source- Source handle.fps- Source frames per second.- Returns:
- True if set succeeded.
-
setSourceConfigJson
Sets source configuration JSON.- Parameters:
source- Source handle.config- Configuration JSON.- Returns:
- True if set succeeded.
-
getSourceConfigJson
Returns source configuration JSON.- Parameters:
source- Source handle.- Returns:
- Source configuration JSON.
-
enumerateSourceVideoModes
Returns list of source's supported video modes.- Parameters:
source- Source handle.- Returns:
- List of source's supported video modes.
-
enumerateSourceSinks
Returns list of source sinks.- Parameters:
source- Source handle.- Returns:
- List of source sinks.
-
copySource
Copies source.- Parameters:
source- Source handle.- Returns:
- New source handle.
-
releaseSource
Releases source.- Parameters:
source- Source handle.
-
setCameraBrightness
Sets camera brightness.- Parameters:
source- Source handle.brightness- Brightness.
-
getCameraBrightness
Returns camera brightness.- Parameters:
source- Source handle.- Returns:
- Camera brightness.
-
setCameraWhiteBalanceAuto
Sets camera white balance to auto.- Parameters:
source- Source handle.
-
setCameraWhiteBalanceHoldCurrent
Sets camera white balance to "hold current".- Parameters:
source- Source handle.
-
setCameraWhiteBalanceManual
Sets camera white balance to the given value.- Parameters:
source- Source handle.value- White balance.
-
setCameraExposureAuto
Sets camera exposure to auto.- Parameters:
source- Source handle.
-
setCameraExposureHoldCurrent
Sets camera exposure to "hold current".- Parameters:
source- Source handle.
-
setCameraExposureManual
Sets camera exposure to the given value.- Parameters:
source- Source handle.value- Exposure.
-
setUsbCameraPath
Sets USB camera path.- Parameters:
source- Source handle.path- USB camera path.
-
getUsbCameraPath
Returns USB camera path.- Parameters:
source- Source handle.- Returns:
- USB camera path.
-
getUsbCameraInfo
Returns USB camera info.- Parameters:
source- Source handle.- Returns:
- USB camera info.
-
getHttpCameraKind
Returns HTTP camera kind.- Parameters:
source- Source handle.- Returns:
- HTTP camera kind.
-
setHttpCameraUrls
Sets HTTP camera URLs.- Parameters:
source- Source handle.urls- HTTP camera URLs.
-
getHttpCameraUrls
Returns HTTP camera URLs.- Parameters:
source- Source handle.- Returns:
- HTTP camera URLs.
-
putRawSourceFrame
Puts raw frame into source.- Parameters:
source- Source handle.frame- Frame handle.
-
putRawSourceFrameBB
public static void putRawSourceFrameBB(int source, ByteBuffer data, int size, int width, int height, int stride, int pixelFormat) Puts raw frame into source.- Parameters:
source- Source handle.data- Frame byte buffer.size- Frame size.width- Frame width.height- Frame height.stride- Frame stride.pixelFormat- Frame pixel format.
-
putRawSourceFrameData
public static void putRawSourceFrameData(int source, long data, int size, int width, int height, int stride, int pixelFormat) Puts raw frame into source.- Parameters:
source- Source handle.data- Frame handle.size- Frame size.width- Frame width.height- Frame height.stride- Frame stride.pixelFormat- Frame pixel format.
-
notifySourceError
Notify source error.- Parameters:
source- Source handle.msg- Error message.
-
setSourceConnected
Sets whether source is connected.- Parameters:
source- Source handle.connected- True if source is connected.
-
setSourceDescription
Sets source description.- Parameters:
source- Source handle.description- Source description.
-
createSourceProperty
public static int createSourceProperty(int source, String name, int kind, int minimum, int maximum, int step, int defaultValue, int value) Creates a source property.- Parameters:
source- Source handle.name- Property name.kind- Property kind.minimum- Property minimum.maximum- Property maximum.step- Property step.defaultValue- Property default value.value- Property value.- Returns:
- Source property handle.
-
setSourceEnumPropertyChoices
Sets list of possible property values.- Parameters:
source- Source handle.property- Property handle.choices- List of possible property values.
-
createMjpegServer
Creates an MJPEG server.- Parameters:
name- MJPEG server name.listenAddress- IP address at which server should listen.port- Port on which server should listen.- Returns:
- MJPEG server handle.
-
createRawSink
Creates a raw sink.- Parameters:
name- Sink name.isCv- true for a Cv source.- Returns:
- Raw sink handle.
-
getSinkKind
Returns sink kind.- Parameters:
sink- Sink handle.- Returns:
- Sink kind.
-
getSinkName
Returns sink name.- Parameters:
sink- Sink handle.- Returns:
- Sink name.
-
getSinkDescription
Returns sink description.- Parameters:
sink- Sink handle.- Returns:
- Sink description.
-
getSinkProperty
Returns sink property.- Parameters:
sink- Sink handle.name- Property name.- Returns:
- Sink property handle.
-
enumerateSinkProperties
Returns list of sink property handles.- Parameters:
sink- Sink handle.- Returns:
- List of sink property handles.
-
setSinkConfigJson
Sets sink configuration JSON.- Parameters:
sink- Sink handle.config- Configuration JSON.- Returns:
- True if set succeeded.
-
getSinkConfigJson
Returns sink configuration JSON.- Parameters:
sink- Sink handle.- Returns:
- Sink configuration JSON.
-
setSinkSource
Sets sink source.- Parameters:
sink- Sink handle.source- Source handle.
-
getSinkSourceProperty
Returns sink source property.- Parameters:
sink- Sink handle.name- Property name.- Returns:
- Sink source property handle.
-
getSinkSource
Returns sink source.- Parameters:
sink- Sink handle.- Returns:
- Sink source handle.
-
copySink
Copies sink.- Parameters:
sink- Sink handle.- Returns:
- New sink handle.
-
releaseSink
Releases sink.- Parameters:
sink- Sink handle.
-
getMjpegServerListenAddress
Returns MJPEG server listen address.- Parameters:
sink- Sink handle.- Returns:
- MJPEG server listen address.
-
getMjpegServerPort
Returns MJPEG server port.- Parameters:
sink- Sink handle.- Returns:
- MJPEG server port.
-
setSinkDescription
Sets sink description.- Parameters:
sink- Sink handle.description- Sink description.
-
grabRawSinkFrame
Returns raw sink frame.- Parameters:
sink- Sink handle.frame- Raw frame.nativeObj- Native object.- Returns:
- Raw sink frame handle.
-
grabRawSinkFrameTimeout
public static long grabRawSinkFrameTimeout(int sink, RawFrame frame, long nativeObj, double timeout) Returns raw sink frame timeout.- Parameters:
sink- Sink handle.frame- Raw frame.nativeObj- Native object.timeout- Timeout in seconds.- Returns:
- Raw sink frame timeout.
-
getSinkError
Returns sink error message.- Parameters:
sink- Sink handle.- Returns:
- Sink error message.
-
setSinkEnabled
Sets sink enable.- Parameters:
sink- Sink handle.enabled- True if sink should be enabled.
-
addListener
public static int addListener(Consumer<VideoEvent> listener, int eventMask, boolean immediateNotify) Adds listener.- Parameters:
listener- Video event callback.eventMask- Event mask.immediateNotify- True to immediately notify on event.- Returns:
- Listener handle.
-
removeListener
Removes listener.- Parameters:
handle- Listener handle.
-
createListenerPoller
Creates listener poller.- Returns:
- Listener poller handle.
-
destroyListenerPoller
Destroys listener poller.- Parameters:
poller- Listener poller handle.
-
addPolledListener
Add polled listener.- Parameters:
poller- Poller handle.eventMask- Event mask.immediateNotify- True to immediately notify on event.- Returns:
- Polled listener handle.
-
pollListener
Polls listener.- Parameters:
poller- Poller handle.- Returns:
- List of video events.
- Throws:
InterruptedException- if polling was interrupted.
-
pollListenerTimeout
public static VideoEvent[] pollListenerTimeout(int poller, double timeout) throws InterruptedException Polls listener with timeout.- Parameters:
poller- Poller handle.timeout- Timeout in seconds.- Returns:
- List of video events.
- Throws:
InterruptedException- if polling was interrupted.
-
cancelPollListener
Cancels poll listener.- Parameters:
poller- Poller handle.
-
setTelemetryPeriod
Sets telemetry period.- Parameters:
seconds- Telemetry period in seconds.
-
getTelemetryElapsedTime
Returns telemetry elapsed time.- Returns:
- Telemetry elapsed time.
-
getTelemetryValue
Returns telemetry value.- Parameters:
handle- Telemetry handle.kind- Telemetry kind.- Returns:
- Telemetry value.
-
getTelemetryValue
Returns telemetry value.- Parameters:
handle- Telemetry handle.kind- Telemetry kind.- Returns:
- Telemetry value.
-
getTelemetryAverageValue
Returns telemetry average value.- Parameters:
handle- Telemetry handle.kind- Telemetry kind.- Returns:
- Telemetry average value.
-
getTelemetryAverageValue
Returns telemetry average value.- Parameters:
handle- Telemetry handle.kind- Telemetry kind.- Returns:
- Telemetry average value.
-
setLogger
Sets logger.- Parameters:
func- Logger function.minLevel- Minimum logging level.
-
enumerateUsbCameras
Returns list of USB cameras.- Returns:
- List of USB cameras.
-
enumerateSources
Returns list of sources.- Returns:
- List of sources.
-
enumerateSinks
Returns list of sinks.- Returns:
- List of sinks.
-
getHostname
Returns hostname.- Returns:
- Hostname.
-
getNetworkInterfaces
Returns list of network interfaces.- Returns:
- List of network interfaces.
-
runMainRunLoop
Runs main run loop. -
runMainRunLoopTimeout
Runs main run loop with timeout.- Parameters:
timeoutSeconds- Timeout in seconds.- Returns:
- 3 on timeout, 2 on signal, 1 on other.
-
stopMainRunLoop
Stops main run loop.
-