WPILibC++ 2024.3.2
cs::RawCvSource Class Reference

A source for using the raw frame API to provide opencv images. More...

#include <cscore_raw_cv.h>

Inheritance diagram for cs::RawCvSource:
cs::RawSource cs::ImageSource cs::VideoSource

Public Member Functions

 RawCvSource ()=default
 
 RawCvSource (std::string_view name, const VideoMode &mode)
 Create a Raw OpenCV source. More...
 
 RawCvSource (std::string_view name, VideoMode::PixelFormat pixelFormat, int width, int height, int fps)
 Create a Raw OpenCV source. More...
 
void PutFrame (cv::Mat &image)
 Put an OpenCV image and notify sinks. More...
 
- Public Member Functions inherited from cs::RawSource
 RawSource ()=default
 
 RawSource (std::string_view name, const VideoMode &mode)
 Create a raw frame source. More...
 
 RawSource (std::string_view name, VideoMode::PixelFormat pixelFormat, int width, int height, int fps)
 Create a raw frame source. More...
 
- Public Member Functions inherited from cs::ImageSource
void NotifyError (std::string_view msg)
 Signal sinks that an error has occurred. More...
 
void SetConnected (bool connected)
 Set source connection status. More...
 
void SetDescription (std::string_view description)
 Set source description. More...
 
VideoProperty CreateProperty (std::string_view name, VideoProperty::Kind kind, int minimum, int maximum, int step, int defaultValue, int value)
 Create a property. More...
 
VideoProperty CreateIntegerProperty (std::string_view name, int minimum, int maximum, int step, int defaultValue, int value)
 Create an integer property. More...
 
VideoProperty CreateBooleanProperty (std::string_view name, bool defaultValue, bool value)
 Create a boolean property. More...
 
VideoProperty CreateStringProperty (std::string_view name, std::string_view value)
 Create a string property. More...
 
void SetEnumPropertyChoices (const VideoProperty &property, std::span< const 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 () noexcept=default
 
 VideoSource (const VideoSource &source)
 
 VideoSource (VideoSource &&other) noexcept
 
VideoSourceoperator= (VideoSource other) noexcept
 
 ~VideoSource ()
 
 operator bool () const
 
int GetHandle () const
 
bool operator== (const VideoSource &other) const
 
Kind GetKind () const
 Get the kind of the source. More...
 
std::string GetName () const
 Get the name of the source. More...
 
std::string GetDescription () const
 Get the source description. More...
 
uint64_t GetLastFrameTime () const
 Get the last time a frame was captured. More...
 
void SetConnectionStrategy (ConnectionStrategy strategy)
 Sets the connection strategy. More...
 
bool IsConnected () const
 Is the source currently connected to whatever is providing the images? More...
 
bool IsEnabled () const
 Gets source enable status. More...
 
VideoProperty GetProperty (std::string_view name)
 Get a property. More...
 
std::vector< VideoPropertyEnumerateProperties () const
 Enumerate all properties of this source. More...
 
VideoMode GetVideoMode () const
 Get the current video mode. More...
 
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...
 
bool SetConfigJson (std::string_view config)
 Set video mode and properties from a JSON configuration string. More...
 
bool SetConfigJson (const wpi::json &config)
 Set video mode and properties from a JSON configuration object. More...
 
std::string GetConfigJson () const
 Get a JSON configuration string. More...
 
wpi::json GetConfigJsonObject () const
 Get a JSON configuration object. 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. More...
 
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 }
 Video source kind. More...
 
enum  ConnectionStrategy { kConnectionAutoManage = CS_CONNECTION_AUTO_MANAGE , kConnectionKeepOpen = CS_CONNECTION_KEEP_OPEN , kConnectionForceClose = CS_CONNECTION_FORCE_CLOSE }
 Connection strategy. More...
 
- Static Public Member Functions inherited from cs::VideoSource
static std::vector< VideoSourceEnumerateSources ()
 Enumerate all existing sources. More...
 
- Protected Member Functions inherited from cs::RawSource
void PutFrame (wpi::RawFrame &image)
 Put a raw image and notify sinks. More...
 
- Protected Member Functions inherited from cs::ImageSource
 ImageSource ()=default
 
- 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 {0}
 Video source handle. More...
 

Detailed Description

A source for using the raw frame API to provide opencv images.

If you are using the WPILib OpenCV builds, do not use this, and instead include "cscore_cv.h" to get a more performant version.

This is not dependent on any opencv binary ABI, and can be used with versions of OpenCV that are not 3. If using OpenCV 3, use CvSource.

Constructor & Destructor Documentation

◆ RawCvSource() [1/3]

cs::RawCvSource::RawCvSource ( )
default

◆ RawCvSource() [2/3]

cs::RawCvSource::RawCvSource ( std::string_view  name,
const VideoMode mode 
)
inline

Create a Raw OpenCV source.

Parameters
nameSource name (arbitrary unique identifier)
modeVideo mode being generated

◆ RawCvSource() [3/3]

cs::RawCvSource::RawCvSource ( std::string_view  name,
VideoMode::PixelFormat  pixelFormat,
int  width,
int  height,
int  fps 
)
inline

Create a Raw OpenCV source.

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

Member Function Documentation

◆ PutFrame()

void cs::RawCvSource::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

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