Visualization Library 2.0.0-b3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::CalibratedCamera Class Reference

Calibrated camera for augmented reality. More...

#include <CalibratedCamera.hpp>

+ Inheritance diagram for vl::CalibratedCamera:

Public Member Functions

 CalibratedCamera ()
 
void setCalibratedImageSize (int width, int height, float pixelaspect=1.0)
 Set the size of the image in pixels that was used while calibrating the camera model. More...
 
void setIntrinsicParameters (float fx, float fy, float cx, float cy)
 Set the intrinsic parameters as determined from camera calibration. More...
 
void setScreenSize (int width, int height)
 Usually you don't need to call this as the renderer takes care of keeping it up to date with whatever the current framebuffer size is. More...
 
int imageWidth () const
 Image width in pixels. More...
 
int imageHeight () const
 Image height in pixels. More...
 
int screenWidth () const
 Image width in pixels. More...
 
int screenHeight () const
 Screen height in pixels. More...
 
float pixelAspectRatio () const
 The width of a single pixel divided by its height. More...
 
void updateCalibration ()
 Recomputes the projection matrix and viewport based on the calibration data specified by setCalibratedImageSize(), setScreenSize(), setIntrinsicParameters(), setNearPlane(), setFarPlane() More...
 
- Public Member Functions inherited from vl::Camera
 Camera ()
 Constructs a perspective projecting camera with FOV = 60.0, Near Plane = 0.05, Far Plane = 10000.0. More...
 
void computeNearFarOptimizedProjMatrix (const Sphere &scene_bounding_sphere)
 The near and far clipping planes are adjusted to fit the provided scene_bounding_sphere. More...
 
void computeFrustumPlanes ()
 Computes the Camera's frustum planes in world space. More...
 
void applyModelViewMatrix (const mat4 &model_matrix) const
 Loads the GL_MODELVIEW matrix with the Camera's view matrix multiplied by the specified model matrix. More...
 
void applyViewMatrix () const
 Loads the GL_MODELVIEW matrix with the Camera's view matrix. More...
 
void applyProjMatrix () const
 Loads the GL_PROJECTION matrix with the Camera's projection matrix. More...
 
real aspectRatio () const
 Returns the aspect ratio computed as viewport()->width()/viewport()->height(). More...
 
void setFOV (real fov)
 The field of view of the camera. More...
 
real fov () const
 The field of view of the camera. More...
 
void setNearPlane (real nearplane)
 The near clipping plane. More...
 
real nearPlane () const
 The near clipping plane. More...
 
void setFarPlane (real farplane)
 The far clipping plane. More...
 
real farPlane () const
 The far clipping plane. More...
 
real left () const
 'left' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() More...
 
void setLeft (real v)
 
real right () const
 'right' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() More...
 
void setRight (real v)
 
real bottom () const
 'bottom' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() More...
 
void setBottom (real v)
 
real top () const
 'top' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() More...
 
void setTop (real v)
 
void setFrustum (const Frustum &frustum)
 The view frustum of the camera used to perform frustum culling. More...
 
const Frustumfrustum () const
 The view frustum of the camera used to perform frustum culling. More...
 
Frustumfrustum ()
 The view frustum of the camera used to perform frustum culling. More...
 
void setViewport (Viewport *viewport)
 The viewport bound to a camera. More...
 
Viewportviewport ()
 The viewport bound to a camera. More...
 
const Viewportviewport () const
 The viewport bound to a camera. More...
 
void bindTransform (Transform *transform)
 Bind the camera to a Transform. More...
 
const TransformboundTransform () const
 Returns the Transform bound to a camera. More...
 
TransformboundTransform ()
 Returns the Transform bound to a camera. More...
 
void setViewMatrix (const mat4 &mat)
 Sets the Camera's view matrix (inverse of the modeling matrix). More...
 
const mat4viewMatrix () const
 Returns the Camera's view matrix (inverse of the modeling matrix). More...
 
void setModelingMatrix (const mat4 &mat)
 Sets the Camera's modelingMatrix() (inverse of the view matrix). More...
 
const mat4modelingMatrix () const
 Returns the Camera's modelingMatrix() (inverse of the view matrix). More...
 
void setProjectionMatrix (const mat4 &mat, EProjectionMatrixType proj_type)
 The Camera's projection matrix. More...
 
const mat4projectionMatrix () const
 The Camera's projection matrix. More...
 
EProjectionMatrixType projectionMatrixType () const
 The Camera's projection matrix type. More...
 
void setProjectionPerspective ()
 Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings. More...
 
void setProjectionPerspective (real fov, real near, real far)
 Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings. More...
 
void setProjectionFrustum (real left, real right, real bottom, real top, real znear, real zfar)
 Produces a perspective projection matrix. More...
 
void setProjectionOrtho (real left, real right, real bottom, real top, real znear, real zfar)
 Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings. More...
 
void setProjectionOrtho ()
 Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings. More...
 
void setProjectionOrtho (real offset)
 Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings. More...
 
void setViewMatrixLookAt (const vec3 &eye, const vec3 &at, const vec3 &up)
 Setup the modelview transform of the camera based on look-at parameters. More...
 
void getViewMatrixAsLookAt (vec3 &eye, vec3 &at, vec3 &up, vec3 &right) const
 Returns the look-at parameters of the modelview transform. More...
 
bool project (const vec4 &in_world, vec4 &out_viewp) const
 Projects a vector from world coordinates to viewport coordinates. More...
 
bool unproject (const vec3 &in_viewp, vec4 &out_world) const
 Unprojects a vector from viewport coordinates to world coordinates. More...
 
bool unproject (std::vector< vec3 > &points) const
 Unprojects a set of points. More...
 
Ray computeRay (int viewp_x, int viewp_y)
 Computes the ray passing through the point <viewp_x,viewp_y>. More...
 
Frustum computeRayFrustum (int viewp_x, int viewp_y)
 Computes a 1 pixel wide frustum suitable to cull objects during ray intersection detection. More...
 
void adjustView (const AABB &aabb, const vec3 &dir, const vec3 &up, real bias=1.0f)
 Adjusts the camera position so that the given aabb can be properly viewed. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Attributes

int mImageWidth
 
int mImageHeight
 
int mScreenWidth
 
int mScreenHeight
 
float mPixelAspectRatio
 
float mFx
 
float mFy
 
float mCx
 
float mCy
 
- Protected Attributes inherited from vl::Camera
mat4 mViewMatrix
 
mat4 mModelingMatrix
 
mat4 mProjectionMatrix
 
ref< ViewportmViewport
 
Frustum mFrustum
 
ref< TransformmBoundTransform
 
real mFOV
 
real mLeft
 
real mRight
 
real mBottom
 
real mTop
 
real mNearPlane
 
real mFarPlane
 
EProjectionMatrixType mProjectionType
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

Calibrated camera for augmented reality.

To use the CalibratedCamera keep the following in mind:

See also
http://strawlab.org/2011/11/05/augmented-reality-with-OpenGL/
http://sightations.wordpress.com/2010/08/03/simulating-calibrated-cameras-in-opengl/
http://jamesgregson.blogspot.co.uk/2011/11/matching-calibrated-cameras-with-opengl.html
http://www.robots.ox.ac.uk/~vgg/hzbook/

Definition at line 28 of file CalibratedCamera.hpp.

Constructor & Destructor Documentation

◆ CalibratedCamera()

CalibratedCamera::CalibratedCamera ( )

Definition at line 11 of file CalibratedCamera.cpp.

Member Function Documentation

◆ imageHeight()

int vl::CalibratedCamera::imageHeight ( ) const
inline

Image height in pixels.

Definition at line 75 of file CalibratedCamera.hpp.

◆ imageWidth()

int vl::CalibratedCamera::imageWidth ( ) const
inline

Image width in pixels.

Definition at line 72 of file CalibratedCamera.hpp.

◆ pixelAspectRatio()

float vl::CalibratedCamera::pixelAspectRatio ( ) const
inline

