d i f f   - - g i t   a / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / C a m e r a M a n a g e r . k t   b / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / C a m e r a M a n a g e r . k t 
 
 i n d e x   b 2 7 a 2 0 3 . . 4 5 1 2 5 2 7   1 0 0 6 4 4 
 
 - - -   a / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / C a m e r a M a n a g e r . k t 
 
 + + +   b / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / C a m e r a M a n a g e r . k t 
 
 @ @   - 2 3 3 , 1 7   + 2 3 3 , 1 5   @ @   c l a s s   C a m e r a M a n a g e r ( p r i v a t e   v a l   a c t i v i t y :   A c t i v i t y )   :   P o s e L a n d m a r k e r H e l p e r . L a n d m 
 
                           / /   - - - - -   F P S   c a l c u l a t i o n   - - - - - 
 
                           v a l   c u r r e n t T i m e   =   S y s t e m C l o c k . e l a p s e d R e a l t i m e ( ) 
 
                           v a l   d e l t a T i m e   =   c u r r e n t T i m e   -   l a s t F r a m e T i m e 
 
 + 
 
                           i f   ( d e l t a T i m e   >   0 )   { 
 
                                   f p s   =   1 0 0 0 . 0   /   d e l t a T i m e 
 
                           } 
 
                           l a s t F r a m e T i m e   =   c u r r e n t T i m e 
 
                           / /   - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   
 
 -                         v a l   h e l p e r   =   p o s e L a n d m a r k e r H e l p e r 
 
 -                         i f   ( h e l p e r   = =   n u l l )   { 
 
 -                                 i m a g e P r o x y . c l o s e ( ) 
 
 -                                 r e t u r n @ s e t A n a l y z e r 
 
 -                         } 
 
 +                         v a l   h e l p e r   =   e n s u r e H e l p e r ( ) 
 
 + 
 
   
 
                           t r y   { 
 
                                   h e l p e r . d e t e c t L i v e S t r e a m ( 
 
 d i f f   - - g i t   a / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / F l u t t e r M p P o s e L a n d m a r k e r P l u g i n . k t   b / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / F l u t t e r M p P o s e L a n d m a r k e r P l u g i n . k t 
 
 i n d e x   1 b f 4 7 0 2 . . d 2 c 2 a 0 8   1 0 0 6 4 4 
 
 - - -   a / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / F l u t t e r M p P o s e L a n d m a r k e r P l u g i n . k t 
 
 + + +   b / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / F l u t t e r M p P o s e L a n d m a r k e r P l u g i n . k t 
 
 @ @   - 3 4 , 6   + 3 4 , 8   @ @   c l a s s   F l u t t e r M p P o s e L a n d m a r k e r P l u g i n   :   F l u t t e r P l u g i n ,   E v e n t C h a n n e l . S t r e a m H a n d l e r , 
 
           p r i v a t e   v a r   i s L o g g i n g E n a b l e d :   B o o l e a n   =   f a l s e 
 
           p r i v a t e   v a r   p e n d i n g P e r m i s s i o n R e s u l t :   M e t h o d C h a n n e l . R e s u l t ?   =   n u l l 
 
           p r i v a t e   v a l   C A M E R A _ P E R M I S S I O N _ R E Q U E S T _ C O D E   =   9 8 7 6 
 
 +         p r i v a t e   v a r   i s C a m e r a R e a d y   =   f a l s e 
 
 +         p r i v a t e   v a r   p e n d i n g A n a l y s i s E n a b l e   =   f a l s e 
 
   
 
           o v e r r i d e   f u n   o n A t t a c h e d T o E n g i n e ( @ N o n N u l l   f l u t t e r P l u g i n B i n d i n g :   F l u t t e r P l u g i n . F l u t t e r P l u g i n B i n d i n g )   { 
 
                   L o g . d ( " P o s e L a n d m a r k e r P l u g i n " ,   " o n A t t a c h e d T o E n g i n e   c a l l e d " ) 
 
 d i f f   - - g i t   a / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / P o s e L a n d m a r k e r H e l p e r . k t   b / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / P o s e L a n d m a r k e r H e l p e r . k t 
 
 i n d e x   b a 2 6 2 9 e . . c 5 e 8 5 6 e   1 0 0 6 4 4 
 
 - - -   a / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / P o s e L a n d m a r k e r H e l p e r . k t 
 
 + + +   b / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / P o s e L a n d m a r k e r H e l p e r . k t 
 
 @ @   - 1 4 , 7   + 1 4 , 7   @ @ 
 
     *   l i m i t a t i o n s   u n d e r   t h e   L i c e n s e . 
 
     * / 
 
   p a c k a g e   c o m . c a r e c o d e . f l u t t e r _ m p _ p o s e _ l m 
 
 - i m p o r t   c o m . c a r e c o d e . f l u t t e r _ m p _ p o s e _ l m . Y u v T o R g b C o n v e r t e r 
 
 + 
 
   i m p o r t   a n d r o i d . c o n t e n t . C o n t e x t 
 
   i m p o r t   a n d r o i d . g r a p h i c s . B i t m a p 
 
   i m p o r t   a n d r o i d . g r a p h i c s . M a t r i x 
 
 @ @   - 3 4 , 1 6   + 3 4 , 1 6   @ @   i m p o r t   c o m . g o o g l e . m e d i a p i p e . t a s k s . v i s i o n . p o s e l a n d m a r k e r . P o s e L a n d m a r k e r R e s u l t 
 
   i m p o r t   j a v a . u t i l . c o n c u r r e n t . a t o m i c . A t o m i c B o o l e a n 
 
   
 
   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
 -         v a r   m i n P o s e D e t e c t i o n C o n f i d e n c e :   F l o a t   =   D E F A U L T _ P O S E _ D E T E C T I O N _ C O N F I D E N C E , 
 
 -         v a r   m i n P o s e T r a c k i n g C o n f i d e n c e :   F l o a t   =   D E F A U L T _ P O S E _ T R A C K I N G _ C O N F I D E N C E , 
 
 -         v a r   m i n P o s e P r e s e n c e C o n f i d e n c e :   F l o a t   =   D E F A U L T _ P O S E _ P R E S E N C E _ C O N F I D E N C E , 
 
 -         v a r   c u r r e n t M o d e l :   I n t   =   M O D E L _ P O S E _ L A N D M A R K E R _ L I T E , 
 
 -         v a r   c u r r e n t D e l e g a t e :   I n t   =   D E L E G A T E _ G P U , 
 
 -         v a r   r u n n i n g M o d e :   R u n n i n g M o d e   =   R u n n i n g M o d e . I M A G E , 
 
 -         v a l   c o n t e x t :   C o n t e x t , 
 
 - 
 
 -         / /   t h i s   l i s t e n e r   i s   o n l y   u s e d   w h e n   r u n n i n g   i n   R u n n i n g M o d e . L I V E _ S T R E A M 
 
 -         v a l   p o s e L a n d m a r k e r H e l p e r L i s t e n e r :   L a n d m a r k e r L i s t e n e r ?   =   n u l l 
 
 +                 v a r   m i n P o s e D e t e c t i o n C o n f i d e n c e :   F l o a t   =   D E F A U L T _ P O S E _ D E T E C T I O N _ C O N F I D E N C E , 
 
 +                 v a r   m i n P o s e T r a c k i n g C o n f i d e n c e :   F l o a t   =   D E F A U L T _ P O S E _ T R A C K I N G _ C O N F I D E N C E , 
 
 +                 v a r   m i n P o s e P r e s e n c e C o n f i d e n c e :   F l o a t   =   D E F A U L T _ P O S E _ P R E S E N C E _ C O N F I D E N C E , 
 
 +                 v a r   c u r r e n t M o d e l :   I n t   =   M O D E L _ P O S E _ L A N D M A R K E R _ L I T E , 
 
 +                 v a r   c u r r e n t D e l e g a t e :   I n t   =   D E L E G A T E _ G P U , 
 
 +                 v a r   r u n n i n g M o d e :   R u n n i n g M o d e   =   R u n n i n g M o d e . I M A G E , 
 
 +                 v a l   c o n t e x t :   C o n t e x t , 
 
 + 
 
 +                 / /   t h i s   l i s t e n e r   i s   o n l y   u s e d   w h e n   r u n n i n g   i n   R u n n i n g M o d e . L I V E _ S T R E A M 
 
 +                 v a l   p o s e L a n d m a r k e r H e l p e r L i s t e n e r :   L a n d m a r k e r L i s t e n e r ?   =   n u l l 
 
   )   { 
 
   
 
           / /   F o r   t h i s   e x a m p l e   t h i s   n e e d s   t o   b e   a   v a r   s o   i t   c a n   b e   r e s e t   o n   c h a n g e s . 
 
 @ @   - 5 3 , 6   + 5 3 , 8   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
           p r i v a t e   v a r   r o t a t e d B i t m a p :   B i t m a p ?   =   n u l l 
 
           p r i v a t e   v a l   i s C l o s e d   =   A t o m i c B o o l e a n ( f a l s e ) 
 
           p r i v a t e   v a l   y u v T o R g b C o n v e r t e r   b y   l a z y   {   Y u v T o R g b C o n v e r t e r ( c o n t e x t )   } 
 
 +         p r i v a t e   v a r   l a s t D e t e c t e d T i m e s t a m p   =   L o n g . M I N _ V A L U E 
 
 + 
 
   
 
           i n i t   { 
 
                   s e t u p P o s e L a n d m a r k e r ( ) 
 
 @ @   - 9 5 , 6   + 9 7 , 7   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
           / /   t h e   G P U   d e l e g a t e   n e e d s   t o   b e   u s e d   o n   t h e   t h r e a d   t h a t   i n i t i a l i z e d   t h e 
 
           / /   L a n d m a r k e r 
 
           f u n   s e t u p P o s e L a n d m a r k e r ( )   { 
 
 +                 i s C l o s e d . s e t ( f a l s e ) 
 
                   / /   S e t   g e n e r a l   p o s e   l a n d m a r k e r   o p t i o n s 
 
                   v a l   b a s e O p t i o n B u i l d e r   =   B a s e O p t i o n s . b u i l d e r ( ) 
 
   
 
 @ @   - 1 0 9 , 1 2   + 1 1 2 , 1 2   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
                   } 
 
   
 
                   v a l   m o d e l N a m e   = 
 
 -                         w h e n   ( c u r r e n t M o d e l )   { 
 
 -                                 M O D E L _ P O S E _ L A N D M A R K E R _ F U L L   - >   " p o s e _ l a n d m a r k e r _ f u l l . t a s k " 
 
 -                                 M O D E L _ P O S E _ L A N D M A R K E R _ L I T E   - >   " p o s e _ l a n d m a r k e r _ l i t e . t a s k " 
 
 -                                 M O D E L _ P O S E _ L A N D M A R K E R _ H E A V Y   - >   " p o s e _ l a n d m a r k e r _ h e a v y . t a s k " 
 
 -                                 e l s e   - >   " p o s e _ l a n d m a r k e r _ f u l l . t a s k " 
 
 -                         } 
 
 +                                 w h e n   ( c u r r e n t M o d e l )   { 
 
 +                                         M O D E L _ P O S E _ L A N D M A R K E R _ F U L L   - >   " p o s e _ l a n d m a r k e r _ f u l l . t a s k " 
 
 +                                         M O D E L _ P O S E _ L A N D M A R K E R _ L I T E   - >   " p o s e _ l a n d m a r k e r _ l i t e . t a s k " 
 
 +                                         M O D E L _ P O S E _ L A N D M A R K E R _ H E A V Y   - >   " p o s e _ l a n d m a r k e r _ h e a v y . t a s k " 
 
 +                                         e l s e   - >   " p o s e _ l a n d m a r k e r _ f u l l . t a s k " 
 
 +                                 } 
 
   
 
                   b a s e O p t i o n B u i l d e r . s e t M o d e l A s s e t P a t h ( m o d e l N a m e ) 
 
   
 
 @ @   - 1 2 3 , 7   + 1 2 6 , 7   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
                           R u n n i n g M o d e . L I V E _ S T R E A M   - >   { 
 
                                   i f   ( p o s e L a n d m a r k e r H e l p e r L i s t e n e r   = =   n u l l )   { 
 
                                           t h r o w   I l l e g a l S t a t e E x c e p t i o n ( 
 
 -                                                 " p o s e L a n d m a r k e r H e l p e r L i s t e n e r   m u s t   b e   s e t   w h e n   r u n n i n g M o d e   i s   L I V E _ S T R E A M . " 
 
 +                                                         " p o s e L a n d m a r k e r H e l p e r L i s t e n e r   m u s t   b e   s e t   w h e n   r u n n i n g M o d e   i s   L I V E _ S T R E A M . " 
 
                                           ) 
 
                                   } 
 
                           } 
 
 @ @   - 1 3 7 , 6 4   + 1 4 0 , 6 2   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
                           / /   C r e a t e   a n   o p t i o n   b u i l d e r   w i t h   b a s e   o p t i o n s   a n d   s p e c i f i c 
 
                           / /   o p t i o n s   o n l y   u s e   f o r   P o s e   L a n d m a r k e r . 
 
                           v a l   o p t i o n s B u i l d e r   = 
 
 -                                 P o s e L a n d m a r k e r . P o s e L a n d m a r k e r O p t i o n s . b u i l d e r ( ) 
 
 -                                         . s e t B a s e O p t i o n s ( b a s e O p t i o n s ) 
 
 -                                         . s e t M i n P o s e D e t e c t i o n C o n f i d e n c e ( m i n P o s e D e t e c t i o n C o n f i d e n c e ) 
 
 -                                         . s e t M i n T r a c k i n g C o n f i d e n c e ( m i n P o s e T r a c k i n g C o n f i d e n c e ) 
 
 -                                         . s e t M i n P o s e P r e s e n c e C o n f i d e n c e ( m i n P o s e P r e s e n c e C o n f i d e n c e ) 
 
 -                                         . s e t R u n n i n g M o d e ( r u n n i n g M o d e ) 
 
 +                                         P o s e L a n d m a r k e r . P o s e L a n d m a r k e r O p t i o n s . b u i l d e r ( ) 
 
 +                                                         . s e t B a s e O p t i o n s ( b a s e O p t i o n s ) 
 
 +                                                         . s e t M i n P o s e D e t e c t i o n C o n f i d e n c e ( m i n P o s e D e t e c t i o n C o n f i d e n c e ) 
 
 +                                                         . s e t M i n T r a c k i n g C o n f i d e n c e ( m i n P o s e T r a c k i n g C o n f i d e n c e ) 
 
 +                                                         . s e t M i n P o s e P r e s e n c e C o n f i d e n c e ( m i n P o s e P r e s e n c e C o n f i d e n c e ) 
 
 +                                                         . s e t R u n n i n g M o d e ( r u n n i n g M o d e ) 
 
   
 
                           / /   T h e   R e s u l t L i s t e n e r   a n d   E r r o r L i s t e n e r   o n l y   u s e   f o r   L I V E _ S T R E A M   m o d e . 
 
                           i f   ( r u n n i n g M o d e   = =   R u n n i n g M o d e . L I V E _ S T R E A M )   { 
 
                                   o p t i o n s B u i l d e r 
 
 -                                         . s e t R e s u l t L i s t e n e r ( t h i s : : r e t u r n L i v e s t r e a m R e s u l t ) 
 
 -                                         . s e t E r r o r L i s t e n e r ( t h i s : : r e t u r n L i v e s t r e a m E r r o r ) 
 
 +                                                 . s e t R e s u l t L i s t e n e r ( t h i s : : r e t u r n L i v e s t r e a m R e s u l t ) 
 
 +                                                 . s e t E r r o r L i s t e n e r ( t h i s : : r e t u r n L i v e s t r e a m E r r o r ) 
 
                           } 
 
   
 
                           v a l   o p t i o n s   =   o p t i o n s B u i l d e r . b u i l d ( ) 
 
 -                         p o s e L a n d m a r k e r   = 
 
 -                                 P o s e L a n d m a r k e r . c r e a t e F r o m O p t i o n s ( c o n t e x t ,   o p t i o n s ) 
 
 +                         p o s e L a n d m a r k e r   =   P o s e L a n d m a r k e r . c r e a t e F r o m O p t i o n s ( c o n t e x t ,   o p t i o n s ) 
 
                   }   c a t c h   ( e :   I l l e g a l S t a t e E x c e p t i o n )   { 
 
                           p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( 
 
 -                                 " P o s e   L a n d m a r k e r   f a i l e d   t o   i n i t i a l i z e .   S e e   e r r o r   l o g s   f o r   "   + 
 
 -                                                 " d e t a i l s " 
 
 -                         ) 
 
 -                         L o g . e ( 
 
 -                                 T A G ,   " M e d i a P i p e   f a i l e d   t o   l o a d   t h e   t a s k   w i t h   e r r o r :   "   +   e 
 
 -                                         . m e s s a g e 
 
 +                                         " P o s e   L a n d m a r k e r   f a i l e d   t o   i n i t i a l i z e .   S e e   e r r o r   l o g s   f o r   "   +   " d e t a i l s " 
 
                           ) 
 
 +                         L o g . e ( T A G ,   " M e d i a P i p e   f a i l e d   t o   l o a d   t h e   t a s k   w i t h   e r r o r :   "   +   e . m e s s a g e ) 
 
                   }   c a t c h   ( e :   R u n t i m e E x c e p t i o n )   { 
 
                           / /   G P U   d e l e g a t e   f a i l e d       a u t o - f a l l b a c k   t o   C P U 
 
                           i f   ( c u r r e n t D e l e g a t e   = =   D E L E G A T E _ G P U )   { 
 
                                   L o g . w ( T A G ,   " G P U   d e l e g a t e   f a i l e d ,   f a l l i n g   b a c k   t o   C P U :   $ { e . m e s s a g e } " ) 
 
                                   c u r r e n t D e l e g a t e   =   D E L E G A T E _ C P U 
 
                                   t r y   { 
 
 -                                         v a l   c p u B a s e O p t i o n s   =   B a s e O p t i o n s . b u i l d e r ( ) 
 
 -                                                 . s e t D e l e g a t e ( D e l e g a t e . C P U ) 
 
 -                                                 . s e t M o d e l A s s e t P a t h ( m o d e l N a m e ) 
 
 -                                                 . b u i l d ( ) 
 
 -                                         v a l   c p u O p t i o n s   =   P o s e L a n d m a r k e r . P o s e L a n d m a r k e r O p t i o n s . b u i l d e r ( ) 
 
 -                                                 . s e t B a s e O p t i o n s ( c p u B a s e O p t i o n s ) 
 
 -                                                 . s e t M i n P o s e D e t e c t i o n C o n f i d e n c e ( m i n P o s e D e t e c t i o n C o n f i d e n c e ) 
 
 -                                                 . s e t M i n T r a c k i n g C o n f i d e n c e ( m i n P o s e T r a c k i n g C o n f i d e n c e ) 
 
 -                                                 . s e t M i n P o s e P r e s e n c e C o n f i d e n c e ( m i n P o s e P r e s e n c e C o n f i d e n c e ) 
 
 -                                                 . s e t R u n n i n g M o d e ( r u n n i n g M o d e ) 
 
 +                                         v a l   c p u B a s e O p t i o n s   = 
 
 +                                                         B a s e O p t i o n s . b u i l d e r ( ) 
 
 +                                                                         . s e t D e l e g a t e ( D e l e g a t e . C P U ) 
 
 +                                                                         . s e t M o d e l A s s e t P a t h ( m o d e l N a m e ) 
 
 +                                                                         . b u i l d ( ) 
 
 +                                         v a l   c p u O p t i o n s   = 
 
 +                                                         P o s e L a n d m a r k e r . P o s e L a n d m a r k e r O p t i o n s . b u i l d e r ( ) 
 
 +                                                                         . s e t B a s e O p t i o n s ( c p u B a s e O p t i o n s ) 
 
 +                                                                         . s e t M i n P o s e D e t e c t i o n C o n f i d e n c e ( m i n P o s e D e t e c t i o n C o n f i d e n c e ) 
 
 +                                                                         . s e t M i n T r a c k i n g C o n f i d e n c e ( m i n P o s e T r a c k i n g C o n f i d e n c e ) 
 
 +                                                                         . s e t M i n P o s e P r e s e n c e C o n f i d e n c e ( m i n P o s e P r e s e n c e C o n f i d e n c e ) 
 
 +                                                                         . s e t R u n n i n g M o d e ( r u n n i n g M o d e ) 
 
                                           i f   ( r u n n i n g M o d e   = =   R u n n i n g M o d e . L I V E _ S T R E A M )   { 
 
                                                   c p u O p t i o n s 
 
 -                                                         . s e t R e s u l t L i s t e n e r ( t h i s : : r e t u r n L i v e s t r e a m R e s u l t ) 
 
 -                                                         . s e t E r r o r L i s t e n e r ( t h i s : : r e t u r n L i v e s t r e a m E r r o r ) 
 
 +                                                                 . s e t R e s u l t L i s t e n e r ( t h i s : : r e t u r n L i v e s t r e a m R e s u l t ) 
 
 +                                                                 . s e t E r r o r L i s t e n e r ( t h i s : : r e t u r n L i v e s t r e a m E r r o r ) 
 
                                           } 
 
                                           p o s e L a n d m a r k e r   =   P o s e L a n d m a r k e r . c r e a t e F r o m O p t i o n s ( c o n t e x t ,   c p u O p t i o n s . b u i l d ( ) ) 
 
                                           L o g . i ( T A G ,   " S u c c e s s f u l l y   f e l l   b a c k   t o   C P U   d e l e g a t e " ) 
 
                                   }   c a t c h   ( c p u E r r o r :   E x c e p t i o n )   { 
 
                                           p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( 
 
 -                                                 " P o s e   L a n d m a r k e r   f a i l e d   t o   i n i t i a l i z e   w i t h   b o t h   G P U   a n d   C P U . " 
 
 +                                                         " P o s e   L a n d m a r k e r   f a i l e d   t o   i n i t i a l i z e   w i t h   b o t h   G P U   a n d   C P U . " 
 
                                           ) 
 
                                           L o g . e ( T A G ,   " C P U   f a l l b a c k   a l s o   f a i l e d :   $ { c p u E r r o r . m e s s a g e } " ) 
 
                                   } 
 
                           }   e l s e   { 
 
                                   p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( 
 
 -                                         " P o s e   L a n d m a r k e r   f a i l e d   t o   i n i t i a l i z e .   S e e   e r r o r   l o g s   f o r   d e t a i l s " ,   G P U _ E R R O R 
 
 +                                                 " P o s e   L a n d m a r k e r   f a i l e d   t o   i n i t i a l i z e .   S e e   e r r o r   l o g s   f o r   d e t a i l s " , 
 
 +                                                 G P U _ E R R O R 
 
                                   ) 
 
                                   L o g . e ( T A G ,   " M o d e l   l o a d   f a i l e d :   $ { e . m e s s a g e } " ) 
 
                           } 
 
 @ @   - 2 0 4 , 9   + 2 0 5 , 9   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
           / /   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
           / /   N e w   m e t h o d   t o   d y n a m i c a l l y   u p d a t e   d e l e g a t e ,   m o d e l ,   a n d   d e t e c t i o n   c o n f i d e n c e 
 
           f u n   u p d a t e C o n f i g ( 
 
 -                 d e l e g a t e :   I n t ?   =   n u l l , 
 
 -                 m o d e l :   I n t ?   =   n u l l , 
 
 -                 m i n P o s e D e t e c t i o n C o n f i d e n c e :   F l o a t ?   =   n u l l 
 
 +                         d e l e g a t e :   I n t ?   =   n u l l , 
 
 +                         m o d e l :   I n t ?   =   n u l l , 
 
 +                         m i n P o s e D e t e c t i o n C o n f i d e n c e :   F l o a t ?   =   n u l l 
 
           )   { 
 
                   d e l e g a t e ? . l e t   {   c u r r e n t D e l e g a t e   =   i t   } 
 
                   m o d e l ? . l e t   {   c u r r e n t M o d e l   =   i t   } 
 
 @ @   - 2 2 1 , 7   + 2 2 2 , 9   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
           f u n   d e t e c t L i v e S t r e a m ( i m a g e P r o x y :   I m a g e P r o x y ,   i s F r o n t C a m e r a :   B o o l e a n )   { 
 
                   i f   ( r u n n i n g M o d e   ! =   R u n n i n g M o d e . L I V E _ S T R E A M )   { 
 
                           i m a g e P r o x y . c l o s e ( ) 
 
 -                         t h r o w   I l l e g a l A r g u m e n t E x c e p t i o n ( " R u n n i n g   m o d e   m u s t   b e   L I V E _ S T R E A M   t o   c a l l   d e t e c t L i v e S t r e a m " ) 
 
 +                         t h r o w   I l l e g a l A r g u m e n t E x c e p t i o n ( 
 
 +                                         " R u n n i n g   m o d e   m u s t   b e   L I V E _ S T R E A M   t o   c a l l   d e t e c t L i v e S t r e a m " 
 
 +                         ) 
 
                   } 
 
   
 
                   / /   I f   w e   a r e   a l r e a d y   c l o s e d   /   c l e a r i n g ,   d o n ' t   p r o c e s s   t h i s   f r a m e 
 
 @ @   - 2 3 0 , 1 9   + 2 3 3 , 2 7   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
                           r e t u r n 
 
                   } 
 
   
 
 -                 v a l   f r a m e T i m e   =   S y s t e m C l o c k . u p t i m e M i l l i s ( ) 
 
 +                 v a l   f r a m e T i m e   =   i m a g e P r o x y . i m a g e I n f o . t i m e s t a m p 
 
 + 
 
 +                 / /   D r o p   d u p l i c a t e   /   o u t - o f - o r d e r   f r a m e s   t o   p r e v e n t   M e d i a P i p e   f i l t e r   w a r n i n g 
 
 +                 i f   ( f r a m e T i m e   < =   l a s t D e t e c t e d T i m e s t a m p )   { 
 
 +                         i m a g e P r o x y . c l o s e ( ) 
 
 +                         r e t u r n 
 
 +                 } 
 
 +                 l a s t D e t e c t e d T i m e s t a m p   =   f r a m e T i m e 
 
   
 
                   t r y   { 
 
                           / /   1 )   P r e p a r e   b i t m a p   b u f f e r 
 
                           i f   ( b i t m a p B u f f e r   = =   n u l l   | | 
 
 -                                 b i t m a p B u f f e r ? . w i d t h   ! =   i m a g e P r o x y . w i d t h   | | 
 
 -                                 b i t m a p B u f f e r ? . h e i g h t   ! =   i m a g e P r o x y . h e i g h t 
 
 +                                                         b i t m a p B u f f e r ? . w i d t h   ! =   i m a g e P r o x y . w i d t h   | | 
 
 +                                                         b i t m a p B u f f e r ? . h e i g h t   ! =   i m a g e P r o x y . h e i g h t 
 
                           )   { 
 
 -                                 b i t m a p B u f f e r   =   B i t m a p . c r e a t e B i t m a p ( 
 
 -                                         i m a g e P r o x y . w i d t h , 
 
 -                                         i m a g e P r o x y . h e i g h t , 
 
 -                                         B i t m a p . C o n f i g . A R G B _ 8 8 8 8 
 
 -                                 ) 
 
 +                                 b i t m a p B u f f e r   = 
 
 +                                                 B i t m a p . c r e a t e B i t m a p ( 
 
 +                                                                 i m a g e P r o x y . w i d t h , 
 
 +                                                                 i m a g e P r o x y . h e i g h t , 
 
 +                                                                 B i t m a p . C o n f i g . A R G B _ 8 8 8 8 
 
 +                                                 ) 
 
                           } 
 
   
 
                           v a l   b i t m a p   =   b i t m a p B u f f e r ! ! 
 
 @ @   - 2 5 0 , 7   + 2 6 1 , 6   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
                           / /   2 )   C o n v e r t   Y U V   - >   R G B   u s i n g   a   r e u s a b l e   c o n v e r t e r 
 
                           v a l   i m a g e   =   i m a g e P r o x y . i m a g e 
 
                           i f   ( i m a g e   = =   n u l l )   { 
 
 -                                 / /   n o   u s a b l e   i m a g e ,   j u s t   d r o p   f r a m e 
 
                                   i m a g e P r o x y . c l o s e ( ) 
 
                                   r e t u r n 
 
                           } 
 
 @ @   - 2 5 9 , 2 9   + 2 6 9 , 1 6   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
   
 
                           / /   3 )   R e a d   r o t a t i o n   &   d i m e n s i o n s   B E F O R E   c l o s i n g   t h e   p r o x y 
 
                           v a l   r o t a t i o n D e g r e e s   =   i m a g e P r o x y . i m a g e I n f o . r o t a t i o n D e g r e e s . t o F l o a t ( ) 
 
 -                         v a l   w i d t h   =   i m a g e P r o x y . w i d t h 
 
 -                         v a l   h e i g h t   =   i m a g e P r o x y . h e i g h t 
 
   
 
                           / /   W e   h a v e   a l l   i n f o   n e e d e d   n o w ;   s a f e   t o   c l o s e 
 
                           i m a g e P r o x y . c l o s e ( ) 
 
   
 
                           / /   4 )   B u i l d   t r a n s f o r m   m a t r i x       r o t a t e   o n l y ,   n o   m i r r o r i n g . 
 
 -                         / /   M e d i a P i p e   w o r k s   f i n e   w i t h   u n m i r r o r e d   f r a m e s ;   m i r r o r i n g   i s 
 
 -                         / /   h a n d l e d   o n   t h e   D a r t   d i s p l a y   s i d e   t o   m a t c h   P r e v i e w V i e w . 
 
 -                         v a l   m a t r i x   =   M a t r i x ( ) . a p p l y   { 
 
 -                                 p o s t R o t a t e ( r o t a t i o n D e g r e e s ) 
 
 -                         } 
 
 +                         v a l   m a t r i x   =   M a t r i x ( ) . a p p l y   {   p o s t R o t a t e ( r o t a t i o n D e g r e e s )   } 
 
   
 
                           / /   5 )   P r e p a r e   r o t a t e d   b i t m a p 
 
 -                         r o t a t e d B i t m a p   =   B i t m a p . c r e a t e B i t m a p ( 
 
 -                                 b i t m a p , 
 
 -                                 0 , 
 
 -                                 0 , 
 
 -                                 b i t m a p . w i d t h , 
 
 -                                 b i t m a p . h e i g h t , 
 
 -                                 m a t r i x , 
 
 -                                 t r u e 
 
 -                         ) 
 
 +                         r o t a t e d B i t m a p   = 
 
 +                                         B i t m a p . c r e a t e B i t m a p ( b i t m a p ,   0 ,   0 ,   b i t m a p . w i d t h ,   b i t m a p . h e i g h t ,   m a t r i x ,   t r u e ) 
 
   
 
                           v a l   m p I m a g e   =   B i t m a p I m a g e B u i l d e r ( r o t a t e d B i t m a p ! ! ) . b u i l d ( ) 
 
   
 
 @ @   - 2 9 0 , 1 5   + 2 8 7 , 1 3   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
   
 
                           d e t e c t A s y n c ( m p I m a g e ,   f r a m e T i m e ) 
 
                   }   c a t c h   ( t :   T h r o w a b l e )   { 
 
 -                         / /   A L W A Y S   c l o s e   p r o x y   o n   e r r o r   t o   u n b l o c k   t h e   I m a g e A n a l y s i s   p i p e l i n e 
 
                           t r y   { 
 
                                   i m a g e P r o x y . c l o s e ( ) 
 
 -                         }   c a t c h   ( _ :   T h r o w a b l e )   {   / *   i g n o r e   s e c o n d a r y   e r r o r s   * /   } 
 
 +                         }   c a t c h   ( _ :   T h r o w a b l e )   { } 
 
   
 
                           L o g . e ( " P o s e L a n d m a r k e r H e l p e r " ,   " E r r o r   i n   d e t e c t L i v e S t r e a m " ,   t ) 
 
                   } 
 
 - } 
 
 - 
 
 +         } 
 
           / /   R u n   p o s e   l a n d m a r k   u s i n g   M e d i a P i p e   P o s e   L a n d m a r k e r   A P I 
 
           @ V i s i b l e F o r T e s t i n g 
 
           f u n   d e t e c t A s y n c ( m p I m a g e :   M P I m a g e ,   f r a m e T i m e :   L o n g )   { 
 
 @ @   - 3 1 1 , 1 4   + 3 0 6 , 1 0   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
           / /   p o s e   l a n d m a r k e r   i n f e r e n c e   o n   t h e   v i d e o .   T h i s   p r o c e s s   w i l l   e v a l u a t e   e v e r y 
 
           / /   f r a m e   i n   t h e   v i d e o   a n d   a t t a c h   t h e   r e s u l t s   t o   a   b u n d l e   t h a t   w i l l   b e 
 
           / /   r e t u r n e d . 
 
 -         f u n   d e t e c t V i d e o F i l e ( 
 
 -                 v i d e o U r i :   U r i , 
 
 -                 i n f e r e n c e I n t e r v a l M s :   L o n g 
 
 -         ) :   R e s u l t B u n d l e ?   { 
 
 +         f u n   d e t e c t V i d e o F i l e ( v i d e o U r i :   U r i ,   i n f e r e n c e I n t e r v a l M s :   L o n g ) :   R e s u l t B u n d l e ?   { 
 
                   i f   ( r u n n i n g M o d e   ! =   R u n n i n g M o d e . V I D E O )   { 
 
                           t h r o w   I l l e g a l A r g u m e n t E x c e p t i o n ( 
 
 -                                 " A t t e m p t i n g   t o   c a l l   d e t e c t V i d e o F i l e "   + 
 
 -                                                 "   w h i l e   n o t   u s i n g   R u n n i n g M o d e . V I D E O " 
 
 +                                         " A t t e m p t i n g   t o   c a l l   d e t e c t V i d e o F i l e "   +   "   w h i l e   n o t   u s i n g   R u n n i n g M o d e . V I D E O " 
 
                           ) 
 
                   } 
 
   
 
 @ @   - 3 3 2 , 8   + 3 2 3 , 7   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
                   v a l   r e t r i e v e r   =   M e d i a M e t a d a t a R e t r i e v e r ( ) 
 
                   r e t r i e v e r . s e t D a t a S o u r c e ( c o n t e x t ,   v i d e o U r i ) 
 
                   v a l   v i d e o L e n g t h M s   = 
 
 -                         r e t r i e v e r . e x t r a c t M e t a d a t a ( M e d i a M e t a d a t a R e t r i e v e r . M E T A D A T A _ K E Y _ D U R A T I O N ) 
 
 -                                 ? . t o L o n g ( ) 
 
 +                                 r e t r i e v e r . e x t r a c t M e t a d a t a ( M e d i a M e t a d a t a R e t r i e v e r . M E T A D A T A _ K E Y _ D U R A T I O N ) ? . t o L o n g ( ) 
 
   
 
                   / /   N o t e :   W e   n e e d   t o   r e a d   w i d t h / h e i g h t   f r o m   f r a m e   i n s t e a d   o f   g e t t i n g   t h e   w i d t h / h e i g h t 
 
                   / /   o f   t h e   v i d e o   d i r e c t l y   b e c a u s e   M e d i a R e t r i e v e r   r e t u r n s   f r a m e s   t h a t   a r e   s m a l l e r   t h a n   t h e 
 
 @ @   - 3 5 2 , 4 5   + 3 4 2 , 4 5   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
                   f o r   ( i   i n   0 . . n u m b e r O f F r a m e T o R e a d )   { 
 
                           v a l   t i m e s t a m p M s   =   i   *   i n f e r e n c e I n t e r v a l M s   / /   m s 
 
   
 
 -                         r e t r i e v e r 
 
 -                                 . g e t F r a m e A t T i m e ( 
 
 -                                         t i m e s t a m p M s   *   1 0 0 0 ,   / /   c o n v e r t   f r o m   m s   t o   m i c r o - s 
 
 -                                         M e d i a M e t a d a t a R e t r i e v e r . O P T I O N _ C L O S E S T 
 
 -                                 ) 
 
 -                                 ? . l e t   {   f r a m e   - > 
 
 -                                         / /   C o n v e r t   t h e   v i d e o   f r a m e   t o   A R G B _ 8 8 8 8   w h i c h   i s   r e q u i r e d   b y   t h e   M e d i a P i p e 
 
 -                                         v a l   a r g b 8 8 8 8 F r a m e   = 
 
 -                                                 i f   ( f r a m e . c o n f i g   = =   B i t m a p . C o n f i g . A R G B _ 8 8 8 8 )   f r a m e 
 
 -                                                 e l s e   f r a m e . c o p y ( B i t m a p . C o n f i g . A R G B _ 8 8 8 8 ,   f a l s e ) 
 
 - 
 
 -                                         / /   C o n v e r t   t h e   i n p u t   B i t m a p   o b j e c t   t o   a n   M P I m a g e   o b j e c t   t o   r u n   i n f e r e n c e 
 
 -                                         v a l   m p I m a g e   =   B i t m a p I m a g e B u i l d e r ( a r g b 8 8 8 8 F r a m e ) . b u i l d ( ) 
 
 - 
 
 -                                         / /   R u n   p o s e   l a n d m a r k e r   u s i n g   M e d i a P i p e   P o s e   L a n d m a r k e r   A P I 
 
 -                                         p o s e L a n d m a r k e r ? . d e t e c t F o r V i d e o ( m p I m a g e ,   t i m e s t a m p M s ) 
 
 -                                                 ? . l e t   {   d e t e c t i o n R e s u l t   - > 
 
 +                         r e t r i e v e r . g e t F r a m e A t T i m e ( 
 
 +                                                         t i m e s t a m p M s   *   1 0 0 0 ,   / /   c o n v e r t   f r o m   m s   t o   m i c r o - s 
 
 +                                                         M e d i a M e t a d a t a R e t r i e v e r . O P T I O N _ C L O S E S T 
 
 +                                         ) 
 
 +                                         ? . l e t   {   f r a m e   - > 
 
 +                                                 / /   C o n v e r t   t h e   v i d e o   f r a m e   t o   A R G B _ 8 8 8 8   w h i c h   i s   r e q u i r e d   b y   t h e   M e d i a P i p e 
 
 +                                                 v a l   a r g b 8 8 8 8 F r a m e   = 
 
 +                                                                 i f   ( f r a m e . c o n f i g   = =   B i t m a p . C o n f i g . A R G B _ 8 8 8 8 )   f r a m e 
 
 +                                                                 e l s e   f r a m e . c o p y ( B i t m a p . C o n f i g . A R G B _ 8 8 8 8 ,   f a l s e ) 
 
 + 
 
 +                                                 / /   C o n v e r t   t h e   i n p u t   B i t m a p   o b j e c t   t o   a n   M P I m a g e   o b j e c t   t o   r u n   i n f e r e n c e 
 
 +                                                 v a l   m p I m a g e   =   B i t m a p I m a g e B u i l d e r ( a r g b 8 8 8 8 F r a m e ) . b u i l d ( ) 
 
 + 
 
 +                                                 / /   R u n   p o s e   l a n d m a r k e r   u s i n g   M e d i a P i p e   P o s e   L a n d m a r k e r   A P I 
 
 +                                                 p o s e L a n d m a r k e r ? . d e t e c t F o r V i d e o ( m p I m a g e ,   t i m e s t a m p M s ) ? . l e t   {   d e t e c t i o n R e s u l t 
 
 +                                                         - > 
 
                                                           r e s u l t L i s t . a d d ( d e t e c t i o n R e s u l t ) 
 
 -                                                 }   ? :   r u n   { 
 
 +                                                 } 
 
 +                                                                 ? :   r u n   { 
 
 +                                                                         d i d E r r o r O c c u r r e d   =   t r u e 
 
 +                                                                         p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( 
 
 +                                                                                         " R e s u l t B u n d l e   c o u l d   n o t   b e   r e t u r n e d "   + 
 
 +                                                                                                         "   i n   d e t e c t V i d e o F i l e " 
 
 +                                                                         ) 
 
 +                                                                 } 
 
 +                                         } 
 
 +                                         ? :   r u n   { 
 
                                                   d i d E r r o r O c c u r r e d   =   t r u e 
 
                                                   p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( 
 
 -                                                         " R e s u l t B u n d l e   c o u l d   n o t   b e   r e t u r n e d "   + 
 
 -                                                                         "   i n   d e t e c t V i d e o F i l e " 
 
 +                                                                 " F r a m e   a t   s p e c i f i e d   t i m e   c o u l d   n o t   b e "   + 
 
 +                                                                                 "   r e t r i e v e d   w h e n   d e t e c t i n g   i n   v i d e o . " 
 
                                                   ) 
 
                                           } 
 
 -                                 } 
 
 -                                 ? :   r u n   { 
 
 -                                         d i d E r r o r O c c u r r e d   =   t r u e 
 
 -                                         p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( 
 
 -                                                 " F r a m e   a t   s p e c i f i e d   t i m e   c o u l d   n o t   b e "   + 
 
 -                                                                 "   r e t r i e v e d   w h e n   d e t e c t i n g   i n   v i d e o . " 
 
 -                                         ) 
 
 -                                 } 
 
                   } 
 
   
 
                   r e t r i e v e r . r e l e a s e ( ) 
 
   
 
                   v a l   i n f e r e n c e T i m e P e r F r a m e M s   = 
 
 -                         ( S y s t e m C l o c k . u p t i m e M i l l i s ( )   -   s t a r t T i m e ) . d i v ( n u m b e r O f F r a m e T o R e a d ) 
 
 +                                 ( S y s t e m C l o c k . u p t i m e M i l l i s ( )   -   s t a r t T i m e ) . d i v ( n u m b e r O f F r a m e T o R e a d ) 
 
   
 
                   r e t u r n   i f   ( d i d E r r o r O c c u r r e d )   { 
 
                           n u l l 
 
 @ @   - 4 0 4 , 1 2   + 3 9 4 , 1 0   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
           f u n   d e t e c t I m a g e ( i m a g e :   B i t m a p ) :   R e s u l t B u n d l e ?   { 
 
                   i f   ( r u n n i n g M o d e   ! =   R u n n i n g M o d e . I M A G E )   { 
 
                           t h r o w   I l l e g a l A r g u m e n t E x c e p t i o n ( 
 
 -                                 " A t t e m p t i n g   t o   c a l l   d e t e c t I m a g e "   + 
 
 -                                                 "   w h i l e   n o t   u s i n g   R u n n i n g M o d e . I M A G E " 
 
 +                                         " A t t e m p t i n g   t o   c a l l   d e t e c t I m a g e "   +   "   w h i l e   n o t   u s i n g   R u n n i n g M o d e . I M A G E " 
 
                           ) 
 
                   } 
 
   
 
 - 
 
                   / /   I n f e r e n c e   t i m e   i s   t h e   d i f f e r e n c e   b e t w e e n   t h e   s y s t e m   t i m e   a t   t h e 
 
                   / /   s t a r t   a n d   f i n i s h   o f   t h e   p r o c e s s 
 
                   v a l   s t a r t T i m e   =   S y s t e m C l o c k . u p t i m e M i l l i s ( ) 
 
 @ @   - 4 2 0 , 4 6   + 4 0 8 , 2 9   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
                   / /   R u n   p o s e   l a n d m a r k e r   u s i n g   M e d i a P i p e   P o s e   L a n d m a r k e r   A P I 
 
                   p o s e L a n d m a r k e r ? . d e t e c t ( m p I m a g e ) ? . a l s o   {   l a n d m a r k R e s u l t   - > 
 
                           v a l   i n f e r e n c e T i m e M s   =   S y s t e m C l o c k . u p t i m e M i l l i s ( )   -   s t a r t T i m e 
 
 -                         r e t u r n   R e s u l t B u n d l e ( 
 
 -                                 l i s t O f ( l a n d m a r k R e s u l t ) , 
 
 -                                 i n f e r e n c e T i m e M s , 
 
 -                                 i m a g e . h e i g h t , 
 
 -                                 i m a g e . w i d t h 
 
 -                         ) 
 
 +                         r e t u r n   R e s u l t B u n d l e ( l i s t O f ( l a n d m a r k R e s u l t ) ,   i n f e r e n c e T i m e M s ,   i m a g e . h e i g h t ,   i m a g e . w i d t h ) 
 
                   } 
 
   
 
                   / /   I f   p o s e L a n d m a r k e r ? . d e t e c t ( )   r e t u r n s   n u l l ,   t h i s   i s   l i k e l y   a n   e r r o r .   R e t u r n i n g   n u l l 
 
                   / /   t o   i n d i c a t e   t h i s . 
 
 -                 p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( 
 
 -                         " P o s e   L a n d m a r k e r   f a i l e d   t o   d e t e c t . " 
 
 -                 ) 
 
 +                 p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( " P o s e   L a n d m a r k e r   f a i l e d   t o   d e t e c t . " ) 
 
                   r e t u r n   n u l l 
 
           } 
 
   
 
           / /   R e t u r n   t h e   l a n d m a r k   r e s u l t   t o   t h i s   P o s e L a n d m a r k e r H e l p e r ' s   c a l l e r 
 
 -         p r i v a t e   f u n   r e t u r n L i v e s t r e a m R e s u l t ( 
 
 -                 r e s u l t :   P o s e L a n d m a r k e r R e s u l t , 
 
 -                 i n p u t :   M P I m a g e 
 
 -         )   { 
 
 +         p r i v a t e   f u n   r e t u r n L i v e s t r e a m R e s u l t ( r e s u l t :   P o s e L a n d m a r k e r R e s u l t ,   i n p u t :   M P I m a g e )   { 
 
                   v a l   f i n i s h T i m e M s   =   S y s t e m C l o c k . u p t i m e M i l l i s ( ) 
 
                   v a l   i n f e r e n c e T i m e   =   f i n i s h T i m e M s   -   r e s u l t . t i m e s t a m p M s ( ) 
 
   
 
                   p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n R e s u l t s ( 
 
 -                         R e s u l t B u n d l e ( 
 
 -                                 l i s t O f ( r e s u l t ) , 
 
 -                                 i n f e r e n c e T i m e , 
 
 -                                 i n p u t . h e i g h t , 
 
 -                                 i n p u t . w i d t h 
 
 -                         ) 
 
 +                                 R e s u l t B u n d l e ( l i s t O f ( r e s u l t ) ,   i n f e r e n c e T i m e ,   i n p u t . h e i g h t ,   i n p u t . w i d t h ) 
 
                   ) 
 
           } 
 
   
 
           / /   R e t u r n   e r r o r s   t h r o w n   d u r i n g   d e t e c t i o n   t o   t h i s   P o s e L a n d m a r k e r H e l p e r ' s 
 
           / /   c a l l e r 
 
           p r i v a t e   f u n   r e t u r n L i v e s t r e a m E r r o r ( e r r o r :   R u n t i m e E x c e p t i o n )   { 
 
 -                 p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( 
 
 -                         e r r o r . m e s s a g e   ? :   " A n   u n k n o w n   e r r o r   h a s   o c c u r r e d " 
 
 -                 ) 
 
 +                 p o s e L a n d m a r k e r H e l p e r L i s t e n e r ? . o n E r r o r ( e r r o r . m e s s a g e   ? :   " A n   u n k n o w n   e r r o r   h a s   o c c u r r e d " ) 
 
           } 
 
   
 
           c o m p a n i o n   o b j e c t   { 
 
 @ @   - 4 7 9 , 1 1   + 4 5 0 , 1 0   @ @   c l a s s   P o s e L a n d m a r k e r H e l p e r ( 
 
           } 
 
   
 
           d a t a   c l a s s   R e s u l t B u n d l e ( 
 
 -                 v a l   r e s u l t s :   L i s t < P o s e L a n d m a r k e r R e s u l t > , 
 
 -                 v a l   i n f e r e n c e T i m e :   L o n g , 
 
 -                 v a l   i n p u t I m a g e H e i g h t :   I n t , 
 
 -                 v a l   i n p u t I m a g e W i d t h :   I n t , 
 
 - 
 
 +                         v a l   r e s u l t s :   L i s t < P o s e L a n d m a r k e r R e s u l t > , 
 
 +                         v a l   i n f e r e n c e T i m e :   L o n g , 
 
 +                         v a l   i n p u t I m a g e H e i g h t :   I n t , 
 
 +                         v a l   i n p u t I m a g e W i d t h :   I n t , 
 
           ) 
 
   
 
           i n t e r f a c e   L a n d m a r k e r L i s t e n e r   { 
 
 d i f f   - - g i t   a / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / Y u v T o R g b C o n v e r t e r . k t   b / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / Y u v T o R g b C o n v e r t e r . k t 
 
 i n d e x   4 0 8 7 a d 7 . . 7 4 1 c e 6 6   1 0 0 6 4 4 
 
 - - -   a / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / Y u v T o R g b C o n v e r t e r . k t 
 
 + + +   b / a n d r o i d / s r c / m a i n / k o t l i n / c o m / c a r e c o d e / f l u t t e r _ m p _ p o s e _ l m / Y u v T o R g b C o n v e r t e r . k t 
 
 @ @   - 3 , 2 7   + 3 , 4 0   @ @   p a c k a g e   c o m . c a r e c o d e . f l u t t e r _ m p _ p o s e _ l m 
 
   i m p o r t   a n d r o i d . c o n t e n t . C o n t e x t 
 
   i m p o r t   a n d r o i d . g r a p h i c s . B i t m a p 
 
   i m p o r t   a n d r o i d . m e d i a . I m a g e 
 
 - i m p o r t   a n d r o i d x . c a m e r a . c o r e . I m a g e P r o x y 
 
 - i m p o r t   a n d r o i d . r e n d e r s c r i p t . * 
 
 + i m p o r t   a n d r o i d . r e n d e r s c r i p t . A l l o c a t i o n 
 
 + i m p o r t   a n d r o i d . r e n d e r s c r i p t . E l e m e n t 
 
 + i m p o r t   a n d r o i d . r e n d e r s c r i p t . R e n d e r S c r i p t 
 
 + i m p o r t   a n d r o i d . r e n d e r s c r i p t . S c r i p t I n t r i n s i c Y u v T o R G B 
 
   
 
   c l a s s   Y u v T o R g b C o n v e r t e r ( c o n t e x t :   C o n t e x t )   { 
 
           p r i v a t e   v a l   r s :   R e n d e r S c r i p t   =   R e n d e r S c r i p t . c r e a t e ( c o n t e x t ) 
 
 -         p r i v a t e   v a l   s c r i p t Y u v T o R g b :   S c r i p t I n t r i n s i c Y u v T o R G B   =   S c r i p t I n t r i n s i c Y u v T o R G B . c r e a t e ( r s ,   E l e m e n t . U 8 _ 4 ( r s ) ) 
 
 +         p r i v a t e   v a l   s c r i p t Y u v T o R g b :   S c r i p t I n t r i n s i c Y u v T o R G B   = 
 
 +                 S c r i p t I n t r i n s i c Y u v T o R G B . c r e a t e ( r s ,   E l e m e n t . U 8 _ 4 ( r s ) ) 
 
 + 
 
           p r i v a t e   v a r   i n p u t A l l o c :   A l l o c a t i o n ?   =   n u l l 
 
           p r i v a t e   v a r   o u t p u t A l l o c :   A l l o c a t i o n ?   =   n u l l 
 
           p r i v a t e   v a r   l a s t I n p u t S i z e :   I n t   =   0 
 
           p r i v a t e   v a r   l a s t W i d t h :   I n t   =   0 
 
           p r i v a t e   v a r   l a s t H e i g h t :   I n t   =   0 
 
   
 
 +         @ S y n c h r o n i z e d 
 
           f u n   y u v T o R g b ( i m a g e :   I m a g e ,   o u t p u t :   B i t m a p )   { 
 
 +                 r e q u i r e ( ! o u t p u t . i s R e c y c l e d )   {   " O u t p u t   b i t m a p   i s   a l r e a d y   r e c y c l e d "   } 
 
 +                 r e q u i r e ( o u t p u t . c o n f i g   ! =   B i t m a p . C o n f i g . H A R D W A R E )   { 
 
 +                         " H a r d w a r e   b i t m a p s   c a n n o t   b e   u s e d   w i t h   R e n d e r S c r i p t       c r e a t e   o u t p u t   w i t h   B i t m a p . C o n f i g . A R G B _ 8 8 8 8 " 
 
 +                 } 
 
 +                 r e q u i r e ( o u t p u t . w i d t h   = =   i m a g e . w i d t h   & &   o u t p u t . h e i g h t   = =   i m a g e . h e i g h t )   { 
 
 +                         " O u t p u t   b i t m a p   s i z e   ( $ { o u t p u t . w i d t h } x $ { o u t p u t . h e i g h t } )   m u s t   m a t c h   i m a g e   s i z e   ( $ { i m a g e . w i d t h } x $ { i m a g e . h e i g h t } ) " 
 
 +                 } 
 
 + 
 
                   v a l   y u v B u f f e r   =   i m a g e . p l a n e s . t o Y u v B y t e A r r a y ( i m a g e . w i d t h ,   i m a g e . h e i g h t ) 
 
   
 
 -                 / /   R e u s e   a l l o c a t i o n s   w h e n   d i m e n s i o n s   h a v e n ' t   c h a n g e d 
 
                   i f   ( i n p u t A l l o c   = =   n u l l   | |   y u v B u f f e r . s i z e   ! =   l a s t I n p u t S i z e )   { 
 
                           i n p u t A l l o c ? . d e s t r o y ( ) 
 
                           i n p u t A l l o c   =   A l l o c a t i o n . c r e a t e S i z e d ( r s ,   E l e m e n t . U 8 ( r s ) ,   y u v B u f f e r . s i z e ) 
 
                           l a s t I n p u t S i z e   =   y u v B u f f e r . s i z e 
 
                   } 
 
 + 
 
                   i f   ( o u t p u t A l l o c   = =   n u l l   | |   o u t p u t . w i d t h   ! =   l a s t W i d t h   | |   o u t p u t . h e i g h t   ! =   l a s t H e i g h t )   { 
 
                           o u t p u t A l l o c ? . d e s t r o y ( ) 
 
                           o u t p u t A l l o c   =   A l l o c a t i o n . c r e a t e F r o m B i t m a p ( r s ,   o u t p u t ) 
 
 @ @   - 3 7 , 4 4   + 5 0 , 5 9   @ @   c l a s s   Y u v T o R g b C o n v e r t e r ( c o n t e x t :   C o n t e x t )   { 
 
                   o u t p u t A l l o c ! ! . c o p y T o ( o u t p u t ) 
 
           } 
 
   
 
 +         @ S y n c h r o n i z e d 
 
           f u n   d e s t r o y ( )   { 
 
                   i n p u t A l l o c ? . d e s t r o y ( ) 
 
 +                 i n p u t A l l o c   =   n u l l 
 
                   o u t p u t A l l o c ? . d e s t r o y ( ) 
 
 +                 o u t p u t A l l o c   =   n u l l 
 
                   s c r i p t Y u v T o R g b . d e s t r o y ( ) 
 
                   r s . d e s t r o y ( ) 
 
           } 
 
   
 
           p r i v a t e   f u n   A r r a y < I m a g e . P l a n e > . t o Y u v B y t e A r r a y ( w i d t h :   I n t ,   h e i g h t :   I n t ) :   B y t e A r r a y   { 
 
 -                 i f   ( t h i s . s i z e   <   3 )   { 
 
 -                         t h r o w   I l l e g a l A r g u m e n t E x c e p t i o n ( " Y U V _ 4 2 0 _ 8 8 8   f o r m a t   r e q u i r e s   3   p l a n e s ,   b u t   g o t   $ { t h i s . s i z e } " ) 
 
 +                 r e q u i r e ( s i z e   > =   3 )   { 
 
 +                         " Y U V _ 4 2 0 _ 8 8 8   f o r m a t   r e q u i r e s   3   p l a n e s ,   b u t   g o t   $ s i z e " 
 
                   } 
 
   
 
 -                 v a l   y P l a n e   =   t h i s [ 0 ] . b u f f e r 
 
 -                 v a l   u P l a n e   =   t h i s [ 1 ] . b u f f e r 
 
 -                 v a l   v P l a n e   =   t h i s [ 2 ] . b u f f e r 
 
 +                 v a l   y P l a n e   =   t h i s [ 0 ] 
 
 +                 v a l   u P l a n e   =   t h i s [ 1 ] 
 
 +                 v a l   v P l a n e   =   t h i s [ 2 ] 
 
 + 
 
 +                 v a l   y B u f f e r   =   y P l a n e . b u f f e r 
 
 +                 v a l   u B u f f e r   =   u P l a n e . b u f f e r 
 
 +                 v a l   v B u f f e r   =   v P l a n e . b u f f e r 
 
   
 
                   v a l   y S i z e   =   w i d t h   *   h e i g h t 
 
                   v a l   u v S i z e   =   w i d t h   *   h e i g h t   /   2 
 
                   v a l   n v 2 1   =   B y t e A r r a y ( y S i z e   +   u v S i z e ) 
 
   
 
 -                 y P l a n e . g e t ( n v 2 1 ,   0 ,   y S i z e ) 
 
 +                 / /   Y   p l a n e       m u s t   r e s p e c t   r o w   s t r i d e ;   s t r i d e   > =   w i d t h   o n   m o s t   d e v i c e s 
 
 +                 v a l   y R o w S t r i d e   =   y P l a n e . r o w S t r i d e 
 
 +                 i f   ( y R o w S t r i d e   = =   w i d t h )   { 
 
 +                         y B u f f e r . g e t ( n v 2 1 ,   0 ,   y S i z e ) 
 
 +                 }   e l s e   { 
 
 +                         f o r   ( r o w   i n   0   u n t i l   h e i g h t )   { 
 
 +                                 y B u f f e r . p o s i t i o n ( r o w   *   y R o w S t r i d e ) 
 
 +                                 y B u f f e r . g e t ( n v 2 1 ,   r o w   *   w i d t h ,   w i d t h ) 
 
 +                         } 
 
 +                 } 
 
   
 
 -                 v a l   c h r o m a R o w S t r i d e   =   t h i s [ 1 ] . r o w S t r i d e 
 
 -                 v a l   c h r o m a P i x e l S t r i d e   =   t h i s [ 1 ] . p i x e l S t r i d e 
 
 +                 / /   U V   p l a n e s       i n t e r l e a v e d   i n t o   N V 2 1   ( V   f i r s t ,   t h e n   U ) 
 
 +                 / /   U s e   s e p a r a t e   i n d i c e s   f o r   U   a n d   V   b u f f e r s ;   t h e y   s h a r e   t h e   s a m e   r o w / p i x e l 
 
 +                 / /   s t r i d e   b u t   a r e   d i s t i n c t   b u f f e r s   a n d   m u s t   n o t   b e   i n d e x e d   i n t e r c h a n g e a b l y . 
 
 +                 v a l   c h r o m a R o w S t r i d e   =   u P l a n e . r o w S t r i d e 
 
 +                 v a l   c h r o m a P i x e l S t r i d e   =   u P l a n e . p i x e l S t r i d e 
 
   
 
                   v a r   o f f s e t   =   y S i z e 
 
                   f o r   ( r o w   i n   0   u n t i l   h e i g h t   /   2 )   { 
 
                           f o r   ( c o l   i n   0   u n t i l   w i d t h   /   2 )   { 
 
 -                                 v a l   u I n d e x   =   r o w   *   c h r o m a R o w S t r i d e   +   c o l   *   c h r o m a P i x e l S t r i d e 
 
 -                                 v a l   u   =   u P l a n e . g e t ( u I n d e x ) 
 
 -                                 v a l   v   =   v P l a n e . g e t ( u I n d e x ) 
 
 - 
 
 -                                 / /   N V 2 1   f o r m a t   r e q u i r e s   V U   o r d e r i n g 
 
 -                                 n v 2 1 [ o f f s e t + + ]   =   v 
 
 -                                 n v 2 1 [ o f f s e t + + ]   =   u 
 
 +                                 v a l   i n d e x   =   r o w   *   c h r o m a R o w S t r i d e   +   c o l   *   c h r o m a P i x e l S t r i d e 
 
 +                                 n v 2 1 [ o f f s e t + + ]   =   v B u f f e r . g e t ( i n d e x )   / /   V   f i r s t       N V 2 1 
 
 +                                 n v 2 1 [ o f f s e t + + ]   =   u B u f f e r . g e t ( i n d e x ) 
 
                           } 
 
                   } 
 
   
 
                   r e t u r n   n v 2 1 
 
           } 
 
 - } 
 
 + } 
 
 \   N o   n e w l i n e   a t   e n d   o f   f i l e 
 
 d i f f   - - g i t   a / e x a m p l e / p u b s p e c . l o c k   b / e x a m p l e / p u b s p e c . l o c k 
 
 i n d e x   5 a 8 0 0 7 c . . a 5 2 6 e a 3   1 0 0 6 4 4 
 
 - - -   a / e x a m p l e / p u b s p e c . l o c k 
 
 + + +   b / e x a m p l e / p u b s p e c . l o c k 
 
 @ @   - 8 9 , 7   + 8 9 , 7   @ @   p a c k a g e s : 
 
               p a t h :   " . . " 
 
               r e l a t i v e :   t r u e 
 
           s o u r c e :   p a t h 
 
 -         v e r s i o n :   " 0 . 1 . 5 " 
 
 +         v e r s i o n :   " 0 . 1 . 6 " 
 
       f l u t t e r _ t e s t : 
 
           d e p e n d e n c y :   " d i r e c t   d e v " 
 
           d e s c r i p t i o n :   f l u t t e r 
 
 d i f f   - - g i t   a / e x a m p l e / p u b s p e c . y a m l   b / e x a m p l e / p u b s p e c . y a m l 
 
 i n d e x   5 b 5 5 1 6 4 . . 8 1 a e 0 e 2   1 0 0 6 4 4 
 
 - - -   a / e x a m p l e / p u b s p e c . y a m l 
 
 + + +   b / e x a m p l e / p u b s p e c . y a m l 
 
 @ @   - 3 6 , 5 1   + 3 6 , 9   @ @   d e v _ d e p e n d e n c i e s : 
 
       f l u t t e r _ t e s t : 
 
           s d k :   f l u t t e r 
 
   
 
 -     #   T h e   " f l u t t e r _ l i n t s "   p a c k a g e   b e l o w   c o n t a i n s   a   s e t   o f   r e c o m m e n d e d   l i n t s   t o 
 
 -     #   e n c o u r a g e   g o o d   c o d i n g   p r a c t i c e s .   T h e   l i n t   s e t   p r o v i d e d   b y   t h e   p a c k a g e   i s 
 
 -     #   a c t i v a t e d   i n   t h e   ` a n a l y s i s _ o p t i o n s . y a m l `   f i l e   l o c a t e d   a t   t h e   r o o t   o f   y o u r 
 
 -     #   p a c k a g e .   S e e   t h a t   f i l e   f o r   i n f o r m a t i o n   a b o u t   d e a c t i v a t i n g   s p e c i f i c   l i n t 
 
 -     #   r u l e s   a n d   a c t i v a t i n g   a d d i t i o n a l   o n e s . 
 
       f l u t t e r _ l i n t s :   ^ 4 . 0 . 0 
 
   
 
 - #   F o r   i n f o r m a t i o n   o n   t h e   g e n e r i c   D a r t   p a r t   o f   t h i s   f i l e ,   s e e   t h e 
 
 - #   f o l l o w i n g   p a g e :   h t t p s : / / d a r t . d e v / t o o l s / p u b / p u b s p e c 
 
 - 
 
 - #   T h e   f o l l o w i n g   s e c t i o n   i s   s p e c i f i c   t o   F l u t t e r   p a c k a g e s . 
 
   f l u t t e r : 
 
   
 
 -     #   T h e   f o l l o w i n g   l i n e   e n s u r e s   t h a t   t h e   M a t e r i a l   I c o n s   f o n t   i s 
 
 -     #   i n c l u d e d   w i t h   y o u r   a p p l i c a t i o n ,   s o   t h a t   y o u   c a n   u s e   t h e   i c o n s   i n 
 
 -     #   t h e   m a t e r i a l   I c o n s   c l a s s . 
 
       u s e s - m a t e r i a l - d e s i g n :   t r u e 
 
   
 
 -     #   T o   a d d   a s s e t s   t o   y o u r   a p p l i c a t i o n ,   a d d   a n   a s s e t s   s e c t i o n ,   l i k e   t h i s : 
 
 -     #   a s s e t s : 
 
 -     #       -   i m a g e s / a _ d o t _ b u r r . j p e g 
 
 -     #       -   i m a g e s / a _ d o t _ h a m . j p e g 
 
 - 
 
 -     #   A n   i m a g e   a s s e t   c a n   r e f e r   t o   o n e   o r   m o r e   r e s o l u t i o n - s p e c i f i c   " v a r i a n t s " ,   s e e 
 
 -     #   h t t p s : / / f l u t t e r . d e v / t o / r e s o l u t i o n - a w a r e - i m a g e s 
 
 - 
 
 -     #   F o r   d e t a i l s   r e g a r d i n g   a d d i n g   a s s e t s   f r o m   p a c k a g e   d e p e n d e n c i e s ,   s e e 
 
 -     #   h t t p s : / / f l u t t e r . d e v / t o / a s s e t - f r o m - p a c k a g e 
 
 - 
 
 -     #   T o   a d d   c u s t o m   f o n t s   t o   y o u r   a p p l i c a t i o n ,   a d d   a   f o n t s   s e c t i o n   h e r e , 
 
 -     #   i n   t h i s   " f l u t t e r "   s e c t i o n .   E a c h   e n t r y   i n   t h i s   l i s t   s h o u l d   h a v e   a 
 
 -     #   " f a m i l y "   k e y   w i t h   t h e   f o n t   f a m i l y   n a m e ,   a n d   a   " f o n t s "   k e y   w i t h   a 
 
 -     #   l i s t   g i v i n g   t h e   a s s e t   a n d   o t h e r   d e s c r i p t o r s   f o r   t h e   f o n t .   F o r 
 
 -     #   e x a m p l e : 
 
 -     #   f o n t s : 
 
 -     #       -   f a m i l y :   S c h y l e r 
 
 -     #           f o n t s : 
 
 -     #               -   a s s e t :   f o n t s / S c h y l e r - R e g u l a r . t t f 
 
 -     #               -   a s s e t :   f o n t s / S c h y l e r - I t a l i c . t t f 
 
 -     #                   s t y l e :   i t a l i c 
 
 -     #       -   f a m i l y :   T r a j a n   P r o 
 
 -     #           f o n t s : 
 
 -     #               -   a s s e t :   f o n t s / T r a j a n P r o . t t f 
 
 -     #               -   a s s e t :   f o n t s / T r a j a n P r o _ B o l d . t t f 
 
 -     #                   w e i g h t :   7 0 0 
 
 -     # 
 
 -     #   F o r   d e t a i l s   r e g a r d i n g   f o n t s   f r o m   p a c k a g e   d e p e n d e n c i e s , 
 
 -     #   s e e   h t t p s : / / f l u t t e r . d e v / t o / f o n t - f r o m - p a c k a g e 
 
 