La Réalité Augmentée
ARToolKit
ARToolKit est une bibliothèque logicielle permettant de créer ses propres applications de réalité augmentée. Il permet d'affranchir le développeur de tous les calculs d'analyse et de rendu d'images dont nous avons parlés précédemment.
Architecture
La bibliothèque se découpe en trois couches principales:
- OpenGL pour le rendu de l'image
- GLUT pour les évènements et dépendances hardware de la librairie video
- Une API standard pour chacune des platformes sur lesquelles vont être éxecutées les applications (e.g win32 pour Windows)
Fonctionnement globale
Le fonctionnement globale d'une application de réalité augmentée en utilisant ARToolKit se décompose en 5 étapes distinctes :
- Recherche du marqueur
- Calcul de la position et de l'orientation du marqueur par rapport à la caméra
- Identification du symbole à l'intérieur du marqueur
- Calcul de la position et de l'orientation de l'objet que l'on veut insérer sur le marqueur
- Création de l'image en mixant l'image issue de la caméra avec les éléments virtuels que l'on souhaite intégrer
Développement
Utilisation du pattern dans le code
char *patt_name = "Data/patt.hiro";
static void init( void ) { arParamChangeSize( &wparam, xsize, ysize, &cparam ); arInitCparam( &cparam ); printf("*** Camera Parameter ***\n"); arParamDisp( &cparam );
if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
printf("pattern load error !!\n"); exit(0); } /* open the graphics window */ argInit( &cparam, 1.0, 0, 0, 0, 0 ); }
Chargement d'une image
static void mainLoop(void) { static int contF = 0; ARUint8 *dataPtr; ARMarkerInfo *marker_info; int marker_num; int j, k; /* grab a vide frame */
if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL )
{ arUtilSleep(2); return; } if( count == 0 ) arUtilTimerReset(); count++; argDrawMode2D(); }
Détection du marqueur
/* grab a vide frame */ if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ){ arUtilSleep(2); return; } if( count == 0 ) arUtilTimerReset(); count++; argDrawMode2D(); argDispImage( dataPtr, 0,0 ); /* detect the markers in the video frame */
if( arDetectMarker(dataPtr, thresh, &marker_info,&marker_num) < 0 ){
cleanup(); exit(0); } arVideoCapNext();
Calcul de la matrice de transformation
/* check for object visibility */ .... /* get the transformation between the marker and the real camera */
arGetTransMat(&marker_info[k], patt_center, patt_width, patt_trans); draw();
argSwapBuffers(); }
Notre première application!!!
OSGArt >>>