Introduction Vision synthese vision → synthese Realite Augmentee
Matrices de projectionpour la realite augmentee
Vincent Nozick
Vincent Nozick Matrices de projection 1 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Vision par ordinateur
Vision vs. synthese :
vision par ordinateur
scene
−→
descriptionreelle
←−
numerique
synthese d’images
Vincent Nozick Matrices de projection 2 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Vision par ordinateur
Vision vs. synthese :
vision par ordinateur
scene −→ descriptionreelle
←−
numerique
synthese d’images
Vincent Nozick Matrices de projection 2 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Vision par ordinateur
Vision vs. synthese :
vision par ordinateur
scene −→ descriptionreelle ←− numerique
synthese d’images
Vincent Nozick Matrices de projection 2 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Vision vs. synthese
Camera :
Vincent Nozick Matrices de projection 3 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Vision vs. synthese
Pixels :
capteurs viewport
Vincent Nozick Matrices de projection 4 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Vision vs. synthese
Optiques :
optiques matrice de projection
Vincent Nozick Matrices de projection 5 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Vision vs. synthese
Position :
position matriceorientation de modelview
Vincent Nozick Matrices de projection 6 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Vision vs. synthese
Image :
acquisition rendu
Vincent Nozick Matrices de projection 7 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Matrice de projection vision par ordinateur
Matrice de projection : P3×4 = K3×3 [R3×3|t]
P =
f 0 x00 f y00 0 1
︸ ︷︷ ︸
K
r r r txr r r tyr r r tz
︸ ︷︷ ︸
[R|t]
avec :
• K : parametres intrinseques de la camera (l’optique)
• R : matrice de rotation 3× 3 → orientation de la camera
• t = −RC : translation pour une camera placee en un point C
Vincent Nozick Matrices de projection 8 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Matrice de projection vision par ordinateur
Matrice de projection : P3×4 = K3×3 [R3×3|t]
K =
fx s cx0 fy cy0 0 1
avec :
• fx et fy : focale (en unite de pixel)
• s : oblique (skew en anglais), souvent 0
• c = (cx, cy, 1)> : point principal, souvent centre de l’image
Vincent Nozick Matrices de projection 9 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Matrice de projection vision par ordinateur
Matrice de projection : P3×4 = K3×3 [R3×3|t]
P =
fx s cx0 fy cy0 0 1
r r r txr r r tyr r r tz
remarque : Pour x = (x, y, 1)> = PX (X visible), on a :
• x ∈ [0, w[
• y ∈ [0, h[
• w = 1
Vincent Nozick Matrices de projection 10 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Matrice de projection OpenGL
Projection et Modelview :
PGL =
2nr−l 0 r+l
r−l 0
0 2nt−b
t+bt−b 0
0 0 −f+nf−n − 2fn
f−n0 0 −1 0
︸ ︷︷ ︸
GLfrustum
r r r tx
r r r ty
r r r tz
0 0 0 1
︸ ︷︷ ︸position / orientation
Remarques :Pour x = (x, y, z, 1)> = PGLX (X visible), on a :
• x ∈ [−1, 1]• y ∈ [−1, 1]• z ∈ [−1, 1] (z ∈ [0, 1] pour DirectX)
Vincent Nozick Matrices de projection 11 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Conversion
Introduction :on cherche la matrice openGL permettant d’exprimer les memesproprietes qu’une camera reelle calibree.
Application : realite augmentee (AR)
Vincent Nozick Matrices de projection 12 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Conversion
Pvision =
fx s cx0 fy cy0 0 1
r r r txr r r tyr r r tz
↓
PGL =
2nr−l 0 r+l
r−l 0
0 2nt−b
t+bt−b 0
0 0 −f+nf−n − 2fn
f−n0 0 −1 0
r r r tx
r r r ty
r r r tz
0 0 0 1
Vincent Nozick Matrices de projection 13 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Conversion
Etape 1 : ajout d’une dimension
P =
fx s cx0 fy cy0 0 1
r r r txr r r tyr r r tz
equivalent a :
P =
fx s cx 00 fy cy 0• • • •0 0 1 0
r r r txr r r tyr r r tz0 0 0 1
Vincent Nozick Matrices de projection 14 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Conversion
Etape 2 : on norme les donnees
P =
fx s cx 00 fy cy 0• • • •0 0 1 0
r r r txr r r tyr r r tz0 0 0 1
→ x ∈ [0, w[ et y ∈ [0, h[
P =
2/w 0 0 −10 2/h 0 −10 0 1 00 0 0 1
fx s cx 00 fy cy 0• • • •0 0 1 0
r r r txr r r tyr r r tz0 0 0 1
→ x ∈ [−1, 1] et y ∈ [−1, 1]
Vincent Nozick Matrices de projection 15 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Conversion
Etape 2 : on norme les donnees
P =
2/w 0 0 −10 2/h 0 −10 0 1 00 0 0 1
fx s cx 00 fy cy 0• • • •0 0 1 0
︸ ︷︷ ︸
on groupe
r r r txr r r tyr r r tz0 0 0 1
soit :
P =
2fxw
2sw
2cxw − 1 0
02fyh
2cyh − 1 0
• • • •0 0 1 0
r r r tx
r r r ty
r r r tz
0 0 0 1
Vincent Nozick Matrices de projection 16 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Conversion
Etape 3 : on regarde vers les −z
P =
2fxw
2sw
2cxw − 1 0
02fyh
2cyh − 1 0
• • • •0 0 1 0
r r r tx
r r r ty
r r r tz
0 0 0 1
devient :
P =
2fxw
2sw
w−2cxw 0
02fyh
h−2cyh 0
• • • •0 0 −1 0
r r r tx
r r r ty
−r −r −r −tz0 0 0 1
Vincent Nozick Matrices de projection 17 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Conversion
Etape 4 : near et far
K =
2fxw
2sw
w−2cxw 0
02fyh
h−2cyh 0
• • • •0 0 −1 0
r r r tx
r r r ty
−r −r −r −tz0 0 0 1
devient
P =
2fxw
2sw
w−2cxw 0
02fyh
h−2cyh 0
0 0 −f+nf−n − 2fn
f−n0 0 −1 0
r r r tx
r r r ty
−r −r −r −tz0 0 0 1
Vincent Nozick Matrices de projection 18 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Conversion
Axe des z :
P =
2fxw
2sw
w−2cxw 0
02fyh
h−2cyh 0
0 0 −f+nf−n − 2fn
f−n0 0 −1 0
r r r tx
r r r ty
r r r tz
0 0 0 1
P =
2fxw
2sw
2cx−ww 0
02fyh
2cy−hh 0
0 0 f+nf−n − 2fn
f−n0 0 1 0
r r r tx
r r r ty
−r −r −r −tz0 0 0 1
Vincent Nozick Matrices de projection 19 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Conversion
comparaison avec GLfrustum :
P =
2fxw
2sw
2cx−ww 0
02fyh
2cy−hh 0
0 0 f+nf−n − 2fn
f−n0 0 1 0
r r r tx
r r r ty
−r −r −r −tz0 0 0 1
PGL =
2nr−l 0 r+l
r−l 0
0 2nt−b
t+bt−b 0
0 0 −f+nf−n − 2fn
f−n0 0 −1 0
r r r tx
r r r ty
r r r tz
0 0 0 1
Vincent Nozick Matrices de projection 20 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Realite Augmentee
En pratique :
Vincent Nozick Matrices de projection 21 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Methode
Repeter :
1 capture d’une image I
2 calibre la camera → P
3 OpenGL : dessine l’image I
4 OpenGL : initialise le zBuffer a “far”
5 converti P en PGL
6 OpenGL : charge PGL
7 OpenGL : dessine les objets GL
8 OpenGL : swap les buffers
Vincent Nozick Matrices de projection 22 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Methode
Repeter :
1 capture d’une image I
2 calibre la camera → P
3 OpenGL : dessine l’image I
4 OpenGL : initialise le zBuffer a “far”
5 converti P en PGL
6 OpenGL : charge PGL
7 OpenGL : dessine les objets GL
8 OpenGL : swap les buffers
Vincent Nozick Matrices de projection 22 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Methode
Repeter :
1 capture d’une image I
2 calibre la camera → P
3 OpenGL : dessine l’image I
4 OpenGL : initialise le zBuffer a “far”
5 converti P en PGL
6 OpenGL : charge PGL
7 OpenGL : dessine les objets GL
8 OpenGL : swap les buffers
Vincent Nozick Matrices de projection 22 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Methode
Repeter :
1 capture d’une image I
2 calibre la camera → P
3 OpenGL : dessine l’image I
4 OpenGL : initialise le zBuffer a “far”
5 converti P en PGL
6 OpenGL : charge PGL
7 OpenGL : dessine les objets GL
8 OpenGL : swap les buffers
Vincent Nozick Matrices de projection 22 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Methode
Repeter :
1 capture d’une image I
2 calibre la camera → P
3 OpenGL : dessine l’image I
4 OpenGL : initialise le zBuffer a “far”
5 converti P en PGL
6 OpenGL : charge PGL
7 OpenGL : dessine les objets GL
8 OpenGL : swap les buffers
Vincent Nozick Matrices de projection 22 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Methode
Repeter :
1 capture d’une image I
2 calibre la camera → P
3 OpenGL : dessine l’image I
4 OpenGL : initialise le zBuffer a “far”
5 converti P en PGL
6 OpenGL : charge PGL
7 OpenGL : dessine les objets GL
8 OpenGL : swap les buffers
Vincent Nozick Matrices de projection 22 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Methode
Repeter :
1 capture d’une image I
2 calibre la camera → P
3 OpenGL : dessine l’image I
4 OpenGL : initialise le zBuffer a “far”
5 converti P en PGL
6 OpenGL : charge PGL
7 OpenGL : dessine les objets GL
8 OpenGL : swap les buffers
Vincent Nozick Matrices de projection 22 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Methode
Repeter :
1 capture d’une image I
2 calibre la camera → P
3 OpenGL : dessine l’image I
4 OpenGL : initialise le zBuffer a “far”
5 converti P en PGL
6 OpenGL : charge PGL
7 OpenGL : dessine les objets GL
8 OpenGL : swap les buffers
Vincent Nozick Matrices de projection 22 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Methode
Repeter :
1 capture d’une image I
2 calibre la camera → P
3 OpenGL : dessine l’image I
4 OpenGL : initialise le zBuffer a “far”
5 converti P en PGL
6 OpenGL : charge PGL
7 OpenGL : dessine les objets GL
8 OpenGL : swap les buffers
Vincent Nozick Matrices de projection 22 / 23
Introduction Vision synthese vision → synthese Realite Augmentee
Realite Augmentee
Vincent Nozick Matrices de projection 23 / 23