Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

multigl.cpp File Reference

Real-time augmentation using OpenGL and shaders. More...

#include <iostream>
#include <vector>
#include <cv.h>
#include <highgui.h>
#include <calib/camera.h>
#include "multigrab.h"
#include <GL/glut.h>

Include dependency graph for multigl.cpp:

Include dependency graph

Go to the source code of this file.

Functions

void photo_start ()
 Starts photometric calibration.
void geom_calib_start (bool cache)
 Start geometric calibration. If the calibration can be loaded from disk, continue directly with photometric calibration.
void reshape (int width, int height)
 GLUT callback on window size change.
void usage (const char *s)
 Print a command line help and exit.
bool init (int argc, char **argv)
 Initialize everything.
void keyboard (unsigned char c, int x, int y)
void emptyWindow ()
int main (int argc, char *argv[])
bool drawBackground (IplTexture *tex)
 Draw a frame contained in an IplTexture object on an OpenGL viewport.
void geom_calib_draw (void)
 A draw callback during camera calibration.
void geom_calib_end ()
 Called when geometric calibration ends. It makes sure that the CamAugmentation object is ready to work.
void geom_calib_idle (void)
void photo_draw (void)
void photo_idle ()

Variables

MultiGrabmulti = 0
int geom_calib_nb_homography
CamCalibrationcalib = 0
int current_cam = 0
IplTextureframeTexture = 0
bool frameOK = false
int nbLightMeasures = 0
bool cacheLight = false
bool dynamicLight = false
bool sphereObject = false


Detailed Description

Real-time augmentation using OpenGL and shaders.

This example first calibrates connected camera(s) and then uses OpenGL to augment the calibration target with a teapot, shaded by the calibrated light map.

Definition in file multigl.cpp.


Function Documentation

bool drawBackground IplTexture tex  )  [static]
 

Draw a frame contained in an IplTexture object on an OpenGL viewport.

Definition at line 159 of file multigl.cpp.

References IplTexture::disableTexture(), IplTexture::getIm(), IplTexture::loadTexture(), IplTexture::u(), and IplTexture::v().

Referenced by geom_calib_draw(), and photo_draw().

void emptyWindow  )  [static]
 

Definition at line 136 of file multigl.cpp.

Referenced by main().

void geom_calib_draw void   )  [static]
 

A draw callback during camera calibration.

GLUT calls that function during camera calibration when repainting the window is required. During geometric calibration, no 3D is known: we just plot 2d points where some feature points have been recognized.

Definition at line 205 of file multigl.cpp.

References MultiGrab::cams, PyrImage::convCoordf(), current_cam, drawBackground(), frameTexture, and multi.

Referenced by geom_calib_start().

void geom_calib_end  )  [static]
 

Called when geometric calibration ends. It makes sure that the CamAugmentation object is ready to work.

Definition at line 253 of file multigl.cpp.

References CalibModel::augm, calib, CamAugmentation::LoadOptimalStructureFromFile(), MultiGrab::model, and multi.

Referenced by geom_calib_idle().

void geom_calib_idle void   )  [static]
 

Called by GLUT during geometric calibration when there's nothing else to do. This function grab frames from camera(s), run the 2D detection on every image, and keep the result in memory for calibration. When enough homographies have been detected, it tries to actually calibrate the cameras.

Definition at line 272 of file multigl.cpp.

References add_detected_homography(), CamCalibration::AddHomography(), calib, CamCalibration::Calibrate(), MultiGrab::cams, current_cam, frameTexture, geom_calib_end(), geom_calib_nb_homography, MultiGrab::grabFrames(), multi, photo_start(), CamCalibration::PrintOptimizedResultsToFile1(), and IplTexture::setImage().

Referenced by geom_calib_start().

void geom_calib_start bool  cache  )  [static]
 

Start geometric calibration. If the calibration can be loaded from disk, continue directly with photometric calibration.

Definition at line 327 of file multigl.cpp.

References CamCalibration::AddCamera(), CalibModel::augm, calib, MultiGrab::cams, geom_calib_draw(), geom_calib_idle(), geom_calib_nb_homography, CamAugmentation::LoadOptimalStructureFromFile(), MultiGrab::model, multi, and photo_start().

Referenced by init().

bool init int  argc,
char **  argv
[static]
 

Initialize everything.

  • Parse the command line
  • Initialize all the cameras
  • Load or interactively build a model, with its classifier.
  • Set the GLUT callbacks for geometric calibration or, if already done, for photometric calibration.

Definition at line 71 of file multigl.cpp.

References cacheLight, geom_calib_start(), MultiGrab::init(), modelFile, multi, and usage().

Referenced by main().

void keyboard unsigned char  c,
int  x,
int  y
[static]
 

The keyboard callback: reacts to '+' and '-' to change the viewed cam, 'q' exits. 'o' switches between a teapot and a sphere 'd' turns on/off the dynamic lightmap update. 'f' goes fullscreen.

Definition at line 117 of file multigl.cpp.

References MultiGrab::cams, current_cam, dynamicLight, multi, and sphereObject.

Referenced by main().

int main int  argc,
char *  argv[]
 

Definition at line 140 of file multigl.cpp.

References emptyWindow(), init(), and keyboard().

void photo_draw void   )  [static]
 

The paint callback during photometric calibration and augmentation. In this case, we have access to 3D data. Thus, we can augment the calibration target with cool stuff.

Definition at line 351 of file multigl.cpp.

References CalibModel::augm, CalibModel::corners, current_cam, cvmGet(), LightMap::disableShader(), IplTexture::disableTexture(), drawBackground(), LightMap::enableShader(), PerspectiveProjection::flip(), frameTexture, LightMap::getBias(), LightMap::getGain(), CamAugmentation::GetObjectToWorld(), CamAugmentation::GetProjectionMatrix(), PerspectiveCamera::getWorldToEyeMat(), CalibModel::image, LightMap::isReady(), PerspectiveCamera::loadTdir(), IplTexture::loadTexture(), Mat3x4::m, M_PI, LightMap::map, CalibModel::map, CamCalibration::Mat3x4Mul(), MultiGrab::model, Mat3x4::mul(), multi, LightMap::readMap(), PerspectiveCamera::setGlModelView(), PerspectiveProjection::setGlProjection(), Mat3x4::setInverseByTranspose(), PerspectiveProjection::setPlanes(), Mat3x4::setRotate(), Mat3x4::setTranslate(), PerspectiveCamera::setWorldToEyeMat(), and Mat3x4::transform().

Referenced by photo_start().

void photo_idle  )  [static]
 

GLUT calls this during photometric calibration or augmentation phase when there's nothing else to do. This function does the 2D detection and bundle adjusts the 3D pose of the calibration pattern. Then, it extracts the surface normal, and pass all the lighting measurements to the LightMap object. When enough is collected, the lightmap is computed.

Definition at line 548 of file multigl.cpp.

References CamAugmentation::Accomodate(), add_detected_homography(), CamAugmentation::AddHomography(), LightMap::addNormal(), CalibModel::augm, MultiGrab::cams, CamAugmentation::Clear(), LightMap::computeLightParams(), current_cam, frameOK, frameTexture, CamAugmentation::GetObjectToWorld(), MultiGrab::grabFrames(), LightMap::isReady(), CalibModel::map, MultiGrab::model, multi, nbLightMeasures, LightMap::nbNormals(), LightMap::save(), and IplTexture::setImage().

Referenced by photo_start().

void photo_start  )  [static]
 

Starts photometric calibration.

Definition at line 606 of file multigl.cpp.

References MultiGrab::allocLightCollector(), LightMap::load(), CalibModel::map, MultiGrab::model, multi, nbLightMeasures, photo_draw(), and photo_idle().

Referenced by geom_calib_idle(), and geom_calib_start().

void reshape int  width,
int  height
[static]
 

GLUT callback on window size change.

Definition at line 43 of file multigl.cpp.

void usage const char *  s  )  [static]
 

Print a command line help and exit.

Definition at line 52 of file multigl.cpp.


Variable Documentation

bool cacheLight = false
 

Definition at line 34 of file multigl.cpp.

Referenced by init().

CamCalibration* calib = 0
 

Definition at line 29 of file multigl.cpp.

Referenced by add_detected_homography(), geom_calib_end(), geom_calib_idle(), geom_calib_start(), geometric_calibration(), and main().

int current_cam = 0
 

Definition at line 30 of file multigl.cpp.

Referenced by geom_calib_draw(), geom_calib_idle(), keyboard(), photo_draw(), and photo_idle().

bool dynamicLight = false
 

Definition at line 35 of file multigl.cpp.

Referenced by keyboard().

bool frameOK = false
 

Definition at line 32 of file multigl.cpp.

Referenced by photo_idle(), and photometric_calibration().

IplTexture* frameTexture = 0
 

Definition at line 31 of file multigl.cpp.

Referenced by geom_calib_draw(), geom_calib_idle(), photo_draw(), and photo_idle().

int geom_calib_nb_homography
 

Definition at line 28 of file multigl.cpp.

Referenced by geom_calib_idle(), and geom_calib_start().

MultiGrab* multi = 0
 

Definition at line 26 of file multigl.cpp.

Referenced by geom_calib_draw(), geom_calib_end(), geom_calib_idle(), geom_calib_start(), geometric_calibration(), init(), keyboard(), main(), photo_draw(), photo_idle(), photo_start(), and photometric_calibration().

int nbLightMeasures = 0
 

Definition at line 33 of file multigl.cpp.

Referenced by photo_idle(), photo_start(), and photometric_calibration().

bool sphereObject = false
 

Definition at line 36 of file multigl.cpp.

Referenced by keyboard().


Generated on Mon Oct 2 14:36:01 2006 for bazar by  doxygen 1.3.9.1