CameraServer¶
- class cscore.CameraServer¶
Bases:
pybind11_object
Singleton class for creating and keeping camera servers.
Also publishes camera information to NetworkTables.
- static addAxisCamera(*args, **kwargs)¶
Overloaded function.
addAxisCamera(host: str) -> cscore._cscore.AxisCamera
Adds an Axis IP camera.
This overload calls AddAxisCamera() with name “Axis Camera”.
- Parameters:
host – Camera host IP or DNS name (e.g. “10.x.y.11”)
addAxisCamera(hosts: List[str]) -> cscore._cscore.AxisCamera
Adds an Axis IP camera.
This overload calls AddAxisCamera() with name “Axis Camera”.
- Parameters:
hosts – Array of Camera host IPs/DNS names
addAxisCamera(name: str, host: str) -> cscore._cscore.AxisCamera
Adds an Axis IP camera.
- Parameters:
name – The name to give the camera
host – Camera host IP or DNS name (e.g. “10.x.y.11”)
addAxisCamera(name: str, hosts: List[str]) -> cscore._cscore.AxisCamera
Adds an Axis IP camera.
- Parameters:
name – The name to give the camera
hosts – Array of Camera host IPs/DNS names
- static addCamera(camera: cscore._cscore.VideoSource) None ¶
Adds an already created camera.
- Parameters:
camera – Camera
- static addServer(*args, **kwargs)¶
Overloaded function.
addServer(name: str) -> cscore._cscore.MjpegServer
Adds a MJPEG server at the next available port.
- Parameters:
name – Server name
addServer(name: str, port: int) -> cscore._cscore.MjpegServer
Adds a MJPEG server.
- Parameters:
name – Server name
port – Port number
addServer(server: cscore._cscore.VideoSink) -> None
Adds an already created server.
- Parameters:
server – Server
- static addSwitchedCamera(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 enableLogging(level: int | None = None) None ¶
Enable cscore logging
- static getServer(*args, **kwargs)¶
Overloaded function.
getServer() -> 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().
getServer(name: str) -> cscore._cscore.VideoSink
Gets a server by name.
- Parameters:
name – Server name
- static getVideo(*args, **kwargs)¶
Overloaded function.
getVideo() -> 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 roboRIO.
This is only valid to call after a camera feed has been added with startAutomaticCapture() or addServer().
getVideo(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 roboRIO.
- Parameters:
camera – Camera (e.g. as returned by startAutomaticCapture).
getVideo(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 roboRIO.
- Parameters:
name – Camera name
- kBasePort = 1181¶
- kSize160x120 = 2¶
- kSize320x240 = 1¶
- kSize640x480 = 0¶
- static putVideo(name: str, width: int, height: int) 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 removeCamera(name: str) None ¶
Removes a camera by name.
- Parameters:
name – Camera name
- static removeServer(name: str) None ¶
Removes a server by name.
- Parameters:
name – Server name
- static setSize(size: int) None ¶
Sets the size of the image to use. Use the public kSize constants to set the correct mode, or set it directly on a camera and call the appropriate StartAutomaticCapture method.
- Deprecated:
Use SetResolution on the UsbCamera returned by StartAutomaticCapture() instead.
- Parameters:
size – The size to use
- static startAutomaticCapture(*args, **kwargs)¶
Overloaded function.
startAutomaticCapture() -> 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 roboRIO, 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).
startAutomaticCapture(dev: int) -> 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
startAutomaticCapture(name: str, dev: int) -> 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
startAutomaticCapture(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
startAutomaticCapture(camera: cscore._cscore.VideoSource) -> cscore._cscore.MjpegServer
Start automatically capturing images to send to the dashboard from an existing camera.
- Parameters:
camera – Camera
- static waitForever() None ¶
Infinitely loops until the process dies