WPILibC++ 2024.3.2
frc::CameraServer Class Reference

Singleton class for creating and keeping camera servers. More...

#include <cameraserver/CameraServer.h>

Static Public Member Functions

static cs::UsbCamera StartAutomaticCapture ()
 Start automatically capturing images to send to the dashboard. More...
 
static cs::UsbCamera StartAutomaticCapture (int dev)
 Start automatically capturing images to send to the dashboard. More...
 
static cs::UsbCamera StartAutomaticCapture (std::string_view name, int dev)
 Start automatically capturing images to send to the dashboard. More...
 
static cs::UsbCamera StartAutomaticCapture (std::string_view name, std::string_view path)
 Start automatically capturing images to send to the dashboard. More...
 
static cs::MjpegServer StartAutomaticCapture (const cs::VideoSource &camera)
 Start automatically capturing images to send to the dashboard from an existing camera. More...
 
static cs::AxisCamera AddAxisCamera (std::string_view host)
 Adds an Axis IP camera. More...
 
static cs::AxisCamera AddAxisCamera (const char *host)
 Adds an Axis IP camera. More...
 
static cs::AxisCamera AddAxisCamera (const std::string &host)
 Adds an Axis IP camera. More...
 
static cs::AxisCamera AddAxisCamera (std::span< const std::string > hosts)
 Adds an Axis IP camera. More...
 
template<typename T >
static cs::AxisCamera AddAxisCamera (std::initializer_list< T > hosts)
 Adds an Axis IP camera. More...
 
static cs::AxisCamera AddAxisCamera (std::string_view name, std::string_view host)
 Adds an Axis IP camera. More...
 
static cs::AxisCamera AddAxisCamera (std::string_view name, const char *host)
 Adds an Axis IP camera. More...
 
static cs::AxisCamera AddAxisCamera (std::string_view name, const std::string &host)
 Adds an Axis IP camera. More...
 
static cs::AxisCamera AddAxisCamera (std::string_view name, std::span< const std::string > hosts)
 Adds an Axis IP camera. More...
 
template<typename T >
static cs::AxisCamera AddAxisCamera (std::string_view name, std::initializer_list< T > hosts)
 Adds an Axis IP camera. More...
 
static cs::MjpegServer AddSwitchedCamera (std::string_view name)
 Adds a virtual camera for switching between two streams. More...
 
static cs::CvSink GetVideo ()
 Get OpenCV access to the primary camera feed. More...
 
static cs::CvSink GetVideo (const cs::VideoSource &camera)
 Get OpenCV access to the specified camera. More...
 
static cs::CvSink GetVideo (const cs::VideoSource &camera, cs::VideoMode::PixelFormat pixelFormat)
 Get OpenCV access to the specified camera. More...
 
static cs::CvSink GetVideo (std::string_view name)
 Get OpenCV access to the specified camera. More...
 
static cs::CvSink GetVideo (std::string_view name, cs::VideoMode::PixelFormat pixelFormat)
 Get OpenCV access to the specified camera. More...
 
static cs::CvSource PutVideo (std::string_view name, int width, int height)
 Create a MJPEG stream with OpenCV input. More...
 
static cs::MjpegServer AddServer (std::string_view name)
 Adds a MJPEG server at the next available port. More...
 
static cs::MjpegServer AddServer (std::string_view name, int port)
 Adds a MJPEG server. More...
 
static void AddServer (const cs::VideoSink &server)
 Adds an already created server. More...
 
static void RemoveServer (std::string_view name)
 Removes a server by name. More...
 
static cs::VideoSink GetServer ()
 Get server for the primary camera feed. More...
 
static cs::VideoSink GetServer (std::string_view name)
 Gets a server by name. More...
 
static void AddCamera (const cs::VideoSource &camera)
 Adds an already created camera. More...
 
static void RemoveCamera (std::string_view name)
 Removes a camera by name. More...
 

Static Public Attributes

