WPILibC++
2018.4.1-20180921151738-1194-gf89274f
|
A sink for user code to accept video frames as OpenCV images. More...
#include <cscore_oo.h>
Public Member Functions | |
CvSink (const wpi::Twine &name) | |
Create a sink for accepting OpenCV images. More... | |
CvSink (const wpi::Twine &name, std::function< void(uint64_t time)> processFrame) | |
Create a sink for accepting OpenCV images in a separate thread. More... | |
void | SetDescription (const wpi::Twine &description) |
Set sink description. More... | |
uint64_t | GrabFrame (cv::Mat &image, double timeout=0.225) const |
Wait for the next frame and get the image. More... | |
uint64_t | GrabFrameNoTimeout (cv::Mat &image) const |
Wait for the next frame and get the image. More... | |
std::string | GetError () const |
Get error string. More... | |
void | SetEnabled (bool enabled) |
Enable or disable getting new frames. More... | |
![]() | |
VideoSink (const VideoSink &sink) | |
VideoSink (VideoSink &&sink) noexcept | |
VideoSink & | operator= (VideoSink other) noexcept |
operator bool () const | |
int | GetHandle () const |
bool | operator== (const VideoSink &other) const |
bool | operator!= (const VideoSink &other) const |
Kind | GetKind () const |
Get the kind of the sink. | |
std::string | GetName () const |
Get the name of the sink. More... | |
std::string | GetDescription () const |
Get the sink description. More... | |
VideoProperty | GetProperty (const wpi::Twine &name) |
Get a property of the sink. More... | |
std::vector< VideoProperty > | EnumerateProperties () const |
Enumerate all properties of this sink. | |
void | SetSource (VideoSource source) |
Configure which source should provide frames to this sink. More... | |
VideoSource | GetSource () const |
Get the connected source. More... | |
VideoProperty | GetSourceProperty (const wpi::Twine &name) |
Get a property of the associated source. More... | |
CS_Status | GetLastStatus () const |
Additional Inherited Members | |
![]() | |
enum | Kind { kUnknown = CS_SINK_UNKNOWN, kMjpeg = CS_SINK_MJPEG, kCv = CS_SINK_CV } |
![]() | |
static std::vector< VideoSink > | EnumerateSinks () |
Enumerate all existing sinks. More... | |
![]() | |
VideoSink (CS_Sink handle) | |
![]() | |
CS_Status | m_status = 0 |
CS_Sink | m_handle |
A sink for user code to accept video frames as OpenCV images.
|
inlineexplicit |
Create a sink for accepting OpenCV images.
WaitForFrame() must be called on the created sink to get each new image.
name | Source name (arbitrary unique identifier) |
|
inline |
Create a sink for accepting OpenCV images in a separate thread.
A thread will be created that calls WaitForFrame() and calls the processFrame() callback each time a new frame arrives.
name | Source name (arbitrary unique identifier) |
processFrame | Frame processing function; will be called with a time=0 if an error occurred. processFrame should call GetImage() or GetError() as needed, but should not call (except in very unusual circumstances) WaitForImage(). |
|
inline |
Get error string.
Call this if WaitForFrame() returns 0 to determine what the error is.
|
inline |
Wait for the next frame and get the image.
Times out (returning 0) after timeout seconds. The provided image will have three 8-bit channels stored in BGR order.
|
inline |
Wait for the next frame and get the image.
May block forever. The provided image will have three 8-bit channels stored in BGR order.
|
inline |
Set sink description.
description | Description |
|
inline |
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.