bazar  1.3.1
Classes | Public Member Functions | Public Attributes | List of all members
LightMap Class Reference

Irradiance map computation, storage and augmentation. More...

#include <lightmap.h>

Collaboration diagram for LightMap:
Collaboration graph
[legend]

Classes

struct  Observation

Public Member Functions

 LightMap ()
 ~LightMap ()
 LightMap (const LightMap &a)
bool init (int nbCam, IplImage *model, float corners[4][2], int nx, int ny)
void setCamNum (int n)
bool initGL ()
void enableShader (int cam, CvMat *obj2world)
void disableShader ()
bool load (const char *lightParamsFN="lightParams.mat", const char *normalsFN="normals.mat")
bool save (const char *lightParamsFN="lightParams.mat", const char *normalsFN="normals.mat")
bool addNormal (float normal[3], LightCollector &lc, int cam)
 calls addNormalCalib if the system is not yet solved, or addNormallightMap otherwise.
bool addNormalCalib (float normal[3], LightCollector &lc, int cam)
 Add a normal for future light map computation.
bool addNormalLightMap (float normal[3], LightCollector &lc, int cam)
 Update the current light map with given observation.
bool computeLightParams ()
bool isReady ()
 return true when computeLightParams() has succeeded.
bool saveImage (const char *filename)
const float * getGain (int cam)
 return the (B,G,R) gain of a camera.
const float * getBias (int cam)
 return the (B,G,R) bias of a camera.
CvScalar readMap (const float normal[3])
 returns the irradiance for a given normal.
int nbNormals () const
 the number of normals measured that'll be used by computeLightParams.

Public Attributes

IplTexture map
 Contains the irradiance map. Read it with readMap, update it with addNormal.
LightCollector reflc

Detailed Description

Irradiance map computation, storage and augmentation.

Author
Julien Pilet

This class computes a environmental radiance map and uses OpenGL to augment 3D objects accordingly.

The process to build a light map is the following: After geometric calibration, it becomes possible to turn an homography into a 3D pose (see CamAugmentation). Thus, when the planar target is detected on an image, it is possible to compute its normal in a reference coordinate system. It is also possible to compare its color with the model one. After collecting many views, a simple linear system computes gain and bias of each camera and the irradiance for each normal.

All of this is done under lambertian assumption and might not behave very well in presence of specularities, specially in a multi-camera environment.

Relighting 3D objects for augmentation can done by GPU using a vertex and a pixel shader.

Definition at line 42 of file lightmap.h.

Constructor & Destructor Documentation

LightMap::LightMap ( )

Definition at line 16 of file lightmap.cpp.

LightMap::~LightMap ( )

Definition at line 37 of file lightmap.cpp.

LightMap::LightMap ( const LightMap a)

Definition at line 25 of file lightmap.cpp.

References IplTexture::getIm(), map, and reflc.

Member Function Documentation

bool LightMap::addNormal ( float  normal[3],
LightCollector lc,
int  cam 
)

calls addNormalCalib if the system is not yet solved, or addNormallightMap otherwise.

Examples:
fullcalib.cpp, and multigl.cpp.

Definition at line 121 of file lightmap.cpp.

Referenced by photo_idle(), and photometric_calibration().

bool LightMap::addNormalCalib ( float  normal[3],
LightCollector lc,
int  cam 
)

Add a normal for future light map computation.

Definition at line 439 of file lightmap.cpp.

References LightCollector::avg, LightCollector::avgChannels, LightCollector::nbTri, and normalize().

bool LightMap::addNormalLightMap ( float  normal[3],
LightCollector lc,
int  cam 
)

Update the current light map with given observation.

Definition at line 143 of file lightmap.cpp.

References LightCollector::cmpWithRef().

bool LightMap::computeLightParams ( )

Compute the light map using all available observations, previously added with addNormalCalib ir addNormal.

Examples:
fullcalib.cpp, and multigl.cpp.

Definition at line 611 of file lightmap.cpp.

Referenced by photo_idle(), and photometric_calibration().

void LightMap::disableShader ( )
Examples:
multigl.cpp.

Definition at line 407 of file lightmap.cpp.

Referenced by photo_draw().

void LightMap::enableShader ( int  cam,
CvMat *  obj2world 
)
Examples:
multigl.cpp.

Definition at line 337 of file lightmap.cpp.

Referenced by photo_draw().

const float * LightMap::getBias ( int  cam)

return the (B,G,R) bias of a camera.

Examples:
fullcalib.cpp, multicam.cpp, and multigl.cpp.

Definition at line 136 of file lightmap.cpp.

Referenced by augment_scene(), photo_draw(), and photometric_calibration().

const float * LightMap::getGain ( int  cam)

return the (B,G,R) gain of a camera.

Examples:
fullcalib.cpp, multicam.cpp, and multigl.cpp.

Definition at line 129 of file lightmap.cpp.

Referenced by augment_scene(), photo_draw(), and photometric_calibration().

bool LightMap::init ( int  nbCam,
IplImage *  model,
float  corners[4][2],
int  nx,
int  ny 
)

Definition at line 45 of file lightmap.cpp.

Referenced by CalibModel::buildCached().

bool LightMap::initGL ( )

Definition at line 259 of file lightmap.cpp.

bool LightMap::isReady ( )
inline

return true when computeLightParams() has succeeded.

Examples:
fullcalib.cpp, multicam.cpp, and multigl.cpp.

Definition at line 73 of file lightmap.h.

Referenced by augment_scene(), photo_draw(), photo_idle(), and photometric_calibration().

bool LightMap::load ( const char *  lightParamsFN = "lightParams.mat",
const char *  normalsFN = "normals.mat" 
)
Examples:
fullcalib.cpp, and multigl.cpp.

Definition at line 677 of file lightmap.cpp.

References loadMat().

Referenced by photo_start(), and photometric_calibration().

int LightMap::nbNormals ( ) const
inline

the number of normals measured that'll be used by computeLightParams.

Examples:
multigl.cpp.

Definition at line 91 of file lightmap.h.

Referenced by photo_idle().

CvScalar LightMap::readMap ( const float  normal[3])

returns the irradiance for a given normal.

Examples:
fullcalib.cpp, multicam.cpp, and multigl.cpp.

Definition at line 104 of file lightmap.cpp.

Referenced by augment_scene(), and photo_draw().

bool LightMap::save ( const char *  lightParamsFN = "lightParams.mat",
const char *  normalsFN = "normals.mat" 
)
Examples:
fullcalib.cpp, and multigl.cpp.

Definition at line 605 of file lightmap.cpp.

References saveMat().

Referenced by photo_idle(), and photometric_calibration().

bool LightMap::saveImage ( const char *  filename)

Definition at line 712 of file lightmap.cpp.

void LightMap::setCamNum ( int  n)

Definition at line 416 of file lightmap.cpp.

Member Data Documentation

IplTexture LightMap::map

Contains the irradiance map. Read it with readMap, update it with addNormal.

Examples:
fullcalib.cpp, and multigl.cpp.

Definition at line 76 of file lightmap.h.

Referenced by LightMap(), photo_draw(), and photometric_calibration().

LightCollector LightMap::reflc
Examples:
fullcalib.cpp.

Definition at line 78 of file lightmap.h.

Referenced by MultiGrab::allocLightCollector(), LightMap(), and photometric_calibration().


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