static constexpr uint16_t kBasePort = 1181
 CameraServer base port. More...
 

Detailed Description

Singleton class for creating and keeping camera servers.

Also publishes camera information to NetworkTables.

Member Function Documentation

◆ AddAxisCamera() [1/10]

static cs::AxisCamera frc::CameraServer::AddAxisCamera ( const char *  host)
static

Adds an Axis IP camera.

This overload calls AddAxisCamera() with name "Axis Camera".

Parameters
hostCamera host IP or DNS name (e.g. "10.x.y.11")

◆ AddAxisCamera() [2/10]

static cs::AxisCamera frc::CameraServer::AddAxisCamera ( const std::string &  host)
static

Adds an Axis IP camera.

This overload calls AddAxisCamera() with name "Axis Camera".

Parameters
hostCamera host IP or DNS name (e.g. "10.x.y.11")

◆ AddAxisCamera() [3/10]

template<typename T >
cs::AxisCamera frc::CameraServer::AddAxisCamera ( std::initializer_list< T >  hosts)
inlinestatic

Adds an Axis IP camera.

This overload calls AddAxisCamera() with name "Axis Camera".

Parameters
hostsArray of Camera host IPs/DNS names

◆ AddAxisCamera() [4/10]

static cs::AxisCamera frc::CameraServer::AddAxisCamera ( std::span< const std::string >  hosts)
static

Adds an Axis IP camera.

This overload calls AddAxisCamera() with name "Axis Camera".

Parameters
hostsArray of Camera host IPs/DNS names

◆ AddAxisCamera() [5/10]

static cs::AxisCamera frc::CameraServer::AddAxisCamera ( std::string_view  host)
static

Adds an Axis IP camera.

This overload calls AddAxisCamera() with name "Axis Camera".

Parameters
hostCamera host IP or DNS name (e.g. "10.x.y.11")

◆ AddAxisCamera() [6/10]

static cs::AxisCamera frc::CameraServer::AddAxisCamera ( std::string_view  name,
const char *  host 
)
static

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostCamera host IP or DNS name (e.g. "10.x.y.11")

◆ AddAxisCamera() [7/10]

static cs::AxisCamera frc::CameraServer::AddAxisCamera ( std::string_view  name,
const std::string &  host 
)
static

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostCamera host IP or DNS name (e.g. "10.x.y.11")

◆ AddAxisCamera() [8/10]

template<typename T >
cs::AxisCamera frc::CameraServer::AddAxisCamera ( std::string_view  name,
std::initializer_list< T >  hosts 
)
inlinestatic

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostsArray of Camera host IPs/DNS names

◆ AddAxisCamera() [9/10]

static cs::AxisCamera frc::CameraServer::AddAxisCamera ( std::string_view  name,
std::span< const std::string >  hosts 
)
static

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostsArray of Camera host IPs/DNS names

◆ AddAxisCamera() [10/10]

static cs::AxisCamera frc::CameraServer::AddAxisCamera ( std::string_view  name,
std::string_view  host 
)
static

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostCamera host IP or DNS name (e.g. "10.x.y.11")

◆ AddCamera()

static void frc::CameraServer::AddCamera ( const cs::VideoSource camera)
static

Adds an already created camera.

Parameters
cameraCamera

◆ AddServer() [1/3]

static void frc::CameraServer::AddServer ( const cs::VideoSink server)
static

Adds an already created server.

Parameters
serverServer

◆ AddServer() [2/3]

static cs::MjpegServer frc::CameraServer::AddServer ( std::string_view  name)
static

Adds a MJPEG server at the next available port.

Parameters
nameServer name

◆ AddServer() [3/3]

static cs::MjpegServer frc::CameraServer::AddServer ( std::string_view  name,
int  port 
)
static

Adds a MJPEG server.

Parameters
nameServer name
portPort number

◆ AddSwitchedCamera()

static cs::MjpegServer frc::CameraServer::AddSwitchedCamera ( std::string_view  name)
static

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.

