ryan, daniel james

Upload: felipe-martins

Post on 14-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 Ryan, Daniel James

    1/81

    F i n g e r a n d g e s t u r e r e c o g n i t i o n w i t h

    M i c r o s o f t K i n e c t

    D a n i e l J a m e s R y a n

    D e p a r t m e n t o f E l e c t r i c a l a n d C o m p u t e r E n g i n e e r i n g

    U n i v e r s i t y o f S t a v a n g e r

    http://www.uis.no/http://ide.ux.uis.no/mailto:[email protected]
  • 7/30/2019 Ryan, Daniel James

    2/81

    i i

  • 7/30/2019 Ryan, Daniel James

    3/81

    A b s t r a c t

    T h e K i n e c t i s a c h e a p a n d w i l d l y s p r e a d s e n s o r a r r a y w i t h s o m e i n t e r e s t i n g

    f e a t u r e s , s u c h a s a d e p t h s e n s o r a n d f u l l b o d y s k e l e t o n t r a c k i n g .

    T h e K i n e c t S D K d o e s n o t s u p p o r t n g e r t r a c k i n g ; W e h a v e t h e r e f o r e c r e a t e d

    a l g o r i t h m s t o n d n g e r p o s i t i o n s f r o m d e p t h s e n s o r d a t a . W i t h t h e d e t e c t e d

    n g e r p o s i t i o n w e u s e d y n a m i c t i m e w a r p i n g t o r e c o r d a n d r e c o g n i z e n g e r

    g e s t u r e s .

    W e h a v e c r e a t e d a n A P I t h a t c a n r e c o r d a n d r e c o g n i z e n g e r g e s t u r e s . T h e

    A P I w a s c r e a t e d w i t h f o c u s o n e a s e o f u s e a n d t h e p o s s i b i l i t y t o c u s t o m i z e

    a n d c h a n g e c o r e a l g o r i t h m s . E v e n t h e K i n e c t c a n b e c h a n g e d f o r o t h e r

    s i m i l a r d e v i c e s . T h i s o p e n s u p a n e w e l d o f a p p l i c a t i o n s u t i l i z i n g t h e K i n e c t

    a n d n g e r g e s t u r e s .

  • 7/30/2019 Ryan, Daniel James

    4/81

    i v

  • 7/30/2019 Ryan, Daniel James

    5/81

    A c k n o w l e d g e m e n t s

    I w o u l d l i k e t o t h a n k p r o f e s s o r R e g g i e D a v i d r a j u h f o r p r o v i d i n g v a l u a b l e

    f e e d b a c k o n w r i t i n g t h i s t h e s i s .

    I w o u l d a l s o l i k e t o t h a n k G l e n n F . H e n r i k s e n a t E V R Y f o r p r o v i d i n g c o n -

    s t r u c t i v e f e e d b a c k o n c o d i n g t h e A P I a n d f o r p r o g r a m m i n g a d v i c e i n g e n e r a l .

  • 7/30/2019 Ryan, Daniel James

    6/81

    i i

  • 7/30/2019 Ryan, Daniel James

    7/81

    C o n t e n t s

    L i s t o f F i g u r e s v i i

    G l o s s a r y i x

    1 I n t r o d u c t i o n 1

    1 . 1 I n s p i r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1 . 2 E x i s t i n g s o l u t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    1 . 3 V i s i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    2 T h e K i n e c t s e n s o r 3

    2 . 1 K i n e c t v e r s i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    2 . 1 . 1 C o m m e r c i a l a n d d e v e l o p m e n t u s a g e . . . . . . . . . . . . . . . . 3

    2 . 2 S p e c s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    2 . 3 K i n e c t f o r W i n d o w s S D K . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    2 . 3 . 1 D a t a s t r e a m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    2 . 4 P o s s i b i l i t i e s w i t h t h e K i n e c t . . . . . . . . . . . . . . . . . . . . . . . . . 4

    3 C o n t o u r t r a c k i n g 7

    3 . 1 E x i s t i n g a l g o r i t h m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    3 . 2 F i n d i n g t h e i n i t i a l p i x e l . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    3 . 3 T r a c k i n g t h e c o n t o u r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    3 . 3 . 1 S e a r c h d i r e c t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    3 . 3 . 2 S i n g l e p i x e l l i n e s . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0

    3 . 3 . 3 B a c k t r a c k i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1

    3 . 3 . 4 T r a c k t w o h a n d s . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2

    3 . 4 T e r m i n a t i o n s t a t e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2

    i i i

  • 7/30/2019 Ryan, Daniel James

    8/81

    C O N T E N T S

    3 . 4 . 1 T e r m i n a t i o n s t a t e 1 : A p i x e l w a s d i s c o v e r e d t w i c e . . . . . . . . . 1 3

    3 . 4 . 2 T e r m i n a t i o n s t a t e 2 : A x e d n u m b e r o f p i x e l s w e r e d i s c o v e r e d . . 1 3

    4 F i n g e r r e c o g n i t i o n 1 5

    4 . 1 R e l a t e d w o r k s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 6

    4 . 2 C u r v e d e t e c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 6

    4 . 3 F i n g e r d e t e c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7

    5 G e s t u r e R e c o g n i t i o n 1 9

    5 . 1 R e l a t e d w o r k s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9

    5 . 2 N o t e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9

    5 . 3 R e c o r d i n g a g e s t u r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0

    5 . 4 R e c o g n i z i n g a g e s t u r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0

    5 . 4 . 1 S t e p 1 : F i n d i n g a c a n d i d a t e g e s t u r e . . . . . . . . . . . . . . . . 2 0

    5 . 4 . 2 S t e p 2 : E u c l i d e a n d i s t a n c e m a t r i x . . . . . . . . . . . . . . . . . 2 1

    5 . 4 . 3 S t e p 3 : A c c u m u l a t e d d i s t a n c e m a t r i x . . . . . . . . . . . . . . . . 2 1

    5 . 4 . 4 S t e p 4 : L o w e s t d i s t a n c e p a t h . . . . . . . . . . . . . . . . . . . . 2 2

    5 . 4 . 5 O p t i m i z a t i o n s a n d i m p r o v e m e n t s . . . . . . . . . . . . . . . . . . 2 2

    5 . 4 . 5 . 1 E u c l i d e a n d i s t a n c e . . . . . . . . . . . . . . . . . . . . . 2 3

    5 . 4 . 5 . 2 A c c u m u l a t e d c o s t m a t r i x . . . . . . . . . . . . . . . . . 2 3

    5 . 4 . 5 . 3 L o w e s t d i s t a n c e p a t h . . . . . . . . . . . . . . . . . . . 2 4

    5 . 5 S t o r e g e s t u r e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 4

    5 . 6 R e t r i e v e s t o r e d g e s t u r e s . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 5

    6 A u t o d e p t h i n t e r v a l d e t e c t i o n 2 7

    7 E n h a n c e m e n t s 3 1

    7 . 1 S m o o t h i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1

    7 . 2 P r e d i c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1

    7 . 2 . 1 E x p o n e n t i a l m o v i n g a v e r a g e . . . . . . . . . . . . . . . . . . . . . 3 2

    8 V i r t u a l r e a l i t y 3 3

    8 . 1 R e l a t e d w o r k s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3

    8 . 2 I n t r o d u c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3

    8 . 2 . 1 O n - a x i s p e r s p e c t i v e . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3

    i v

  • 7/30/2019 Ryan, Daniel James

    9/81

    C O N T E N T S

    8 . 2 . 2 O - a x i s p e r s p e c t i v e . . . . . . . . . . . . . . . . . . . . . . . . . 3 4

    8 . 3 V i e w f r u s t u m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 4

    8 . 4 I m p l e m e n t a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 6

    8 . 5 L i m i t a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 6

    9 R e s u l t s 3 7

    9 . 1 P r o g r a m o w . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 7

    9 . 2 E v e n t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 7

    9 . 2 . 1 D e p t h D i s t a n c e U p d a t e d . . . . . . . . . . . . . . . . . . . . . . . 3 7

    9 . 2 . 2 C o n t o u r D a t a R e a d y . . . . . . . . . . . . . . . . . . . . . . . . . . 3 8

    9 . 2 . 3 F i n g e r t i p L o c a t i o n s R e a d y . . . . . . . . . . . . . . . . . . . . . . 3 9

    9 . 2 . 4 G e s t u r e R e c o g n i z e d . . . . . . . . . . . . . . . . . . . . . . . . . . 3 9

    9 . 2 . 5 G e s t u r e R e c o r d e d . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 9

    9 . 2 . 6 P e r f o r m a n c e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 0

    9 . 3 M o d u l a r i t y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 0

    9 . 3 . 1 I n t e r f a c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1

    9 . 3 . 2 M o d u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1

    9 . 3 . 2 . 1 K i n e c t . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2

    9 . 3 . 2 . 2 C o n t o u r T r a c k i n g . . . . . . . . . . . . . . . . . . . . . . 4 3

    9 . 3 . 2 . 3 C u r v e D e t e c t i o n . . . . . . . . . . . . . . . . . . . . . . . 4 4

    9 . 3 . 2 . 4 F i n g e r R e c o g n i t i o n . . . . . . . . . . . . . . . . . . . . . 4 5

    9 . 3 . 2 . 5 G e s t u r e R e c o g n i t i o n . . . . . . . . . . . . . . . . . . . . 4 6

    9 . 3 . 3 T y i n g m o d u l e s t o g e t h e r . . . . . . . . . . . . . . . . . . . . . . . 4 7

    9 . 4 V i r t u a l r e a l i t y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 7

    9 . 5 C o d e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 8

    1 0 D i s c u s s i o n 4 9

    1 0 . 1 C o n t o u r t r a c k i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 9

    1 0 . 1 . 1 F i n d i n g t h e i n i t i a l p i x e l . . . . . . . . . . . . . . . . . . . . . . . 4 9

    1 0 . 2 C u r v e d e t e c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 0

    1 0 . 2 . 1 T h e k - c u r v a t u r e a l g o r i t h m . . . . . . . . . . . . . . . . . . . . . . 5 0

    1 0 . 3 D e t e c t i n g F i n g e r t i p s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 0

    1 0 . 3 . 1 F a l s e n g e r t i p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 0

    1 0 . 4 T h e K i n e c t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 0

    v

  • 7/30/2019 Ryan, Daniel James

    10/81

    C O N T E N T S

    1 0 . 5 C o m m e r c i a l i z a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1

    1 1 C o n c l u s i o n 5 3

    R e f e r e n c e s 5 5

    A p p e n d i x A C r e a t e l i n e s e g m e n t 5 7

    A p p e n d i x B 5 9

    B . 1 C o n t o u r D a t a R e a d y e v e n t w i t h a u t o i n t e r v a l s c a n . . . . . . . . . . . . . . 6 0

    B . 2 P r o g r a m o w . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1

    B . 3 M a i n c l a s s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3

    v i

  • 7/30/2019 Ryan, Daniel James

    11/81

    L i s t o f F i g u r e s

    3 . 1 L o c a l s e a r c h g r i d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    3 . 2 S i n g l e p i x e l l i n e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1

    3 . 3 M i n i m u m h a n d c o n t o u r p i x e l s ( t h e r e d c o l o r e d p i x e l s ) . . . . . . . . . . . 1 4

    4 . 1 T h e r a w a n d p r o c e s s e d i m a g e s . . . . . . . . . . . . . . . . . . . . . . . . 1 5

    4 . 2 F i n d i n g t h e n g e r t i p s a n d t h e i r p o i n t i n g d i r e c t i o n . . . . . . . . . . . . . 1 8

    5 . 1 H a n d f r a m e m a t r i x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2

    5 . 2 W a r p i n g C o n s t r a i n t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 4

    6 . 1 E x a m p l e o f a s c a n s e q u e n c e . . . . . . . . . . . . . . . . . . . . . . . . . . 2 8

    6 . 2 D e p t h f r a m e s f r o m a n a u t o i n t e r v a l s c a n . . . . . . . . . . . . . . . . . . . 2 9

    8 . 1 P e r s p e c t i v e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5

    8 . 2 F r u s t u m e x t e n t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 6

    8 . 3 V R s p a c e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 6

    9 . 1 I K i n e c t a n d t h e i m p l e m e n t a t i o n . . . . . . . . . . . . . . . . . . . . . . . 4 2

    9 . 2 I C o n t o u r T r a c k i n g a n d t h e i m p l e m e n t a t i o n . . . . . . . . . . . . . . . . . . 4 3

    9 . 3 I C u r v e D e t e c t i o n a n d t h e i m p l e m e n t a t i o n . . . . . . . . . . . . . . . . . . 4 4

    9 . 4 I F i n g e r R e c o g n i t i o n a n d t h e i m p l e m e n t a t i o n . . . . . . . . . . . . . . . . . 4 5

    9 . 5 I G e s t u r e R e c o g n i t i o n a n d t h e i m p l e m e n t a t i o n . . . . . . . . . . . . . . . . 4 6

    v i i

  • 7/30/2019 Ryan, Daniel James

    12/81

    L I S T O F F I G U R E S

    v i i i

  • 7/30/2019 Ryan, Daniel James

    13/81

    G l o s s a r y

    K i n e c t K i n e c t i s a s e n s o r d e v i c e f r o m M i -

    c r o s o f t f o r X b o x 3 6 0 a n d W i n d o w s .

    I t h a s a m i c r o p h o n e a r r a y , R G B c a m -

    e r a a n d a d e p t h s e n s o r .

    X N A X N A i s a p r o d u c t f r o m M i c r o s o f t

    t h a t f a c i l i t a t e s v i d e o g a m e d e v e l o p -

    m e n t f o r W i n d o w s , X b o x 3 6 0 a n d

    W i n d o w s P h o n e .

    N U I N a t u r a l U s e r I n t e r f a c e .

    A P I A p p l i c a t i o n P r o g r a m m i n g I n t e r f a c e .

    S D K S o f t w a r e D e v e l o p m e n t K i t .

    R G B A n a d d i t i v e c o l o r m o d e l ; R e d , G r e e n ,

    B l u e .

    Y U V A c o l o r m o d e l u s e d t o e n c o d e v i d e o

    i m a g e s .

    D T W D y n a m i c t i m e w a r p i n g . R e c o g n i t i o n

    a l g o r i t h m b e t w e e n t w o t i m e s e r i e s .

    V i e w f r u s t u m T h e r e g i o n o f s p a c e a c a m e r a

    s e e s i n a 3 D e n v i r o n m e n t .

    V R V i r t u a l R e a l i t y .

    i x

  • 7/30/2019 Ryan, Daniel James

    14/81

    L I S T O F F I G U R E S

    x

  • 7/30/2019 Ryan, Daniel James

    15/81

    1

    I n t r o d u c t i o n

    W i t h t h e l a u n c h o f K i n e c t f o r X b o x 3 6 0 i n N o v e m b e r 2 0 1 0 a n d f o r W i n d o w s i n F e b r u a r y

    2 0 1 2 , o r d i n a r y c o n s u m e r s h a v e t h e a b i l i t y t o c h e a p l y b u y a s e n s o r a r r a y a n d , w i t h s o m e

    p r o g r a m m i n g k n o w l e d g e , e a s i l y p l a y w i t h t h e r e c e i v e d d a t a .

    T h e K i n e c t f o r W i n d o w s S D K p r o v i d e s , a m o n g s t o t h e r t h i n g s , o u t o f t h e b o x s k e l e -

    t o n t r a c k i n g . H o w e v e r i t d o e s n o t p r o v i d e n g e r t r a c k i n g o r g e s t u r e r e c o g n i t i o n . W e

    h a v e t h e r e f o r e c r e a t e d a n A P I t h a t e n a b l e u s e r s t o n d n g e r t i p l o c a t i o n s a n d p o i n t i n g

    d i r e c t i o n a n d t o r e c o r d a n d r e c o g n i z e n g e r g e s t u r e s . I n a d d i t i o n i t a l s o g i v e s t h e a b i l i t y

    t o c r e a t e v i r t u a l r e a l i t y u s i n g h e a d t r a c k i n g a n d t h e X N A f r a m e w o r k . W e w i l l t a l k m o r e

    a b o u t t h e K i n e c t i n c h a p t e r 2 .

    1 . 1 I n s p i r a t i o n

    T h e i n s p i r a t i o n t o d o n g e r t r a c k i n g a n d g e s t u r e r e c o g n i t i o n w a s f o u n d i n t h e s c i e n c e

    c t i o n m o v i e " M i n o r i t y R e p o r t " ( 1 ) w h e r e t h e m a i n c h a r a c t e r u s e s h i s h a n d s a n d n g e r s

    t o n a v i g a t e a n d m a n i p u l a t e v i d e o a n d p i c t u r e s o n a l a r g e h o r i z o n t a l s c r e e n . H o w e v e r

    h i s h a n d s a n d n g e r s w e r e n o t t o u c h i n g a n y t h i n g b u t t h e a i r . T h i s g i v e s u s s o m e i n s i g h t

    o n h o w N U I c a n b e u s e d t o i n t e r a c t w i t h a c o m p u t e r . I n a d d i t i o n t h e r e d i d n o t e x i s t

    a n y s a t i s f y i n g s o l u t i o n t h a t w o u l d e n a b l e s o m e o n e , w i t h r e l a t i v e e a s e , t o c r e a t e a N U I

    a s s e e n i n t h e m o v i e o r a n y N U I b a s e d o n n g e r t r a c k i n g w i t h K i n e c t . T h i s g a v e u s t h e

    o p p o r t u n i t y t o b e t h e r s t t o c r e a t e a t o o l t o f a c i l i t a t e e a s y a n d q u i c k N U I d e v e l o p m e n t ,

    s p e c i c a l l y w i t h t h e u s e o f n g e r s , w i t h K i n e c t .

    1

  • 7/30/2019 Ryan, Daniel James

    16/81

    1 . I N T R O D U C T I O N

    I n s p i r a t i o n t o c r e a t e v i r t u a l r e a l i t y c a m e f r o m a v i d e o ( 2 ) w e r e a N i t e n d o W i i r e m o t e

    w a s u s e d t o a c h i e v e V R o n a n o l d t e l e v i s i o n b y u t i l i z i n g t h e u s e r s h e a d m o v e m e n t .

    1 . 2 E x i s t i n g s o l u t i o n s

    T h e r e e x i s t s s o m e o p e n s o u r c e l i b r a r i e s t h a t t r y t o d o n g e r t r a c k i n g a n d g e s t u r e r e c o g -

    n i t i o n , b u t m o s t o f t h e s e w e r e e i t h e r n o t w o r k i n g c o r r e c t l y , p e r f o r m e d p o o r l y d u e t o p o o r

    p r o g r a m m i n g o r w e r e n o t d o c u m e n t e d a n d h a r d i n t e g r a t e i n t o o t h e r a p p l i c a t i o n s . W e

    w e r e n o t a b l e t o n d a n y l i b r a r i e s t h a t c o m b i n e d n g e r t r a c k i n g a n d g e s t u r e r e c o g n i t i o n

    t h a t w o u l d p e r f o r m o n a r e a s o n a b l y l e v e l .

    1 . 3 V i s i o n

    O u r v i s i o n i s t o c r e a t e a n A P I t h a t c a n d o n g e r t r a c k i n g a n d g e s t u r e r e c o g n i t i o n w i t h

    r e a s o n a b l y g o o d r e s u l t s a n d m a k e i t a v a i l a b l e t o a b r o a d s p e c t r u m o f p e o p l e . T o d o

    t h i s t h e A P I s h o u l d b e e a s y t o u s e a n d t h e c o d e s h o u l d b e w e l l d o c u m e n t e d a n d e a s y

    t o r e a d . W e w i l l t a l k m o r e i n d e p t h a b o u t t h e A P I i n c h a p t e r 9 .

    2

  • 7/30/2019 Ryan, Daniel James

    17/81

    2

    T h e K i n e c t s e n s o r

    2 . 1 K i n e c t v e r s i o n s

    T h e r e a r e t w o d i e r e n t v e r s i o n s o f t h e M i c r o s o f t K i n e c t s e n s o r ; K i n e c t f o r W i n d o w s

    a n d K i n e c t f o r X b o x 3 6 0 . T h e K i n e c t f o r W i n d o w s s e n s o r d o e s n o t w o r k w i t h t h e X b o x

    3 6 0 g a m i n g c o n s o l e .

    2 . 1 . 1 C o m m e r c i a l a n d d e v e l o p m e n t u s a g e

    B o t h v e r s i o n s c a n b e u s e d f o r d e v e l o p m e n t , b u t o n l y t h e K i n e c t f o r W i n d o w s c a n b e

    u s e d f o r c o m m e r c i a l p u r p o s e s . T h e K i n e c t f o r X b o x s e n s o r w i l l n o t w o r k w i t h t h e

    K i n e c t f o r W i n d o w s r u n t i m e ( v 1 . 0 a t t h e t i m e o f w r i t i n g ) , h o w e v e r i t d o e s w o r k w i t h

    t h e K i n e c t f o r W i n d o w s S D K . T h e K i n e c t f o r W i n d o w s r u n t i m e n e e d s t o b e i n s t a l l e d

    b y t h e e n d u s e r t o e n a b l e t h e K i n e c t f o r W i n d o w s s e n s o r t o w o r k w i t h t h e a p p l i c a t i o n .

    T h e c o m m e r c i a l l i c e n s e o f t h e v 1 . 0 r e l e a s e a l l o w s u s t o d e v e l o p , d i s t r i b u t e a n d s e l l

    o u r a p p l i c a t i o n s u s i n g t h e K i n e c t f o r W i n d o w s s e n s o r o n W i n d o w s p l a t f o r m s ( 3 ) .

    2 . 2 S p e c s

    T h e K i n e c t h a s a R G B c a m e r a , d e p t h s e n s o r ( I R ) a n d a m i c r o p h o n e a r r a y . T h e R G B

    c a m e r a a n d d e p t h s e n s o r h a s a r e s o l u t i o n o f

    640480p i x e l s a t 3 0 H z . T h e s e n s o r a r r a y

    s t a n d a l s o f e a t u r e s a m o t o r s o t h e t i l t c a n b e c h a n g e d w i t h o u t p h y s i c a l i n t e r a c t i o n .

    3

  • 7/30/2019 Ryan, Daniel James

    18/81

    2 . T H E K I N E C T S E N S O R

    2 . 3 K i n e c t f o r W i n d o w s S D K

    T h e K i n e c t f o r W i n d o w s b e t a 2 w a s r e l e a s e d o n N o v e m b e r 1 , 2 0 1 2 . a n d g a v e u s a n

    o c i a l w a y t o c r e a t e a p p l i c a t i o n s u s i n g t h e K i n e c t s e n s o r . T h i s b e t a r e l e a s e i s l i c e n s e d

    o n l y f o r r e s e a r c h a n d d e v e l o p m e n t p u r p o s e s . O n F e b r u a r y 1 . M i c r o s o f t s i m u l t a n e o u s l y

    r e l e a s e d v e r s i o n v e r s i o n 1 o f t h e S D K a n d t h e K i n e c t f o r W i n d o w s s e n s o r . T h i s w o u l d

    a l l o w a n y o n e t o c r e a t e a n d s e l l a p p l i c a t i o n s u s i n g t h e K i n e c t s e n s o r . A v e r s i o n 1 . 5 w a s

    r e l e a s e d M a y 2 2 .

    T h e S D K a l l o w s a p r o g r a m m e r t o a c c e s s t h e v i d e o , d e p t h a n d s o u n d s t r e a m p r o -

    d u c e d f r o m t h e K i n e c t s e n s o r .

    W i t h t h e S D K w e c a n g e t s k e l e t o n t r a c k i n g d a t a f r o m u p t o t w o p l a y e r s w h o a r e

    i n f r o n t o f t h e K i n e c t s e n s o r . T h e s k e l e t o n t r a c k i n g d a t a g i v e s u s t h e p o s i t i o n o f 2 0

    j o i n t s a n d h a s a d e p t h r a g e o f a b o u t

    0.7 6m e t e r s . T h e S D K a l s o p r o v i d e s s o u n d

    t r i a n g u l a t i o n .

    2 . 3 . 1 D a t a s t r e a m s

    T h e d e p t h d a t a s t r e a m i s g i v e n a s a n a r r a y o f s i z e

    640 480 = 307200w i t h d i s t a n c e s

    i n m i l l i m e t e r s f o r e a c h p i x e l . T h e r e i s a d i e r e n c e b e t w e e n t h e K i n e c t f o r X b o x 3 6 0

    a n d t h e K i n e c t f o r W i n d o w s d e p t h s t r e a m . W i t h t h e K i n e c t f o r W i n d o w s a n d i t s N e a r

    M o d e , w e c a n s e e o b j e c t s a s c l o s e a s 4 0 c m f r o m t h e s e n s o r . T h e K i n e c t f o r X b o x c a n

    o n l y s e e o b j e c t s t h a t a r e f u r t h e r t h a n 8 0 c m f r o m t h e s e n s o r .

    T h e v i d e o d a t a s t r e a m i s a l s o g i v e n a s a n a r r a y o f s i z e 640 480 = 307200

    w i t h t h e

    c o l o r v a l u e f o r e a c h p i x e l . W e c a n c h o o s e b e t w e e n R G B a n d Y U V f o r t h e c o l o r v a l u e .

    W e h a v e n o t u s e d t h e a u d i o s t r e a m i n t h i s t h e s i s .

    2 . 4 P o s s i b i l i t i e s w i t h t h e K i n e c t

    T w o r e s e a r c h e r s h a v e c r e a t e d a s y s t e m t h a t u s e s m u l t i p l e K i n e c t d e p t h s t r e a m s t o k e e p

    t r a c k o f o b j e c t s a s t h e y a r e m o v e d a r o u n d i n a b u i l d i n g ( 4 ) . T h i s m a y b e t h e e n d o f

    s e a r c h i n g a f t e r o u r m i s p l a c e d c a r k e y s .

    A g r o u p o f i n d e p e n d e n t g a m e m a k e r s h a s c r e a t e d a p h y s i c a l s a n d b o x w i t h a n i m a g e

    p r o j e c t e d o n t o t h e s a n d f r o m a b o v e . T h e i m a g e a d d s a v i r t u a l w o r l d t o t h e s a n d b o x

    b y f o r i n s t a n c e s h o w i n g s n o w o n h i g h p e a k s o f s a n d o r a d d i n g v i r t u a l w a t e r t o l o w e r

    4

  • 7/30/2019 Ryan, Daniel James

    19/81

    2 . 4 P o s s i b i l i t i e s w i t h t h e K i n e c t

    r e g i o n s o f t h e s a n d b o x . T h e w a t e r i s f u l l y a n i m a t e d a n d d y n a m i c , m e a n i n g t h e w a t e r

    o w s w i t h t e r r a i n c h a n g e s . T h e y h a v e a c h i e v e d t h i s b y u s i n g t h e d e p t h s t r e a m f r o m a

    K i n e c t m o u n t e d a b o v e t h e s a n d b o x ( 5 ) .

    T h i s s h o w w h a t c a n b e d o n e w i t h t h e K i n e c t .

    5

  • 7/30/2019 Ryan, Daniel James

    20/81

    2 . T H E K I N E C T S E N S O R

    6

  • 7/30/2019 Ryan, Daniel James

    21/81

    3

    C o n t o u r t r a c k i n g

    C o n t o u r t r a c k i n g w i l l n d t h e c o n t o u r o f o b j e c t s i n r a n g e o f t h e d e p t h c a m e r a .

    T h i s a l g o r i t h m w o r k s b y s c a n n i n g t h e d e p t h i m a g e f r o m t h e b o t t o m a n d u p f o r

    a v a l i d c o n t o u r p i x e l . W h e n a v a l i d c o n t o u r p i x e l i s f o u n d i t w i l l b e g i n t o t r a c k t h e

    c o n t o u r o f t h e o b j e c t t h a t t h e p i x e l i s a p a r t o f . T h i s i s d o n e b y s e a r c h i n g i n a l o c a l g r i d

    a r o u n d t h e p i x e l . A f t e r t h e c o n t o u r t r a c k i n g a l g o r i t h m h a s t e r m i n a t e d t h e t r a c k i n g i t

    w i l l r e t u r n a n o r d e r e d l i s t w i t h t h e p o s i t i o n s o f t h e c o n t o u r p i x e l s .

    3 . 1 E x i s t i n g a l g o r i t h m s

    T h e r e e x i s t s s e v e r a l c o n t o u r t r a c i n g a l g o r i t h m s , s u c h a s ( 6 ) , ( 7 ) a n d ( 8 ) , b u t w e h a v e

    c h o s e n t o i m p l e m e n t o u r o w n a l g o r i t h m .

    3 . 2 F i n d i n g t h e i n i t i a l p i x e l

    T o s t a r t t h e c o n t o u r t r a c k i n g w e n e e d t o n d a v a l i d c o n t o u r p i x e l . A v a l i d c o n t o u r

    p i x e l i s a p i x e l t h a t i s i n a s p e c i e d r a n g e f r o m t h e K i n e c t s e n s o r a n d h a s a t l e a s t

    o n e n e i g h b o r i n g p i x e l t h a t i s n o t i n t h e s p e c i e d r a n g e . T h e i n i t i a l p i x e l i s f o u n d b y

    s c a n n i n g t h e d e p t h i m a g e , f r o m b o t t o m a n d u p , a f t e r a v a l i d p i x e l . T h i s m e a n s t h e

    s c a n f o r t h e i n i t i a l p i x e l w i l l h a v e t o s c a n a s u b s t a n t i a l a m o u n t o f p i x e l s i f t h e h a n d s

    a r e h i g h u p o n t h e i m a g e . T o r e d u c e t h e t i m e i t t a k e s t o n d t h e i n i t i a l p i x e l w e c a n

    m a k e a n a s s u m p t i o n a b o u t t h e h a n d s p o s i t i o n . W e a s s u m e t h e h a n d i s s o m e w h e r e i n

    t h e m i d d l e o f t h e p i c t u r e . W i t h t h i s a s s u m p t i o n w e c a n a d d a h e i g h t o s e t t o t h e s t a r t

    h e i g h t o f t h e s c a n . I n t h e a l g o r i t h m w e s e t t h e h e i g h t o s e t t o b e 2 0 % o f t h e i m a g e

    7

  • 7/30/2019 Ryan, Daniel James

    22/81

    3 . C O N T O U R T R A C K I N G

    h e i g h t . N o w w e d o n ' t h a v e t o s c a n s o m a n y p i x e l s a n d t o m a k e i t s c a n e v e n l e s s p i x e l s

    w e o n l y s c a n e v e r y f t h r o w . T h e e e c t c a n b e s e e n i f w e h a v e a n e m p t y i m a g e , i . e n o

    o b j e c t s a r e v i s i b l e t o t h e d e p t h c a m e r a . T h i s i s o u r w o r s t c a s e s c e n a r i o .

    T h e b e s t r e s o l u t i o n w e c a n g e t f r o m t h e d e p t h c a m e r a i s 640 480

    . W o r s t c a s e

    n u m b e r o f p i x e l s w e h a v e t o s c a n i f w e d o n ' t o p t i m i z e t h e s c a n i s 3 0 7 2 0 0 p i x e l s . S e e

    e q u a t i o n 3 . 1 .

    imageWidth imageHeight = 640 480 = 307200p i x e l s ( 3 . 1 )

    W o r s t c a s e w i t h t h e o p t i m i z e d v e r s i o n , a s s h o w n i n e q u a t i o n 3 . 2 , i s 4 8 6 4 0 p i x e l s .

    imageHeight 0.80

    5

    imageWidth =

    480 0.80

    5

    640 = 76640 = 48640

    p i x e l s

    ( 3 . 2 )

    T h i s i s a n 8 4 % r e d u c t i o n o f p i x e l s w e h a v e t o s c a n .

    3 . 3 T r a c k i n g t h e c o n t o u r

    A f t e r t h e i n i t i a l c o n t o u r p i x e l i s f o u n d w e c a n b e g i n t h e s e a r c h f o r t h e n e x t c o n t o u r

    p i x e l . T h e a l g o r i t h m w i l l s e a r c h i n a l o c a l g r i d p a t t e r n w i t h t h e c u r r e n t f o u n d p i x e l a t

    t h e o r i g i n . T h e g r i d e x t e n d s o n e p i x e l i n e a c h d i r e c t i o n .

    3 . 3 . 1 S e a r c h d i r e c t i o n s

    W e a s s i g n a s e a r c h d i r e c t i o n t o e a c h f o u n d c o n t o u r p i x e l t o s p e e d u p t h e d i s c o v e r y

    p r o c e s s . T h e s e a r c h d i r e c t i o n s a r e u p - l e f t , u p - r i g h t , d o w n - r i g h t a n d d o w n - l e f t ; t h e y

    a r e r e l a t i v e t o t h e c e n t e r o f t h e s c r e e n . T h e s t a r t i n g d i r e c t i o n i s s e t t o u p - l e f t d u e

    t o t h e V - s h a p e o f t h e h a n d a b o v e t h e w r i s t . T h e s e a r c h f o r a n e w c o n t o u r p i x e l w i l l

    b e g i n i n t h e s a m e d i r e c t i o n a s t h e l a s t p i x e l w a s f o u n d i n . I f w e d o n ' t n d a n e w p i x e l

    i n t h i s d i r e c t i o n , w e b e g i n s e a r c h i n g i n t h e n e x t m o s t p r o b a b l e d i r e c t i o n . T h e m o s t

    p r o b a b l e d i r e c t i o n a f t e r u p - l e f t i s u p - r i g h t : A f t e r w e s e a r c h u p a l o n g a n g e r w e w i l l

    h i t t h e b e g i n n i n g o f t h e n g e r t i p ; h e r e t h e c o n t o u r d i r e c t i o n c h a n g e s t o g o u p - r i g h t . A t

    t h e a p e x o f t h e n g e r t i p i t c u r v e s d o w n - r i g h t , m a k i n g t h i s d i r e c t i o n t h e m o s t p r o b a b l e

    d i r e c t i o n a f t e r u p - r i g h t . A f t e r w e t r a v e r s e d o w n t o a n g e r v a l l e y a n e w n g e r b e g i n s ,

    m a k i n g t h e n e x t m o s t p r o b a b l e d i r e c t i o n u p - r i g h t . I f t h e a l g o r i t h m d o e s n ' t n d a n e w

    p i x e l i n t h e n e x t m o s t p r o b a b l e d i r e c t i o n , i t w i l l s e a r c h i n a l l t h e d i r e c t i o n s , b e g i n n i n g

    8

  • 7/30/2019 Ryan, Daniel James

    23/81

    3 . 3 T r a c k i n g t h e c o n t o u r

    a t t h e l a s t f o u n d p i x e l d i r e c t i o n a n d m o v i n g c l o c k w i s e . T h e s e a r c h w i l l s t o p w h e n a

    v a l i d p i x e l i s f o u n d .

    W i t h t h i s m e t h o d w e c a n r u n i n t o t h e p r o b l e m o f d i s c o v e r i n g a p i x e l t h a t h a s a l r e a d y

    b e e n f o u n d . I f w e f o u n d a p i x e l t h a t h a s p r e v i o u s l y b e e n d i s c o v e r e d w e b e g i n t o s e a r c h

    f r o m t h e l a s t f o u n d p i x e l d i r e c t i o n , b u t t h i s t i m e m o v i n g c o u n t e r c l o c k w i s e . I f w e s t i l l

    n d a p r e v i o u s l y d i s c o v e r e d p i x e l w e c h e c k i f w e a r e o n a s i n g l e , v e r t i c a l o r h o r i z o n t a l ,

    p i x e l l i n e . I f w e a r e n o t o n a s i n g l e p i x e l l i n e , w e c a n a s s u m e t h a t t h e r e a r e n o m o r e

    c o n t o u r p i x e l s t o d i s c o v e r a n d t e r m i n a t e t h e s e a r c h .

    ( a ) S e a r c h U p L e f t a l g o r i t h m . ( b ) S e a r c h U p R i g h t a l g o r i t h m .

    ( c ) S e a r c h D o w n L e f t a l g o r i t h m . ( d ) S e a r c h D o w n R i g h t a l g o r i t h m .

    F i g u r e 3 . 1 : L o c a l s e a r c h g r i d .

    9

  • 7/30/2019 Ryan, Daniel James

    24/81

    3 . C O N T O U R T R A C K I N G

    F i g u r e 3 . 1 s h o w s t h e l o c a l g r i d p a t t e r n u s e d b y t h e c o n t o u r s e a r c h i n g a l g o r i t h m .

    F i g u r e 3 . 1 a d i s p l a y s w h e r e t h e a l g o r i t h m S e a r c h U p L e f t w i l l s e a r c h f o r n e w c o n t o u r

    p i x e l s . I t w i l l r s t c h e c k p i x e l 1 ( i n g u r e 3 . 1 a ) i f i t ' s a v a l i d c o n t o u r p i x e l . I f n o t , t h e

    s e a r c h c o n t i n u e s t o p i x e l 2 a n d t h e n 3 . F i g u r e 3 . 1 b , 3 . 1 c a n d 3 . 1 d a l s o d i s p l a y s p i x e l

    s e a r c h o r d e r , w h e r e 1 i s t h e r s t p i x e l i t c h e c k s .

    I n g u r e 3 . 1 w e c a n s e e t h a t t h e a l g o r i t h m s o v e r l a p p i x e l s e a r c h i n g i n t h e v e r t i c a l

    d i r e c t i o n . W i t h a h a n d c o n t o u r w e w i l l b e m o s t l y s e a r c h i n g i n t h e v e r t i c a l d i r e c t i o n .

    T h e o v e r l a p e n a b l e s a l l a l g o r i t h m s t o s e a r c h d i r e c t l y v e r t i c a l l y . B y o v e r l a p p i n g w e s a v e

    t i m e b y n o t c h a n g i n g s e a r c h d i r e c t i o n s t o o o f t e n .

    3 . 3 . 2 S i n g l e p i x e l l i n e s

    O n e p r o b l e m w i t h t h e f o u r s e a r c h d i r e c t i o n a l g o r i t h m s i s ; I f w e t r a v e r s e u p a s i n g l e p i x e l

    l i n e w e a r e u n a b l e t o t r a v e r s e d o w n a g a i n a n d c o n t i n u e s e a r c h i n g . T h e r e f o r e i f w e c a n t

    n d a n y n e w p i x e l s u s i n g a l l f o u r s e a r c h d i r e c t i o n a l g o r i t h m s , w e m u s t c h e c k i f w e a r e

    o n a s i n g l e p i x e l l i n e . T h i s i s d o n e b y c h e c k i n g t h e p i x e l a b o v e a n d u n d e r t h e c u r r e n t

    p i x e l . I f b o t h o f t h e m a r e n o t v a l i d p i x e l s w e h a v e a h o r i z o n t a l p i x e l l i n e . T o c h e c k i f

    w e a r e o n a v e r t i c a l s i n g l e p i x e l l i n e w e c h e c k t h e l e f t a n d r i g h t p i x e l s .

    O n c e w e h a v e e s t a b l i s h e d t h a t w e a r e o n a s i n g l e p i x e l l i n e t h e s i n g l e p i x e l l i n e

    a l g o r i t h m w i l l t r a v e r s e d o w n t o t h e b a s e . I t w i l l b r e a k o t h e s e a r c h f o r t h e b a s e i f

    w e n d a v a l i d p i x e l o n t h e o t h e r s i d e o f t h e l i n e f r o m w h e r e w e c a m e f r o m . I t h a s

    t h e n s u c c e s s f u l l y f o u n d t h e b a s e . W h e n i t i s n i s h e d i t w i l l r e t u r n a n e w d i r e c t i o n t o

    c o n t i n u e t h e s e a r c h .

    I n c l u d i n g t h e n e w l y f o u n d p i x e l i t w i l l a l s o r e t u r n a s e a r c h d i r e c t i o n t o c o n t i n u e t h e

    s e a r c h i n .

    F i g u r e 3 . 2 d e m o n s t r a t e s h o w t h e s i n g l e p i x e l l i n e a l g o r i t h m w o r k s . I n 3 . 2 a t h e

    S e a r c h U p L e f t a l g o r i t h m n d s c o n t o u r p i x e l s 1 t o 5 . A f t e r i t h a s f o u n d p i x e l 5 i t w i l l

    s e a r c h i n t h e n e x t m o s t p r o b a b l e s e a r c h d i r e c t i o n , u p - r i g h t . T h i s l e a d s t o n d i n g p i x e l

    4 , w h i c h h a s a l r e a d y b e e n d i s c o v e r e d . I t w i l l t h e n t r y t o n d a n e w p i x e l b y s e a r c h i n g

    c o u n t e r c l o c k w i s e . T h i s l e a d s t o n d i n g p i x e l 4 , a g a i n . I t w i l l n o w n d i f w e a r e o n a

    h o r i z o n t a l o r v e r t i c a l s i n g l e p i x e l l i n e b y c h e c k i n g w h i c h n e i g h b o r p i x e l i s a v a l i d p i x e l .

    I n t h i s c a s e w e n d t h a t t h e r i g h t p i x e l i s o u r v a l i d n e i g h b o r , t h i s m e a n s w e a r e o n a

    h o r i z o n t a l l i n e . T h e a l g o r i t h m a l s o c h e c k s w h i c h g e n e r a l d i r e c t i o n w e a r e s e a r c h i n g i n ;

    1 0

  • 7/30/2019 Ryan, Daniel James

    25/81

    3 . 3 T r a c k i n g t h e c o n t o u r

    ( a ) H o r i z o n t a l s i n g l e p i x e l l i n e . ( b ) V e r t i c a l s i n g l e p i x e l l i n e .

    F i g u r e 3 . 2 : S i n g l e p i x e l l i n e s .

    T h e s e a r e u p , d o w n , l e f t a n d r i g h t , a n d d e t e r m i n e s i n w h i c h d i r e c t i o n w e m u s t t r a v e r s e

    t o n d t h e b a s e .

    I n g u r e 3 . 2 a t h e s i n g l e p i x e l l i n e a l g o r i t h m w i l l t r a v e r s e t o t h e r i g h t , d i s c o v e r i n g

    c o n t o u r p i x e l s 7 , 8 a n d 9 . N o t e t h a t t h e a l g o r i t h m w i l l n o t b r e a k t h e s e a r c h w h e n w e

    n d p i x e l 8 b e c a u s e i t k n o w s t h e g e n e r a l s e a r c h d i r e c t i o n i s u p a n d w i l l t h e r e f o r e o n l y

    b r e a k i f t h e r e i s a v a l i d p i x e l a b o v e t h e p i x e l l i n e . W h e n i t i s o n p i x e l 1 0 , i t w i l l d i s c o v e r

    p i x e l 1 1 a n d s t o p ; t h i s i s t h e e n d o f t h e l i n e . T h e a l g o r i t h m w i l l r e t u r n a n e w s e a r c h

    d i r e c t i o n , u p - r i g h t s i n c e t h e g e n e r a l s e a r c h d i r e c t i o n w e r e u p a n d r i g h t , a n d c o n t i n u e

    l o c a l g r i d s e a r c h f r o m t h i s d i r e c t i o n .

    I n g u r e 3 . 2 b w e h a v e a v e r t i c a l s i n g l e p i x e l l i n e . T h e o n l y d i e r e n c e s h e r e a r e t h e

    s e a r c h i n g d i r e c t i o n s . W h e n t h e a l g o r i t h m i s n i s h e d t h e n e w s e a r c h i n g d i r e c t i o n w i l l

    b e d o w n l e f t s i n c e t h e g e n e r a l d i r e c t i o n s w e r e d o w n a n d l e f t .

    3 . 3 . 3 B a c k t r a c k i n g

    W e a l s o h a v e a b a c k t r a c k i n g a l g o r i t h m t o e n s u r e c o n t i n u o u s c o n t o u r t r a c k i n g e v e n i f

    w e e n c o u n t e r u n k n o w n v a l i d p i x e l c o n g u r a t i o n t h a t w o u l d h a l t t h e t r a c k i n g . T h e

    b a c k t r a c k i n g a l g o r i t h m w i l l b a c k t r a c k p i x e l s u p t o a u s e r s p e c i e d p i x e l c o u n t . T h i s

    a l g o r i t h m u t i l i z e s t h e s e a r c h c l o c k w i s e a l g o r i t h m w i t h s o m e a d d i t i o n s ; I t w i l l c o n t i n u e

    u n t i l i t n d s a n e w v a l i d c o n t o u r p i x e l o r u n t i l i t h a s r e a c h i t s s p e c i e d p i x e l c o u n t

    l i m i t . I f n o n e w v a l i d c o n t o u r p i x e l i s f o u n d , t h e n w e c a n s a y t h e c o n t o u r t r a c k i n g i s

    1 1

  • 7/30/2019 Ryan, Daniel James

    26/81

    3 . C O N T O U R T R A C K I N G

    n i s h e d . I f t h e b a c k t r a c k i n g n d s a n e w c o n t o u r p i x e l , i t w i l l r e t u r n t h e n e w l y f o u n d

    p i x e l w i t h t h e s e a r c h d i r e c t i o n i t w a s f o u n d i n . T h i s e n a b l e s u s t o c o n t i n u e n o r m a l

    c o n t o u r t r a c k i n g f r o m h e r e .

    B a c k t r a c k i n g i s u s e d a s a l a s t r e s o r t t o n d n e w c o n t o u r p i x e l s . T h i s a l g o r i t h m

    c o u l d a l s o s u b s t i t u t e t h e n d s i n g l e p i x e l l i n e s a l g o r i t h m ( c h a p t e r 3 . 3 . 2 ) , a l t h o u g h i t

    w o u l d n o t p e r f o r m a s w e l l .

    3 . 3 . 4 T r a c k t w o h a n d s

    F o r t h e c o n t o u r t r a c k i n g t o w o r k w i t h t w o h a n d s i n t h e d e p t h f r a m e s i m u l t a n e o u s l y , w e

    h a v e t o d o t w o s e p a r a t e s e a r c h e s f o r t h e i n i t i a l p i x e l . F i r s t w e f o l l o w t h e s t e p s d e s c r i b e d

    i n s e c t i o n 3 . 2 t o n d t h e i n i t i a l p i x e l a n d t r a c k t h e c o n t o u r o f t h e l e f t h a n d . I f i t d i d

    n o t n d a n y p i x e l s w e k n o w t h e r e a r e n ' t a n y o b j e c t s i n t h e f r a m e a n d d o n ' t n e e d t o

    c o n t i n u e . I f o n e o r m o r e v a l i d p i x e l s w e r e d i s c o v e r e d w e c o n t i n u e t o s e a r c h f o r a s e c o n d

    h a n d .

    T h e i n i t i a l p i x e l s c a n f o r t h e s e c o n d h a n d h a s s o m e a d d i t i o n a l p r o p e r t i e s . S i n c e w e

    s t a r t e d t h e s c a n f r o m t h e l e f t s i d e i t i s r e a s o n a b l e t o a s s u m e t h e d i s c o v e r e d h a n d i s o n

    t h e l e f t s i d e o f t h e d e p t h f r a m e . W i t h t h i s i n m i n d , i t w i l l b e f a s t e r t o d e t e c t t h e r i g h t

    h a n d i f w e s t a r t t h e s e c o n d s c a n f r o m t h e r i g h t s i d e . T h e r e i s s t i l l t h e p o s s i b i l i t y t o

    n d o n e o f t h e c o n t o u r p i x e l s o f t h e l e f t h a n d . T o a v o i d d e t e c t i n g t h e c o n t o u r o f t h e

    s a m e h a n d t w i c e w e c h e c k i f t h e p i x e l h a s a l r e a d y b e e n d i s c o v e r e d . I f t h e p i x e l i s p a r t

    o f t h e r s t h a n d w e k n o w t h e s e c o n d h a n d m u s t b e h i g h e r u p o n t h e d e p t h f r a m e . T h e

    a l g o r i t h m w i l l j u m p 2 0 p i x e l r o w s u p a n d c o n t i n u e t h e s c a n f r o m t h e r e .

    I f t h e p i x e l h a s n o t p r e v i o u s l y b e e n d i s c o v e r e d i t m u s t b e a c o n t o u r p i x e l o n t h e

    r i g h t h a n d . T h i s p i x e l w i l l b e o u r s e c o n d i n i t i a l p i x e l a n d t h e c o n t o u r t r a c k i n g c a n

    b e g i n o n t h e s e c o n d h a n d .

    3 . 4 T e r m i n a t i o n s t a t e s

    T h e a l g o r i t h m h a s t w o t e r m i n a t i o n s t a t e s ; i f i t n d s a p i x e l t h a t h a s a l r e a d y b e e n

    d i s c o v e r e d o r a x e d n u m b e r o f p i x e l s h a v e b e e n d i s c o v e r e d .

    1 2

  • 7/30/2019 Ryan, Daniel James

    27/81

    3 . 4 T e r m i n a t i o n s t a t e s

    3 . 4 . 1 T e r m i n a t i o n s t a t e 1 : A p i x e l w a s d i s c o v e r e d t w i c e .

    W e c a n m a k e t w o a s s u m p t i o n s i f w e n d a p i x e l t h a t h a s p r e v i o u s l y b e e n d i s c o v e r e d .

    T h e r s t a s s u m p t i o n w e m a k e i s t h a t t h e a l g o r i t h m h a s t r a c k e d t h e w h o l e c o n t o u r

    a n d f o u n d t h e i n i t i a l p i x e l t h a t b e g a n t h e t r a c k i n g . I f t h i s i s t h e c a s e w e c a n s a y t h e

    t r a c k i n g w a s s u c c e s s f u l a n d t h e w h o l e c o n t o u r w a s f o u n d . T h e o t h e r a s s u m p t i o n i s t h a t

    t h e a l g o r i t h m i s s t u c k a n d c a n ' t n d a n y n e w c o n t o u r p i x e l s i n i t s l o c a l s e a r c h g r i d . I t

    c a n b e c o m e s t u c k i f t h e p i x e l c o n g u r a t i o n t h a t m a k e u p t h e c o n t o u r h a s u n d i s c o v e r e d

    e d g e c a s e s t h a t w e r e n o t a c c o u n t e d f o r . A l t h o u g h t h i s i s u n l i k e l y , t h e r e i s a p o s s i b i l i t y

    f o r t h i s t o o c c u r .

    T o p r o v i d e a f a s t a n d e a s y m e t h o d t o c h e c k i f a p i x e l h a s p r e v i o u s l y b e e n d i s c o v e r e d ,

    w e a l s o s t o r e a l l d i s c o v e r e d p i x e l s i n a h a s h t a b l e . H a s h t a b l e s h a s O(1)

    l o o k u p a n d

    i n s e r t i o n t i m e a n d i s a n u n o r d e r e d c o l l e c t i o n ; m a k i n g i t g o o d f o r d u p l i c a t e c h e c k i n g

    b u t u n u s a b l e t o u s e a s t h e p r i m a r y c o l l e c t i o n o f d i s c o v e r e d p i x e l s s i n c e w e n e e d t o h a v e

    t h e m s o r t e d i n t h e o r d e r t h e y w e r e f o u n d .

    3 . 4 . 2 T e r m i n a t i o n s t a t e 2 : A x e d n u m b e r o f p i x e l s w e r e d i s c o v e r e d .

    S i n c e w e o n l y a r e i n t e r e s t e d t o n d t h e c o n t o u r a r o u n d t h e n g e r s , w e o n l y n e e d t o

    d i s c o v e r a l i m i t e d n u m b e r o f p i x e l s . A t t h e c l o s e s t d e t e c t i o n r a n g e o f t h e K i n e c t f o r

    X b o x s e n s o r a l l n g e r s i s m a d e u p o f a b o u t 4 5 0 p i x e l s t o t a l , s e e g u r e 3 . 3 . I f w e

    w e r e t o m o v e f u r t h e r a w a y f r o m t h e K i n e c t s e n s o r t h i s v a l u e w o u l d d e c r e a s e . W i t h

    t h i s i n f o r m a t i o n w e c a n s t o p t h e t r a c k i n g a l g o r i t h m a f t e r a x e d n u m b e r o f p i x e l s a r e

    d i s c o v e r e d .

    T h e r e i s a l s o a r i s k w i t h t h i s m e t h o d . T h e t r a c k i n g c o u l d b e t e r m i n a t e d t o o e a r l y ,

    b e f o r e n d i n g a l l t h e n g e r c o n t o u r s . O t h e r b o d y p a r t s c o u l d a l s o b e i n c l u d e d i n t h e

    p i c t u r e , s u c h a s t h e f o r e a r m , u s i n g m o s t o f t h e a v a i l a b l e p i x e l s . T h e a l g o r i t h m i s s e t t o

    d i s c o v e r m a x 7 0 0 p i x e l s p e r h a n d .

    T h e t e r m i n a t i o n v a l u e i s a l s o i m p o r t a n t t o t h e p e r f o r m a n c e o f t h e a l g o r i t h m . T h e

    m o r e p i x e l s i t n e e d t o d i s c o v e r t h e m o r e t i m e t h e a l g o r i t h m w i l l u s e . B y l i m i t i n g t h e

    n u m b e r o f p i x e l s t h e a l g o r i t h m c a n d i s c o v e r w e c a n c a l c u l a t e t h e w o r s t c a s e r u n n i n g

    t i m e . T h i s w a y w e c a n m a k e a d j u s t m e n t s t o m e e t t h e m a x i m u m e x p e c t e d r u n n i n g t i m e .

    1 3

  • 7/30/2019 Ryan, Daniel James

    28/81

    3 . C O N T O U R T R A C K I N G

    F i g u r e 3 . 3 : M i n i m u m h a n d c o n t o u r p i x e l s ( t h e r e d c o l o r e d p i x e l s ) .

    1 4

  • 7/30/2019 Ryan, Daniel James

    29/81

    4

    F i n g e r r e c o g n i t i o n

    F i n g e r r e c o g n i t i o n c o n s i s t s o f t h r e e s t e p s . S t e p o n e i s t o n d c u r v e s o n t h e h a n d c o n t o u r .

    S t e p t w o i s t o n d w h i c h c u r v e s a r e n g e r t i p s a n d t h e l a s t s t e p i s t o n d t h e m i d d l e o f

    t h e n g e r t i p c u r v e s . I n a d d i t i o n w e w i l l a l s o g e t t h e p o i n t i n g d i r e c t i o n o f t h e n g e r t i p s .

    F i g u r e 4 . 1 b s h o w s t h e r e s u l t s o f t h e s e a l g o r i t h m s . T h e r e d p i x e l s a r e t h e e x t r a c t e d h a n d

    c o n t o u r , t h e y e l l o w p i x e l s a r e t h e c u r v e p o i n t s a n d t h e b l u e p i x e l s i n d i c a t e w h e r e t h e

    n g e r t i p a r e l o c a t e d .

    ( a ) R a w d e p t h i m a g e . ( b ) H a n d c o n t o u r w i t h c u r v e p o i n t s a n d

    n g e r t i p l o c a t i o n .

    F i g u r e 4 . 1 : T h e r a w a n d p r o c e s s e d i m a g e s .

    1 5

  • 7/30/2019 Ryan, Daniel James

    30/81

    4 . F I N G E R R E C O G N I T I O N

    4 . 1 R e l a t e d w o r k s

    A g r o u p a t M a s s a c h u s e t t s I n s t i t u t e o f T e c h n o l o g y ( M I T ) h a s d e v e l o p e d a n o p e n s o u r c e

    g r a p h i c a l i n t e r f a c e w i t h t h e u s e o f n g e r t r a c k i n g w i t h t h e K i n e c t . T h e y h a v e h o w e v e r

    u s e d a d i e r e n t a p p r o a c h t o t h e n g e r t r a c k i n g p r o b l e m ; T h e y u s e p o i n t c l o u d s t o n d

    t h e h a n d a n d n g e r s ( 9 ) .

    I n t h e p a p e r ( 1 0 ) t h e y u s e t h e k - c u r v a t u r e a l g o r i t h m t o n d c u r v e s . T h e y h a v e

    u s e d t h i s a p p r o a c h t o n d t h e n g e r t i p f r o m b i n a r y i m a g e s . W e h a v e u s e d t h e s a m e

    a p p r o a c h t o c u r v e d e t e c t i o n i n t h i s t h e s i s .

    4 . 2 C u r v e d e t e c t i o n

    T h e c u r v e d e t e c t i o n i s i m p l e m e n t e d u s i n g t h e k - c u r v a t u r e a l g o r i t h m . T h e k - c u r v a t u r e

    a l g o r i t h m d e t e c t s t h e a n g l e b e t w e e n t w o v e c t o r s .

    T h e i m p l e m e n t e d v e r s i o n o f t h e a l g o r i t h m t a k e s i n t h r e e p a r a m e t e r s ; A n o r d e r e d l i s t

    o f c o n t o u r p o i n t s , a c o n s t a n t k

    a n d a n a n g l e

    , i n r a d i a n s . T h e c o n s t a n t k

    a n d t h e a n g l e

    v a l u e s a r e a p p l i c a t i o n s p e c i c , k w a s f o u n d b y t r a i l a n d e r r o r . I n t h e a p p l i c a t i o n k i s

    s e t t o 2 0 a n d

    t o0.95993

    r a d i a n s , o r 5 5 d e g r e e s . T h e a n g l e

    w a s f o u n d b y m e a s u r i n g

    n g e r t i p a n g l e s i n d e p t h f r a m e s . T h e a v e r a g e n g e r t i p a n g l e w a s m e a s u r e d t o 3 9 d e g r e e s

    a n d t h e l o w e s t n g e r t i p a n g l e w a s m e a s u r e d t o 2 5 d e g r e e s .

    T h e a l g o r i t h m w o r k s b y c r e a t i n g t w o v e c t o r a t e a c h c o n t o u r p o i n t . O n e v e c t o r ,

    v e c t o r a

    , p o i n t s t o a c o n t o u r p o i n t k

    p o i n t s i n f r o n t o f t h e c u r r e n t p o i n t i n t h e l i s t . T h e

    o t h e r v e c t o r , v e c t o r

    b, p o i n t s t o a c o n t o u r p o i n t

    kp o i n t s b e h i n d t h e c u r r e n t p o i n t . I f

    t h e c o n t o u r p o i n t l i s t i s c y c l i c , i . e . t h e c o n t o u r c l o s e s o n i t s e l f , w e c a n c r e a t e v e c t o r s

    a c r o s s t h e s t a r t a n d e n d b o u n d a r y o f t h e l i s t . I f t h e l i s t i s n o t c y c l i c w e s e t a t o p o i n t

    t o t h e r s t c o n t o u r p o i n t i n t h e l i s t w h e n t h e i n d e x o f t h e c u r r e n t p o i n t i s l e s s t h a n

    k.

    W e m u s t a l s o d o t h e s a m e a t t h e e n d ; W e s e t

    bt o p o i n t t o t h e l a s t c o n t o u r p o i n t i f w e

    a r e l e s s t h a n k

    p o i n t s f r o m t h e e n d o f t h e l i s t . S e e a l g o r i t h m A . 0 . 1 i n t h e a p p e n d i x .

    W e a l s o c r e a t e a t h i r d v e c t o r , c

    , b e t w e e n a

    a n d

    b.

    A f t e r t h e v e c t o r s a r e c r e a t e d w e n e e d t o n d t h e a n g l e b e t w e e n a

    a n d

    b. I f t h i s a n g l e

    i s l e s s t h a n

    w e h a v e a c u r v e p o i n t . T h e s c r e e n c o o r d i n a t e s o f t h e c u r r e n t c o n t o u r p o i n t

    a n d t h e t h r e e v e c t o r s , a

    ,

    ba n d

    ca r e s t o r e d i n a l i s t .

    1 6

  • 7/30/2019 Ryan, Daniel James

    31/81

    4 . 3 F i n g e r d e t e c t i o n

    4 . 3 F i n g e r d e t e c t i o n

    T o n d t h e n g e r t i p s w e i t e r a t e t h r o u g h t h e c u r v e p o i n t l i s t a n d t r y t o n d c u r v e p o i n t

    s e g m e n t s . C u r v e p o i n t s e g m e n t s c o n s i s t s o f p o i n t s t h a t a r e n e x t t o e a c h o t h e r .

    W h e n t h e s t a r t a n d e n d p o i n t o f a c u r v e s e g m e n t i s f o u n d w e n d t h e m i d d l e p o i n t

    o f t h e s e g m e n t . T h i s w i l l b e t h e n g e r t i p l o c a t i o n . H o w e v e r , n o t a l l s e g m e n t s a r e

    n g e r t i p s , t h e y c a n a l s o b e n g e r v a l l e y s . T o n d i f t h e s e g m e n t i s a n g e r t i p w e c r e a t e

    a b i s e c t b e t w e e n a

    a n d

    b. I f t h e b i s e c t p o i n t s t o a p i x e l t h a t i s i n t h e s p e c i e d d e p t h

    r a n g e w e k n o w t h a t i t m u s t b e a n g e r t i p o t h e r w i s e i t i s a n g e r v a l l e y , s e e g u r e 4 . 2 b

    a n d 4 . 2 c .

    W e u s e c

    t o n d t h e p o i n t i n g d i r e c t i o n o f t h e n g e r . W e c r e a t e a n e w v e c t o r

    b e t w e e n t h e c u r v e p o i n t a n d t h e m i d d l e o f c

    a n d r e v e r s e t h e v e c t o r . T h i s v e c t o r w i l l b e

    t h e p o i n t i n g d i r e c t i o n o f t h e n g e r . S e e g u r e 4 . 2 a . T h e c u r v e p o i n t a n d t h e p o i n t i n g

    d i r e c t i o n i s s t o r e d i n a l i s t .

    1 7

  • 7/30/2019 Ryan, Daniel James

    32/81

    4 . F I N G E R R E C O G N I T I O N

    ( a ) F i n g e r t i p d i r e c t i o n .

    ( b ) F i n g e r t i p w i t h b i s e c t . ( c ) F i n g e r v a l l e y w i t h b i s e c t .

    F i g u r e 4 . 2 : F i n d i n g t h e n g e r t i p s a n d t h e i r p o i n t i n g d i r e c t i o n .

    1 8

  • 7/30/2019 Ryan, Daniel James

    33/81

    5

    G e s t u r e R e c o g n i t i o n

    T o r e c o g n i z e g e s t u r e s , w e h a v e i m p l e m e n t e d a v a r i a n t o f t h e d y n a m i c t i m e w a r p i n g

    a l g o r i t h m - D T W .

    T h e D T W a l g o r i t h m r e c o g n i z e s s i m i l a r i t i e s b e t w e e n t w o t i m e s e r i e s . T h e t w o t i m e

    s e r i e s d o n o t n e e d t o b e s y n c h r o n i z e d i n t i m e , e n a b l i n g a u s e r t o d o g e s t u r e s s l o w e r o r

    f a s t e r t h a n t h e r e c o r d e d g e s t u r e s p e e d .

    5 . 1 R e l a t e d w o r k s

    A g r o u p o f r e s e a r c h e r s a t M i c r o s o f t R e s e a r c h u s e d d y n a m i c t i m e w a r p i n g t o r e c o g n i z e

    d a n c e g e s t u r e s u s i n g t h e K i n e c t . T h e i r g e s t u r e c l a s s i e r h a s a n a v e r a g e a c c u r a c e o f

    96.9%. T h i s s h o w s t h a t D T W c a n b e u s e d t o a c h i e v e h i g h a c c u r a c y w i t h d a t a f r o m t h e

    K i n e c t ( 1 1 ) .

    5 . 2 N o t e

    F r o m h e r e o n a f r a m e i m p l i e s t h a t w e h a v e p r o c e s s e d t h e d e p t h f r a m e a n d f o u n d t h e

    n g e r p o s i t i o n s i n t h e f r a m e .

    W h e n w e s a y c o s t , w e m e a n t h e t o t a l e u c l i d e a n d i s t a n c e i n o n e f r a m e . S e e e q u a t i o n

    5 . 2 f o r c a l c u l a t i n g t o t a l e u c l i d e a n d i s t a n c e b e t w e e n t w o f r a m e s . I n e q u a t i o n 5 . 2 w e

    a s s u m e o n l y o n e h a n d w i l l b e u s e d f o r g e s t u r e s , a l t h o u g h g e s t u r e s w i t h m u l t i p l e h a n d s

    a r e p o s s i b l e w i t h o u r s o l u t i o n . W e a l s o a s s u m e t h a t t h e n g e r c o u n t n

    t h r o u g h o u t a

    g e s t u r e i s 1 n 5

    .

    1 9

  • 7/30/2019 Ryan, Daniel James

    34/81

    5 . G E S T U R E R E C O G N I T I O N

    I n e q u a t i o n 5 . 1 , p a n d q d e n o t e s a n g e r p o s i t i o n i n a r e f e r e n c e g e s t u r e f r a m e a n d

    i n a i n p u t g e s t u r e f r a m e .

    5 . 3 R e c o r d i n g a g e s t u r e

    T o r e c o r d g e s t u r e s w e s t o r e n g e r p o s i t i o n s a n d d i r e c t i o n f r o m a l l f r a m e s w i t h i n a u s e r

    s p e c i e d t i m e f r a m e o r u n t i l a m a x f r a m e c o u n t h a s b e e n r e a c h e d . W h e n a u s e r s t a r t s

    r e c o r d i n g a g e s t u r e , n g e r p o s i t i o n s a n d d i r e c t i o n f r o m e a c h f r a m e i s s t o r e d i n a q u e u e

    c o l l e c t i o n . A q u e u e c o l l e c t i o n w a s c h o s e n f o r t h e r e m o v a l s p e e d o f t h e r s t i n s e r t e d

    d a t a , w h i c h i s O(1)

    . F a s t r e m o v a l s p e e d i s n e e d e d i f a m a x i m u m f r a m e c o u n t i s s e t

    t o g e t h e r w i t h a t i m e l i m i t , w h e r e i n t h e t i m e l i m i t a g r e a t e r n u m b e r o f f r a m e s w i l l b e

    p r o d u c e d t h a n t h e m a x i m u m f r a m e c o u n t n u m b e r . I f t h i s s h o u l d h a p p e n , t h e o l d e s t

    f r a m e w i l l b e r e m o v e d b e f o r e i n s e r t i n g t h e n e w f r a m e . T h i s c a n b e s e e n a s a s a f e t y

    p r o p e r t y t o a v o i d u s i n g t o o m u c h m e m o r y i f t h e t i m e l i m i t i s t o o l a r g e .

    A l i k e l y s c e n a r i o w h e r e t h i s c o u l d h a p p e n i s w h e n t h e r e c o r d i n g i s s e t t o s t a r t a n d

    e n d b y a b u t t o n c l i c k . I f t h e b u t t o n f o r s t o p p i n g t h e r e c o r d i n g i s n e v e r p r e s s e d , w e h a v e

    a w a y t o p r e v e n t m e m o r y l e a k .

    A f t e r t h e r e c o r d i n g t i m e h a s p a s s e d , a l l t h e d a t a f r o m t h e q u e u e c o l l e c t i o n i s e x -

    t r a c t e d a n d s t o r e d i n a n a r r a y i n i t s o w n o b j e c t .

    5 . 4 R e c o g n i z i n g a g e s t u r e

    W e h a v e d i v i d e d t h e D T W r e c o g n i z i n g a l g o r i t h m d o w n t o s e v e r a l s t e p s f o r e a s y u n d e r -

    s t a n d i n g a n d e x p l a n a t i o n .

    5 . 4 . 1 S t e p 1 : F i n d i n g a c a n d i d a t e g e s t u r e

    W e n d t h e c o s t ( e u c l i d e a n d i s t a n c e ) o f t h e c u r r e n t f r a m e a n d c o m p a r e i t t o t h e l a s t

    f r a m e f r o m a l l t h e g e s t u r e s . T h e c o s t i n d i c a t e s h o w s i m i l a r t h e t w o f r a m e s a r e . I f t h e

    t w o f r a m e s a r e i d e n t i c a l , t h e c o s t w i l l b e z e r o . T h e m o r e d i e r e n c e b e t w e e n t h e f r a m e s

    t h e h i g h e r t h e c o s t w i l l b e .

    T o n d a c a n d i d a t e g e s t u r e w e c a l c u l a t e t h e c o s t o f t h e c u r r e n t f r a m e a n d t h e l a s t

    f r a m e f r o m a l l t h e g e s t u r e s . T h e l o w e s t o f t h e c a l c u l a t e d c o s t s w i l l b e o u r c a n d i d a t e

    g e s t u r e f o r f u l l D T W p r o c e s s i n g . H o w e v e r , i f t h e l o w e s t c o s t i s t o o g r e a t , w e d o n ' t s e l e c t

    2 0

  • 7/30/2019 Ryan, Daniel James

    35/81

    5 . 4 R e c o g n i z i n g a g e s t u r e

    a n y c a n d i d a t e . A s t h e g e s t u r e m i g h t b e t h e c l o s e s t m a t c h b u t t h e c o s t d i e r e n c e i s t o o

    h i g h .

    T h i s i s a n p e r f o r m a n c e o p t i m i z a t i o n s o w e d o n ' t n e e d t o d o f u l l D T W c a l c u l a t i o n s

    t h a t w o u l d y i e l d a n o t r e c o g n i z e d g e s t u r e .

    5 . 4 . 2 S t e p 2 : E u c l i d e a n d i s t a n c e m a t r i x

    W e n o w h a v e o u r t w o g e s t u r e s , a p r e r e c o r d e d g e s t u r e ( r e f e r e n c e g e s t u r e ) a n d t h e n e w l y

    p e r f o r m e d g e s t u r e ( i n p u t g e s t u r e ) , t o d o D T W c a l c u l a t i o n s . T h e r s t t h i n g w e h a v e

    t o d o i s t o c a l c u l a t e t h e c o s t b e t w e e n e a c h r e f e r e n c e a n d i n p u t f r a m e s . T h i s c a n b e

    v i s u a l i z e d b y u s i n g a m a t r i x , s e e g u r e 5 . 1 a .

    T h e m a t r i x w i l l s h o w h o w s i m i l a r e a c h f r a m e i s t o a n o t h e r b e t w e e n t h e t w o g e s t u r e s .

    E u c l i d e a n d i s t a n c e = d(p, q) =

    (px qx)2 + (py qy)2 + (pz qz)2 ( 5 . 1 )

    T o t a l e u c l i d e a n d i s t a n c e =

    5

    i=1

    d(pi, qi)( 5 . 2 )

    5 . 4 . 3 S t e p 3 : A c c u m u l a t e d d i s t a n c e m a t r i x

    A f t e r t h e m a t r i x i s l l e d w i t h t h e c o s t , w e c a n b e g i n c o m p u t i n g t h e l o w e s t a c c u m u l a t e d

    c o s t m a t r i x . I n t h i s m a t r i x w e c o m p u t e t h e l o w e s t c o s t t o r e a c h a c e l l . T h e r e a r e t h r e e

    d i e r e n t w a y s w e c a n r e a c h a c e l l ; F r o m t h e l e f t , b o t t o m o r t h e d i a g o n a l d o w n c e l l , s e e

    g u r e 5 . 1 b . I n g u r e 5 . 1 b w e s e e t h a t c

    c a n o n l y b e r e a c h e d b y c e l l 1 , 2 a n d 3 . T h e

    a c c u m u l a t e d c o s t f o r t h e s e c e l l s m u s t b e c a l c u l a t e d b e f o r e w e c a n c a l c u l a t e i t f o r c

    .

    T h e c o s t t o r e a c h a c e l l c

    i s t h e a c c u m u l a t e d c o s t o f t h e o n e o f t h e t h r e e c e l l s t h a t

    c a n r e a c h c

    p l u s t h e e x i s t i n g c o s t i n c

    ( c a l c u l a t e d i n s e c t i o n 5 . 4 . 2 ) . T h e l o w e s t o f t h e

    t h r e e c a l c u l a t e d a c c u m u l a t e d c o s t f o r c

    g i v e s u s t h e n a l a c c u m u l a t e d c o s t f o r c

    , s e e

    e q u a t i o n 5 . 3 . W e h a v e t o d o t h i s f o r a l l t h e c e l l s , e x c e p t f o r c e l l [ 0 , 0 ] w h i c h w e w i l l

    e x p l a i n l a t e r .

    I n g u r e 5 . 3 , c

    i s t h e c e l l w e w a n t t o c a l c u l a t e t h e a c c u m u l a t e d c o s t ( a c ) f o r a n d c

    i s o n e o f t h e t h r e e c e l l s t h a t c a n r e a c h c

    . T h e l o w e s t o f t h e t h r e e cac w i l l b e c h o s e n a s

    t h e n a l v a l u e f o r c

    .

    2 1

  • 7/30/2019 Ryan, Daniel James

    36/81

    5 . G E S T U R E R E C O G N I T I O N

    T h e l e f t m o s t c o l u m n a n d t h e b o t t o m r o w m u s t h a v e t h e i r a c c u m u l a t e d c o s t c a l -

    c u l a t e d r s t . T h e s e c e l l s c a n o n l y b e r e a c h e d f r o m t h e b e l l o w c e l l a n d t h e l e f t c e l l ,

    r e s p e c t i v e l y , a n d t h u s o n l y d e p e n d o n c e l l [ 0 , 0 ] t o h a v e a n i n i t i a l a c c u m u l a t e d c o s t . T h e

    a c c u m u l a t e d c o s t o f c e l l [ 0 , 0 ] i s s e t t o z e r o s i n c e i t i s n o t r e a c h a b l e b y a n y c e l l .

    cac = c

    ac + ccost ( 5 . 3 )

    5 . 4 . 4 S t e p 4 : L o w e s t d i s t a n c e p a t h

    W e n o w n e e d t o n d t h e l o w e s t a c c u m u l a t e d c o s t p a t h f r o m t h e l a s t c e l l (

    [m, n]) t o t h e

    r s t c e l l ( [ 0 , 0 ] ) . B e g i n n i n g a t t h e l a s t c e l l , w e a l w a y s c h o o s e t h e c h e a p e s t c e l l o f t h e

    t h r e e w e c a n c h o o s e f r o m ( l e f t , d o w n a n d t h e d i a g o n a l d o w n c e l l ) a s t h e n e x t c e l l . T h e

    a c c u m u l a t e d c o s t f o r e a c h c e l l i n t h e p a t h i s a d d e d t o g e t h e r t o b e t h e t o t a l p a t h c o s t .

    ( a ) ( b )

    F i g u r e 5 . 1 : H a n d f r a m e m a t r i x .

    5 . 4 . 5 O p t i m i z a t i o n s a n d i m p r o v e m e n t s

    T o g e t a m o r e d e s i r a b l e r e s u l t w e c a n a p p l y s o m e o p t i m i z a t i o n s t o t h e s t e p s a b o v e .

    2 2

  • 7/30/2019 Ryan, Daniel James

    37/81

    5 . 4 R e c o g n i z i n g a g e s t u r e

    5 . 4 . 5 . 1 E u c l i d e a n d i s t a n c e

    T o m a k e m o v e m e n t a l o n g a c e r t a i n a x i s m o r e i m p o r t a n t t h a n o t h e r , w e c a n a p p l y

    w e i g h i n g t o t h e e u c l i d e a n d i s t a n c e c a l c u l a t i o n . W e m o d i f y e q u a t i o n 5 . 1 b y m u l t i p l y i n g

    e a c h a x i s w i t h a w e i g h t w{x,y,z} , w h e r e 0 w{x,y,z} 1 . E q u a t i o n 5 . 4 s h o w s t h e

    m o d i e d e u c l i d e a n d i s t a n c e w i t h w e i g h t i n g .

    W e i g h t e d e u c l i d e a n d i s t a n c e = dw(p, q) =

    wx(px qx)2 + wy(py qy)2 + wz(pz qz)2

    ( 5 . 4 )

    W i t h t h i s i m p r o v e m e n t w e c a n b e t t e r r e c o g n i z e g e s t u r e s t h a t d o n o t r e l y o n a l l t h r e e

    a x i s . S u c h a g e s t u r e c o u l d b e a s w i p i n g g e s t u r e f r o m l e f t t o r i g h t a s t h i s g e s t u r e w o u l d

    m a i n l y u s e t h e x - a x i s . I t i s t h e r e f o r e d e s i r a b l e t o l e t t h e o t h e r a x i s h a v e a l o w e r i m p a c t

    o n t h e c o s t .

    A w e i g h t i n g v a l u e o f z e r o o n a a x i s w o u l d b e t o n o t t a k e t h e a x i s i n t o c o n s i d e r a t i o n

    w h e n c a l c u l a t i n g t h e c o s t .

    5 . 4 . 5 . 2 A c c u m u l a t e d c o s t m a t r i x

    S i n c e o u r g o a l i s t o n d t h e l o w e s t a c c u m u l a t e d c o s t p a t h a n d o p t i m a l l y t h a t w o u l d b e a

    s t r a i g h t d i a g o n a l l i n e f r o m [m, n]

    t o [ 0 , 0 ] , w e c a n d o a s m a l l o p t i m i z a t i o n t o t h e d i a g o n a l

    c o s t i n s e c t i o n 5 . 4 . 3 . I n s t e a d o f a d d i n g t h e c o s t o f c

    t o t h e d i a g o n a l c e l l s a c c u m u l a t e d

    c o s t , w e a d d

    c2

    , t h u s m a k i n g g o i n g d i a g o n a l m o r e d e s i r a b l e . S e e e q u a t i o n 5 . 5 .

    cac = cdac +

    ccost2

    ( 5 . 5 )

    T o m a k e t h i n g s c l e a r ; w e u s e e q u a t i o n 5 . 3 t o c a l c u l a t e t h e a c c u m u l a t e d c o s t t o c

    f r o m t h e l e f t a n d b e l l o w c e l l a n d e q u a t i o n 5 . 5 f o r t h e d i a g o n a l d o w n c e l l .

    T o g e n e r a l i z e t h e e q u a t i o n s w e c a n u s e a w e i g h t i n g f a c t o r w

    f o r e a c h d i r e c t i o n e . g

    wh f o r h o r i z o n t a l m o v e m e n t ( l e f t c e l l ) , wv f o r v e r t i c a l m o v e m e n t ( b e l o w c e l l ) a n d wd

    f o r d i a g o n a l m o v e m e n t ( d i a g o n a l d o w n c e l l ) . T h i s g i v e s u s e q u a t i o n 5 . 6 .

    cac = c

    ac + w

    ccost ( 5 . 6 )

    T o u s e e q u a t i o n 5 . 6 t o g e t a b o n u s t o t h e d i a g o n a l c e l l , a s s h o w n i n e q u a t i o n 5 . 5 ,

    a n d n o b o n u s t o t h e l e f t o r b o t t o m c e l l , w e s e t w{h,v,d} t o w = {1, 1, 0.5}.

    2 3

  • 7/30/2019 Ryan, Daniel James

    38/81

    5 . G E S T U R E R E C O G N I T I O N

    5 . 4 . 5 . 3 L o w e s t d i s t a n c e p a t h

    W e c a n o p t i m i z e t h e p a t h n d i n g b y c o n s t r u c t i n g s o m e c o n s t r a i n t s , s u c h a s t h e S a k o e -

    C h i b a b a n d ( 1 2 ) ( g u r e 5 . 2 a ) o r t h e I t a k u r a p a r a l l e l o g r a m ( 1 3 ) ( g u r e 5 . 2 b ) .

    C o n s t r a i n t s a s t h o s e w i l l f o r c e t h e w a r p i n g p a t h t o n o t d e v i a t e t o o m u c h f r o m t h e

    s t r a i g h t d i a g o n a l p a t h . T h e p a t h n d i n g c a n a l s o b e a b o r t e d s h o u l d i t g o b e y o n d t h e

    c o n s t r a i n t s . A p r o b l e m c a n a r i s e i f t h e o p t i m a l p a t h h a s s o m e c e l l s o u t s i d e o f t h e

    c o n s t r a i n t s . T h i s w o u l d l e a d t o a h i g h e r t o t a l p a t h c o s t t h a t c o u l d i m p a c t o u r d e c i s i o n

    i f t h e g e s t u r e s h o u l d b e s e e n a s r e c o g n i z e d .

    G e n e r a l l y c o n s t r a i n t s w i l l s p e e d u p t h e D T W a l g o r i t h m s i n c e w e d o n o t n e e d t o

    c a l c u l a t e t h e c e l l s o u t s i d e o f t h e c o n s t r a i n t . T h i s c o u l d l e a d t o a s i g n i c a n t p e r f o r m a n c e

    g a i n .

    ( a ) S a k o e - C h i b a b a n d ( b ) I t a k u r a p a r a l l e l o g r a m

    F i g u r e 5 . 2 : W a r p i n g C o n s t r a i n t s .

    5 . 5 S t o r e g e s t u r e s

    T h e r e c o r d e d g e s t u r e s c a n a l s o b e s t o r e d t o d i s k . I t i s s a v e d a s a X M L - l e t o m a k e i t

    a v a i l a b l e t o b e u s e d i n o t h e r a p p l i c a t i o n s o r t o b e r e a d b y h u m a n s . T h e X M L - l e w i l l

    c o n t a i n n g e r p o s i t i o n s a n d d i r e c t i o n f o r e a c h f r a m e i n a g e s t u r e . O n e l e c a n c o n t a i n

    m u l t i p l e g e s t u r e s .

    2 4

  • 7/30/2019 Ryan, Daniel James

    39/81

    5 . 6 R e t r i e v e s t o r e d g e s t u r e s

    5 . 6 R e t r i e v e s t o r e d g e s t u r e s

    S i n c e w e c a n s t o r e g e s t u r e s t o d i s k , w e c a n a l s o r e t r i e v e t h e m . I t w i l l r e a d a X M L - l e

    w i t h n g e r p o s i t i o n s a n d d i r e c t i o n a n d a d d e a c h g e s t u r e f r o m t h e l e t o t h e l i s t o f a c t i v e

    g e s t u r e s t o b e r e c o g n i z e d .

    2 5

  • 7/30/2019 Ryan, Daniel James

    40/81

    5 . G E S T U R E R E C O G N I T I O N

    2 6

  • 7/30/2019 Ryan, Daniel James

    41/81

    6

    A u t o d e p t h i n t e r v a l d e t e c t i o n

    T h e a u t o d e p t h r a n g e c a l i b r a t i o n w i l l c r e a t e a d e p t h i n t e r v a l t h a t i s l i m i t e d b y t w o

    h a n d s . W h e n t h e d e p t h i n t e r v a l i s f o u n d i t w i l l d i s c a r d a l l d a t a o u t s i d e t h i s r a n g e , o n l y

    a l l o w i n g o b j e c t s t o b e d e t e c t e d i n t h e n e w l y f o u n d d e p t h i n t e r v a l . T h e a l g o r i t h m w o r k s

    b y d e t e c t i n g t h e n g e r s o f t h e h a n d c l o s e s t t o t h e s e n s o r a n d t h e n d e t e c t i n g t h e n g e r s

    o f t h e s e c o n d h a n d ; w h i c h i s f u r t h e r a w a y f r o m t h e s e n s o r . T h e d e p t h i n t e r v a l i s s e t

    f r o m t h e p o s i t i o n o f t h e r s t h a n d t o t h e s e c o n d h a n d . A f t e r t h e s c a n i s c o m p l e t e w e

    c a n f r e e l y m o v e o u r h a n d s i n t h e d e p t h i n t e r v a l .

    T h e a l g o r i t h m w o r k s b y d e t e c t i n g h o w m a n y n g e r s w e r e f o u n d a t a d e t e r m i n e d

    d e p t h i n t e r v a l . I t w i l l s t a r t t h e s c a n f r o m t h e m i n i m u m p o s s i b l e d i s t a n c e f r o m t h e

    s e n s o r . I n o u r c a s e w i t h t h e K i n e c t f o r X b o x s e n s o r i t i s a t 8 0 0 m i l l i m e t e r s . T h e r s t

    p a s s o f t h e a u t o s c a n w i l l s t a r t a t 8 0 0 m i l l i m e t e r s w i t h a n i n t e r v a l , b

    , o f 1 5 0 m i l l i m e t e r s .

    T h e i n t e r v a l v a l u e i s b a s e d o n h o w w i d e a h a n d i s f r o m t h e t i p o f t h e t h u m b t o t h e

    t i p o f t h e l i t t l e n g e r w h e n a l l t h e n g e r s a r e s p r e a d o u t . W e n e e d t h e i n t e r v a l t o b e

    a t l e a s t t h i s w i d e b e c a u s e t h e h a n d c o u l d b e r o t a t e d a r o u n d t h e y - a x i s a n d w e n e e d

    t o b e a b l e t o d e t e c t a l l t h e n g e r s i n a t l e a s t o n e p a s s . A t t h e s u b s e q u e n t p a s s e s t h e

    i n t e r v a l w i l l b e g i n a t prevS tart + b

    2m i l l i m e t e r s a n d e n d a t

    prevStart + b2 3

    , w h e r e

    prevS tarti s t h e p r e v i o u s s t a r t d e p t h . T h i s w i l l o v e r l a p t h e p r e v i o u s i n t e r v a l , a l l o w i n g

    u s t o c o r r e c t l y d e t e c t t h e n u m b e r o f n g e r s i f t h e h a n d s h o u l d b e s p l i t i n h a l f a t t h e

    e n d d e p t h .

    W h e n w e c o r r e c t l y n d t h e r s t h a n d w e s e t t h e n a l s t a r t d e p t h

    pt o b e t h e s t a r t

    d e p t h o f t h e c u r r e n t p a s s . T h e n i n t h e n e x t p a s s t h e s t a r t d e p t h w i l l b e p

    +b

    , t h i s i s t o

    a v o i d d e t e c t i n g t h e f o u n d n g e r s t w i c e . W h e n w e t h e n c o r r e c t l y n d t h e s e c o n d h a n d

    2 7

  • 7/30/2019 Ryan, Daniel James

    42/81

    6 . A U T O D E P T H I N T E R V A L D E T E C T I O N

    w e s e t t h e n a l e n d d e p t h q t o b e t h e e n d d e p t h o f t h e c u r r e n t p a s s . T h e a l g o r i t h m w i l l

    r e t u r n p

    a n dq

    , w h i c h i n t u r n w i l l b e u s e d a s t h e d e p t h i n t e r v a l f o r t h e r a n g e n d e r .

    I f o n l y o n e h a n d w a s f o u n d , o r n o n e a t a l l , i t w i l l r e t u r n d e f a u l t v a l u e s f o r p

    a n dq

    .

    T h e d e f a u l t s t a r t d e p t h i s t h e m i n i m u m d e t e c t i o n d i s t a n c e o f t h e s e n s o r . T h e d e f a u l t

    e n d d e p t h i s t h e d e f a u l t s t a r t d e p t h + b

    .

    W e e n c o u n t e r s o m e p r o b l e m s i f w e g o b e y o n d 1 5 0 0 m i l l i m e t e r s f r o m t h e K i n e c t

    f o r X b o x s e n s o r . A t t h i s r a n g e t h e r e w i l l b e a s i g n i c a n t a m o u n t o f a r t i f a c t s a r o u n d

    o b j e c t s . T h i s l e a d s t o p o o r n g e r d e t e c t i o n q u a l i t y a n d t h a t w i l l i m p a c t t h e a b i l i t y t o

    c o r r e c t l y n d t h e d e p t h i n t e r v a l . T o m a k e t h e a l g o r i t h m m o r e e x i b l e w e o n l y r e q u i r e

    f o u r n g e r s t o b e d e t e c t e d f o r a h a n d t o b e c o r r e c t l y d e t e c t e d . T h i s w i l l g i v e a h i g h e r

    r a t e o f c o r r e c t d e t e c t i o n s .

    T h e r e i s a l s o s u p p o r t t o u s e o n l y o n e h a n d t o c r e a t e a d e p t h i n t e r v a l . A f t e r i t

    c o r r e c t l y d e t e c t s t h e c l o s e s t h a n d i t w i l l s e t t h e n a l s t a r t d e p t h t o t h e s t a r t v a l u e o f

    t h e c u r r e n t p a s s . T h e n a l e n d d e p t h i s t h e n t h e s t a r t d e p t h + u

    , w h e r e u

    i s a u s e r

    s p e c i e d v a l u e i n m i l l i m e t e r s .

    F i g u r e 6 . 1 : E x a m p l e o f a s c a n s e q u e n c e .

    I n g u r e 6 . 1 w e s e e a n e x a m p l e o f h o w t h e a u t o s c a n n i n g w o u l d n d t h e d e p t h

    i n t e r v a l b e t w e e n t w o h a n d s . T h e r s t h a n d i s f o u n d i n t h e s e c o n d p a s s a n d w e s e t t h e

    n a l s t a r t d e p t h t o t h e c u r r e n t p a s s s t a r t d e p t h , p = 875mm

    . A t t h e n e x t p a s s w e s k i p

    t h e o v e r l a p t o a v o i d t h e p o s s i b i l i t y o f d e t e c t i n g t h e r s t h a n d a g a i n . I n t h e s e v e n t h

    p a s s w e n d t h e s e c o n d h a n d a n d s e t t h e n a l e n d d e p t h t o t h e c u r r e n t e n d d e p t h ,

    q = 1475mm. T h e a l g o r i t h m i s n o w n i s h e d a n d w e w i l l o n l y b e a b l e t o d e t e c t o b j e c t s

    2 8

  • 7/30/2019 Ryan, Daniel James

    43/81

    t h a t a r e i n t h e i n t e r v a l p t o q. F i g u r e 6 . 2 s h o w s t h e a c t u a l d e p t h d a t a f r o m t h e s c a n .

    T h e r s t h a n d i s f o u n d i n 6 . 2 b a n d t h e s e c o n d h a n d i n 6 . 2 g .

    ( a ) 8 0 0 - 9 5 0 m m . ( b ) 8 7 5 - 1 0 2 5 m m . ( c ) 9 5 0 - 1 1 0 0 m m .

    ( d ) 1 1 0 0 - 1 2 5 0 m m . ( e ) 1 1 7 5 - 1 3 2 5 m m . ( f ) 1 2 5 0 - 1 4 0 0 m m .

    ( g ) 1 3 2 5 - 1 4 7 5 m m .

    F i g u r e 6 . 2 : D e p t h f r a m e s f r o m a n a u t o i n t e r v a l s c a n .

    2 9

  • 7/30/2019 Ryan, Daniel James

    44/81

    6 . A U T O D E P T H I N T E R V A L D E T E C T I O N

    3 0

  • 7/30/2019 Ryan, Daniel James

    45/81

    7

    E n h a n c e m e n t s

    T h e d e p t h i m a g e s f r o m t h e K i n e c t p r o d u c e s j i t t e r a n d a r t i f a c t s . T h i s m a k e s t h e r e s u l t

    f r o m c o n t o u r t r a c k i n g u n p r e d i c t a b l e . T h i s e e c t i s c a s c a d i n g , m e a n i n g o t h e r a l g o r i t h m s

    d e p e n d i n g o n c o n t o u r d a t a w i l l a l s o b e n e g a t i v e l y a e c t e d .

    T o c o u n t e r t h e s e e e c t s w e h a v e c r e a t e d s o m e a l g o r i t h m s t h a t w i l l h e l p g i v e m o r e

    c o n s i s t e n t r e s u l t s .

    7 . 1 S m o o t h i n g

    T o m a k e t h e n g e r s p o s i t i o n m o r e c o n s i s t e n t w h e n j i t t e r o c c u r s , w e c a n a p p l y a s m o o t h -

    i n g a l g o r i t h m t o t h e n g e r s p o s i t i o n s . A s m o o t h i n g a l g o r i t h m r e d u c e s t h e c h a n g e b e -

    t w e e n t h e n e w a n d o l d p o i n t .

    p

    = q+ s(p q)( 7 . 1 )

    W e h a v e i m p l e m e n t e d e x p o n e n t i a l s m o o t h i n g , a s s h o w n i n e q u a t i o n 7 . 1 . I n e q u a t i o n

    7 . 1 w e h a v e t h e c u r r e n t p o i n t

    p, t h e p r e v i o u s p o i n t

    q, t h e n e w p o i n t w i t h s m o o t h i n g

    a p p l i e d p

    a n d t h e s m o o t h i n g f a c t o r s

    , w h e r e 0 s 1 .

    7 . 2 P r e d i c t i o n

    W e h a v e a l s o i m p l e m e n t e d a n a l g o r i t h m t h a t e n a b l e s u s t o p r e d i c t w h e r e a n g e r t i p i s

    g o i n g t o b e i n t h e n e x t f r a m e . T h e a l g o r i t h m d e t e c t s i f o n e o r m o r e n g e r p o s i t i o n s h a s

    b e e n m i s s i n g i n u p t o n

    f r a m e s , w h e r e n

    i s a s m a l l n u m b e r , a n d r e p l a c e s t h e m w i t h a

    p r e d i c t e d n g e r p o s i t i o n .

    3 1

  • 7/30/2019 Ryan, Daniel James

    46/81

    7 . E N H A N C E M E N T S

    7 . 2 . 1 E x p o n e n t i a l m o v i n g a v e r a g e

    W e u s e e x p o n e n t i a l m o v i n g a v e r a g e ( E M A ) t o p r e d i c t w h e r e a n g e r i s g o i n g t o b e i n t h e

    n e x t f r a m e . T h e e q u a t i o n i s s h o w n i n e q u a t i o n 7 . 2 , w h e r e t

    i s t h e f r a m e n u m b e r ( t i m e

    p e r i o d ) , y

    i s t h e o b s e r v a t i o n , s

    i s t h e p r e d i c t i o n a n d w

    i s t h e w e i g h t f a c t o r ( 0 < w < 1

    ) .

    st = wyt + (1 w)st1 ( 7 . 2 )

    T h e E M A a l g o r i t h m n e e d s a s e t o f v a l u e s t o p r o d u c e a g o o d p r e d i c t i o n . E v e r y

    c o r r e c t f r a m e i s s t o r e d i n a q u e u e c o l l e c t i o n t h a t h o l d s 3 0 f r a m e s . W h e n t h e q u e u e

    i s s a t u r a t e d a n d a n i n c o n s i s t e n t n g e r c o u n t h a s b e e n d e t e c t e d , a l l t h e f r a m e s i n t h e

    q u e u e i s p a s s e d t o t h e E M A a l g o r i t h m . I t w i l l t h e n p r o d u c e t h e n e x t f r a m e a n d u s e

    t h o s e v a l u e s f o r t h e m i s s i n g n g e r s .

    A l l t h e c o r r e c t f r a m e s i s a l s o p a s s e d t o t h e g e s t u r e a l g o r i t h m . T h i s e n s u r e s t h e

    c o n s i s t e n t n g e r c o u n t n e e d e d f o r g e s t u r e r e c o r d i n g a n d r e c o g n i t i o n . T h e g e s t u r e r e c o g -

    n i t i o n w i l l h o w e v e r l a g u p t o n

    f r a m e s .

    3 2

  • 7/30/2019 Ryan, Daniel James

    47/81

    8

    V i r t u a l r e a l i t y

    T h e v i r t u a l r e a l i t y w e h a v e c r e a t e d a t t e m p t s t o u s e t h e s c r e e n a s a p h y s i c a l w i n d o w t o a

    s i m u l a t e d e n v i r o n m e n t . T h i s c h a p t e r g i v e s a n b a s i c o v e r v i e w o n h o w w e h a v e a c h i e v e d

    t h i s . M o r e i n d e p t h e x p l a n a t i o n c a n b e f o u n d i n ( 1 4 ) a n d ( 1 5 ) .

    8 . 1 R e l a t e d w o r k s

    J o h n n y C . L e e b r o u g h t t h e i d e a o f v i r t u a l r e a l i t y w i t h h e a d t r a c k i n g a n d c h e a p c o n s u m e r

    h a r d w a r e t o t h e m a s s e s w i t h a v i d e o h e p o s t e d o n Y o u T u b e i n 2 0 0 7 . H e u s e d t h e N i t e n d o

    W i i r e m o t e a n d a h e a d m o u n t e d s e n s o r t o t r a c k t h e u s e r s h e a d p o s i t i o n . T h e p e r s p e c t i v e

    o n t h e s c r e e n c h a n g e s w i t h h e a d m o v e m e n t t o c r e a t e a v i r t u a l e n v i r o n m e n t i n s i d e t h e

    s c r e e n ( 1 6 ) .

    8 . 2 I n t r o d u c t i o n

    O u r v i r t u a l r e a l i t y w o r k s b y c r e a t i n g a n o - a x i s p e r s p e c t i v e t h a t f o l l o w s t h e h e a d m o v e -

    m e n t o f a u s e r .

    8 . 2 . 1 O n - a x i s p e r s p e c t i v e

    O n - a x i s p e r s p e c t i v e i s t h e p e r s p e c t i v e m o s t o f u s i s k n o w w i t h . I t i s t h e p e r s p e c t i v e

    u s e d i n m o s t 3 D c o m p u t e r a n d c o n s o l e g a m e s . T h i s p e r s p e c t i v e i s s h o w n i n g u r e 8 . 1 a .

    T h e r e t h e u s e r s e y e s , o r t h e c a m e r a o r i g i n , p

    a r e a l w a y s c e n t e r e d t o t h e s c r e e n . T h e

    v i e w f r u s t u m s s i z e d o e s n o t c h a n g e i f w e m o v e t h e v i r t u a l c a m e r a a r o u n d .

    3 3

  • 7/30/2019 Ryan, Daniel James

    48/81

    8 . V I R T U A L R E A L I T Y

    T o v i s u a l i z e o n - a x i s p e r s p e c t i v e w e c a n t h i n k o f u s l o o k i n g t h r o u g h a w i n d o w . W e

    h a v e o u r h e a d c e n t e r e d a n d p e r p e n d i c u l a r t o t h e c e n t e r o f t h e w i n d o w . N o w i f w e w a n t

    t o v i e w s o m e t h i n g e l s e , t h a t i s o u t s i d e o f t h e v i e w s p a c e w e c a n s e e t h r o u g h t h e w i n d o w ,

    w e m u s t a l s o m o v e t h e w i n d o w t o k e e p o u r h e a d c e n t e r e d a n d p e r p e n d i c u l a r t o i t .

    8 . 2 . 2 O - a x i s p e r s p e c t i v e

    O - a x i s p e r s p e c t i v e i s w h e n t h e e y e p o s i t i o n d o e s n o t n e e d t o b e a t t h e c e n t e r o f t h e

    s c r e e n . T h i s p e r s p e c t i v e i s s h o w n i n g u r e 8 . 1 b . T h e r e w e c a n s e e t h a t t h e u s e r s e y e

    p o s i t i o n , o r t h e c a m e r a o r i g i n , p

    d o e s n o t n e e d t o b e c e n t e r e d t o t h e s c r e e n . I n t h i s

    p e r s p e c t i v e t h e s i z e o f t h e v i e w f r u s t u m c h a n g e s d e p e n d i n g o n t h e u s e r s h e a d p o s i t i o n .

    T o v i s u a l i z e o - a x i s p e r s p e c t i v e w e c a n t h i n k o f u s l o o k i n g t h r o u g h a w i n d o w . N o w

    t h e w i n d o w i s i n a x e d p o s i t i o n a n d d o e s n o t m o v e . I f w e w a n t t o s e e s o m e t h i n g

    o u t s i d e o f t h e i n i t i a l v i e w s p a c e t h r o u g h t h e w i n d o w s , w e n e e d o n l y t o m o v e o u r h e a d .

    8 . 3 V i e w f r u s t u m

    I n o - a x i s p e r s p e c t i v e t h e v i e w f r u s t u m s i z e c h a n g e s d e p e n d i n g w h e r e w e h a v e o u r h e a d

    r e l a t i v e t o t h e s c r e e n .

    T h e m a j o r g r a p h i c s l i b r a r y D i r e c t X h a s b u i l t i n s u p p o r t t o c r e a t e o - a x i s p e r s p e c -

    t i v e . T h i s m e a n s t h a t w e d o n ' t h a v e t o m a n u a l l y c r e a t e t h e p r o j e c t i o n m a t r i x n e e d e d .

    A s X N A u s e s D i r e c t X w e h a v e a n e a s y w a y t o c r e a t e t h e m a t r i x ( 1 7 ) .

    T o c r e a t e t h e m a t r i x w e n e e d t o d e t e r m i n e t h e v i e w f r u s t u m e x t e n t s . T h e e x t e n t s

    t h a t n e e d s t o b e c a l c u l a t e d i s s e e n i n g u r e 8 . 2 . T h e r e t

    ,b

    ,r

    a n dl

    a r e t h e t o p , b o t t o m ,

    r i g h t a n d l e f t e x t e n t s , r e s p e c t i v e l y . I n a d d i t i o n w e a l s o n e e d t o c h o o s e a n e a r a n d f a r

    v i e w p l a n e .

    T h e e x t e n t s a r e c a l c u l a t e d i n e q u a t i o n 8 . 1 . W h e r e r

    i s t h e a s p e c t r a t i o o f t h e s c r e e n ,

    vi s t h e n e a r v i e w p l a n e a n d

    pi s t h e p o s i t i o n o f t h e u s e r s h e a d . T h i s e q u a t i o n i s t h e

    3 4

  • 7/30/2019 Ryan, Daniel James

    49/81

    8 . 3 V i e w f r u s t u m

    ( a ) O n - a x i s p e r s p e c t i v e ( b ) O - a x i s p e r s p e c t i v e

    ( c ) O n - a x i s p e r s p e c t i v e ( d ) O - a x i s p e r s p e c t i v e

    F i g u r e 8 . 1 : P e r s p e c t i v e .

    s a m e u s e d b y ( 2 ) .

    t o p

    =v(1/2 py)

    pz

    b o t t o m =

    v(1/2 py)

    pz

    r i g h t =

    v(1/2r px)

    pz

    l e f t =

    v(1/2r px)

    pz

    ( 8 . 1 )

    F i g u r e 8 . 3 d i s p l a y s a n t o p d o w n v i e w o f a u s e r a n d a s c r e e n . W e c a n s e e t h a t t h e

    s c r e e n w o r k s l i k e a p h y s i c a l w i n d o w i n t o t h e v i r t u a l e n v i r o n m e n t .

    3 5

  • 7/30/2019 Ryan, Daniel James

    50/81

    8 . V I R T U A L R E A L I T Y

    F i g u r e 8 . 2 : F r u s t u m e x t e n t s .

    ( a ) ( b )

    F i g u r e 8 . 3 : V R s p a c e .

    8 . 4 I m p l e m e n t a t i o n

    T h e h e a d t r a c k i n g i s p e r f o r m e d b y t h e K i n e c t a n d t h e p e r s p e c t i v e c a m e r a i s i m p l e -

    m e n t e d a s a X N A g a m e c o m p o n e n t . X N A w a s u s e d s i n c e i t s i m p l i e s t h e i m p l e m e n t a -

    t i o n a n d a l l o w s t h e c o d e t o b e u s e d o n d i e r e n t . N E T p l a t f o r m s , s u c h a s t h e X b o x 3 6 0

    a n d W i n d o w s P h o n e .

    V R c a n b e u s e d i n c o m b i n a t i o n w i t h g e s t u r e r e c o g n i t i o n .

    8 . 5 L i m i t a t i o n s

    A d r a w b a c k w i t h c r e a t i n g v i r t u a l r e a l i t y t h i s w a y i s t h a t i t c a n o n l y b e u s e d b y o n e u s e r

    a t a t i m e . I f s o m e o n e e l s e w a t c h e s t h e s c r e e n , i t w i l l l o o k w e i r d a s t h e o b j e c t s a p p e a r

    s k e w e d .

    3 6

  • 7/30/2019 Ryan, Daniel James

    51/81

    9

    R e s u l t s

    T h e r e s u l t i s a n e a s y t o u s e a n d e a s y t o u n d e r s t a n d A P I . A m o d u l a r p r o g r a m m i n g

    t e c h n i q u e w i t h t h e u s e o f i n t e r f a c e s w a s u s e d t o m a k e t h e A P I t o b e e x i b l e a n d e a s y

    t o u s e ( 1 8 ) . C o d e e x a m p l e s i n t h i s c h a p t e r u s e s C # s y n t a x .

    9 . 1 P r o g r a m o w

    A n o v e r v i e w o f t h e i m p l e m e n t e d a p p l i c a t i o n o w c a n b e s e e n i n a p p e n d i x B . 2 .

    9 . 2 E v e n t s

    T h e A P I i s e v e n t - d r i v e n . T h i s g i v e s u s c o m p l e t e c o n t r o l o v e r w h e n w e w a n t t h e a l g o -

    r i t h m s t o r u n a n d w h a t w e w a n t t o d o a f t e r i t h a s n i s h e d i t s t a s k . T h i s a l s o m a t c h e s

    h o w w e a r e n o t i e d o f n e w d a t a f r o m t h e K i n e c t w i t h t h e K i n e c t f o r W i n d o