CvSink
- class cscore.CvSink(name: str, pixelFormat: wpiutil._wpiutil.PixelFormat = <PixelFormat.BGR: 4>)
Bases:
ImageSinkA sink for user code to accept video frames as OpenCV images.
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)
pixelFormat – The pixel format to read
- grabFrame(image: numpy.ndarray, timeout: SupportsFloat | SupportsIndex = 0.225) tuple[int, numpy.ndarray]
Wait for the next frame and get the image. Times out (returning 0) after timeout seconds. The provided image will have the pixelFormat this class was constructed with.
- Returns:
Frame time, or 0 on error (call GetError() to obtain the error message); the frame time is in the same time base as wpi::util::Now(), and is in 1 us increments.
- grabFrameDirect(image: numpy.ndarray, timeout: SupportsFloat | SupportsIndex = 0.225) int
Wait for the next frame and get the image. Times out (returning 0) after timeout seconds. The provided image will have the pixelFormat this class was constructed with. The data is backed by data in the CvSink. It will be invalidated by any grabFrame*() call on the sink.
- Returns:
Frame time, or 0 on error (call GetError() to obtain the error message); the frame time is in the same time base as wpi::util::Now(), and is in 1 us increments.
- grabFrameDirectLastTime(image: numpy.ndarray, lastFrameTime: SupportsInt | SupportsIndex, timeout: SupportsFloat | SupportsIndex = 0.225) int
Wait for the next frame and get the image. Times out (returning 0) after timeout seconds. The provided image will have the pixelFormat this class was constructed with. The data is backed by data in the CvSink. It will be invalidated by any grabFrame*() call on the sink.
If lastFrameTime is provided and non-zero, the sink will fill image with the first frame from the source that is not equal to lastFrameTime. If lastFrameTime is zero, the time of the current frame owned by the CvSource is used, and this function will block until the connected CvSource provides a new frame.
- Returns:
Frame time, or 0 on error (call GetError() to obtain the error message); the frame time is in the same time base as wpi::util::Now(), and is in 1 us increments.
- grabFrameNoTimeout(image: numpy.ndarray) tuple[int, numpy.ndarray]
Wait for the next frame and get the image. May block forever. The provided image will have the pixelFormat this class was constructed with.
- Returns:
Frame time, or 0 on error (call GetError() to obtain the error message); the frame time is in the same time base as wpi::util::Now(), and is in 1 us increments.
- grabFrameNoTimeoutDirect(image: numpy.ndarray) int
Wait for the next frame and get the image. May block forever. The provided image will have the pixelFormat this class was constructed with. The data is backed by data in the CvSink. It will be invalidated by any grabFrame*() call on the sink.
- Returns:
Frame time, or 0 on error (call GetError() to obtain the error message); the frame time is in the same time base as wpi::util::Now(), and is in 1 us increments.
- lastFrameTime() int
Get the last time a frame was grabbed. This uses the same time base as wpi::util::Now().
- Returns:
Time in 1 us increments.
- lastFrameTimeSource() wpiutil._wpiutil.TimestampSource
Get the time source for the timestamp the last frame was grabbed at.
- Returns:
Time source