The width of a single pixel divided by its height.

Definition at line 84 of file CalibratedCamera.hpp.

◆ screenHeight()

int vl::CalibratedCamera::screenHeight ( ) const
inline

Screen height in pixels.

Definition at line 81 of file CalibratedCamera.hpp.

◆ screenWidth()

int vl::CalibratedCamera::screenWidth ( ) const
inline

Image width in pixels.

Definition at line 78 of file CalibratedCamera.hpp.

◆ setCalibratedImageSize()

void CalibratedCamera::setCalibratedImageSize ( int  width,
int  height,
float  pixelaspect = 1.0 
)

Set the size of the image in pixels that was used while calibrating the camera model.

Call updateCalibration() to apply the changes to the projection matrix.

Parameters
widthin pixels.
heightin pixels.
pixelaspectis the width of a single pixel divided by its height.

Definition at line 25 of file CalibratedCamera.cpp.

References mImageHeight, mImageWidth, and mPixelAspectRatio.

◆ setIntrinsicParameters()

void CalibratedCamera::setIntrinsicParameters ( float  fx,
float  fy,
float  cx,
float  cy 
)

Set the intrinsic parameters as determined from camera calibration.

Call updateCalibration() to apply the changes to the projection matrix.

Parameters
fxscale factor of combined focal length * effective pixel size in horizontal direction.
fyscale factor of combined focal length * effective pixel size in vertical direction.
cxcentre of projection in x axis.
cycentre of projection in y axis.

Definition at line 38 of file CalibratedCamera.cpp.

References mCx, mCy, mFx, and mFy.

◆ setScreenSize()

void CalibratedCamera::setScreenSize ( int  width,
int  height 
)

Usually you don't need to call this as the renderer takes care of keeping it up to date with whatever the current framebuffer size is.

Set the screen/widget size currently used.

Call updateCalibration() to apply the changes to the projection matrix.

Parameters
widthin pixels.
heightin pixels.

Definition at line 32 of file CalibratedCamera.cpp.

References mScreenHeight, and mScreenWidth.

◆ updateCalibration()

void CalibratedCamera::updateCalibration ( )

Member Data Documentation

◆ mCx

float vl::CalibratedCamera::mCx
protected

Definition at line 100 of file CalibratedCamera.hpp.

Referenced by setIntrinsicParameters(), and updateCalibration().

◆ mCy

float vl::CalibratedCamera::mCy
protected

Definition at line 101 of file CalibratedCamera.hpp.

Referenced by setIntrinsicParameters(), and updateCalibration().

◆ mFx

float vl::CalibratedCamera::mFx
protected

Definition at line 98 of file CalibratedCamera.hpp.

Referenced by setIntrinsicParameters(), and updateCalibration().

◆ mFy

float vl::CalibratedCamera::mFy
protected

Definition at line 99 of file CalibratedCamera.hpp.

Referenced by setIntrinsicParameters(), and updateCalibration().

◆ mImageHeight

int vl::CalibratedCamera::mImageHeight
protected

Definition at line 94 of file CalibratedCamera.hpp.

Referenced by setCalibratedImageSize(), and updateCalibration().

◆ mImageWidth

int vl::CalibratedCamera::mImageWidth
protected

Definition at line 93 of file CalibratedCamera.hpp.

Referenced by setCalibratedImageSize(), and updateCalibration().

◆ mPixelAspectRatio

float vl::CalibratedCamera::mPixelAspectRatio
protected

Definition at line 97 of file CalibratedCamera.hpp.

Referenced by setCalibratedImageSize(), and updateCalibration().

◆ mScreenHeight

int vl::CalibratedCamera::mScreenHeight
protected

Definition at line 96 of file CalibratedCamera.hpp.

Referenced by setScreenSize(), and updateCalibration().

◆ mScreenWidth

int vl::CalibratedCamera::mScreenWidth
protected

Definition at line 95 of file CalibratedCamera.hpp.

Referenced by setScreenSize(), and updateCalibration().


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