![]() |
WPILibC++ 2025.3.2
|
A source for video that provides a sequence of frames. More...
#include <cscore_oo.h>
Public Types | |
| enum | Kind { kUnknown = CS_SOURCE_UNKNOWN , kUsb = CS_SOURCE_USB , kHttp = CS_SOURCE_HTTP , kCv = CS_SOURCE_CV , kRaw = CS_SOURCE_RAW } |
| Video source kind. More... | |
| enum | ConnectionStrategy { kConnectionAutoManage = CS_CONNECTION_AUTO_MANAGE , kConnectionKeepOpen = CS_CONNECTION_KEEP_OPEN , kConnectionForceClose = CS_CONNECTION_FORCE_CLOSE } |
| Connection strategy. More... | |
Public Member Functions | |
| VideoSource () noexcept=default | |
| VideoSource (const VideoSource &source) | |
| VideoSource (VideoSource &&other) noexcept | |
| VideoSource & | operator= (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. | |
| std::string | GetName () const |
| Get the name of the source. | |
| std::string | GetDescription () const |
| Get the source description. | |
| uint64_t | GetLastFrameTime () const |
| Get the last time a frame was captured. | |
| void | SetConnectionStrategy (ConnectionStrategy strategy) |
| Sets the connection strategy. | |
| bool | IsConnected () const |
| Is the source currently connected to whatever is providing the images? | |
| bool | IsEnabled () const |
| Gets source enable status. | |
| VideoProperty | GetProperty (std::string_view name) |
| Get a property. | |
| std::vector< VideoProperty > | EnumerateProperties () const |
| Enumerate all properties of this source. | |
| VideoMode | GetVideoMode () const |
| Get the current video mode. | |
| bool | SetVideoMode (const VideoMode &mode) |
| Set the video mode. | |
| bool | SetVideoMode (VideoMode::PixelFormat pixelFormat, int width, int height, int fps) |
| Set the video mode. | |
| bool | SetPixelFormat (VideoMode::PixelFormat pixelFormat) |
| Set the pixel format. | |
| bool | SetResolution (int width, int height) |
| Set the resolution. | |
| bool | SetFPS (int fps) |
| Set the frames per second (FPS). | |
| bool | SetConfigJson (std::string_view config) |
| Set video mode and properties from a JSON configuration string. | |
| bool | SetConfigJson (const wpi::json &config) |
| Set video mode and properties from a JSON configuration object. | |
| std::string | GetConfigJson () const |
| Get a JSON configuration string. | |
| wpi::json | GetConfigJsonObject () const |
| Get a JSON configuration object. | |
| double | GetActualFPS () const |
| Get the actual FPS. | |
| double | GetActualDataRate () const |
| Get the data rate (in bytes per second). | |
| std::vector< VideoMode > | EnumerateVideoModes () const |
| Enumerate all known video modes for this source. | |
| CS_Status | GetLastStatus () const |
| std::vector< VideoSink > | EnumerateSinks () |
| Enumerate all sinks connected to this source. | |
Static Public Member Functions | |
| static std::vector< VideoSource > | EnumerateSources () |
| Enumerate all existing sources. | |
Protected Member Functions | |
| VideoSource (CS_Source handle) | |
Protected Attributes | |
| CS_Status | m_status = 0 |
| CS_Source | m_handle {0} |
| Video source handle. | |
Friends | |
| class | VideoEvent |
| class | VideoSink |
| void | swap (VideoSource &first, VideoSource &second) noexcept |
A source for video that provides a sequence of frames.
Connection strategy.
Used for SetConnectionStrategy().
|
defaultnoexcept |
|
inline |
|
inlinenoexcept |
|
inline |
|
inlineexplicitprotected |
| std::vector< VideoProperty > cs::VideoSource::EnumerateProperties | ( | ) | const |
Enumerate all properties of this source.
| std::vector< VideoSink > cs::VideoSource::EnumerateSinks | ( | ) |
Enumerate all sinks connected to this source.
|
static |
Enumerate all existing sources.
|
inline |
Enumerate all known video modes for this source.
|
inline |
Get the data rate (in bytes per second).
SetTelemetryPeriod() must be called for this to be valid.
|
inline |
Get the actual FPS.
SetTelemetryPeriod() must be called for this to be valid.
|
inline |
Get a JSON configuration string.
| wpi::json cs::VideoSource::GetConfigJsonObject | ( | ) | const |
Get a JSON configuration object.
|
inline |
Get the source description.
This is source-kind specific.
|
inline |
|
inline |
Get the kind of the source.
|
inline |
Get the last time a frame was captured.
This uses the same time base as wpi::Now().
|
inline |
|
inline |
Get the name of the source.
The name is an arbitrary identifier provided when the source is created, and should be unique.
|
inline |
Get a property.
| name | Property name |
|
inline |
Get the current video mode.
|
inline |
Is the source currently connected to whatever is providing the images?
|
inline |
Gets source enable status.
This is determined with a combination of connection strategy and the number of sinks connected.
|
inlineexplicit |
|
inlinenoexcept |
|
inline |
|
inline |
Set video mode and properties from a JSON configuration object.
| config | configuration |
|
inline |
Set video mode and properties from a JSON configuration string.
The format of the JSON input is:
{
"pixel format": "MJPEG", "YUYV", etc
"width": video mode width
"height": video mode height
"fps": video mode fps
"brightness": percentage brightness
"white balance": "auto", "hold", or value
"exposure": "auto", "hold", or value
"properties": [
{
"name": property name
"value": property value
}
]
}
| config | configuration |
|
inline |
Sets the connection strategy.
By default, the source will automatically connect or disconnect based on whether any sinks are connected.
This function is non-blocking; look for either a connection open or close event or call IsConnected() to determine the connection state.
| strategy | connection strategy (auto, keep open, or force close) |
|
inline |
Set the frames per second (FPS).
| fps | desired FPS |
|
inline |
Set the pixel format.
| pixelFormat | desired pixel format |
|
inline |
Set the resolution.
| width | desired width |
| height | desired height |
|
inline |
Set the video mode.
| mode | Video mode |
|
inline |
Set the video mode.
| pixelFormat | desired pixel format |
| width | desired width |
| height | desired height |
| fps | desired FPS |
|
friend |
|
friend |
|
friend |
|
protected |
Video source handle.
|
mutableprotected |