bazar
1.3.1
|
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>
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 | |
MultiGrab * | multi = 0 |
int | geom_calib_nb_homography |
CamCalibration * | calib = 0 |
int | current_cam = 0 |
IplTexture * | frameTexture = 0 |
bool | frameOK = false |
int | nbLightMeasures = 0 |
bool | cacheLight = false |
bool | dynamicLight = false |
bool | sphereObject = false |
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.
|
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().
|
static |
|
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(), 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 |
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(), and MultiGrab::model.
Referenced by geom_calib_idle().
|
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(), 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 |
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, MultiGrab::cams, geom_calib_draw(), geom_calib_idle(), geom_calib_nb_homography, CamAugmentation::LoadOptimalStructureFromFile(), MultiGrab::model, and photo_start().
Referenced by init().
|
static |
Initialize everything.
Definition at line 71 of file multigl.cpp.
References cacheLight, geom_calib_start(), MultiGrab::init(), modelFile, and usage().
Referenced by main().
|
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 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 |
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, MultiGrab::cams, CalibModel::corners, current_cam, cvmGet(), LightMap::disableShader(), IplTexture::disableTexture(), drawBackground(), LightMap::enableShader(), PerspectiveProjection::flip(), frameOK, LightMap::getBias(), LightMap::getGain(), CamAugmentation::GetObjectToWorld(), CamAugmentation::GetProjectionMatrix(), PerspectiveCamera::getWorldToEyeMat(), CalibModel::image, LightMap::isReady(), PerspectiveCamera::loadTdir(), IplTexture::loadTexture(), Mat3x4::m, M_PI, CalibModel::map, LightMap::map, CamCalibration::Mat3x4Mul(), MultiGrab::model, Mat3x4::mul(), LightMap::readMap(), PerspectiveCamera::setGlModelView(), PerspectiveProjection::setGlProjection(), Mat3x4::setInverseByTranspose(), PerspectiveProjection::setPlanes(), Mat3x4::setRotate(), Mat3x4::setTranslate(), PerspectiveCamera::setWorldToEyeMat(), sphereObject, and Mat3x4::transform().
Referenced by photo_start().
|
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, 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 |
Starts photometric calibration.
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 |
GLUT callback on window size change.
Definition at line 43 of file multigl.cpp.
|
static |
Print a command line help and exit.
Definition at line 52 of file multigl.cpp.
bool cacheLight = false |
Definition at line 34 of file multigl.cpp.
Referenced by init(), and photo_start().
CamCalibration* calib = 0 |
Definition at line 29 of file multigl.cpp.
Referenced by geom_calib_end(), 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(), and photo_idle().
bool frameOK = false |
Definition at line 32 of file multigl.cpp.
Referenced by photo_draw(), photo_idle(), and photometric_calibration().
IplTexture* frameTexture = 0 |
Definition at line 31 of file multigl.cpp.
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 main().
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(), and photo_draw().