claraty::A_Camera_Model Class Reference
[Data Structure]
#include <a_camera_model.h>
Inheritance diagram for claraty::A_Camera_Model:


Public Member Functions | |
| Camera_Model * | clone () const |
| int | get_image_width () |
| int | get_image_height () |
| void | ray_to_pixel (const Ray &vector, Pixel_Coord &pixel_coord) const |
| void | pixel_to_ray (const Pixel_Coord &pixel_coord, Ray &vector) const |
| std::string | get_typename () const |
| bool | map_model (Camera_Model &mapped_model, Map_Op &map_op) const |
| bool | io (FDM_Map m) |
| bool | operator== (const Camera_Model &rhs) const |
| void | set_frame (Frame *f) |
| void | set_name (const std::string &new_name) |
| virtual const Frame & | get_frame () const |
| const std::string & | get_name () const |
| virtual Pixel_Coord | get_mapped_coordinates (Pixel_Coord unmapped_coord) const |
| virtual Pixel_Coord | get_unmapped_coordinates (Pixel_Coord mapped_coord) const |
| virtual void | subsample (int subsample_factor) |
| virtual void | read (std::istream &str) |
| virtual void | write (std::ostream &str) const |
Static Public Member Functions | |
| static Camera_Model * | build () |
| static Camera_Model * | build_from_file (const char *filename) |
| static Camera_Model * | build_from_stream (std::istream &stream) |
| static Camera_Model * | build_from_typename (const std::string type_name) |
Static Public Attributes | |
| static Factory< Camera_Model, std::string > * | factory |
Protected Attributes | |
| Frame * | _mounting_frame |
| std::string | _name |
Private Attributes | |
| int | _image_width |
| int | _image_height |
Detailed Description
Most basic pin-hole camera model with no lens distortionMap_Op (one-to-one) Camera_Model 1 --------------> Camera_Model 2 (mapped) (unmapped coord) (mapped_coord)
Definition at line 47 of file a_camera_model.h.
Constructor & Destructor Documentation
| claraty::A_Camera_Model::A_Camera_Model | ( | ) | [inline] |
| claraty::A_Camera_Model::A_Camera_Model | ( | int | width, | |
| int | height, | |||
| Frame * | frame | |||
| ) | [inline] |
Definition at line 56 of file a_camera_model.h.
00057 : Camera_Model (frame), 00058 _image_width(width), 00059 _image_height(height) {};
| claraty::A_Camera_Model::A_Camera_Model | ( | ) | [inline] |
| claraty::A_Camera_Model::A_Camera_Model | ( | int | width, | |
| int | height, | |||
| Frame * | frame | |||
| ) | [inline] |
Definition at line 56 of file a_camera_model.h.
00057 : Camera_Model (frame), 00058 _image_width(width), 00059 _image_height(height) {};
Member Function Documentation
| Camera_Model* claraty::A_Camera_Model::clone | ( | ) | const [inline, virtual] |
Implements claraty::Camera_Model.
Definition at line 63 of file a_camera_model.h.
References A_Camera_Model().
00063 {return new A_Camera_Model(*this); }
Here is the call graph for this function:

