Follow this link to skip to the main content

claraty::Camera Class Reference

#include <camera.h>

Inheritance diagram for claraty::Camera:

Inheritance graph
[legend]
Collaboration diagram for claraty::Camera:

Collaboration graph
[legend]
List of all members.

Public Types

enum  IMAGE_FORMAT {
  MONO8, YUV411, YUV422, YUV444,
  RGB8, MONO16, RGB16
}

Public Member Functions

virtual bool io (FDM_Map map)
void set_camera_model_ptr (Camera_Model *cm)
const Camera_Modelget_camera_model_ptr () const
virtual bool set_contrast (double gain_proportion=DONT_CARE)
virtual double get_contrast () const
virtual bool set_brightness (double offset=DONT_CARE)
virtual double get_brightness () const
virtual bool set_exposure (double seconds=DONT_CARE)
virtual double get_exposure () const
virtual bool set_format (IMAGE_FORMAT format, int width_pixels=-1, int height_pixels=-1)
virtual IMAGE_FORMAT get_format () const
virtual int get_width () const=0
virtual int get_height () const=0
virtual bool set_subframe (int width_offset, int height_offset, int width, int height)
virtual int get_subframe_width_offset () const
virtual int get_subframe_height_offset () const
virtual int get_subframe_width () const
virtual int get_subframe_height () const
virtual void acquire (Image< uint8_t > &image, Time *timestamp_ptr=NULL, Feature_Map *feature_map_ptr=NULL)=0 throw (std::exception)
 Acquire an Image (unsigned char version).
virtual void acquire (Image< uint16_t > &image, Time *timestamp_ptr=NULL, Feature_Map *feature_map_ptr=NULL)=0 throw (std::exception)
 Acquire an Image (unsigned short version).
template<class Pixel_Type>
void acquire (Camera_Image< Pixel_Type > &image) throw (std::exception)
 Acquire a Camera_Image (template version).
bool on ()
bool off ()
bool is_on ()
void set_power_switch (Power_Switch &sw)
std::string get_name () const
std::ostream & display_xml (const char *p, std::ostream &os=std::cout) const

Static Public Attributes

static const double DONT_CARE = -DOUBLE_EPSILON

Protected Member Functions

void _verify_pixel_format (size_t pixel_size)
template<class Pixel_Type>
void _verify_resize_image (Image< Pixel_Type > &image)

Protected Attributes

Camera_Model_camera_model_ptr
std::string _name
Power_Switch_power_switch

Friends

class Camera_Group

Detailed Description

Definition at line 107 of file camera.h.


Member Enumeration Documentation

Enumerator:
MONO8 
YUV411 
YUV422 
YUV444 
RGB8 
MONO16 
RGB16 

Definition at line 114 of file camera.h.

00114                     { MONO8,                  // Image<uint8_t>
00115                       YUV411,                 // Image<uint8_t>
00116                       YUV422,                 // Image<uint8_t>
00117                       YUV444,                 // Image<uint8_t>
00118                       RGB8,                   // Image<uint8_t>
00119                       MONO16,                 // Image<uint16_t>
00120                       RGB16 };                // Image<uint16_t>


Constructor & Destructor Documentation

claraty::Camera::Camera ( const std::string &  device_name = "def_cam",
Camera_Model camera_model_ptr = NULL 
)

virtual claraty::Camera::~Camera (  )  [inline, virtual]

Definition at line 134 of file camera.h.

00135   { }

claraty::Camera::Camera ( const std::string &  device_name = "def_cam",
Camera_Model camera_model_ptr = NULL 
)

virtual claraty::Camera::~Camera (  )  [inline, virtual]

Definition at line 134 of file camera.h.

00135   { }


Member Function Documentation

void claraty::Camera::set_camera_model_ptr ( Camera_Model cm  )  [inline]

Definition at line 141 of file camera.h.

References _camera_model_ptr.

00141 {_camera_model_ptr = cm;}

const Camera_Model* claraty::Camera::get_camera_model_ptr (  )  const [inline]

