bazar  1.3.1
Public Member Functions | Public Attributes | List of all members

This class represents a calibrated camera.The camera space is right-handed, i.e.: x -> points right y -> points up z -> points away through screen. More...

#include <camera.h>

Inheritance diagram for PerspectiveProjection:
Inheritance graph
[legend]
Collaboration diagram for PerspectiveProjection:
Collaboration graph
[legend]

Public Member Functions

 PerspectiveProjection ()
 PerspectiveProjection (int w, int h, double f, double g, double cx, double, double s=0)
void set (int w, int h, double f, double g, double cx, double cy, double s=0)
void eyeToImage (const double eye[3], double uv[2]) const
void imageToEye (const double uv[2], double eye[3], double w=0) const
void imageToEye (double u, double v, double eye[3], double w=0) const
void setGlProjection () const
bool setPlanes (double near, double far)
bool getUndistortMap (CvMat *xmap, CvMat *ymap)
void cmpEyeToImageMat ()
void flip ()

Public Attributes

double f
double g
double cx
double cy
double s
double distortion
Mat3x3 eyeToImageMat
int width
int height
double farPlane
double nearPlane

Detailed Description

This class represents a calibrated camera.

The camera space is right-handed, i.e.: x -> points right y -> points up z -> points away through screen.

The image space origin is bottom-left, and the y axis points up.

For square pixels s should be 0 and f==g.

Projection equation of the 3D point P:

\[u = \frac{(f * Px + s * Py)}{Pz + cx}\]

\[v = \frac{g * Py}{Pz + cy}\]

Definition at line 25 of file camera.h.

Constructor & Destructor Documentation

PerspectiveProjection::PerspectiveProjection ( )

Definition at line 32 of file camera.cpp.

PerspectiveProjection::PerspectiveProjection ( int  w,
int  h,
double  f,
double  g,
double  cx,
double  cy,
double  s = 0 
)

Definition at line 37 of file camera.cpp.

Member Function Documentation

void PerspectiveProjection::cmpEyeToImageMat ( )

Definition at line 147 of file camera.cpp.

void PerspectiveProjection::eyeToImage ( const double  eye[3],
double  uv[2] 
) const

Project eye coordinates to image coordinates. uv[0] is the horizontal axis (left -> right) and uv[1] is the vertical axis, pointing up.

Definition at line 78 of file camera.cpp.

void PerspectiveProjection::flip ( )

Inverse V axis (projected image upside/down)

Examples:
multigl.cpp.

Definition at line 162 of file camera.cpp.

Referenced by photo_draw().

bool PerspectiveProjection::getUndistortMap ( CvMat *  xmap,
CvMat *  ymap 
)

Definition at line 169 of file camera.cpp.

void PerspectiveProjection::imageToEye ( const double  uv[2],
double  eye[3],
double  w = 0 
) const

Definition at line 103 of file camera.cpp.

void PerspectiveProjection::imageToEye ( double  u,
double  v,
double  eye[3],
double  w = 0 
) const

Find the 3D eye coordinate of a given pixel. u is the horizontal axis (left -> right) and v is the vertical axis, pointing up.

Definition at line 88 of file camera.cpp.

void PerspectiveProjection::set ( int  w,
int  h,
double  f,
double  g,
double  cx,
double  cy,
double  s = 0 
)

Definition at line 42 of file camera.cpp.

void PerspectiveProjection::setGlProjection ( ) const

This will produce the exact same projection in the case s=0. Otherwise, there might be some clipping problems.

The trick is to remember that OpenGL has a negative Z projection. You should glScale(1,1,-1); if you use positive Z.

OpenGl, after projection, clips coordinates to [-1, 1] on all axis. It is converted then to window coordinates.

Examples:
multigl.cpp.

Definition at line 118 of file camera.cpp.

Referenced by photo_draw().

bool PerspectiveProjection::setPlanes ( double  nearPlane,
double  farPlane 
)

Set near and far clipping planes. Both values have to be positive. Far should also be larger than near. If the values are incorrect, the near and far are not modified.

Returns
true if near and far are valid and accepted, false otherwise.
Examples:
multigl.cpp.

Definition at line 63 of file camera.cpp.

Referenced by photo_draw().

Member Data Documentation

double PerspectiveProjection::cx

Definition at line 43 of file camera.h.

Referenced by operator<<().

double PerspectiveProjection::cy

Definition at line 43 of file camera.h.

Referenced by operator<<().

double PerspectiveProjection::distortion

Definition at line 44 of file camera.h.

Mat3x3 PerspectiveProjection::eyeToImageMat

Definition at line 45 of file camera.h.

double PerspectiveProjection::f

Definition at line 43 of file camera.h.

Referenced by operator<<().

double PerspectiveProjection::farPlane

Definition at line 47 of file camera.h.

Referenced by operator<<().

double PerspectiveProjection::g

Definition at line 43 of file camera.h.

Referenced by operator<<().

int PerspectiveProjection::height

Definition at line 46 of file camera.h.

Referenced by operator<<().

double PerspectiveProjection::nearPlane

Definition at line 47 of file camera.h.

Referenced by operator<<().

double PerspectiveProjection::s

Definition at line 43 of file camera.h.

Referenced by operator<<().

int PerspectiveProjection::width

Definition at line 46 of file camera.h.

Referenced by operator<<().


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