◆ GetServer() [1/2]

static cs::VideoSink frc::CameraServer::GetServer ( )
static

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() [2/2]

static cs::VideoSink frc::CameraServer::GetServer ( std::string_view  name)
static

Gets a server by name.

Parameters
nameServer name

◆ GetVideo() [1/5]

static cs::CvSink frc::CameraServer::GetVideo ( )
static

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() [2/5]

static cs::CvSink frc::CameraServer::GetVideo ( const cs::VideoSource camera)
static

Get OpenCV access to the specified camera.

This allows you to get images from the camera for image processing on the roboRIO.

Parameters
cameraCamera (e.g. as returned by startAutomaticCapture).

◆ GetVideo() [3/5]

static cs::CvSink frc::CameraServer::GetVideo ( const cs::VideoSource camera,
cs::VideoMode::PixelFormat  pixelFormat 
)
static

Get OpenCV access to the specified camera.

This allows you to get images from the camera for image processing on the roboRIO.

Parameters
cameraCamera (e.g. as returned by startAutomaticCapture).
pixelFormatThe desired pixelFormat of captured frames from the camera

◆ GetVideo() [4/5]

static cs::CvSink frc::CameraServer::GetVideo ( std::string_view  name)
static

Get OpenCV access to the specified camera.

This allows you to get images from the camera for image processing on the roboRIO.

Parameters
nameCamera name

◆ GetVideo() [5/5]

static cs::CvSink frc::CameraServer::GetVideo ( std::string_view  name,
cs::VideoMode::PixelFormat  pixelFormat 
)
static

Get OpenCV access to the specified camera.

This allows you to get images from the camera for image processing on the roboRIO.

Parameters
nameCamera name
pixelFormatThe desired pixelFormat of captured frames from the camera

◆ PutVideo()

static cs::CvSource frc::CameraServer::PutVideo ( std::string_view  name,
int  width,
int  height 
)
static

Create a MJPEG stream with OpenCV input.

This can be called to pass custom annotated images to the dashboard.

Parameters
nameName to give the stream
widthWidth of the image being sent
heightHeight of the image being sent

◆ RemoveCamera()

static void frc::CameraServer::RemoveCamera ( std::string_view  name)
static

Removes a camera by name.

Parameters
nameCamera name

◆ RemoveServer()

static void frc::CameraServer::RemoveServer ( std::string_view  name)
static

Removes a server by name.

Parameters
nameServer name

◆ StartAutomaticCapture() [1/5]

static cs::UsbCamera frc::CameraServer::StartAutomaticCapture ( )
static

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() [2/5]

static cs::MjpegServer frc::CameraServer::StartAutomaticCapture ( const cs::VideoSource camera)
static

Start automatically capturing images to send to the dashboard from an existing camera.

Parameters
cameraCamera

◆ StartAutomaticCapture() [3/5]

static cs::UsbCamera frc::CameraServer::StartAutomaticCapture ( int  dev)
static

Start automatically capturing images to send to the dashboard.

This overload calls StartAutomaticCapture() with a name of "USB Camera {dev}".

Parameters
devThe device number of the camera interface

◆ StartAutomaticCapture() [4/5]

static cs::UsbCamera frc::CameraServer::StartAutomaticCapture ( std::string_view  name,
int  dev 
)
static

Start automatically capturing images to send to the dashboard.

Parameters
nameThe name to give the camera
devThe device number of the camera interface

◆ StartAutomaticCapture() [5/5]

static cs::UsbCamera frc::CameraServer::StartAutomaticCapture ( std::string_view  name,
std::string_view  path 
)
static

Start automatically capturing images to send to the dashboard.

Parameters
nameThe name to give the camera
pathThe device path (e.g. "/dev/video0") of the camera

Member Data Documentation

◆ kBasePort

constexpr uint16_t frc::CameraServer::kBasePort = 1181
staticconstexpr

CameraServer base port.


The documentation for this class was generated from the following files: