Public Member Functions | Protected Attributes | List of all members
camera::CamInterface Class Reference

Virtual class which declares an general interface for imaging sensors. More...

#include <CamInterface.h>

Public Member Functions

 CamInterface ()
virtual ~CamInterface ()
virtual int listCameras (std::vector< CamInfo > &cam_infos) const
 Lists all available cameras.
virtual bool findCamera (const CamInfo &pattern, CamInfo &cam) const
 Returns information about the first camera that matches the pattern.
virtual int countCameras () const
 Counts the number of available cameras.
virtual bool open (const CamInfo &cam, const AccessMode mode=Master)
 Opens a specific camera.
virtual bool open2 (const std::string &display_name, const AccessMode mode=Master)
 Opens the first camera that matches the pattern.
virtual bool open2 (unsigned long &unique_camera_id, const AccessMode mode=Master)
 Opens the first camera that matches the pattern.
virtual bool open2 (const CamInfo &pattern, const AccessMode mode=Master)
 Opens the first camera that matches the pattern.
virtual bool isOpen () const
 Checks if the camera is open.
virtual const CamInfogetCameraInfo () const
 Returns a pointer to CamInfo of the opened camera.
virtual bool close ()
 Closes the camera.
virtual bool grab (const GrabMode mode=SingleFrame, const int buffer_len=1)
 Starts capturing into a buffer.
virtual bool retrieveFrame (base::samples::frame::Frame &frame, const int timeout=1000)
 Retrieves the next frame from the buffer (no data are copied).
virtual bool isFrameAvailable ()
 Checks if a frame can be retrieved from the buffer.
virtual int skipFrames ()
 Skips all buffered frame beside the last one.
virtual bool setIpSettings (const CamInfo &cam, const IPSettings &ip_settings) const
 Sets the IP adress and subnetmask of a ethernet camera.
virtual bool setAttrib (const int_attrib::CamAttrib attrib, const int value)
 Sets the value of an integer attribute.
virtual bool setAttrib (const double_attrib::CamAttrib attrib, const double value)
 Sets the value of a double attribute.
virtual bool setAttrib (const str_attrib::CamAttrib attrib, const std::string value)
 Sets the value of a string attribute.
virtual bool setAttrib (const enum_attrib::CamAttrib attrib)
 Sets the value of an enum attribute.
virtual bool isAttribAvail (const int_attrib::CamAttrib attrib)
 Checks if an integer attribute is available.
virtual bool isAttribAvail (const double_attrib::CamAttrib attrib)
 Checks if a double attribute is available.
virtual bool isAttribAvail (const str_attrib::CamAttrib attrib)
 Checks if a string attribute is available.
virtual bool isAttribAvail (const enum_attrib::CamAttrib attrib)
 Checks if a enum attribute is available.
virtual int getAttrib (const int_attrib::CamAttrib attrib)
 Returns the value of an integer attribute.
virtual double getAttrib (const double_attrib::CamAttrib attrib)
 Returns the value of a double attribute.
virtual std::string getAttrib (const str_attrib::CamAttrib attrib)
 Returns the value of a string attribute.
virtual bool isAttribSet (const enum_attrib::CamAttrib attrib)
 Checks if the enum attribute is set.
virtual CamInterfaceoperator>> (base::samples::frame::Frame &frame)
 Retrieves a camera frame (no data are copied)
virtual bool setFrameSettings (const base::samples::frame::frame_size_t size, const base::samples::frame::frame_mode_t mode, const uint8_t color_depth, const bool resize_frames=true)
 Sets the frame settings size, mode and color depth.
virtual bool setFrameSettings (const base::samples::frame::Frame &frame, const bool resize_frames=true)
 Sets the camera frame settings to the values of the frame.
virtual bool getFrameSettings (base::samples::frame::frame_size_t &size, base::samples::frame::frame_mode_t &mode, uint8_t &color_depth)
 Gets the actual frame settings size, mode and color depth.
virtual bool triggerFrame ()
 Triggers a new frame if FrameStartTriggerMode is set to Software.
virtual bool setToDefault ()
 Sets the camera to default settings.
virtual bool setFrameToCameraFrameSettings (base::samples::frame::Frame &frame)
 Configures the frame that it matches the camera frame settings.
virtual bool setCallbackFcn (void(*pcallback_function)(const void *p), void *p)
 Sets a callback function which is called when a new frame can be retrieved.
virtual void synchronizeWithSystemTime (uint32_t time_interval)
 synchronizes the camera time with the system time. Should be called only once
virtual void saveConfiguration (uint8_t index)
 saves the current camera configuration to the non-volatile memory inside the camera
virtual void loadConfiguration (uint8_t index)
 loads the camera configuration from the non-volatile memory
virtual void getRange (const double_attrib::CamAttrib attrib, double &dmin, double &dmax)
 returns the range of an double_attrib
virtual void getRange (const int_attrib::CamAttrib attrib, int &imin, int &imax)
 returns the range of an int_attrib
virtual int getFileDescriptor () const
 returns the file descriptor of the camera
virtual std::string doDiagnose ()
 does a camera diagnose

Protected Attributes

base::samples::frame::frame_size_t image_size_
base::samples::frame::frame_mode_t image_mode_
uint8_t image_color_depth_
GrabMode act_grab_mode_

Detailed Description

Virtual class which declares an general interface for imaging sensors.

Use this class as base class if you want to add your own sensor.

Constructor & Destructor Documentation

camera::CamInterface::CamInterface ( )
camera::CamInterface::~CamInterface ( )
virtual

Member Function Documentation

virtual bool camera::CamInterface::close ( )
inlinevirtual

Closes the camera.

Returns
returns true if no camera is open or the camera was closed
int camera::CamInterface::countCameras ( ) const
virtual

Counts the number of available cameras.

Returns
number of available cameras
std::string camera::CamInterface::doDiagnose ( )
virtual

does a camera diagnose

Returns
returns a diagnose as string
bool camera::CamInterface::findCamera ( const CamInfo pattern,
CamInfo cam 
) const
virtual

Returns information about the first camera that matches the pattern.

Parameters
patterncamera pattern
camstructure where the camera information is stored
Returns
returns false if no camera matches
virtual int camera::CamInterface::getAttrib ( const int_attrib::CamAttrib  attrib)
inlinevirtual

Returns the value of an integer attribute.

Parameters
attribidentifier of the attribute
Returns
attribute value
virtual double camera::CamInterface::getAttrib ( const double_attrib::CamAttrib  attrib)
inlinevirtual

Returns the value of a double attribute.

Parameters
attribidentifier of the attribute
Returns
attribute value
virtual std::string camera::CamInterface::getAttrib ( const str_attrib::CamAttrib  attrib)
inlinevirtual

Returns the value of a string attribute.

Parameters
attribidentifier of the attribute
Returns
attribute value
virtual const CamInfo* camera::CamInterface::getCameraInfo ( ) const
inlinevirtual

Returns a pointer to CamInfo of the opened camera.

Returns
pointer to CamInfo (NULL if no camera is open)
virtual int camera::CamInterface::getFileDescriptor ( ) const
inlinevirtual

returns the file descriptor of the camera

Returns
returns a file descriptor
virtual bool camera::CamInterface::getFrameSettings ( base::samples::frame::frame_size_t &  size,
base::samples::frame::frame_mode_t &  mode,
uint8_t &  color_depth 
)
inlinevirtual

Gets the actual frame settings size, mode and color depth.

Parameters
sizesize of the frame in pixel
modecolor mode of the frame (MODE_GRAYSCALE,MODE_RGB,...)
color_depthnumber of bytes per pixel
Returns
returns false if no camera is opened
virtual void camera::CamInterface::getRange ( const double_attrib::CamAttrib  attrib,
double &  dmin,
double &  dmax 
)
inlinevirtual

returns the range of an double_attrib

Parameters
attribidentifier of the attribute
dminMinimum value returned here
dmaxMaximum value returned here
virtual void camera::CamInterface::getRange ( const int_attrib::CamAttrib  attrib,
int &  imin,
int &  imax 
)
inlinevirtual

returns the range of an int_attrib

Parameters
attribidentifier of the attribute
dminMinimum value returned here
dmaxMaximum value returned here
virtual bool camera::CamInterface::grab ( const GrabMode  mode = SingleFrame,
const int  buffer_len = 1 
)
inlinevirtual

Starts capturing into a buffer.

Parameters
modecapturing mode (SingleFrame, MultiFrame, Continuously)
buffer_lenlength of the buffer in frames.
Returns
returns true if capturing was started
virtual bool camera::CamInterface::isAttribAvail ( const int_attrib::CamAttrib  attrib)
inlinevirtual

Checks if an integer attribute is available.

Parameters
attribidentifier of the attribute to be checked
Returns
returns true if the attribute is available
virtual bool camera::CamInterface::isAttribAvail ( const double_attrib::CamAttrib  attrib)
inlinevirtual

Checks if a double attribute is available.

Parameters
attribidentifier of the attribute to be checked
Returns
returns true if the attribute is available
virtual bool camera::CamInterface::isAttribAvail ( const str_attrib::CamAttrib  attrib)
inlinevirtual

Checks if a string attribute is available.

Parameters
attribidentifier of the attribute to be checked
Returns
returns true if the attribute is available
virtual bool camera::CamInterface::isAttribAvail ( const enum_attrib::CamAttrib  attrib)
inlinevirtual

Checks if a enum attribute is available.

Parameters
attribidentifier of the attribute to be checked
Returns
returns true if the attribute is available
virtual bool camera::CamInterface::isAttribSet ( const enum_attrib::CamAttrib  attrib)
inlinevirtual

Checks if the enum attribute is set.

Parameters
attribidentifier of the attribute
Returns
returns true if the enum attribute is set
virtual bool camera::CamInterface::isFrameAvailable ( )
inlinevirtual

Checks if a frame can be retrieved from the buffer.

Returns
returns true if a frame can be retrieved without blocking
virtual bool camera::CamInterface::isOpen ( ) const
inlinevirtual

Checks if the camera is open.

Returns
returns true if the camera is open
virtual int camera::CamInterface::listCameras ( std::vector< CamInfo > &  cam_infos) const
inlinevirtual

Lists all available cameras.

Parameters
cam_infosvector of all available cameras
Returns
number of listed cameras
virtual void camera::CamInterface::loadConfiguration ( uint8_t  index)
inlinevirtual

loads the camera configuration from the non-volatile memory

Parameters
indexindex of the file (allowed values 0-3; 0 = factory defaults)
virtual bool camera::CamInterface::open ( const CamInfo cam,
const AccessMode  mode = Master 
)
inlinevirtual

Opens a specific camera.

Parameters
camcamera which shall be opened
modeconnection mode (eMaster, eMonitor)
Returns
returns true if the camera is open after the call
bool camera::CamInterface::open2 ( const std::string &  display_name,
const AccessMode  mode = Master 
)
virtual

Opens the first camera that matches the pattern.

This functions uses findCamera() and open() to open the camera.

Parameters
display_namedisplay name of the camera
modeconnection mode (eMaster, eMonitor)
Returns
returns true if the camera is open after the call
bool camera::CamInterface::open2 ( unsigned long &  unique_camera_id,
const AccessMode  mode = Master 
)
virtual

Opens the first camera that matches the pattern.

This functions uses findCamera() and open() to open the camera.

Parameters
unique_camera_idunique camera id
modeconnection mode (eMaster, eMonitor)
Returns
returns true if the camera is open after the call
bool camera::CamInterface::open2 ( const CamInfo pattern,
const AccessMode  mode = Master 
)
virtual

Opens the first camera that matches the pattern.

This functions uses findCamera() and open() to open the camera.

Parameters
patterncamera pattern
modeconnection mode (eMaster, eMonitor)
Returns
returns true if the camera is open after the call
CamInterface & camera::CamInterface::operator>> ( base::samples::frame::Frame &  frame)
virtual

Retrieves a camera frame (no data are copied)

If grab is called in advance the operator is equal to the function retrieveFrame(). Otherwise the function calls grab(eSingleFrame,1) and retrieveFrame().

Parameters
framestructure where the frame is stored.
Attention
The frame must have the same size like the returned frame because the function swaps the image vector and does not copy any data. Therfore any stored pointer to the vector data are no more valid after calling the function.
virtual bool camera::CamInterface::retrieveFrame ( base::samples::frame::Frame &  frame,
const int  timeout = 1000 
)
inlinevirtual

Retrieves the next frame from the buffer (no data are copied).

This function is synchron and blocks until a frame can be retrieved from the buffer or a timeout occurs. To check if a frame can be retrievt call isFrameAvailable().

Parameters
framestructure where the frame is stored.
timeouttimeout waiting for a frame, in milliseconds
Returns
returns true if a frame was retrieved
Attention
The frame must have the same size like the returned frame because the function swaps the image vector and does not copy any data. Therfore any stored pointer to the vector data are no more valid after calling the function.
virtual void camera::CamInterface::saveConfiguration ( uint8_t  index)
inlinevirtual

saves the current camera configuration to the non-volatile memory inside the camera

Parameters
indexindex of the file (allowed values 1-3)
virtual bool camera::CamInterface::setAttrib ( const int_attrib::CamAttrib  attrib,
const int  value 
)
inlinevirtual

Sets the value of an integer attribute.

Parameters
attribidentifier of the attribute to be changed
valuenew integer value.
Returns
returns true if the change was succesfull
virtual bool camera::CamInterface::setAttrib ( const double_attrib::CamAttrib  attrib,
const double  value 
)
inlinevirtual

Sets the value of a double attribute.

Parameters
attribidentifier of the attribute to be changed
valuenew double value.
Returns
returns true if the change was succesfull
virtual bool camera::CamInterface::setAttrib ( const str_attrib::CamAttrib  attrib,
const std::string  value 
)
inlinevirtual

Sets the value of a string attribute.

Parameters
attribidentifier of the attribute to be changed
valuenew string value.
Returns
returns true if the change was succesfull
virtual bool camera::CamInterface::setAttrib ( const enum_attrib::CamAttrib  attrib)
inlinevirtual

Sets the value of an enum attribute.

Parameters
attribidentifier of the attribute to be changed
valuenew enum value.
Returns
returns true if the change was succesfull
virtual bool camera::CamInterface::setCallbackFcn ( void(*)(const void *p)  pcallback_function,
void *  p 
)
inlinevirtual

Sets a callback function which is called when a new frame can be retrieved.

Parameters
pfunctionfunction pointer to a function which is called when a new frame can be retrieved by the function retrieveFrame(). The callback function must follow the syntax 'static void fcn(const void* p)'
Returns
pointer which is passed to the callback function function
Attention
CamInterface is not thread save. Do not call any function of it without mutex protection if you want to use an instance in more than one thread!
bool camera::CamInterface::setFrameSettings ( const base::samples::frame::frame_size_t  size,
const base::samples::frame::frame_mode_t  mode,
const uint8_t  color_depth,
const bool  resize_frames = true 
)
virtual

Sets the frame settings size, mode and color depth.

Parameters
sizesize of the frame in pixel
modecolor mode of the frame (MODE_GRAYSCALE,MODE_RGB,...)
color_depthnumber of bytes per pixel
resize_framesresizes all buffered frame to the right size
Returns
returns true if the settings were set succsessfully
bool camera::CamInterface::setFrameSettings ( const base::samples::frame::Frame &  frame,
const bool  resize_frames = true 
)
virtual

Sets the camera frame settings to the values of the frame.

Parameters
frameframe which descripes the settings to be set
resize_framesresizes all buffered frame to the right size
Returns
returns true if the settings were set succsessfully
bool camera::CamInterface::setFrameToCameraFrameSettings ( base::samples::frame::Frame &  frame)
virtual

Configures the frame that it matches the camera frame settings.

Parameters
frameframe to be configured
Returns
returns false if no camera is opened
virtual bool camera::CamInterface::setIpSettings ( const CamInfo cam,
const IPSettings ip_settings 
) const
inlinevirtual

Sets the IP adress and subnetmask of a ethernet camera.

Parameters
camcamera whose ip settings shall be changed
ip_settingsip settings to be set.
Returns
returns true if the change was succesfull
virtual bool camera::CamInterface::setToDefault ( )
inlinevirtual

Sets the camera to default settings.

Returns
returns false if no camera is opened
virtual int camera::CamInterface::skipFrames ( )
inlinevirtual

Skips all buffered frame beside the last one.

Returns
returns the number of skipped frames
virtual void camera::CamInterface::synchronizeWithSystemTime ( uint32_t  time_interval)
inlinevirtual

synchronizes the camera time with the system time. Should be called only once

Parameters
time_intervallTime interval in ms for statistical calculations. The functions blocks in the meantime
virtual bool camera::CamInterface::triggerFrame ( )
inlinevirtual

Triggers a new frame if FrameStartTriggerMode is set to Software.

Returns
returns false if no camera is opened

Member Data Documentation

GrabMode camera::CamInterface::act_grab_mode_
protected
uint8_t camera::CamInterface::image_color_depth_
protected
base::samples::frame::frame_mode_t camera::CamInterface::image_mode_
protected
base::samples::frame::frame_size_t camera::CamInterface::image_size_
protected

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