VideoSource
- class cscore.VideoSource
Bases:
pybind11_object
A source for video that provides a sequence of frames.
- class ConnectionStrategy(value: int)
Bases:
pybind11_object
Connection strategy. Used for SetConnectionStrategy().
Members:
kConnectionAutoManage : Automatically connect or disconnect based on whether any sinks are
connected to this source. This is the default behavior.
kConnectionKeepOpen : Try to keep the connection open regardless of whether any sinks are
connected.
kConnectionForceClose : Never open the connection. If this is set when the connection is open,
close the connection.
- kConnectionAutoManage = <ConnectionStrategy.kConnectionAutoManage: 0>
- kConnectionForceClose = <ConnectionStrategy.kConnectionForceClose: 2>
- kConnectionKeepOpen = <ConnectionStrategy.kConnectionKeepOpen: 1>
- property name
- property value
- class Kind(value: int)
Bases:
pybind11_object
Video source kind.
Members:
kUnknown : Unknown video source.
kUsb : USB video source.
kHttp : HTTP video source.
kCv : CV video source.
- kCv = <Kind.kCv: 4>
- kHttp = <Kind.kHttp: 2>
- kUnknown = <Kind.kUnknown: 0>
- kUsb = <Kind.kUsb: 1>
- property name
- property value
- enumerateProperties() list[cscore._cscore.VideoProperty]
Enumerate all properties of this source.
- enumerateSinks() list[cscore._cscore.VideoSink]
Enumerate all sinks connected to this source.
- Returns:
Vector of sinks.
- static enumerateSources() list[cscore._cscore.VideoSource]
Enumerate all existing sources.
- Returns:
Vector of sources.
- enumerateVideoModes() list[cscore._cscore.VideoMode]
Enumerate all known video modes for this source.
- getActualDataRate() 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.
- getActualFPS() float
Get the actual FPS.
SetTelemetryPeriod() must be called for this to be valid.
- Returns:
Actual FPS averaged over the telemetry period.
- getConfigJson() str
Get a JSON configuration string.
- Returns:
JSON configuration string
- getConfigJsonObject() wpiutil.json
Get a JSON configuration object.
- Returns:
JSON configuration object
- getDescription() str
Get the source description. This is source-kind specific.
- getHandle() int
- getKind() cscore._cscore.VideoSource.Kind
Get the kind of the source.
- getLastFrameTime() int
Get the last time a frame was captured. This uses the same time base as wpi::Now().
- Returns:
Time in 1 us increments.
- getLastStatus() int
- getName() str
Get the name of the source. The name is an arbitrary identifier provided when the source is created, and should be unique.
- getProperty(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)
- getVideoMode() cscore._cscore.VideoMode
Get the current video mode.
- isConnected() bool
Is the source currently connected to whatever is providing the images?
- isEnabled() 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.
- setConfigJson(*args, **kwargs)
Overloaded function.
setConfigJson(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
setConfigJson(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
- setConnectionStrategy(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)
- setFPS(fps: int) bool
Set the frames per second (FPS).
- Parameters:
fps – desired FPS
- Returns:
True if set successfully
- setPixelFormat(pixelFormat: cscore._cscore.VideoMode.PixelFormat) bool
Set the pixel format.
- Parameters:
pixelFormat – desired pixel format
- Returns:
True if set successfully
- setResolution(width: int, height: int) bool
Set the resolution.
- Parameters:
width – desired width
height – desired height
- Returns:
True if set successfully
- setVideoMode(*args, **kwargs)
Overloaded function.
setVideoMode(self: cscore._cscore.VideoSource, mode: cscore._cscore.VideoMode) -> bool
Set the video mode.
- Parameters:
mode – Video mode
setVideoMode(self: cscore._cscore.VideoSource, pixelFormat: cscore._cscore.VideoMode.PixelFormat, width: int, height: int, fps: int) -> bool
Set the video mode.
- Parameters:
pixelFormat – desired pixel format
width – desired width
height – desired height
fps – desired FPS
- Returns:
True if set successfully