bazar  1.3.1
Functions | Variables
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:

Go to the source code of this file.

Functions

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

static bool drawBackground ( IplTexture tex)
static

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

Examples:
multigl.cpp.

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().

static void emptyWindow ( )
static
Examples:
multigl.cpp.

Definition at line 136 of file multigl.cpp.

Referenced by main().

static 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.

Examples:
multigl.cpp.

Definition at line 205 of file multigl.cpp.

References MultiGrab::cams, PyrImage::convCoordf(), current_cam, drawBackground(), image_object_point_match::image_point, image_object_point_match::inlier, planar_object_recognizer::match_number, planar_object_recognizer::matches, planar_object_recognizer::object_is_detected, keypoint::scale, keypoint::u, and keypoint::v.

Referenced by geom_calib_start().

static void geom_calib_end ( )
static

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

Examples:
multigl.cpp.

Definition at line 253 of file multigl.cpp.

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

Referenced by geom_calib_idle().

static 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.

Examples:
multigl.cpp.

Definition at line 272 of file multigl.cpp.

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

Referenced by geom_calib_start().

static void geom_calib_start ( bool  cache)
static

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

Examples:
multigl.cpp.

Definition at line 327 of file multigl.cpp.

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

Referenced by init().

static 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.
Examples:
multigl.cpp.

Definition at line 71 of file multigl.cpp.

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

Referenced by main().

static 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.

Examples:
multigl.cpp.

Definition at line 117 of file multigl.cpp.

References current_cam, dynamicLight, and sphereObject.

Referenced by main().

int main ( int  argc,
char *  argv[] 
)

Definition at line 140 of file multigl.cpp.

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

static void photo_draw ( void  )
static
static 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.

Examples:
multigl.cpp.

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, dynamicLight, frameOK, CamAugmentation::GetObjectToWorld(), MultiGrab::grabFrames(), LightMap::isReady(), CalibModel::map, MultiGrab::model, nbLightMeasures, LightMap::nbNormals(), LightMap::save(), and IplTexture::setImage().

Referenced by photo_start().

static void photo_start ( )
static

Starts photometric calibration.

Examples:
multigl.cpp.

Definition at line 606 of file multigl.cpp.

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

Referenced by geom_calib_idle(), and geom_calib_start().

static void reshape ( int  width,
int  height 
)
static

GLUT callback on window size change.

Examples:
multigl.cpp.

Definition at line 43 of file multigl.cpp.

static 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
Examples:
multigl.cpp.

Definition at line 34 of file multigl.cpp.

Referenced by init(), and photo_start().

CamCalibration* calib = 0
int current_cam = 0
Examples:
multigl.cpp.

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
Examples:
multigl.cpp.

Definition at line 35 of file multigl.cpp.

Referenced by keyboard(), and photo_idle().

bool frameOK = false
Examples:
multicam.cpp, and multigl.cpp.

Definition at line 32 of file multigl.cpp.

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

IplTexture* frameTexture = 0
Examples:
multigl.cpp.

Definition at line 31 of file multigl.cpp.

int geom_calib_nb_homography
Examples:
multigl.cpp.

Definition at line 28 of file multigl.cpp.

Referenced by geom_calib_idle(), and geom_calib_start().

MultiGrab* multi = 0
Examples:
multicam.cpp, and multigl.cpp.

Definition at line 26 of file multigl.cpp.

Referenced by main().

int nbLightMeasures = 0
Examples:
multicam.cpp, and multigl.cpp.

Definition at line 33 of file multigl.cpp.

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

bool sphereObject = false
Examples:
multigl.cpp.

Definition at line 36 of file multigl.cpp.

Referenced by keyboard(), and photo_draw().