WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
frc::CameraServer Class Reference

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

#include <CameraServer.h>

Public Member Functions

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

Static Public Member Functions

static CameraServerGetInstance ()
 Get the CameraServer instance.
 

Static Public Attributes

static constexpr uint16_t kBasePort = 1181
 
static constexpr int kSize640x480 = 0
 
static constexpr int kSize320x240 = 1
 
static constexpr int kSize160x120 = 2
 

Detailed Description

Singleton class for creating and keeping camera servers.

Also publishes camera information to NetworkTables.

Member Function Documentation

cs::AxisCamera frc::CameraServer::AddAxisCamera ( const wpi::Twine host)

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")
cs::AxisCamera frc::CameraServer::AddAxisCamera ( const char *  host)

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")
cs::AxisCamera frc::CameraServer::AddAxisCamera ( const std::string &  host)

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")
cs::AxisCamera frc::CameraServer::AddAxisCamera ( wpi::ArrayRef< std::string >  hosts)

Adds an Axis IP camera.

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

Parameters
hostsArray of Camera host IPs/DNS names
template<typename T >
cs::AxisCamera frc::CameraServer::AddAxisCamera ( std::initializer_list< T >  hosts)
inline

Adds an Axis IP camera.

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

Parameters
hostsArray of Camera host IPs/DNS names
cs::AxisCamera frc::CameraServer::AddAxisCamera ( const wpi::Twine name,
const wpi::Twine host 
)

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostCamera host IP or DNS name (e.g. "10.x.y.11")
cs::AxisCamera frc::CameraServer::AddAxisCamera ( const wpi::Twine name,
const char *  host 
)

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostCamera host IP or DNS name (e.g. "10.x.y.11")
cs::AxisCamera frc::CameraServer::AddAxisCamera ( const wpi::Twine name,
const std::string &  host 
)

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostCamera host IP or DNS name (e.g. "10.x.y.11")
cs::AxisCamera frc::CameraServer::AddAxisCamera ( const wpi::Twine name,
wpi::ArrayRef< std::string >  hosts 
)

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostsArray of Camera host IPs/DNS names
template<typename T >
cs::AxisCamera frc::CameraServer::AddAxisCamera ( const wpi::Twine name,
std::initializer_list< T >  hosts 
)
inline

Adds an Axis IP camera.

Parameters
nameThe name to give the camera
hostsArray of Camera host IPs/DNS names
void frc::CameraServer::AddCamera ( const cs::VideoSource camera)

Adds an already created camera.

Parameters
cameraCamera
cs::MjpegServer frc::CameraServer::AddServer ( const wpi::Twine name)

Adds a MJPEG server at the next available port.

Parameters
nameServer name
cs::MjpegServer frc::CameraServer::AddServer ( const wpi::Twine name,
int  port 
)

Adds a MJPEG server.

Parameters
nameServer name
void frc::CameraServer::AddServer ( const cs::VideoSink server)

Adds an already created server.

Parameters
serverServer
cs::MjpegServer frc::CameraServer::AddSwitchedCamera ( const wpi::Twine name)

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.

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

Get server for the primary camera feed.

This is only valid to call after a camera feed has been added with StartAutomaticCapture() or AddServer().

cs::VideoSink frc::CameraServer::GetServer ( const wpi::Twine name)

Gets a server by name.

Parameters
nameServer name
cs::CvSink frc::CameraServer::GetVideo ( )

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().

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

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).
cs::CvSink frc::CameraServer::GetVideo ( const wpi::Twine name)

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
cs::CvSource frc::CameraServer::PutVideo ( const wpi::Twine name,
int  width,
int  height 
)

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
void frc::CameraServer::RemoveCamera ( const wpi::Twine name)

Removes a camera by name.

Parameters
nameCamera name
void frc::CameraServer::RemoveServer ( const wpi::Twine name)

Removes a server by name.

Parameters
nameServer name
void frc::CameraServer::SetSize ( int  size)

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
sizeThe size to use
cs::UsbCamera frc::CameraServer::StartAutomaticCapture ( )

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).

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

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
cs::UsbCamera frc::CameraServer::StartAutomaticCapture ( const wpi::Twine name,
int  dev 
)

Start automatically capturing images to send to the dashboard.

Parameters
nameThe name to give the camera
devThe device number of the camera interface
cs::UsbCamera frc::CameraServer::StartAutomaticCapture ( const wpi::Twine name,
const wpi::Twine path 
)

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
cs::MjpegServer frc::CameraServer::StartAutomaticCapture ( const cs::VideoSource camera)

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

Parameters
cameraCamera

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