WPILibC++  unspecified
cs::CvSource Class Reference

A source for user code to provide OpenCV images as video frames. More...

#include <cscore_oo.h>

Inheritance diagram for cs::CvSource:
Collaboration diagram for cs::CvSource:

Public Member Functions

 CvSource (wpi::StringRef name, const VideoMode &mode)
 Create an OpenCV source. More...
 
 CvSource (wpi::StringRef name, VideoMode::PixelFormat pixelFormat, int width, int height, int fps)
 Create an OpenCV source. More...
 
void PutFrame (cv::Mat &image)
 Put an OpenCV image and notify sinks. More...
 
void NotifyError (wpi::StringRef msg)
 Signal sinks that an error has occurred. More...
 
void SetConnected (bool connected)
 Set source connection status. More...
 
void SetDescription (wpi::StringRef description)
 Set source description. More...
 
VideoProperty CreateProperty (wpi::StringRef name, VideoProperty::Kind kind, int minimum, int maximum, int step, int defaultValue, int value)
 Create a property. More...
 
VideoProperty CreateIntegerProperty (wpi::StringRef name, int minimum, int maximum, int step, int defaultValue, int value)
 Create an integer property. More...
 
VideoProperty CreateBooleanProperty (wpi::StringRef name, bool defaultValue, bool value)
 Create a boolean property. More...
 
VideoProperty CreateStringProperty (wpi::StringRef name, wpi::StringRef value)
 Create a string property. More...
 
void SetEnumPropertyChoices (const VideoProperty &property, wpi::ArrayRef< std::string > choices)
 Configure enum property choices. More...
 
template<typename T >
void SetEnumPropertyChoices (const VideoProperty &property, std::initializer_list< T > choices)
 Configure enum property choices. More...
 
- Public Member Functions inherited from cs::VideoSource
 VideoSource (const VideoSource &source)
 
 VideoSource (VideoSource &&other) noexcept
 
VideoSourceoperator= (VideoSource other) noexcept
 
 operator bool () const
 
int GetHandle () const
 
bool operator== (const VideoSource &other) const
 
bool operator!= (const VideoSource &other) const
 
Kind GetKind () const
 Get the kind of the source.
 
std::string GetName () const
 Get the name of the source. More...
 
std::string GetDescription () const
 Get the source description. This is source-kind specific.
 
uint64_t GetLastFrameTime () const
 Get the last time a frame was captured. More...
 
bool IsConnected () const
 Is the source currently connected to whatever is providing the images?
 
VideoProperty GetProperty (wpi::StringRef name)
 Get a property. More...
 
std::vector< VideoPropertyEnumerateProperties () const
 Enumerate all properties of this source.
 
VideoMode GetVideoMode () const
 Get the current video mode.
 
bool SetVideoMode (const VideoMode &mode)
 Set the video mode. More...
 
bool SetVideoMode (VideoMode::PixelFormat pixelFormat, int width, int height, int fps)
 Set the video mode. More...
 
bool SetPixelFormat (VideoMode::PixelFormat pixelFormat)
 Set the pixel format. More...
 
bool SetResolution (int width, int height)
 Set the resolution. More...
 
bool SetFPS (int fps)
 Set the frames per second (FPS). More...
 
double GetActualFPS () const
 Get the actual FPS. More...
 
double GetActualDataRate () const
 Get the data rate (in bytes per second). More...
 
std::vector< VideoModeEnumerateVideoModes () const
 Enumerate all known video modes for this source.
 
CS_Status GetLastStatus () const
 
std::vector< VideoSinkEnumerateSinks ()
 Enumerate all sinks connected to this source. More...
 

Additional Inherited Members

- Public Types inherited from cs::VideoSource
enum  Kind { kUnknown = CS_SOURCE_UNKNOWN, kUsb = CS_SOURCE_USB, kHttp = CS_SOURCE_HTTP, kCv = CS_SOURCE_CV }
 
- Static Public Member Functions inherited from cs::VideoSource
static std::vector< VideoSourceEnumerateSources ()
 Enumerate all existing sources. More...
 
- Protected Member Functions inherited from cs::VideoSource
 VideoSource (CS_Source handle)
 
- Protected Attributes inherited from cs::VideoSource
CS_Status m_status = 0
 
CS_Source m_handle
 

Detailed Description

A source for user code to provide OpenCV images as video frames.

Constructor & Destructor Documentation

cs::CvSource::CvSource ( wpi::StringRef  name,
const VideoMode mode 
)
inline

Create an OpenCV source.

Parameters
nameSource name (arbitrary unique identifier)
modeVideo mode being generated
cs::CvSource::CvSource ( wpi::StringRef  name,
VideoMode::PixelFormat  pixelFormat,
int  width,
int  height,
int  fps 
)
inline

Create an OpenCV source.

Parameters
nameSource name (arbitrary unique identifier)
pixelFormatPixel format
widthwidth
heightheight
fpsfps

Member Function Documentation

VideoProperty cs::CvSource::CreateBooleanProperty ( wpi::StringRef  name,
bool  defaultValue,
bool  value 
)
inline

Create a boolean property.

Parameters
nameProperty name
defaultValueDefault value
valueCurrent value
Returns
Property
VideoProperty cs::CvSource::CreateIntegerProperty ( wpi::StringRef  name,
int  minimum,
int  maximum,
int  step,
int  defaultValue,
int  value 
)
inline

Create an integer property.

Parameters
nameProperty name
minimumMinimum value
maximumMaximum value
stepStep value
defaultValueDefault value
valueCurrent value
Returns
Property
VideoProperty cs::CvSource::CreateProperty ( wpi::StringRef  name,
VideoProperty::Kind  kind,
int  minimum,
int  maximum,
int  step,
int  defaultValue,
int  value 
)
inline

Create a property.

Parameters
nameProperty name
kindProperty kind
minimumMinimum value
maximumMaximum value
stepStep value
defaultValueDefault value
valueCurrent value
Returns
Property
VideoProperty cs::CvSource::CreateStringProperty ( wpi::StringRef  name,
wpi::StringRef  value 
)
inline

Create a string property.

Parameters
nameProperty name
defaultValueDefault value
valueCurrent value
Returns
Property
void cs::CvSource::NotifyError ( wpi::StringRef  msg)
inline

Signal sinks that an error has occurred.

This should be called instead of NotifyFrame when an error occurs.

void cs::CvSource::PutFrame ( cv::Mat &  image)
inline

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 cv::Mat::convertTo() and/or cv::cvtColor() to convert it first.

Parameters
imageOpenCV image
void cs::CvSource::SetConnected ( bool  connected)
inline

Set source connection status.

Defaults to true.

Parameters
connectedTrue for connected, false for disconnected
void cs::CvSource::SetDescription ( wpi::StringRef  description)
inline

Set source description.

Parameters
descriptionDescription
void cs::CvSource::SetEnumPropertyChoices ( const VideoProperty property,
wpi::ArrayRef< std::string >  choices 
)
inline

Configure enum property choices.

Parameters
propertyProperty
choicesChoices
template<typename T >
void cs::CvSource::SetEnumPropertyChoices ( const VideoProperty property,
std::initializer_list< T >  choices 
)
inline

Configure enum property choices.

Parameters
propertyProperty
choicesChoices

The documentation for this class was generated from the following files: