ARToolkit
Augmented Reality Augmented Reality
Toolkit Toolkit
N N G G
U U K K Y Y E E E E T T N N T T Y Y
P P O O
N N J J R R O O O O N N Y Y A A
T T
H H
A A
N N
Ce que nous allons présenter…
Ce que nous allons présenter…
• Introduction Introduction
• Architecture Architecture
• Installation Installation
• Principes de développement Principes de développement
• Tout ce qu’on peut faire avec… Tout ce qu’on peut faire avec…
• Limitations Limitations
• Outils autour de ARToolkit Outils autour de ARToolkit
• Demo Demo
NGUYEN Ketty & PONROY Jonathan
= 2 =
En quelques mots…
En quelques mots…
• Librairie C/C++ avec des outils vidéo Librairie C/C++ avec des outils vidéo – Fonctions prédéfinies
– Utilisation des différents outils
• Réalité augmentée en temps réel Réalité augmentée en temps réel
Introduction d’objets 3D dans le monde réel par marqueurs
NGUYEN Ketty & PONROY Jonathan
= 3 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
Architecture Architecture
• OpenGL pour le rendu OpenGL pour le rendu
• GLUT pour les évènements et GLUT pour les évènements et
dépendance hardware de la librairie dépendance hardware de la librairie
video video
• API standard sur chaque platform (e.g API standard sur chaque platform (e.g win32 pour Windows)
win32 pour Windows)
NGUYEN Ketty & PONROY Jonathan
= 4 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
Structure Structure
• L’utilisateur peut facilement L’utilisateur peut facilement
remplacer un module par un autre remplacer un module par un autre
• Flux de données
Qu’est-ce Architecture Installation Développement Possibilités Limitations Outils Demo
NGUYEN Ketty & PONROY Jonathan
= 5 =
Installation Installation
• Le site http://www.hitl.washington.edu/artoolkit/ Le site (section documentation
(section documentation setup ARToolkit) setup ARToolkit) donne la liste des éléments à télécharger donne la liste des éléments à télécharger
ARToolkit Glut
Librairies pour la webcam
• ReadMe disponible pour chaque ReadMe disponible pour chaque
application expliquant toute la procédure à application expliquant toute la procédure à suivre
suivre
• Multi-plateforme : Windows, Linux et Mac Multi-plateforme : Windows, Linux et Mac
NGUYEN Ketty & PONROY Jonathan
= 6 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
Le fonctionnement global Le fonctionnement global
Principes de développement Principes de développement
NGUYEN Ketty & PONROY Jonathan
= 7 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
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();
...
Chargement d'une image Chargement d'une image
NGUYEN Ketty & PONROY Jonathan
= 8 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
Détection du marqueur 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();
...
NGUYEN Ketty & PONROY Jonathan
= 9 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
....
if( arDetectMarker(dataPtr, thresh, &marker_info, &marker_num) < 0 ) { cleanup();
exit(0);
}
arVideoCapNext();
/* check for object visibility */
k = -1;
for( j = 0; j < marker_num; j++ ) {
if( patt_id == marker_info[j].id ) { if( k == -1 ) k = j;
else if( marker_info[k].cf < marker_info[j].cf ) k = j;
} }
if( k == -1 ) { ....
Reconnaissance du symbole Reconnaissance du symbole
NGUYEN Ketty & PONROY Jonathan
= 10 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
....
/* 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();
}
Calcul de la matrice de transformation Calcul de la matrice de transformation
NGUYEN Ketty & PONROY Jonathan
= 11 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
static void draw( void ) {
....
/* load the camera transformation matrix */
argConvGlpara(patt_trans, gl_para);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd( gl_para );
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMatrixMode(GL_MODELVIEW);
//glTranslatef( 0.0, 0.0, 25.0 );
glTranslatef( 0, 0, 25.0 );
glutSolidCube(50.0);
glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST );
Ajout des objets 3D Ajout des objets 3D
NGUYEN Ketty & PONROY Jonathan
= 12 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
Tout ce qu'on peut faire avec ...
Tout ce qu'on peut faire avec ...
Ex:
#pattern1 cone
Data/patt.hiro 80.0
0.0 0.0
• Un fichier contient l’ensemble des Un fichier contient l’ensemble des patterns à reconnaître pendant la patterns à reconnaître pendant la
session session
Description du pattern comme suit Description du pattern comme suit
– Nom
– Fichier du pattern
– Largeur du marqueur
– Centre du marqueur
Utiliser plusieurs patterns Utiliser plusieurs patterns
simultanément simultanément
NGUYEN Ketty & PONROY Jonathan
= 13 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
Créer ses propres patterns avec Créer ses propres patterns avec
bin/mk_patt bin/mk_patt
NGUYEN Ketty & PONROY Jonathan
= 14 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
Utilisation du pattern au niveau du Utilisation du pattern au niveau du
code 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 );
}
NGUYEN Ketty & PONROY Jonathan
= 15 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
Calibrer la caméra Calibrer la caméra
Deux types de calibration (one Deux types de calibration (one
step, two step) step, two step)
• Two step Two step
– Imprimer calib_cpara.pdf et calib_dist.pdf
– Lancer calib_dist avant calib_cpara
NGUYEN Ketty & PONROY Jonathan
= 16 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
calib_dist calib_dist
NGUYEN Ketty & PONROY Jonathan
= 17 =
Qu’est-ce Architecture Installation Développement Possibilités Limitations Outils Demo
• Prendre une autre image et
répéter le processus 5 à 10 fois avec des angles de vues
différents pour avoir une calibration plus précise
• Ce programme donne le facteur
de distorsion et les coordonnées
du centre de l'image
calib_cparam calib_cparam
– Pour trouver la focale et autres paramètres
– Entrer les données fournies par calib_dist
– Reculer l’image de la caméra – Répéter le processus 5 fois
NGUYEN Ketty & PONROY Jonathan
= 18 =
Qu’est-ce Architecture Installation Développement Possibilités
Limitations Outils Demo
Par défaut
Espacement entre les points : 40mm
Distance d’éloignement à la caméra : 100mm Nombre de fois à répéter la procédure : 5
inter_coord[k][j][i+7][0] = 40.0*i;
inter_coord[k][j][i+7][1] = 40.0*j;
inter_coord[k][j][i+7][2] = 100.0*k;
*loop_num = 5;