rec::robotino::api2 C++ interface
Public Member Functions | Static Public Member Functions | Friends | List of all members
rec::robotino::api2::Camera Class Reference

Represents a camera. More...

#include <Camera.h>

Inheritance diagram for rec::robotino::api2::Camera:
rec::robotino::api2::ComObject

Public Member Functions

 Camera ()
 
 Camera (const ComId &id)
 
virtual ~Camera ()
 
void setComId (const ComId &id)
 
void setCameraNumber (int number)
 
int cameraNumber () const
 
void setJPGDecodingEnabled (bool enable)
 
bool isJPGDecodingEnabled () const
 
void processEvents ()
 
void setReadWrite ()
 
void setWriteOnly ()
 
void setJPGImage (const unsigned char *data, unsigned int dataSize)
 
void setFormat (unsigned int width, unsigned int height, const char *format)
 
void setBrightness (int value)
 
void setContrast (int value)
 
void setSaturation (int value)
 
void setAutoWhiteBalanceEnabled (bool enable)
 
void setGain (int value)
 
void setWhiteBalanceTemperature (int value)
 
void setBacklightCompensation (int value)
 
void setAutoExposureEnabled (bool enable)
 
void setExposure (int value)
 
void setAutoFocusEnabled (bool enable)
 
void setFocus (int value)
 
void setSharpness (int value)
 
CameraCapabilities capabilities () const
 
int calibration (double **buffer, unsigned int bufferSize)
 
bool isNewImageAvailable (unsigned int *dataSize) const
 
bool getImage (unsigned char **data, unsigned int dataSize, unsigned int *width, unsigned int *height, unsigned int *step)
 
void setBGREnabled (bool enable)
 
bool isBGRenabled () const
 
bool isLocalConnection () const
 
virtual void imageReceivedEvent (const unsigned char *data, unsigned int dataSize, unsigned int width, unsigned int height, unsigned int step)
 
virtual void capabilitiesChangedEvent (const rec::robotino::api2::CameraCapabilities &capablities)
 
virtual void settingsChangedEvent (unsigned int width, unsigned int height, const char *format)
 
virtual void calibrationChanged (const double *data, unsigned int dataSize)
 
- Public Member Functions inherited from rec::robotino::api2::ComObject
 ComObject ()
 
virtual ~ComObject ()
 
ComId comId () const
 

Static Public Member Functions

static unsigned int numCameras ()
 

Friends

class CameraImpl
 

Additional Inherited Members

- Protected Attributes inherited from rec::robotino::api2::ComObject
ComId _comID
 

Detailed Description

Represents a camera.

Constructor & Destructor Documentation

rec::robotino::api2::Camera::Camera ( )

Constructs a camera.

virtual rec::robotino::api2::Camera::~Camera ( )
virtual

Destructor.

Member Function Documentation

int rec::robotino::api2::Camera::calibration ( double **  buffer,
unsigned int  bufferSize 
)

Get the current calibration

Parameters
bufferA array of doubles provided by you to be filled with the calibration
bufferSizeThe size of the buffer provided
Returns
Returns the number of values copied to buffer.
virtual void rec::robotino::api2::Camera::calibrationChanged ( const double *  data,
unsigned int  dataSize 
)
virtual

Called when camera calibration is received

Exceptions
nothing.
Remarks
This function is called from the thread in which Com::processEvents() or Camera::processEvents() is called.
See also
Com::processEvents, Camera::processEvents
int rec::robotino::api2::Camera::cameraNumber ( ) const

Get the current camera number.

Returns
Returns the current camera number or -1 if no camera is selected.
Exceptions
nothing
See also
setCameraNumber
CameraCapabilities rec::robotino::api2::Camera::capabilities ( ) const
Returns
The camera's capapibilities.
virtual void rec::robotino::api2::Camera::capabilitiesChangedEvent ( const rec::robotino::api2::CameraCapabilities capablities)
virtual

Called when camera capabilities are received

Exceptions
nothing.
Remarks
This function is called from the thread in which Com::processEvents() or Camera::processEvents() is called.
See also
Com::processEvents
bool rec::robotino::api2::Camera::getImage ( unsigned char **  data,
unsigned int  dataSize,
unsigned int *  width,
unsigned int *  height,
unsigned int *  step 
)

Get the latest image.

Parameters
dataBuffer where the RGB interleaved image is copied to.
dataSizeMaximum dataSize bytes are copied to the buffer data is pointing to.
widthThe number of pixels per line. If width=height=step=0 this is a JPG encoded image.
heightThe number of lines
stepThe number of bytes per line.
Returns
Returns true if the image fits into the provided buffer, i.e. dataSize >= step*height. Returns false otherwise.
Exceptions
nothing.
See also
isNewImageAvailable
virtual void rec::robotino::api2::Camera::imageReceivedEvent ( const unsigned char *  data,
unsigned int  dataSize,
unsigned int  width,
unsigned int  height,
unsigned int  step 
)
virtual

Called when an image is received.

