CameraServer
- class cscore.CameraServer
Bases:
pybind11_objectSingleton class for creating and keeping camera servers.
Also publishes camera information to NetworkTables.
- BASE_PORT = 1181
- static add_camera(camera: cscore._cscore.VideoSource) None
Adds an already created camera.
- Parameters:
camera – Camera
- static add_server(*args, **kwargs)
Overloaded function.
add_server(name: str) -> cscore._cscore.MjpegServer
Adds a MJPEG server at the next available port.
- Parameters:
name – Server name
add_server(name: str, port: typing.SupportsInt | typing.SupportsIndex) -> cscore._cscore.MjpegServer
Adds a MJPEG server.
- Parameters:
name – Server name
port – Port number
add_server(server: cscore._cscore.VideoSink) -> None
Adds an already created server.
- Parameters:
server – Server
- static add_switched_camera(name: str) cscore._cscore.MjpegServer
Adds a virtual camera for switching between two streams. Unlike the other addCamera methods, this returns a VideoSink rather than a VideoSource. Calling SetSource() on the returned object can be used to switch the actual source of the stream.
- static enable_logging(level: SupportsInt | SupportsIndex | None = None) None
Enable cscore logging
- static get_server(*args, **kwargs)
Overloaded function.
get_server() -> cscore._cscore.VideoSink
Get server for the primary camera feed.
This is only valid to call after a camera feed has been added with StartAutomaticCapture() or AddServer().
get_server(name: str) -> cscore._cscore.VideoSink
Gets a server by name.
- Parameters:
name – Server name
- static get_video(*args, **kwargs)
Overloaded function.
get_video() -> cscore._cscore.CvSink
Get OpenCV access to the primary camera feed. This allows you to get images from the camera for image processing on the Systemcore.
This is only valid to call after a camera feed has been added with startAutomaticCapture() or addServer().
get_video(camera: cscore._cscore.VideoSource) -> cscore._cscore.CvSink
Get OpenCV access to the specified camera. This allows you to get images from the camera for image processing on the Systemcore.
- Parameters:
camera – Camera (e.g. as returned by startAutomaticCapture).
get_video(camera: cscore._cscore.VideoSource, pixel_format: wpiutil._wpiutil.PixelFormat) -> cscore._cscore.CvSink
Get OpenCV access to the specified camera. This allows you to get images from the camera for image processing on the Systemcore.
- Parameters:
camera – Camera (e.g. as returned by startAutomaticCapture).
pixel_format – The desired pixelFormat of captured frames from the camera
get_video(name: str) -> cscore._cscore.CvSink
Get OpenCV access to the specified camera. This allows you to get images from the camera for image processing on the Systemcore.
- Parameters:
name – Camera name
get_video(name: str, pixel_format: wpiutil._wpiutil.PixelFormat) -> cscore._cscore.CvSink
Get OpenCV access to the specified camera. This allows you to get images from the camera for image processing on the Systemcore.
- Parameters:
name – Camera name
pixel_format – The desired pixelFormat of captured frames from the camera
- static put_video(name: str, width: SupportsInt | SupportsIndex, height: SupportsInt | SupportsIndex) cscore._cscore.CvSource
Create a MJPEG stream with OpenCV input. This can be called to pass custom annotated images to the dashboard.
- Parameters:
name – Name to give the stream
width – Width of the image being sent
height – Height of the image being sent
- static remove_camera(name: str) None
Removes a camera by name.
- Parameters:
name – Camera name
- static remove_server(name: str) None
Removes a server by name.
- Parameters:
name – Server name
- static start_automatic_capture(*args, **kwargs)
Overloaded function.
start_automatic_capture() -> cscore._cscore.UsbCamera
Start automatically capturing images to send to the dashboard.
You should call this method to see a camera feed on the dashboard. If you also want to perform vision processing on the Systemcore, use getVideo() to get access to the camera images.
The first time this overload is called, it calls StartAutomaticCapture() with device 0, creating a camera named “USB Camera 0”. Subsequent calls increment the device number (e.g. 1, 2, etc).
start_automatic_capture(dev: typing.SupportsInt | typing.SupportsIndex) -> cscore._cscore.UsbCamera
Start automatically capturing images to send to the dashboard.
This overload calls StartAutomaticCapture() with a name of “USB Camera {dev}”.
- Parameters:
dev – The device number of the camera interface
start_automatic_capture(name: str, dev: typing.SupportsInt | typing.SupportsIndex) -> cscore._cscore.UsbCamera
Start automatically capturing images to send to the dashboard.
- Parameters:
name – The name to give the camera
dev – The device number of the camera interface
start_automatic_capture(name: str, path: str) -> cscore._cscore.UsbCamera
Start automatically capturing images to send to the dashboard.
- Parameters:
name – The name to give the camera
path – The device path (e.g. “/dev/video0”) of the camera
start_automatic_capture(camera: cscore._cscore.VideoSource) -> cscore._cscore.MjpegServer
Start automatically capturing images to send to the dashboard from an existing camera.
- Parameters:
camera – Camera
- static wait_forever() None
Infinitely loops until the process dies