Definition at line 143 of file camera.h.

References _camera_model_ptr.

00144   {
00145     return _camera_model_ptr;
00146   }

virtual bool claraty::Camera::set_contrast ( double  gain_proportion = DONT_CARE  )  [inline, virtual]

Definition at line 151 of file camera.h.

00151 { return false; }

virtual double claraty::Camera::get_contrast (  )  const [inline, virtual]

Definition at line 152 of file camera.h.

00152 { return 1.0; }

virtual bool claraty::Camera::set_brightness ( double  offset = DONT_CARE  )  [inline, virtual]

Definition at line 155 of file camera.h.

00155 { return false; }

virtual double claraty::Camera::get_brightness (  )  const [inline, virtual]

Definition at line 156 of file camera.h.

00156 { return 1.0;   }

virtual bool claraty::Camera::set_exposure ( double  seconds = DONT_CARE  )  [inline, virtual]

Definition at line 157 of file camera.h.

00157 { return false; }

virtual double claraty::Camera::get_exposure (  )  const [inline, virtual]

Definition at line 158 of file camera.h.

00158 { return 1.0;   }

virtual bool claraty::Camera::set_format ( IMAGE_FORMAT  format,
int  width_pixels = -1,
int  height_pixels = -1 
) [inline, virtual]

Definition at line 161 of file camera.h.

00163                                                                    { return false; }

virtual IMAGE_FORMAT claraty::Camera::get_format (  )  const [inline, virtual]

Definition at line 164 of file camera.h.

References MONO8.

Referenced by _verify_pixel_format().

00164 { return MONO8; }

virtual int claraty::Camera::get_width (  )  const [pure virtual]

Implemented in claraty::A_Camera.

Referenced by _verify_resize_image(), and get_subframe_width().

virtual int claraty::Camera::get_height (  )  const [pure virtual]

Implemented in claraty::A_Camera.

Referenced by _verify_resize_image(), and get_subframe_height().

virtual bool claraty::Camera::set_subframe ( int  width_offset,
int  height_offset,
int  width,
int  height 
) [inline, virtual]

Definition at line 178 of file camera.h.

00181                                                     { return false; }

virtual int claraty::Camera::get_subframe_width_offset (  )  const [inline, virtual]

Definition at line 182 of file camera.h.

00182 { return 0; }

virtual int claraty::Camera::get_subframe_height_offset (  )  const [inline, virtual]

Definition at line 183 of file camera.h.

00183 { return 0; }

virtual int claraty::Camera::get_subframe_width (  )  const [inline, virtual]

Definition at line 187 of file camera.h.

References get_width().

00187 { return get_width(); };

Here is the call graph for this function:

virtual int claraty::Camera::get_subframe_height (  )  const [inline, virtual]

Definition at line 188 of file camera.h.

References get_height().

00188 { return get_height(); };

Here is the call graph for this function:

virtual void claraty::Camera::acquire ( Image< uint8_t > &  image,
Time timestamp_ptr = NULL,
Feature_Map *  feature_map_ptr = NULL 
) throw (std::exception) [pure virtual]

Acquire an Image (unsigned char version).

A derived class must implement acquire with the following behavior: 1. Verify that the the current image format (as set by set_format) is not one of the 8 bit formats (MONO8, YUV411, YUV422, YUV444, RGB8), otherwise throw invalid_argument. 2. Set the physical camera parameter settings to match those of this logical camera parameters. 3. Resize the image to match the current camera format if necessary. 4. Acquire an image from the physical camera. 5. If *timestamp_ptr not NULL, fill with the time the image was acquired. 6. If *feature_map_prt not NULL, fill with the camera parameter setting in effect at the time the image was acquired.

During this process any other error encountered causes an exception derived from Camera_Exception to be thrown.

Parameters:
[out] image Returns newly acquired Image. The Image is resized to match the image size returned by the camera.
[out] timestamp_ptr If not NULL, returns time of image acquisition.
[out] feature_map_ptr If not NULL, returns camera feature settings in effect at image acquisition time.

Implemented in claraty::A_Camera.

Referenced by acquire().

virtual void claraty::Camera::acquire ( Image< uint16_t > &  image,
Time timestamp_ptr = NULL,
Feature_Map *  feature_map_ptr = NULL 
) throw (std::exception) [pure virtual]

Acquire an Image (unsigned short version).

Behavior is the same as that of the unsigned char version except that this version works with MONO16 and RGB16 formats only.

Implemented in claraty::A_Camera.

template<class Pixel_Type>
void claraty::Camera::acquire ( Camera_Image< Pixel_Type > &  image  )  throw (std::exception)

Acquire a Camera_Image (template version).

Acquire a Camera_Image using the current feature settings from this logical camera. This routine may fail for a number of reasons. In particular, it fails if the Pixel_Type of the image parameter does not match that expected by the camera, as controlled by the set_format member function. On failure, an exception is thrown.

Parameters:
[out] image Returns newly acquired Camera_Image. The image is resized to match the image size returned by the camera. The timestamp, and feature_map portions of the Camera_Image are updated by this routine. The camera_model portion of the Camera_Image returns the Camera_Model as set by the Camera constructor or set_camera_model_ptr().

Definition at line 281 of file camera.h.

References acquire().

00282 {
00283   // Camera must be a friend of Camera_Image; requires change in Camera_Image  
00284   acquire(image, &image._timestamp, &image._feature_map);
00285   image._frame_num = 0;
00286 }

Here is the call graph for this function:

bool claraty::Camera::io ( FDM_Map  map  )  [virtual]

Serializes a camera. Camera id, name and camera model that captures lens parameters are all option

Parameters:
[in] map a map that holds the content of a serialized camera

Reimplemented from claraty::Device.

Definition at line 54 of file camera.cc.

References claraty::Device::io().

00055 {
00056   bool ok = Device::io(map);
00057   // Check to make sure that the the output is read back in will
00058   // operator >> construct the camera model. Check who owns it
00059   // Need to add an IO to the Camera Model object
00060   // ok &= map.field("_camera_model_ptr", _camera_model_ptr);
00061   return ok;
00062 }

Here is the call graph for this function:

void claraty::Camera::_verify_pixel_format ( size_t  pixel_size  )  [protected]

Verify that the camera format matches the pixel size (either 8-bit or 16-bit/pixel (see IMAGE_FORMAT). Throw exception if mismatched

Parameters:
[in] pixel_size number of bytes used for image pixels

Definition at line 105 of file camera.cc.

References AT_FUNCTION, get_format(), MONO16, MONO8, RGB16, RGB8, YUV411, YUV422, and YUV444.

Referenced by claraty::Camera_Group::_verify_pixel_format().

00106 { 
00107   IMAGE_FORMAT format = get_format();
00108 
00109   switch(pixel_size) {
00110 
00111   case 1:  // 8 Bits
00112     if (format != MONO8  &&  format != YUV411 &&
00113         format != YUV422 &&  format != YUV444 &&
00114         format != RGB8) {
00115       std::ostringstream os;
00116       os << AT_FUNCTION << " camera: " << (*this) 
00117          << " acquiring 16 bit-format images with camera set to 8 bit format"
00118          << endl;
00119       throw (os.str());
00120     }
00121     break;
00122 
00123   case 2:  // 16 bits
00124     if (format != MONO16  &&  format != RGB16) {
00125       std::ostringstream os;
00126       os << AT_FUNCTION << " camera: " << (*this) 
00127          << " acquiring 8 bit-format images with camera set to 16 bit format"
00128          << endl;
00129       throw (os.str());
00130     }    
00131     break;
00132   }
00133 }

Here is the call graph for this function:

template<class Pixel_Type>
void claraty::Camera::_verify_resize_image ( Image< Pixel_Type > &  image  )  [protected]

Verify that the image size matches the camera frame size. If the image size does not match the camera frame size, this function will resize the image to the proper camera frame size.

Parameters:
[in] image reference to an image object to be resized

Definition at line 298 of file camera.h.

References get_height(), claraty::Image< T >::get_height(), get_width(), claraty::Image< T >::get_width(), and claraty::N_2D_Array< T >::resize().

Referenced by claraty::Camera_Group::_verify_resize_images().

00299 {
00300   if ((image.get_width () != get_width()) && 
00301       (image.get_height() != get_height())) 
00302     image.resize(get_height(), get_width());
00303 }

Here is the call graph for this function:

bool claraty::Device::on (  )  [inherited]

Turn on the device.

Returns:
Returns true on success, false on failure.

Definition at line 61 of file device.cc.

References claraty::Device::_power_switch, and claraty::Power_Switch::set().

00062 {
00063   if (_power_switch == NULL) 
00064     return true;
00065   else
00066     return _power_switch->set(true);
00067 }

Here is the call graph for this function:

bool claraty::Device::off (  )  [inherited]

Turn off a device

Returns:
Returns true on success, false on failure.

Definition at line 75 of file device.cc.

References claraty::Device::_power_switch, and claraty::Power_Switch::set().

00076 {
00077   if (_power_switch == NULL) 
00078     return false;
00079   else
00080     return _power_switch->set(false);
00081 }

Here is the call graph for this function:

bool claraty::Device::is_on (  )  [inherited]

Check if a device is turned on.

Returns:
Returns true if this device is on, false if this device is off.

Definition at line 89 of file device.cc.

References claraty::Device::_power_switch, and claraty::Power_Switch::get().

00090 {
00091   if (_power_switch == NULL) 
00092     return true;
00093   else
00094     return _power_switch->get();
00095 }

Here is the call graph for this function:

void claraty::Device::set_power_switch ( Power_Switch new_sw  )  [inherited]

Initialize the power switch functor. This should typically only be called at initialization time to bind a hardware switch, or other switching method, to this device.

Parameters:
[in] new_sw power switch function object

Definition at line 106 of file device.cc.

References claraty::Device::_power_switch.

00107 {
00108   _power_switch = &new_sw;
00109 }

std::string claraty::Device::get_name (  )  const [inherited]

Gets the name of the device

Returns:
Returns string containing name of this device.

Definition at line 117 of file device.cc.

References claraty::Device::_name.

Referenced by claraty::Device::display_xml().

00118 { 
00119   return _name; 
00120 };

std::ostream & claraty::Device::display_xml ( const char *  pmsg,
std::ostream &  os = std::cout 
) const [inherited]

Output the contents of device in an XML format

Parameters:
[in] pmsg a text message to display before the output
[in] os output stream with cout as a default
Returns:
the formatted output stream

Definition at line 148 of file device.cc.

References claraty::XML_Out::get_indentation_space(), and claraty::Device::get_name().

Referenced by claraty::operator<<().

00149 {
00150   // Set up the spacing for the indentation of the fields in the file
00151   std::string spacing = "";
00152   spacing.append(XML_Out::get_indentation_space(), ' ');
00153   os << spacing << "<Device ";
00154   os << "name = \"" << get_name() << "\" ";
00155   os << " >";
00156   return os;
00157 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Camera_Group [friend]

Definition at line 108 of file camera.h.


Member Data Documentation

const double claraty::Camera::DONT_CARE = -DOUBLE_EPSILON [static]

Definition at line 111 of file camera.h.

Definition at line 254 of file camera.h.

Referenced by get_camera_model_ptr(), and set_camera_model_ptr().

std::string claraty::Device::_name [protected, inherited]

name of this device

Definition at line 72 of file device.h.

Referenced by claraty::Device::get_name(), and claraty::Device::io().

switch for turning device ON and OFF

Definition at line 73 of file device.h.

Referenced by claraty::Device::io(), claraty::Device::is_on(), claraty::Device::off(), claraty::Device::on(), and claraty::Device::set_power_switch().


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