Parameters
dataContains the image data as RGB interleaved image. You must not delete this buffer. Instead you should make a copy of this buffer within this function call.
dataSizeIs the size of the data buffer containing the RGB image.
widthThe number of pixels per line. If width=height=step=0 this is a JPG encoded image.
heightThe number of lines
stepThe number of bytes per line.
Exceptions
nothing.
Remarks
This function is called from the thread in which Com::processEvents() or Camera::processEvents() is called.
See also
Com::processEvents
bool rec::robotino::api2::Camera::isBGRenabled ( ) const

Get the current channel order.

Returns
If true the channel order is BGR. Otherwise the channel order is RGB (the default).
bool rec::robotino::api2::Camera::isJPGDecodingEnabled ( ) const

Shows the current settings for decoding JPG images.

Returns
Returns the current setting. True - decoding enabled, false otherwise.
Exceptions
nothing
bool rec::robotino::api2::Camera::isLocalConnection ( ) const
Returns
Returns true if the connection is a local connection. Otherwise returns false.
bool rec::robotino::api2::Camera::isNewImageAvailable ( unsigned int *  dataSize) const

Check for new images.

Parameters
dataSizeStores the size in bytes of the available image. When you get the image with getImage your buffer must be at least of size dataSize.
Exceptions
nothing
See also
getImage
static unsigned int rec::robotino::api2::Camera::numCameras ( )
static
Returns
Returns the number of supported cameras.
void rec::robotino::api2::Camera::processEvents ( )

Call this function from your main thread to get the virtual Camera functions called. The virtual functions are called directly by a call of this function

Exceptions
nothing
See also
Com::processEvents
void rec::robotino::api2::Camera::setAutoExposureEnabled ( bool  enable)

Enable auto exposure.

Parameters
enable
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setAutoFocusEnabled ( bool  enable)

Enable auto focus.

Parameters
enable
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setAutoWhiteBalanceEnabled ( bool  enable)

Enable auto white balance.

Parameters
enable
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setBacklightCompensation ( int  value)

Set the backlight compensation.

Parameters
value
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setBGREnabled ( bool  enable)

Swap channels in the received image

By default the channel order is RGB.

Parameters
enableIf true the channel order is set to BGR.
void rec::robotino::api2::Camera::setBrightness ( int  value)

Set the brightness.

Parameters
value
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setCameraNumber ( int  number)

Sets the number of this camera device.

Set the number of this camera to number. The default camera number is 0. Setting the camera number only makes sense when your Robotino is equipped with more than one camera.

Parameters
numberThe camera number. Range [0; numCameras()-1]. When setting number < 0 no camera is selected.
Exceptions
RobotinoExceptionif the given input number is out of range. RobotinoException if given com object is invalid.
See also
numCameras
void rec::robotino::api2::Camera::setComId ( const ComId id)

Sets the associated communication object.

Parameters
idThe id of the associated communication object.
Exceptions
RobotinoExceptionif given id is invalid.
Remarks
This function is thread save
void rec::robotino::api2::Camera::setContrast ( int  value)

Set the contrast.

Parameters
value
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setExposure ( int  value)

Set the exposure.

Parameters
value
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setFocus ( int  value)

Set the focus.

Parameters
value
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setFormat ( unsigned int  width,
unsigned int  height,
const char *  format 
)

Sets this camera to the given resolution (if possible)

Parameters
widthRequested image width
heightRequested image height
format"mjpg" to request JPEG compress images. "raw" to request raw RGB images.
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setGain ( int  value)

Set the gain.

Parameters
value
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setJPGDecodingEnabled ( bool  enable)

Enable/Disable decoding of JPG images. The decoding is enabled by default.

On iOS libjpeg is not linked into the API2 libraries. Decoding a jpeg image by this camera class will crash your app. Disable decoding and look for imageReceivedEvents with dataSize>0 and width==0. This is a jpeg image which must be decoded by yourself. If you have a Qt app you can use QImage::fromData(data,dataSize,"jpg") for decoding.

If true, decoding is enabled. If false, decoding is disabled.

Exceptions
nothing
void rec::robotino::api2::Camera::setJPGImage ( const unsigned char *  data,
unsigned int  dataSize 
)

Publish a jpg image to the camera topic.

Parameters
dataThe jpg image data.
dataSizeNumber of bytes in the data array.
void rec::robotino::api2::Camera::setReadWrite ( )

Enable this camera to receive images and to write inmages.

void rec::robotino::api2::Camera::setSaturation ( int  value)

Set the saturation.

Parameters
value
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setSharpness ( int  value)

Set the sharpness.

Parameters
value
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
virtual void rec::robotino::api2::Camera::settingsChangedEvent ( unsigned int  width,
unsigned int  height,
const char *  format 
)
virtual

Called when camera settings are received

Exceptions
nothing.
Remarks
This function is called from the thread in which Com::processEvents() or Camera::processEvents() is called.
See also
Com::processEvents
void rec::robotino::api2::Camera::setWhiteBalanceTemperature ( int  value)

Set the white balance temperature.

Parameters
value
Exceptions
RobotinoExceptionif given com object is invalid.
See also
capabilites
void rec::robotino::api2::Camera::setWriteOnly ( )

Enable this camera to write inmages but disable the receiving of images. This disables calls to imageReceivedEvent.


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