Professional Documents
Culture Documents
CENTRO DE INVESTIGACION
August 2011
,
J.B. Hayet
1 / 57
Outline
Overview
Dissection of an example
Handling 3D models
Conclusions
,
J.B. Hayet
2 / 57
Overview
Outline
Overview
Dissection of an example
Handling 3D models
Conclusions
,
J.B. Hayet
3 / 57
Overview
ARToolKit
C and C++ library to
easily develop Augmented
Reality applications.
Uses computer vision to
detect the markers;
track the markers;
estimate the camera
position/orientation relative
to planar markers.
4 / 57
Overview
ARToolKit
Features:
,
J.B. Hayet
5 / 57
Overview
NyARToolKit
,
J.B. Hayet
6 / 57
Overview
NyARToolKit
,
J.B. Hayet
7 / 57
Overview
NyARToolKit: Licensing
GPL
Free to use for non-commercial applications under the GPL license.
Commercial Licence
License managed by ARToolWorks.
,
J.B. Hayet
8 / 57
Overview
Processing
,
J.B. Hayet
9 / 57
Overview
Processing
,
J.B. Hayet
10 / 57
Overview
Processing
,
J.B. Hayet
11 / 57
Overview
Processing
,
J.B. Hayet
12 / 57
Overview
Processing
,
J.B. Hayet
13 / 57
Overview
Processing
Video library:
display QuickTime video files,
grab video data from a camera (USB Cameras, IEEE 1394
(Firewire) Cameras, or Video Cards),
make QuickTime videos directly from a running program.
Class Capture for RA applications.
http://processing.org/reference/libraries/video/index.html
,
J.B. Hayet
14 / 57
Overview
Processing
,
J.B. Hayet
15 / 57
Overview
Installation:
Download the NyARToolkit library for Processing at
http://nyatla.jp/nyartoolkit/wiki/index.php?NyAR4psg.en
,
J.B. Hayet
16 / 57
Overview
,
J.B. Hayet
17 / 57
Overview
,
J.B. Hayet
18 / 57
Overview
Yc
yc
Zm
Xm
Ym
,
J.B. Hayet
19 / 57
Overview
,
J.B. Hayet
20 / 57
Overview
Xc
Xm
Yc
= Tcm Ym ,
Zc
Zm
1
1
they are the extrinsic parameters of the camera, that vary while
the camera moves.
,
J.B. Hayet
21 / 57
Overview
Xc
Yc
= tcm ,
Zc
1
1
i.e tcm are the coordinates in the camera frame of the center
of the marker.
,
J.B. Hayet
22 / 57
Overview
Xc
sx f 0 x0 0
xc
yc = 0 sy f y0 0 Yc ,
Zc
0
0 1 0
1
1
they are the intrinsic parameters of the camera, that are supposed to
stay stationary while the camera moves. To determine them, the
camera has to be calibrated, ARToolKit has tools to determine them.
,
J.B. Hayet
23 / 57
Overview
Intrinsic parameters:
(x0 , y0 ): coordinates of the projection onto the image of the
projection center;
f : focal distance (generally in mm);
(sx , sy ): scale parameters to give the focal distance in pixels;
: scale factor; not a parameter (can be expressed through the
last line).
,
J.B. Hayet
24 / 57
Overview
Hence, when
the intrinsic parameters are known,
the extrinsic parameters are known,
I can project on the image any virtual shape that I have defined
relatively to the marker. If it is done dynamically and fast enough, I
will have the impression that the virtual shape is sticked to the
marker. That is the principle of augmented reality.
,
J.B. Hayet
25 / 57
Overview
,
J.B. Hayet
26 / 57
Overview
,
J.B. Hayet
27 / 57
Overview
The steps:
detect markers (as black squares on a white background),
recognize the markers (i.e. see whats inside and if it looks like
one of the known markers),
compute the extrinsic parameters by putting in correspondence
points from the detected markers with points fron the known
marker and resolving the corresponding optimization problem.
,
J.B. Hayet
28 / 57
Overview
,
J.B. Hayet
29 / 57
Overview
1.
2.
3.
4.
5.
6.
,
J.B. Hayet
30 / 57
Overview
,
J.B. Hayet
31 / 57
Overview
Contour extraction.
Straight line fitting.
Sub-pixel line intersections (xi , yi ).
,
J.B. Hayet
32 / 57
Overview
Pattern recognition:
Image pattern normalization.
Template matching.
Deduce the nature and orientation of the true pattern,
and its corner coordinates (Xi , Yi ).
,
J.B. Hayet
33 / 57
Dissection of an example
Outline
Overview
Dissection of an example
Handling 3D models
Conclusions
,
J.B. Hayet
34 / 57
Dissection of an example
1.
2.
3.
4.
5.
6.
,
J.B. Hayet
35 / 57
Dissection of an example
,
J.B. Hayet
36 / 57
Dissection of an example
Needed libraries
,
J.B. Hayet
36 / 57
Dissection of an example
,
J.B. Hayet
36 / 57
Dissection of an example
,
J.B. Hayet
36 / 57
Dissection of an example
,
J.B. Hayet
36 / 57
Dissection of an example
Constructor.
,
J.B. Hayet
36 / 57
Dissection of an example
,
J.B. Hayet
36 / 57
Dissection of an example
Steps 2 to 5.
,
J.B. Hayet
36 / 57
Dissection of an example
Check camera.
,
J.B. Hayet
36 / 57
Dissection of an example
Step 2.
,
J.B. Hayet
36 / 57
Dissection of an example
Steps 3, 4.
,
J.B. Hayet
36 / 57
Dissection of an example
,
J.B. Hayet
36 / 57
Dissection of an example
Step 5.
,
J.B. Hayet
36 / 57
Dissection of an example
NyARToolKit: MultiMarker
The main class for managing multiple markers with the Processing
version is MultiMarker
It inherits from NyARPsgBaseClass.
Serves as a container for several markers.
Manages traditional ARToolkit markers OR id-Markers.
,
J.B. Hayet
37 / 57
Dissection of an example
NyARToolKit: MultiMarker
Traditional ARToolkit markers: image patterns.
Need training.
Template matching not super-fast.
A lot of possible appearances.
Id-markers: binary pattern on a regular grid
Dont need training.
Fast recognition.
Can cover up to 512 different appearances.
,
J.B. Hayet
38 / 57
Dissection of an example
NyARToolKit: MultiMarker
[From http://flash.tarotaro.org]
,
J.B. Hayet
39 / 57
Dissection of an example
NyARToolKit: MultiMarker
void setup ( ) {
s i z e ( 6 4 0 , 4 8 0 , P3D ) ;
c o l o r M o d e (RGB, 1 0 0 ) ;
p r i n t l n ( M u l t i M a r k e r . VERSION ) ;
cam=new C a p t u r e ( t h i s , 6 4 0 , 4 8 0 ) ;
nya=new M u l t i M a r k e r ( t h i s , width , h e i g h t , c a m e r a p a r a . d
nya . addARMarker ( p a t t . h i r o , 8 0 ) ; // i d =0
nya . addARMarker ( p a t t . k a n j i , 8 0 ) ; // i d =1
nya . addNyIdMarker ( 0 , 8 0 ) ; // i d =2
nya . addNyIdMarker ( 1 , 8 0 ) ; // i d =3
}
,
J.B. Hayet
40 / 57
Dissection of an example
NyARToolKit: MultiMarker
Methods
addARMarker(String fileName, float width): Add a marker.
detect(PImage image): Detect markers in the image.
isExistMarker(int id): Check if a given marker has been detected.
beginTransform(int id): 3D objects will be specified relatively to
the marker.
endTransform().
,
J.B. Hayet
41 / 57
Dissection of an example
NyARToolKit: MultiMarker
Get methods
getConfidence(int id): Get confidence on marker recognition.
getCurrentThreshold(): Get binarization threshold.
getLife(int id): Get number of consecutive marker detection.
getLostCount(int id): Consecutive lost detections before fail.
getMarkerVertex2D(int id): Get 2D vertices of the markers.
,
J.B. Hayet
42 / 57
Dissection of an example
NyARToolKit: MultiMarker
Set methods
setConfidenceThreshold(double val): Set threshold on
confidence.
setThreshold(int ith): Set binarization threshold.
setLostDelay(int val): Delay before considering fail.
,
J.B. Hayet
43 / 57
Dissection of an example
NyARToolKit: MultiMarker
getMarkerMatrix(int id): gives the aforementioned rigid
transform between the marker frame and the camera frame
Rcm tcm
Tcm =
,
0
1
getProjectionMatrix(): Get the intrinsics parameter matrix (with
clipping).
You get the full projection matrix by multiplying them
PMatrix3D t r a n s f = nya . g e t M a r k e r M a t r i x ( 0 ) ;
PMatrix3D p r o j
= nya . g e t P r o j e c t i o n M a t r i x ( ) ;
proj . apply ( t r a n s f ) ;
,
J.B. Hayet
44 / 57
Dissection of an example
NyARToolKit: MultiMarker
Example: triggers events when the distance between the two markers
frame centers is inferior to some quantity.
,
J.B. Hayet
45 / 57
Dissection of an example
NyARToolKit: MultiMarker
To perform the projection of a point by hand:
float
i n [ ] = new f l o a t [ 4 ] ;
in [0] = x ;
in [1] = y ;
in [2] = z ;
in [3] = 1.0;
f l o a t o u t [ ] = new f l o a t [ 4 ] ;
p r o j . mult ( i n , o u t ) ;
f l o a t x = w i d t h /2 + w i d t h ( o u t [ 0 ] / o u t [ 3 ] ) / 2 ;
f l o a t y = h e i g h t /2+ h e i g h t ( o u t [ 1 ] / o u t [ 3 ] ) / 2 ;
pp [ k ] = new PV e c t o r ( x , y ) ;
e l l i p s e (x , y ,10 ,10);
,
J.B. Hayet
46 / 57
Dissection of an example
NyARToolKit: MultiMarker
pickupMarkerImage
pickupRectMarkerImage
define a quadrilateral in the marker frame and map it in given size
image.
,
J.B. Hayet
47 / 57
Dissection of an example
NyARToolKit: MultiMarker
,
J.B. Hayet
48 / 57
Handling 3D models
Outline
Overview
Dissection of an example
Handling 3D models
Conclusions
,
J.B. Hayet
49 / 57
Handling 3D models
,
J.B. Hayet
50 / 57
Handling 3D models
Built-in functions:
box()
sphere()
vertex()
Sufficient for many cool applications.
,
J.B. Hayet
51 / 57
Handling 3D models
,
J.B. Hayet
52 / 57
Handling 3D models
,
J.B. Hayet
53 / 57
Handling 3D models
objimp: library to import .obj files, and render them (in OpenGL
mode)
http://www.pixelnerve.com/processing/libraries/objimport/
,
J.B. Hayet
54 / 57
Conclusions
Outline
Overview
Dissection of an example
Handling 3D models
Conclusions
,
J.B. Hayet
55 / 57
Conclusions
NyARToolKit + Processing
,
J.B. Hayet
56 / 57
Conclusions
Contact
Slides + material at
http://www.cimat.mx/jbhayet/era2011.zip
,
J.B. Hayet
57 / 57