| static Camera_Model* claraty::A_Camera_Model::build | ( | ) | [inline, static] |
| int claraty::A_Camera_Model::get_image_width | ( | ) | [inline] |
Definition at line 66 of file a_camera_model.h.
References _image_width.
00066 { return _image_width; }
| int claraty::A_Camera_Model::get_image_height | ( | ) | [inline] |
Definition at line 67 of file a_camera_model.h.
References _image_height.
00067 { return _image_height; }
| void claraty::A_Camera_Model::ray_to_pixel | ( | const Ray & | ray, | |
| Pixel_Coord & | pixel_coord | |||
| ) | const [virtual] |
Computes the 2D pixel location in the image from a 3D ray described by the pointing 'vector' with respect to the model's coordinate frame
Implements claraty::Camera_Model.
Definition at line 89 of file a_camera_model.h.
00091 { 00092 pixel_coord(0) = ray(0) / ray(2); 00093 pixel_coord(1) = ray(1) / ray(2); 00094 00095 pixel_coord += 0.01; // Adding DC offset for noise 00096 };
| void claraty::A_Camera_Model::pixel_to_ray | ( | const Pixel_Coord & | pixel_coord, | |
| Ray & | ray | |||
| ) | const [virtual] |
Computes the 3D ray 'vector' (not necessarily a unit vector) with respect to the camera model's reference that passes through the given image pixel
Implements claraty::Camera_Model.
Definition at line 105 of file a_camera_model.h.
References _image_height, _image_width, and claraty::Point< T >::normalize().
00107 { 00108 float x = pixel_coord(0); 00109 float y = pixel_coord(1); 00110 00111 float _fx = 1.0, _fy = 1.0; 00112 00113 ray(0) = (x - _image_width/2) / _fx; 00114 ray(1) = (y - _image_height/2) / _fy; 00115 ray(2) = 1.0; 00116 00117 ray.normalize(); 00118 };
Here is the call graph for this function:

| std::string claraty::A_Camera_Model::get_typename | ( | ) | const [inline, virtual] |
| bool claraty::A_Camera_Model::map_model | ( | Camera_Model & | mapped_model, | |
| Map_Op & | map_op | |||
| ) | const [inline, virtual] |
This function provides a way for the user to correct models and images for lens distortion. Subclasses should do the right thing to ensure that a reasonable new camera model is built and returned in the mapped_model argument. This should return true if it's possible to build a processed model and mapping op for this model, and false otherwise. Pretty much all subclasses should have a function here that returns true.
- Parameters:
-
[in] mapped_model The linearized model. [in] map_op The rectified map.
- Returns:
- False under all input conditions.
Reimplemented from claraty::Camera_Model.
Definition at line 76 of file a_camera_model.h.
| bool claraty::A_Camera_Model::io | ( | FDM_Map | m | ) | [inline, virtual] |
Serializes a camera model.
- Parameters:
-
[in] m A map that holds the content of a serialized camera model
Reimplemented from claraty::Camera_Model.
Definition at line 133 of file a_camera_model.h.
References _image_height, _image_width, claraty::FDM_Map::field(), claraty::Camera_Model::io(), and claraty::FDM_Map::is_read().
00134 { 00135 bool ok = Camera_Model::io(m); 00136 00137 double dummy; 00138 00139 if (m.is_read()) { 00140 std::string distString; 00141 00142 ok &= m.field("distortion", distString); 00143 00144 std::istringstream dist(distString); 00145 00146 for (int i = 0; i < 4; i++) 00147 dist >> dummy; 00148 return ok; 00149 } 00150 ok &= m.field("width", _image_width); 00151 ok &= m.field("height", _image_height); 00152 return ok; 00153 }
Here is the call graph for this function:

| bool claraty::Camera_Model::operator== | ( | const Camera_Model & | rhs | ) | const [inherited] |
Definition at line 74 of file camera_model.cc.
References claraty::Camera_Model::_mounting_frame, and claraty::Camera_Model::_name.
00075 { 00076 return _mounting_frame == rhs._mounting_frame && _name == rhs._name; 00077 }
| void claraty::Camera_Model::set_frame | ( | Frame * | f | ) | [inherited] |
Assign frame to the camera model
- Parameters:
-
[in] f The frame coordinate transformation that defines the mounting of the camera relative to other coordinate frames
Definition at line 99 of file camera_model.cc.
References claraty::Camera_Model::_mounting_frame.
00100 { 00101 _mounting_frame = f; 00102 }
| void claraty::Camera_Model::set_name | ( | const std::string & | new_name | ) | [inline, inherited] |
Definition at line 94 of file camera_model.h.
References claraty::Camera_Model::_name.
00094 { _name = new_name; }
| virtual const Frame& claraty::Camera_Model::get_frame | ( | ) | const [inline, virtual, inherited] |
Definition at line 96 of file camera_model.h.
References claraty::Camera_Model::_mounting_frame.
Referenced by claraty::Stereovision::compute_point_image().
00096 { return *_mounting_frame; }
| const std::string& claraty::Camera_Model::get_name | ( | ) | const [inline, inherited] |
Definition at line 97 of file camera_model.h.
References claraty::Camera_Model::_name.
00097 { return _name; }
| Pixel_Coord claraty::Camera_Model::get_mapped_coordinates | ( | Pixel_Coord | unmapped_coord | ) | const [virtual, inherited] |
Most camera models deal with lens distortion by mapping raw images that contain lens distortion to some form of "ideal" images that filter out this distortion. This function maps coordinates from the raw image to the processed (linearized) image. For mapping between raw (unrectified) images and their processed (rectified/linearized) versions, subclasses should override this function. Default implementation models no distortion at all.
- Parameters:
-
[in] unmapped_coord The (x,y) coordinates of the pixel in the raw unmapped image
- Returns:
- The corresponding (x,y) pixel coordinates in the mapped processed image.
Reimplemented in claraty::Tsai_Camera_Model.
Definition at line 120 of file camera_model.cc.
| Pixel_Coord claraty::Camera_Model::get_unmapped_coordinates | ( | Pixel_Coord | mapped_coord | ) | const [virtual, inherited] |
Most camera models deal with lens distortion by mapping raw images that contain lens distortion to some form of "ideal" images that filter out this distortion. This function maps coordinates from the processed (linearized) image back to the original raw image. For mapping between processed and raw images, subclasses should override this function. Default implementation models no distortion at all. This function provides the inverse mapping of the above function. Lens distortion models are often difficult to invert, and must be inverted numerically. So typically one of these two functions is going significantly more expensive to call than the other. Map_Op assumes that the previous function is low-cost; subclasses should document complexity of both.
- Parameters:
-
[in] mapped_coord The (x,y) coordinates of the pixel in the mapped image.
- Returns:
- The (x,y) pixel coordinates of the original raw (or unrectified) image.
Reimplemented in claraty::Tsai_Camera_Model.
Definition at line 146 of file camera_model.cc.
| void claraty::Camera_Model::subsample | ( | int | factor | ) | [virtual, inherited] |
Subsample the internal model so that the ray-to-pixel and pixel-to-ray functions work on images subsampled by the same amount. This way image algorithms can work with subsampled images and still have correct camera models to work with. The subsample_factor is a factor; images are sampled to 1/factor, so a factor of 3 means 1/3 the image height & width. Default behavior is to print a warning message and return.
Reimplemented in claraty::Tsai_Camera_Model.
Definition at line 160 of file camera_model.cc.
References AT_FUNCTION.
00161 { 00162 cerr << AT_FUNCTION << "subsamping not supported in this camera model type" 00163 << endl; 00164 }
| virtual void claraty::Camera_Model::read | ( | std::istream & | str | ) | [inline, virtual, inherited] |
| virtual void claraty::Camera_Model::write | ( | std::ostream & | str | ) | const [inline, virtual, inherited] |
Reimplemented in claraty::Tsai_Camera_Model.
Definition at line 128 of file camera_model.h.
Referenced by claraty::operator<<().
| Camera_Model * claraty::Camera_Model::build_from_file | ( | const char * | filename | ) | [static, inherited] |
These are factory wrappers, which load a (subclass of) camera_model from disk. Subclasses have to implement hooks to tie into the factory at startup time.
Definition at line 251 of file camera_model.cc.
References AT_FUNCTION, and claraty::Camera_Model::build_from_stream().
00252 { 00253 ifstream stream(filename); 00254 if (!stream) { 00255 cerr << AT_FUNCTION << " : unable to open file " << filename 00256 << " for reading camera model" << endl; 00257 return NULL; 00258 } 00259 return build_from_stream(stream); 00260 }
Here is the call graph for this function:

| static Camera_Model* claraty::Camera_Model::build_from_stream | ( | std::istream & | stream | ) | [static, inherited] |
Referenced by claraty::Camera_Model::build_from_file().
| static Camera_Model* claraty::Camera_Model::build_from_typename | ( | const std::string | type_name | ) | [inline, static, inherited] |
Definition at line 137 of file camera_model.h.
References claraty::Camera_Model::factory.
Referenced by claraty::io_object().
00137 { 00138 return (*factory)(type_name); 00139 }
Member Data Documentation
int claraty::A_Camera_Model::_image_width [private] |
Definition at line 50 of file a_camera_model.h.
Referenced by get_image_width(), io(), and pixel_to_ray().
int claraty::A_Camera_Model::_image_height [private] |
Definition at line 51 of file a_camera_model.h.
Referenced by get_image_height(), io(), and pixel_to_ray().
Frame* claraty::Camera_Model::_mounting_frame [protected, inherited] |
Extrinsic camera parameters
Definition at line 76 of file camera_model.h.
Referenced by claraty::Camera_Model::get_frame(), claraty::Camera_Model::operator=(), claraty::Camera_Model::operator==(), and claraty::Camera_Model::set_frame().
std::string claraty::Camera_Model::_name [protected, inherited] |
Definition at line 77 of file camera_model.h.
Referenced by claraty::Camera_Model::get_name(), claraty::Camera_Model::io(), claraty::Camera_Model::operator=(), claraty::Camera_Model::operator==(), and claraty::Camera_Model::set_name().
Factory< Camera_Model, string > * claraty::Camera_Model::factory [static, inherited] |
Definition at line 80 of file camera_model.h.
Referenced by claraty::Camera_Model::build_from_typename().
The documentation for this class was generated from the following file: