claraty::Camera_Group Class Reference
[I/O]
#include <camera_group.h>
Inheritance diagram for claraty::Camera_Group:


Public Member Functions | |
| Camera_Group (Camera &cam1, Camera &cam2) | |
| Camera_Group (Camera &cam1, Camera &cam2, Camera &cam3) | |
| Camera_Group (Camera &cam1, Camera &cam2, Camera &cam3, Camera &cam4) | |
| Camera_Group (int size, const std::string &group_name="") | |
| Camera & | get_camera (unsigned int cam_index) const throw (std::out_of_range) |
| virtual bool | io (FDM_Map map) |
| template<class Pixel_Type> | |
| void | _verify_resize_images (vector< Image< Pixel_Type > * > &img_vec) |
| template<class Sub, class Arg> | |
| int | for_each (bool Sub::*memb_func(const Arg &), const Arg &value) |
| template<class Sub, class Arg1, class Arg2> | |
| int | for_each (bool Sub::*memb_func(const Arg1 &, const Arg2 &), const Arg1 &val1, const Arg2 &val2) |
| virtual int | acquire (std::vector< Image< uint8_t > * > &image_vec, std::vector< Time > *timestamp_vec=NULL, std::vector< Feature_Map * > *feature_map_vec=NULL) throw (std::exception) |
| virtual int | acquire (std::vector< Image< uint16_t > * > &image_vec, std::vector< Time > *timestamp_vec=NULL, std::vector< Feature_Map * > *feature_map_vec=NULL) throw (std::exception) |
| template<class Pixel_Type> | |
| int | acquire (std::vector< Camera_Image< Pixel_Type > * > &cam_img_ptr_vec) |
| template<class Pixel_Type> | |
| int | acquire (std::vector< Camera_Image< Pixel_Type > > &cam_img_ptr_vec) |
| unsigned int | get_size () const |
| |
| std::string | get_name () const |
| |
| void | get_devices (std::vector< Device * > &ptr_vec) const |
| Device & | get_device (unsigned int device_index) const throw (std::out_of_range) |
| int | lookup_index (const Device &device) const |
| int | lookup_index (const std::string &name) const |
| void | append (Device &device) throw (std::invalid_argument, std::bad_cast) |
| void | remove (Device &device) throw (std::invalid_argument) |
| Device & | remove (unsigned int device_index) throw (std::out_of_range) |
| template<class Sub, class Arg> | |
| int | for_each (bool Sub::*memb_func(const Arg &), const Arg &value) |
| template<class Sub, class Arg1, class Arg2> | |
| int | for_each (bool Sub::*memb_func(const Arg1 &, const Arg2 &), const Arg1 &val1, const Arg2 &val2) |
| std::ostream & | display_xml (const char *p=NULL, std::ostream &os=std::cout) const |
Protected Member Functions | |
| void | _verify_pixel_format (size_t pixel_size) |
| template<class Pixel_Type> | |
| void | _verify_resize_images (std::vector< Image< Pixel_Type > * > &img_vec) |
| template<class Pixel_Type> | |
| int | _acquire (std::vector< Image< Pixel_Type > * > &img_vec, std::vector< Time > *time_vec=NULL, std::vector< Feature_Map * > *feature_map_vec=NULL) throw (std::exception) |
| Acquire synchronized Images (unsigned char version). All vectors (even empty vectors) grow or shrink to match the number of cameras in the camera group, except for the default argument values which are left empty by this routine. | |
| virtual bool | _device_type_is_ok (const Device &device) const |
Protected Attributes | |
| std::string | _group_name |
| std::vector< Device * > | _device_vec |
Detailed Description
Image acquisition/Camera related classes.The Camera_Group base class defines operations for cameras in a group. This class provides a default group acquire that uses sequential image acquisition from the cameras. This function needs to be specialized for synchronized image acquisition.
A_Camera cam1, cam2; Camera_Group cam_pair1 ( cam1, cam2 ); // Uses default group acquire A_Camera_Group cam_pair2 ( cam1, cam2 ); // Uses hw-based sync. acquire
vector< Image<uint8_t> > img_vec; cam_pair.acquire(img_vec);
Definition at line 56 of file camera_group.h.
Constructor & Destructor Documentation
Construct a group with two cameras
- Parameters:
-
[in] cam1 first camera to append to group [in] cam2 second camera to append to group
Definition at line 36 of file camera_group.cc.
References claraty::Device_Group::append().
00037 : Device_Group(2) 00038 { 00039 append(cam1); 00040 append(cam2); 00041 }
Here is the call graph for this function:

