WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
frc::CameraServer Class Reference

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

#include <CameraServer.h>

Inheritance diagram for frc::CameraServer:
frc::ErrorBase

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 (llvm::StringRef name, int dev)
 Start automatically capturing images to send to the dashboard. More...
 
cs::UsbCamera StartAutomaticCapture (llvm::StringRef name, llvm::StringRef path)
 Start automatically capturing images to send to the dashboard. More...
 
void StartAutomaticCapture (const cs::VideoSource &camera)
 Start automatically capturing images to send to the dashboard from an existing camera. 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 (llvm::StringRef name)
 Get OpenCV access to the specified camera. More...
 
cs::CvSource PutVideo (llvm::StringRef name, int width, int height)
 Create a MJPEG stream with OpenCV input. More...
 
cs::MjpegServer AddServer (llvm::StringRef name)
 Adds a MJPEG server at the next available port. More...
 
cs::MjpegServer AddServer (llvm::StringRef name, int port)
 Adds a MJPEG server. More...
 
void AddServer (const cs::VideoSink &server)
 Adds an already created server. More...
 
void RemoveServer (llvm::StringRef name)
 Removes a server by name. More...
 
void AddCamera (const cs::VideoSource &camera)
 Adds an already created camera. More...
 
void RemoveCamera (llvm::StringRef name)
 Removes a camera by name. More...
 
void SetSize (int size)
 Sets the size of the image to use. More...
 
- Public Member Functions inherited from frc::ErrorBase
 ErrorBase (const ErrorBase &)=delete
 
ErrorBaseoperator= (const ErrorBase &)=delete
 
virtual ErrorGetError ()
 Retrieve the current error. More...
 
virtual const ErrorGetError () const
 
virtual void SetErrnoError (llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetErrorRange (Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (llvm::StringRef errorMessage, Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (const ErrorBase &rhs) const
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 

Static Public Member Functions

static CameraServerGetInstance ()
 Get the CameraServer instance.
 
- Static Public Member Functions inherited from frc::ErrorBase
static void SetGlobalError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber)
 
static void SetGlobalWPIError (llvm::StringRef errorMessage, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber)
 
static ErrorGetGlobalError ()
 Retrieve the current global error.
 

Static Public Attributes

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

Additional Inherited Members

- Protected Attributes inherited from frc::ErrorBase
Error m_error
 
- Static Protected Attributes inherited from frc::ErrorBase
static priority_mutex _globalErrorMutex
 
static Error _globalError
 

Detailed Description

Singleton class for creating and keeping camera servers.

Also publishes camera information to NetworkTables.

Member Function Documentation

void CameraServer::AddCamera ( const cs::VideoSource &  camera)

Adds an already created camera.

Parameters
cameraCamera
cs::MjpegServer CameraServer::AddServer ( llvm::StringRef  name)

Adds a MJPEG server at the next available port.

Parameters
nameServer name
cs::MjpegServer CameraServer::AddServer ( llvm::StringRef  name,
int  port 
)

Adds a MJPEG server.

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

Adds an already created server.

Parameters
serverServer
cs::CvSink 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 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 CameraServer::GetVideo ( llvm::StringRef  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 CameraServer::PutVideo ( llvm::StringRef  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 CameraServer::RemoveCamera ( llvm::StringRef  name)

Removes a camera by name.

Parameters
nameCamera name
void CameraServer::RemoveServer ( llvm::StringRef  name)

Removes a server by name.

Parameters
nameServer name
void 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 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.

This overload calls StartAutomaticCapture(int) with device 0, creating a camera named "USB Camera 0".

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

Start automatically capturing images to send to the dashboard.

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

Parameters
devThe device number of the camera interface
cs::UsbCamera CameraServer::StartAutomaticCapture ( llvm::StringRef  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 CameraServer::StartAutomaticCapture ( llvm::StringRef  name,
llvm::StringRef  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
void 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: