Package edu.wpi.cscore
Class CvSink
- java.lang.Object
-
- edu.wpi.cscore.VideoSink
-
- edu.wpi.cscore.ImageSink
-
- edu.wpi.cscore.CvSink
-
- All Implemented Interfaces:
AutoCloseable
public class CvSink extends ImageSink
A sink for user code to accept video frames as OpenCV images. These sinks require the WPILib OpenCV builds. For an alternate OpenCV, see the documentation how to build your own with RawSink.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.wpi.cscore.VideoSink
VideoSink.Kind
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgrabFrame(Mat image)Wait for the next frame and get the image.longgrabFrame(Mat image, double timeout)Wait for the next frame and get the image.longgrabFrameNoTimeout(Mat image)Wait for the next frame and get the image.-
Methods inherited from class edu.wpi.cscore.ImageSink
getError, setDescription, setEnabled
-
Methods inherited from class edu.wpi.cscore.VideoSink
close, enumerateProperties, enumerateSinks, equals, getConfigJson, getDescription, getHandle, getKind, getKindFromInt, getName, getProperty, getSource, getSourceProperty, hashCode, isValid, setConfigJson, setSource
-
-
-
-
Constructor Detail
-
CvSink
public CvSink(String name)
Create a sink for accepting OpenCV images. WaitForFrame() must be called on the created sink to get each new image.- Parameters:
name- Source name (arbitrary unique identifier)
-
-
Method Detail
-
grabFrame
public long grabFrame(Mat image)
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.- Returns:
- Frame time, or 0 on error (call GetError() to obtain the error message)
-
grabFrame
public long grabFrame(Mat image, double timeout)
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.- Returns:
- Frame time, or 0 on error (call GetError() to obtain the error message); the frame time is in 1 us increments.
-
grabFrameNoTimeout
public long grabFrameNoTimeout(Mat image)
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.- Returns:
- Frame time, or 0 on error (call GetError() to obtain the error message); the frame time is in 1 us increments.
-
-