Construct a group with three cameras
- Parameters:
-
[in] cam1 first camera to append to group [in] cam2 second camera to append to group [in] cam3 third camera to append to group
Definition at line 52 of file camera_group.cc.
References claraty::Device_Group::append().
00053 : Device_Group(3) 00054 { 00055 append(cam1); 00056 append(cam2); 00057 append(cam3); 00058 }
Here is the call graph for this function:

Construct a group with four cameras
- Parameters:
-
[in] cam1 first camera to append to group [in] cam2 second camera to append to group [in] cam3 third camera to append to group [in] cam4 fourth camera to append to group
Definition at line 69 of file camera_group.cc.
References claraty::Device_Group::append().
00070 : Device_Group(4) 00071 { 00072 append(cam1); 00073 append(cam2); 00074 append(cam3); 00075 append(cam4); 00076 }
Here is the call graph for this function:

| claraty::Camera_Group::Camera_Group | ( | int | size, | |
| const std::string & | group_name = "" | |||
| ) |
Member Function Documentation
| Camera & claraty::Camera_Group::get_camera | ( | unsigned int | camera_index | ) | const throw (std::out_of_range) |
- Parameters:
-
[in] camera_index
- Returns:
- device group
Definition at line 98 of file camera_group.cc.
References claraty::Device_Group::get_device().
Referenced by _verify_pixel_format(), and _verify_resize_images().
00100 { 00101 return static_cast<Camera &> (Device_Group::get_device(camera_index)); 00102 };
Here is the call graph for this function:

| virtual int claraty::Camera_Group::acquire | ( | std::vector< Image< uint8_t > * > & | image_vec, | |
| std::vector< Time > * | timestamp_vec = NULL, |
|||
| std::vector< Feature_Map * > * | feature_map_vec = NULL | |||
| ) | throw (std::exception) [virtual] |
| virtual int claraty::Camera_Group::acquire | ( | std::vector< Image< uint16_t > * > & | image_vec, | |
| std::vector< Time > * | timestamp_vec = NULL, |
|||
| std::vector< Feature_Map * > * | feature_map_vec = NULL | |||
| ) | throw (std::exception) [virtual] |
| int claraty::Camera_Group::acquire | ( | std::vector< Camera_Image< Pixel_Type > * > & | cam_img_ptr_vec | ) |
The vector arguments are not resized (to match the number of cameras in the group). However, each image is resized to match the image size implied by the current Camera state. The return value is the number of valid images returned in cam_img_ptr_vec. This value may be less than cam_img_ptr_vec.size(). It is equal to min(image_vec.size(), this.get_size()).
Definition at line 99 of file camera_group.ipp.
References _acquire().
00100 { 00101 std::vector< Image< Pixel_Type > * > img_ptr_vec(cam_img_ptr_vec.size()); 00102 std::vector< Time > time_ptr_vec(cam_img_ptr_vec.size()); 00103 std::vector< Feature_Map * > feature_map_ptr_vec(cam_img_ptr_vec.size()); 00104 for (unsigned int i = 0; i < cam_img_ptr_vec.size(); ++i) { 00105 img_ptr_vec[i] = cam_img_ptr_vec[i]; 00106 time_ptr_vec[i] = &cam_img_ptr_vec[i]->_timestamp; 00107 feature_map_ptr_vec[i] = &cam_img_ptr_vec[i]->_feature_map; 00108 } 00109 return _acquire(img_ptr_vec, time_ptr_vec, feature_map_ptr_vec); 00110 }
Here is the call graph for this function:

