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


Public Member Functions | |
| bool | operator== (const Camera_Model &rhs) const |
| Camera_Model & | operator= (const Camera_Model &rhs) |
| virtual Camera_Model * | clone () const=0 |
| 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 std::string | get_typename () const=0 |
| virtual void | ray_to_pixel (const Ray &vector, Pixel_Coord &pixel_coord) const =0 |
| virtual void | pixel_to_ray (const Pixel_Coord &pixel_coord, Ray &vector) const =0 |
| 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 bool | map_model (Camera_Model &mapped_model, Map_Op &map_op) const |
| virtual bool | io (FDM_Map m) |
| virtual void | read (std::istream &str) |
| virtual void | write (std::ostream &str) const |
Static Public Member Functions | |
| 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 Member Functions | |
| Camera_Model () | |
| Camera_Model (Camera_Model *m) | |
Private Attributes | |
| int | model |
Detailed Description
Map_Op Camera_Model 1 --------------> Camera_Model 2 (mapped) (unmapped coord) (mapped_coord)Each camera model has a frame, which is intended to represent the location (and orientation) of the camera -- its extrinsic parameters. Many types of camera models have explicit or implicit ways to represent extrinsic parameters, but all of them have to be grounded in some frame of reference. That's what the localFrame is for. In CAHVOR models, for example, the C vector will be relative to the localFrame, and the A vector will point in a direction relative to the localFrame.
The base class includes some implemented virutal functions, which assume that the underlying camera is a perfect pinhole camera (so straight perspective projection works, and in particular, there's no lens distortion). This is of course not realistic, and most model types which override this class should override the distortion-related functions. These functions are marked in the definition below.
Definition at line 36 of file camera_image.cc.
Constructor & Destructor Documentation
| claraty::Camera_Model::Camera_Model | ( | ) | [inline, private] |
| claraty::Camera_Model::Camera_Model | ( | Camera_Model * | m | ) | [inline, private] |
| claraty::Camera_Model::Camera_Model | ( | ) |
| claraty::Camera_Model::Camera_Model | ( | Frame * | frame | ) |
| claraty::Camera_Model::Camera_Model | ( | const Camera_Model & | rhs | ) | [explicit] |
Definition at line 58 of file camera_model.cc.
00059 : _mounting_frame ( rhs._mounting_frame), 00060 _name ( rhs._name ) 00061 { 00062 }
| claraty::Camera_Model::~Camera_Model | ( | ) | [virtual] |
| claraty::Camera_Model::Camera_Model | ( | ) |
| claraty::Camera_Model::Camera_Model | ( | Frame * | frame | ) |
| claraty::Camera_Model::Camera_Model | ( | const Camera_Model & | rhs | ) | [explicit] |
Definition at line 58 of file camera_model.cc.
00059 : _mounting_frame ( rhs._mounting_frame), 00060 _name ( rhs._name ) 00061 { 00062 }
| claraty::Camera_Model::~Camera_Model | ( | ) | [virtual] |
Member Function Documentation
| bool claraty::Camera_Model::operator== | ( | const Camera_Model & | rhs | ) | const |
Definition at line 74 of file camera_model.cc.
References _mounting_frame, and _name.
00075 { 00076 return _mounting_frame == rhs._mounting_frame && _name == rhs._name; 00077 }
| Camera_Model & claraty::Camera_Model::operator= | ( | const Camera_Model & | rhs | ) |
Definition at line 82 of file camera_model.cc.
References _mounting_frame, and _name.
00083 { 00084 if (this != &rhs) { 00085 _mounting_frame = rhs._mounting_frame; 00086 _name = rhs._name; 00087 } 00088 return *this; 00089 }
| virtual Camera_Model* claraty::Camera_Model::clone | ( | ) | const [pure virtual] |
Implemented in claraty::A_Camera_Model, and claraty::Tsai_Camera_Model.
| void claraty::Camera_Model::set_frame | ( | Frame * | f | ) |
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 _mounting_frame.
00100 { 00101 _mounting_frame = f; 00102 }
| void claraty::Camera_Model::set_name | ( | const std::string & | new_name | ) | [inline] |
| virtual const Frame& claraty::Camera_Model::get_frame | ( | ) | const [inline, virtual] |
Definition at line 96 of file camera_model.h.
References _mounting_frame.
Referenced by claraty::Stereovision::compute_point_image().
00096 { return *_mounting_frame; }
| const std::string& claraty::Camera_Model::get_name | ( | ) | const [inline] |
| virtual std::string claraty::Camera_Model::get_typename | ( | ) | const [pure virtual] |
| virtual void claraty::Camera_Model::ray_to_pixel | ( | const Ray & | vector, | |
| Pixel_Coord & | pixel_coord | |||
| ) | const [pure 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
Implemented in claraty::A_Camera_Model, and claraty::Tsai_Camera_Model.
| virtual void claraty::Camera_Model::pixel_to_ray | ( | const Pixel_Coord & | pixel_coord, | |
| Ray & | vector | |||
| ) | const [pure 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
Implemented in claraty::A_Camera_Model, and claraty::Tsai_Camera_Model.
| Pixel_Coord claraty::Camera_Model::get_mapped_coordinates | ( | Pixel_Coord | unmapped_coord | ) | const [virtual] |
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] |
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] |
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 }
| bool claraty::Camera_Model::map_model | ( | Camera_Model & | mapped_model, | |
| Map_Op & | map_op | |||
| ) | const [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 in claraty::A_Camera_Model, and claraty::Tsai_Camera_Model.
Definition at line 181 of file camera_model.cc.
| bool claraty::Camera_Model::io | ( | FDM_Map | m | ) | [virtual] |
Serializes a camera model.
- Parameters:
-
[in] m A map that holds the content of a serialized camera model
Reimplemented in claraty::A_Camera_Model, and claraty::Tsai_Camera_Model.
Definition at line 194 of file camera_model.cc.
References _name, claraty::FDM_Map::field(), get_typename(), claraty::FDM_Map::is_read(), claraty::FDM_Map::is_write(), and claraty::FDM_Map::peekfield().
Referenced by claraty::Tsai_Camera_Model::io(), and claraty::A_Camera_Model::io().
00195 { 00196 std::string type = get_typename(); 00197 bool ok = m.field("type", type); 00198 assert(type == get_typename()); 00199 00200 const unsigned int latest_version = 1; 00201 unsigned int this_version = latest_version; 00202 00203 if (m.is_read() && m.peekfield("camera_model_version", this_version)) { 00204 ok &= m.field("camera_model_version", this_version); 00205 assert(this_version <= latest_version); 00206 ok &= m.field("name", _name); 00207 } 00208 00209 if (m.is_write()) { 00210 ok &= m.field("camera_model_version", this_version); 00211 ok &= m.field("name", _name); 00212 } 00213 00214 //ok &= map.field("frame", *_mounting_frame); 00215 00216 return ok; 00217 }
Here is the call graph for this function:

| virtual void claraty::Camera_Model::read | ( | std::istream & | str | ) | [inline, virtual] |
| virtual void claraty::Camera_Model::write | ( | std::ostream & | str | ) | const [inline, virtual] |
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] |
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 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] |
Referenced by build_from_file().
| static Camera_Model* claraty::Camera_Model::build_from_typename | ( | const std::string | type_name | ) | [inline, static] |
Definition at line 137 of file camera_model.h.
References factory.
Referenced by claraty::io_object().
00137 { 00138 return (*factory)(type_name); 00139 }
Member Data Documentation
int claraty::Camera_Model::model [private] |
Definition at line 38 of file camera_image.cc.
Frame* claraty::Camera_Model::_mounting_frame [protected] |
Extrinsic camera parameters
Definition at line 76 of file camera_model.h.
Referenced by get_frame(), operator=(), operator==(), and set_frame().
std::string claraty::Camera_Model::_name [protected] |
Definition at line 77 of file camera_model.h.
Referenced by get_name(), io(), operator=(), operator==(), and set_name().
Factory< Camera_Model, string > * claraty::Camera_Model::factory [static] |
The documentation for this class was generated from the following files: