VideoSource
- class cscore.VideoSource
Bases:
pybind11_objectA source for video that provides a sequence of frames.
- class ConnectionStrategy(value: SupportsInt | SupportsIndex)
Bases:
pybind11_objectConnection strategy. Used for SetConnectionStrategy().
Members:
CONNECTION_AUTO_MANAGE : Automatically connect or disconnect based on whether any sinks are
connected to this source. This is the default behavior.
CONNECTION_KEEP_OPEN : Try to keep the connection open regardless of whether any sinks are
connected.
CONNECTION_FORCE_CLOSE : Never open the connection. If this is set when the connection is open,
close the connection.
- CONNECTION_AUTO_MANAGE = <ConnectionStrategy.CONNECTION_AUTO_MANAGE: 0>
- CONNECTION_FORCE_CLOSE = <ConnectionStrategy.CONNECTION_FORCE_CLOSE: 2>
- CONNECTION_KEEP_OPEN = <ConnectionStrategy.CONNECTION_KEEP_OPEN: 1>
- VideoSource.ConnectionStrategy.name -> str
- property value
- class Kind(value: SupportsInt | SupportsIndex)
Bases:
pybind11_objectVideo source kind.
Members:
UNKNOWN : Unknown video source.
USB : USB video source.
HTTP : HTTP video source.
CV : CV video source.
RAW : Raw video source.
- CV = <Kind.CV: 4>
- HTTP = <Kind.HTTP: 2>
- RAW = <Kind.RAW: 8>
- UNKNOWN = <Kind.UNKNOWN: 0>
- USB = <Kind.USB: 1>
- VideoSource.Kind.name -> str
- property value
- enumerate_properties() list[cscore._cscore.VideoProperty]
Enumerate all properties of this source.
- enumerate_sinks() list[cscore._cscore.VideoSink]
Enumerate all sinks connected to this source.
- Returns:
Vector of sinks.
- static enumerate_sources() list[cscore._cscore.VideoSource]
Enumerate all existing sources.
- Returns:
Vector of sources.
- enumerate_video_modes() list[cscore._cscore.VideoMode]
Enumerate all known video modes for this source.
- get_actual_data_rate() float
Get the data rate (in bytes per second).
SetTelemetryPeriod() must be called for this to be valid.
- Returns:
Data rate averaged over the telemetry period.
- get_actual_fps() float
Get the actual FPS.
SetTelemetryPeriod() must be called for this to be valid.
- Returns:
Actual FPS averaged over the telemetry period.
- get_config_json() str
Get a JSON configuration string.
- Returns:
JSON configuration string
- get_config_json_object() wpiutil.json
Get a JSON configuration object.
- Returns:
JSON configuration object
- get_description() str
Get the source description. This is source-kind specific.
- get_handle() int
- get_kind() cscore._cscore.VideoSource.Kind
Get the kind of the source.
- get_last_frame_time() int
Get the last time a frame was captured. This uses the same time base as wpi::util::Now().
- Returns:
Time in 1 us increments.
- get_last_status() int
- get_name() str
Get the name of the source. The name is an arbitrary identifier provided when the source is created, and should be unique.
- get_property(name: str) cscore._cscore.VideoProperty
Get a property.
- Parameters:
name – Property name
- Returns:
Property contents (of kind Property::kNone if no property with the given name exists)
- get_video_mode() cscore._cscore.VideoMode
Get the current video mode.
- is_connected() bool
Is the source currently connected to whatever is providing the images?
- is_enabled() bool
Gets source enable status. This is determined with a combination of connection strategy and the number of sinks connected.
- Returns:
True if enabled, false otherwise.
- set_config_json(*args, **kwargs)
Overloaded function.
set_config_json(self: cscore._cscore.VideoSource, config: str) -> bool
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 } ] }
- Parameters:
config – configuration
- Returns:
True if set successfully
set_config_json(self: cscore._cscore.VideoSource, config: wpiutil.json) -> bool
Set video mode and properties from a JSON configuration object.
- Parameters:
config – configuration
- Returns:
True if set successfully
- set_connection_strategy(strategy: cscore._cscore.VideoSource.ConnectionStrategy) None
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.
- Parameters:
strategy – connection strategy (auto, keep open, or force close)
- set_fps(fps: SupportsInt | SupportsIndex) bool
Set the frames per second (FPS).
- Parameters:
fps – desired FPS
- Returns:
True if set successfully
- set_pixel_format(pixel_format: wpiutil._wpiutil.PixelFormat) bool
Set the pixel format.
- Parameters:
pixel_format – desired pixel format
- Returns:
True if set successfully
- set_resolution(width: SupportsInt | SupportsIndex, height: SupportsInt | SupportsIndex) bool
Set the resolution.
- Parameters:
width – desired width
height – desired height
- Returns:
True if set successfully
- set_video_mode(*args, **kwargs)
Overloaded function.
set_video_mode(self: cscore._cscore.VideoSource, mode: cscore._cscore.VideoMode) -> bool
Set the video mode.
- Parameters:
mode – Video mode
set_video_mode(self: cscore._cscore.VideoSource, pixel_format: wpiutil._wpiutil.PixelFormat, width: typing.SupportsInt | typing.SupportsIndex, height: typing.SupportsInt | typing.SupportsIndex, fps: typing.SupportsInt | typing.SupportsIndex) -> bool
Set the video mode.
- Parameters:
pixel_format – desired pixel format
width – desired width
height – desired height
fps – desired FPS
- Returns:
True if set successfully