| int claraty::Camera_Group::acquire | ( | std::vector< Camera_Image< Pixel_Type > > & | cam_img_vec | ) |
The vector (even if empty) grows or shrinks to match the number of cameras in the camera group.
Definition at line 118 of file camera_group.ipp.
References _acquire(), and claraty::Device_Group::get_size().
00119 { 00120 if (cam_img_vec.size() != get_size()) cam_img_vec.resize(get_size()); 00121 std::vector< Image< Pixel_Type > * > img_ptr_vec(get_size()); 00122 std::vector< Time * > time_ptr_vec(get_size()); 00123 std::vector< Feature_Map * > feature_map_ptr_vec(get_size()); 00124 for (unsigned int i = 0; i < get_size(); ++i) { 00125 img_ptr_vec[i] = &cam_img_vec[i]; 00126 time_ptr_vec[i] = &cam_img_vec[i]._timestamp; 00127 feature_map_ptr_vec[i] = &cam_img_vec[i]._feature_map; 00128 } 00129 return _acquire(img_ptr_vec, time_ptr_vec, feature_map_ptr_vec); 00130 }
Here is the call graph for this function:

| bool claraty::Camera_Group::io | ( | FDM_Map | map | ) | [inline, virtual] |
[description]
- Parameters:
-
[in] map
- Returns:
- true or false
Reimplemented from claraty::Device_Group.
Definition at line 206 of file camera_group.cc.
References claraty::Device_Group::io().
00207 { 00208 return Device_Group::io(map); 00209 }
Here is the call graph for this function:

| void claraty::Camera_Group::_verify_pixel_format | ( | size_t | pixel_size | ) | [protected] |
Verify that all camera formats are either set to 8-bit pixels or 16-bit pixels. If the current format (as set by set_format) of any logical camera in this Camera_Group is not one of the 8 or 16 bit known formats (see Camera class), then return throw an exception
- Parameters:
-
[in] pixel_size format pixel format which is either set to PIXEL_FORMAT::BIT8 or PIXEL_FORMAT::BIT16
- Returns:
- true if all camera formats match requested format
Definition at line 116 of file camera_group.cc.
References claraty::Camera::_verify_pixel_format(), get_camera(), and claraty::Device_Group::get_size().
00117 { 00118 for (int i = 0; i < (int)get_size(); ++i) { // compiler warning chage 00119 Camera & cam = get_camera(i); 00120 cam._verify_pixel_format(pixel_size); 00121 } 00122 }
Here is the call graph for this function:

| void claraty::Camera_Group::_verify_resize_images | ( | std::vector< Image< Pixel_Type > * > & | img_vec | ) | [protected] |
| int claraty::Camera_Group::_acquire | ( | std::vector< Image< Pixel_Type > * > & | image_vec, | |
| std::vector< Time > * | timestamp_vec = NULL, |
|||
| std::vector< Feature_Map * > * | feature_map_vec = NULL | |||
| ) | throw (std::exception) [protected] |
Acquire synchronized Images (unsigned char version). All vectors (even empty vectors) grow or shrink to match the number of cameras in the camera group, except for the default argument values which are left empty by this routine.
This version of acquire treats the default values differently from the NULL (or empty) vector. If an empty vector is passed in, it is grown to match the number of cameras in the group. The default values are checked for explicitly, and are used to signify that the user does not want this result returned.
- Parameters:
-
[out] image_vec Returns newly acquired Images. Each Image is resized to match the image size returned by the corresponding camera. The size of the image_vec vector is not changed by this routine. The number of images actually returned equals min(image_vec.size(), this.size()). Any images beyond this number are left unchanged. [out] timestamp_vec Returns timestamps for each image. [out] feature_map_vec Returns camera feature settings for each image.
- Returns:
- The number of valid images returned in image_vec. This value may be less than image_vec.size(). It is equal to min(image_vec.size(), this.size()).
Definition at line 54 of file camera_group.ipp.
References AT_FUNCTION.
Referenced by acquire().
00058 { 00059 if (image_vec.size() != get_size() || 00060 timestamp_vec->size() != get_size() || 00061 feature_map_vec->size() != get_size()) { 00062 std::ostringstream os; 00063 os << AT_FUNCTION << "camera group acquire failed: invalid argument" 00064 << "image vector size does not match group size" << std::endl; 00065 throw std::invalid_argument(os.str()); 00066 } 00067 00068 // Verify that all cameras have proper pixel format 00069 _verify_pixel_format(sizeof(Pixel_Type)); 00070 00071 // Verify and resize images if necessary 00072 _verify_resize_images(image_vec); 00073 00074 // Default implementation - loop through each camera and acquire image 00075 for (unsigned int i = 0; i < image_vec.size(); ++i) { 00076 Camera & cam = get_camera(i); 00077 if (timestamp_vec && feature_map_vec) 00078 cam.acquire(*image_vec[i], &(*timestamp_vec)[i], (*feature_map_vec)[i]); 00079 else if (timestamp_vec) 00080 cam.acquire(*image_vec[i], &(*timestamp_vec)[i]); 00081 else 00082 cam.acquire(*image_vec[i]); 00083 } 00084 return image_vec.size(); 00085 }
| void claraty::Camera_Group::_verify_resize_images | ( | vector< Image< Pixel_Type > * > & | img_vec | ) |
Verify that all image sizes match all camera frame sizes. If the image sizes do not match the camera frame sizes, this function will resize each image to the proper corresponding camera frame size.
- Parameters:
-
[in] img_vec Reference to an image object to be resized.
Definition at line 134 of file camera_group.cc.
References claraty::Camera::_verify_resize_image(), get_camera(), and claraty::Device_Group::get_size().
00135 { 00136 for (unsigned int i = 0; i < get_size(); ++i) { 00137 Camera & cam = get_camera(i); 00138 cam._verify_resize_image(*(img_vec[i])); 00139 } 00140 }
Here is the call graph for this function:

| unsigned int claraty::Device_Group::get_size | ( | ) | const [inline, inherited] |
- Returns:
- the number of devices currently in this group.
Definition at line 57 of file device_group.h.
References claraty::Device_Group::_device_vec.
Referenced by _verify_pixel_format(), _verify_resize_images(), acquire(), claraty::Device_Group::for_each(), claraty::Device_Group::io(), and claraty::Device_Group::lookup_index().
00057 { return _device_vec.size(); }
| std::string claraty::Device_Group::get_name | ( | ) | const [inline, inherited] |
- Returns:
- a string containing name of this device group.
Definition at line 60 of file device_group.h.
References claraty::Device_Group::_group_name.
Referenced by claraty::Device_Group::display_xml(), and claraty::Device_Group::lookup_index().
00060 { return _group_name; }
| void claraty::Device_Group::get_devices | ( | std::vector< Device * > & | ptr_vec | ) | const [inherited] |
- Returns:
- a vector of pointers to all devices in the device list. Devices in the returned vector are in the same order as the device indices. I.e. For all i in 0..A.size()-1: A.lookup_index(ptr_vec[i]) == i
Definition at line 62 of file device_group.cc.
References claraty::Device_Group::_device_vec.
00063 { 00064 // This is a copy, so _device_vec is not exposed. 00065 ptr_vec = _device_vec; 00066 }
| Device & claraty::Device_Group::get_device | ( | unsigned int | device_index | ) | const throw (std::out_of_range) [inherited] |
- Returns:
- a reference to the device_indexTH element of the device list. Throw an exception if device_index is not in the range 0..size()-1.
Definition at line 74 of file device_group.cc.
References AT_FUNCTION.
Referenced by get_camera().
00075 { 00076 if (device_index < 0 || device_index >= get_size()) { 00077 std::ostringstream os; 00078 os << AT_FUNCTION << "-- index (" << device_index << ")" 00079 << " out of range of " << (*this) << ", size()=" << get_size() 00080 << endl; 00081 throw std::out_of_range(os.str()); 00082 } 00083 // Note that it is impossible to add a NULL _device_vec entry, so this 00084 // dereference is safe. 00085 return *_device_vec[device_index]; 00086 }
| int claraty::Device_Group::lookup_index | ( | const Device & | device | ) | const [inherited] |
- Returns:
- the index of the device with the given address, if it is on the device list, or -1 if it is not.
Definition at line 94 of file device_group.cc.
References claraty::Device_Group::_device_vec, ERROR, and claraty::Device_Group::get_size().
00095 { 00096 for (unsigned int i = 0; i < get_size(); ++i) { 00097 if (&device == _device_vec[i]) return (int)i; 00098 } 00099 return ERROR; 00100 }
Here is the call graph for this function:

| int claraty::Device_Group::lookup_index | ( | const std::string & | name | ) | const [inherited] |
- Returns:
- the index of the first device in the device list with the given name, or -1 if no device on the list has that name.
Definition at line 108 of file device_group.cc.
References claraty::Device_Group::_device_vec, ERROR, claraty::Device_Group::get_name(), and claraty::Device_Group::get_size().
00109 { 00110 for (unsigned int i = 0; i < get_size(); ++i) { 00111 if (name == _device_vec[i]->get_name()) return (int)i; 00112 } 00113 return ERROR; 00114 }
Here is the call graph for this function:

| void claraty::Device_Group::append | ( | Device & | device | ) | throw (std::invalid_argument, std::bad_cast) [inherited] |
Add a new device to the end of the device list. Failure occurs if the device is already included in the list, or if the type of the device does not match the type expected by the derived class. An exception is thrown upon failure.
- Parameters:
-
[in] device a constant reference to the device to be added
Definition at line 125 of file device_group.cc.
References AT_FUNCTION.
Referenced by Camera_Group().
00126 { 00127 if (lookup_index(device) >= 0) { 00128 std::ostringstream os; 00129 os << AT_FUNCTION << " device " << device << " already in list for " 00130 << endl << "device group=" << (*this); 00131 throw std::invalid_argument(os.str()); 00132 } 00133 if (!_device_type_is_ok(device)) throw std::bad_cast(); 00134 00135 _device_vec.push_back(&device); 00136 }
| void claraty::Device_Group::remove | ( | Device & | device | ) | throw (std::invalid_argument) [inherited] |
Remove the given device from the device list. An exception is thrown if the device is not in the list.
Definition at line 170 of file device_group.cc.
References AT_FUNCTION.
00171 { 00172 int index = lookup_index(device); 00173 if (index < 0) { 00174 std::ostringstream os; 00175 os << AT_FUNCTION << "--" << device << "is not in list for " << endl 00176 << "device group=" << (*this); 00177 throw std::invalid_argument(os.str()); 00178 } 00179 (void)remove(index); 00180 }
| Device & claraty::Device_Group::remove | ( | unsigned int | device_index | ) | throw (std::out_of_range) [inherited] |
Remove the device_indexTH device from the device list. The return value is a reference to the removed device. An exception is thrown if device_index is out of range.
Definition at line 145 of file device_group.cc.
References AT_FUNCTION.
00146 { 00147 unsigned int old_size = get_size(); 00148 if (device_index < 0 || device_index >= old_size) { 00149 std::ostringstream os; 00150 os << AT_FUNCTION << "-- index (" << device_index << ")" 00151 << " out of range of " << (*this) << ", size()=" << get_size() 00152 << std::endl; 00153 throw std::out_of_range(os.str()); 00154 } 00155 00156 Device* return_ptr = _device_vec[device_index]; 00157 for (unsigned int i = device_index + 1; i < old_size; ++i) { 00158 _device_vec[i-1] = _device_vec[i]; 00159 } 00160 _device_vec.resize(old_size - 1); 00161 return *return_ptr; 00162 }
| int claraty::Device_Group::for_each | ( | bool Sub::* | memb_func(const Arg &), | |
| const Arg & | value | |||
| ) | [inherited] |
Here's a way to make the group execute function such as set_contrast etc. generic such that we do no not need to define these in the Camera_Group.
This template version should work for members of derived classes which are not members of the base Device class. It assumes a single parameter (of generic type) to the set_X function. A similar template function is supplied for 2 generic params.
Note that this template function is so generic that very little type checking is done.
From a user standpoint the call will look like this:
XYZ_Camera_Group cg(...); cg.for_each(&XYZ_Camera::set_feature, 0.13);
Definition at line 148 of file device_group.h.
| int claraty::Device_Group::for_each | ( | bool Sub::* | memb_func(const Arg1 &, const Arg2 &), | |
| const Arg1 & | val1, | |||
| const Arg2 & | val2 | |||
| ) | [inherited] |
Definition at line 162 of file device_group.h.
| int claraty::Device_Group::for_each | ( | bool Sub::* | memb_func(const Arg &), | |
| const Arg & | value | |||
| ) | [inherited] |
Here's a way to make the group execute function such as set_contrast etc. generic such that we do no not need to define these in the Camera_Group.
This template version should work for members of derived classes which are not members of the base Device class. It assumes a single parameter (of generic type) to the set_X function. A similar template function is supplied for 2 generic params.
Note that this template function is so generic that very little type checking is done.
From a user standpoint the call will look like this:
XYZ_Camera_Group cg(...); cg.for_each(&XYZ_Camera::set_feature, 0.13);
Definition at line 45 of file device_group.ipp.
References claraty::Device_Group::_device_vec, and claraty::Device_Group::get_size().
00047 { 00048 int ok_count = 0; 00049 for (unsigned int i = 0; i < get_size(); i++) { 00050 ok_count += (static_cast<Sub*>(_device_vec[i])->*memb_func)(value); 00051 } 00052 return ok_count; 00053 };
Here is the call graph for this function:

| int claraty::Device_Group::for_each | ( | bool Sub::* | memb_func(const Arg1 &, const Arg2 &), | |
| const Arg1 & | val1, | |||
| const Arg2 & | val2 | |||
| ) | [inherited] |
Definition at line 59 of file device_group.ipp.
References claraty::Device_Group::_device_vec, and claraty::Device_Group::get_size().
00062 { 00063 int ok_count = 0; 00064 for (unsigned int i = 0; i < get_size(); i++) { 00065 ok_count += (static_cast<Sub*>(_device_vec[i])->*memb_func)(val1, val2); 00066 } 00067 return ok_count; 00068 };
Here is the call graph for this function:

| std::ostream & claraty::Device_Group::display_xml | ( | const char * | pmsg = NULL, |
|
| std::ostream & | os = std::cout | |||
| ) | const [inherited] |
Output the contents of device in an XML format (not fully implemented)
- 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 213 of file device_group.cc.
References claraty::XML_Out::get_indentation_space(), and claraty::Device_Group::get_name().
Referenced by claraty::operator<<().
00214 { 00215 // Set up the spacing for the indentation of the fields in the file 00216 std::string spacing = ""; 00217 spacing.append(XML_Out::get_indentation_space(), ' '); 00218 os << spacing << "<Device_Group "; 00219 os << "size = \"" << get_name() << "\" "; 00220 os << "name = \"" << get_name() << "\" "; 00221 os << " >"; 00222 return os; 00223 }
Here is the call graph for this function:

| bool claraty::Device_Group::_device_type_is_ok | ( | const Device & | device | ) | const [protected, virtual, inherited] |
This function is called from member function append to insure that the derived type of the given device is compatible with the derived type of this Device_Group. Return true if they are compatible, else false.
Definition at line 264 of file device_group.cc.
Member Data Documentation
std::string claraty::Device_Group::_group_name [protected, inherited] |
Definition at line 95 of file device_group.h.
Referenced by claraty::Device_Group::get_name(), and claraty::Device_Group::io().
std::vector<Device *> claraty::Device_Group::_device_vec [protected, inherited] |
Definition at line 96 of file device_group.h.
Referenced by claraty::Device_Group::Device_Group(), claraty::Device_Group::for_each(), claraty::Device_Group::get_devices(), claraty::Device_Group::get_size(), claraty::Device_Group::io(), and claraty::Device_Group::lookup_index().
The documentation for this class was generated from the following files: