/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t ( E x t e n s i o n ) 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h e   N y A R T o o l k i t   i s   J a v a   e d i t i o n   A R T o o l K i t   c l a s s   l i b r a r y . 
 
   *   C o p y r i g h t   ( C ) 2 0 0 8 - 2 0 0 9   R y o   I i z u k a 
 
   * 
 
   *   T h i s   p r o g r a m   i s   f r e e   s o f t w a r e :   y o u   c a n   r e d i s t r i b u t e   i t   a n d / o r   m o d i f y 
 
   *   i t   u n d e r   t h e   t e r m s   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e   a s   p u b l i s h e d   b y 
 
   *   t h e   F r e e   S o f t w a r e   F o u n d a t i o n ,   e i t h e r   v e r s i o n   3   o f   t h e   L i c e n s e ,   o r 
 
   *   ( a t   y o u r   o p t i o n )   a n y   l a t e r   v e r s i o n . 
 
   *   
 
   *   T h i s   p r o g r a m   i s   d i s t r i b u t e d   i n   t h e   h o p e   t h a t   i t   w i l l   b e   u s e f u l , 
 
   *   b u t   W I T H O U T   A N Y   W A R R A N T Y ;   w i t h o u t   e v e n   t h e   i m p l i e d   w a r r a n t y   o f 
 
   *   M E R C H A N T A B I L I T Y   o r   F I T N E S S   F O R   A   P A R T I C U L A R   P U R P O S E .     S e e   t h e 
 
   *   G N U   G e n e r a l   P u b l i c   L i c e n s e   f o r   m o r e   d e t a i l s . 
 
   * 
 
   *   Y o u   s h o u l d   h a v e   r e c e i v e d   a   c o p y   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e 
 
   *   a l o n g   w i t h   t h i s   p r o g r a m .     I f   n o t ,   s e e   < h t t p : / / w w w . g n u . o r g / l i c e n s e s / > . 
 
   *   
 
   *   F o r   f u r t h e r   i n f o r m a t i o n   p l e a s e   c o n t a c t . 
 
   * 	 h t t p : / / n y a t l a . j p / n y a t o o l k i t / 
 
   * 	 < a i r m a i l ( a t ) e b o n y . p l a l a . o r . j p >   o r   < n y a t l a ( a t ) n y a t l a . j p > 
 
   *   
 
   * / 
 
 u s i n g   S y s t e m . C o l l e c t i o n s . G e n e r i c ; 
 
 u s i n g   j p . n y a t l a . n y a r t o o l k i t . c s . c o r e ; 
 
 n a m e s p a c e   j p . n y a t l a . n y a r t o o l k i t . c s . m a r k e r s y s t e m . u t i l s 
 
 { 
 
 
 
 
 
         p u b l i c   c l a s s   A R M a r k e r L i s t   :   S y s t e m . C o l l e c t i o n s . G e n e r i c . L i s t < A R M a r k e r L i s t . I t e m > 
 
         { 
 
 	         / * * 
 
 	           *   S0n0000o00A R 000n0iQP}g0OX[Y00000000g0Y00
 
 	           * / 
 
 	         p u b l i c   c l a s s   I t e m   :   T M a r k e r D a t a 
 
 	         { 
 
 	 	         / * *   M K _ A R n0`1X0kn0_00n00A R T o o l K i t 0000<h
}W0~0Y00* / 
 
 	 	         p u b l i c   N y A R M a t c h P a t t _ C o l o r _ W I T H O U T _ P C A   m a t c h p a t t ; 
 
 	 	         / * *   M K _ A R n0`1X0iQW0_0wb_n0<h
}	Ype0000n0 N^0<h
}W0~0Y00* / 
 
 	 	         p u b l i c   d o u b l e   c f ; 
 
 	 	         p u b l i c   i n t   p a t t _ w ; 
 
 	 	         p u b l i c   i n t   p a t t _ h ; 
 
 	 	         / * *   M K _ A R n0`1X00000n0000rRT0* / 
 
 	 	         p u b l i c   i n t   p a t t _ e d g e _ p e r c e n t a g e ; 
 
 	 	         / * *   * / 
 
 	 	         p u b l i c   I t e m ( N y A R C o d e   i _ p a t t , i n t   i _ p a t t _ e d g e _ p e r c e n t a g e , d o u b l e   i _ p a t t _ s i z e ) 
 
 	 	         { 
 
 	 	 	         / / b a s e ( ) ; 
 
 	 	 	         t h i s . m a t c h p a t t = n e w   N y A R M a t c h P a t t _ C o l o r _ W I T H O U T _ P C A ( i _ p a t t ) ; 
 
 	 	 	         t h i s . p a t t _ e d g e _ p e r c e n t a g e = i _ p a t t _ e d g e _ p e r c e n t a g e ; 
 
 	 	 	         t h i s . m a r k e r _ o f f s e t . s e t S q u a r e ( i _ p a t t _ s i z e ) ; 
 
 	 	 	         t h i s . p a t t _ w = i _ p a t t . g e t W i d t h ( ) ; 
 
 	 	 	         t h i s . p a t t _ h = i _ p a t t . g e t H e i g h t ( ) ; 
 
 	 	 	         r e t u r n ; 
 
 	 	         } 	 	 
 
 	         } 	 
 
                 / * * 
 
                   *   
 
                   * / 
 
                 p r i v a t e   d o u b l e   _ c o n f i g e n s e _ t h   =   0 . 5 ; 
 
                 p r i v a t e   r e a d o n l y   N y A R M a t c h P a t t R e s u l t   _ p a t t _ r e s u l t   =   n e w   N y A R M a t c h P a t t R e s u l t ( ) ; 
 
                 p r i v a t e   r e a d o n l y   M u l t i R e s o l u t i o n P a t t P r o v i d e r   _ m p i c k u p   =   n e w   M u l t i R e s o l u t i o n P a t t P r o v i d e r ( ) ; 
 
                 p r i v a t e   A R M a r k e r S o r t L i s t   _ m k m a p ; 
 
                 p u b l i c   A R M a r k e r L i s t ( ) 
 
                 { 
 
                         t h i s . _ m k m a p   =   n e w   A R M a r k e r S o r t L i s t ( ) ; / / Rg$P1 000
 
                         / / s q o0t r a c k i n g g0n u l l RgSn0
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0A d d NYO0j0D0g0m00
 
                   * / 
 
                 p u b l i c   v o i d   a d d ( A R M a r k e r L i s t . I t e m   i _ e ) 
 
                 { 
 
                         / / 0000000n00000te
 
                         i n t   s   =   t h i s . C o u n t   +   1 ; 
 
                         w h i l e   ( t h i s . _ m k m a p . g e t L e n g t h ( )   <   s   *   s ) 
 
                         { 
 
                                 t h i s . _ m k m a p . a p p e n d ( ) ; 
 
                         } 
 
                         b a s e . A d d ( i _ e ) ; 
 
                 } 
 
                 / * * 
 
                   *   000n0 NweE\$P0-[Y000
 
                   * / 
 
                 p u b l i c   v o i d   s e t C o n f i c e n c e T h ( d o u b l e   i _ t h ) 
 
                 { 
 
                         t h i s . _ c o n f i g e n s e _ t h   =   i _ t h ; 
 
                 } 
 
                 / * * 
 
                   *   o _ t a r g e t s k00weE\$P0H0_0000000000ԏtSY000
 
                   *   @ p a r a m   i _ p i x _ d r v 
 
                   *   @ p a r a m   i _ v e r t e x 
 
                   *   @ p a r a m   o _ t a r g e t s 
 
                   *   @ r e t u r n 
 
                   *   @   
 
                   * / 
 
                 p u b l i c   b o o l   u p d a t e ( I N y A R P e r s p e c t i v e C o p y   i _ p i x _ d r v ,   S q u a r e S t a c k . I t e m   i _ s q ) 
 
                 { 
 
                         / / s q _ t m p k0$P0ubW0_0K0n0000
 
                         b o o l   i s _ g a n a l a t e d _ s q   =   f a l s e ; 
 
                         f o r   ( i n t   i   =   t h i s . C o u n t   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 A R M a r k e r L i s t . I t e m   t a r g e t   =   t h i s [ i ] ; 
 
                                 / / P^k0 NY00;uP0S_
 
                                 N y A R M a t c h P a t t D e v i a t i o n C o l o r D a t a   d i f f   =   t h i s . _ m p i c k u p . g e t D e v i a t i o n C o l o r D a t a ( t a r g e t ,   i _ p i x _ d r v ,   i _ s q . o b _ v e r t e x ) ; 
 
                                 / / 000n00000P^k0 NW0_0000000;uPh0kY000
 
                                 i f   ( ! t a r g e t . m a t c h p a t t . e v a l u a t e ( d i f f ,   t h i s . _ p a t t _ r e s u l t ) ) 
 
                                 { 
 
                                         c o n t i n u e ; 
 
                                 } 
 
                                 / / weE\$P00000
 
                                 i f   ( t h i s . _ p a t t _ r e s u l t . c o n f i d e n c e   <   t h i s . _ c o n f i g e n s e _ t h ) 
 
                                 { 
 
                                         c o n t i n u e ; 
 
                                 } 
 
                                 / / 000000x0n0R[aK0y000
 
                                 A R M a r k e r S o r t L i s t . I t e m   i p   =   t h i s . _ m k m a p . g e t I n s e r t P o i n t ( t h i s . _ p a t t _ r e s u l t . c o n f i d e n c e ) ; 
 
                                 i f   ( i p   = =   n u l l ) 
 
                                 { 
 
                                         c o n t i n u e ; 
 
                                 } 
 
                                 / / 0000000000n0wb_k0Sgq$P0-[Y000
 
                                 i p   =   t h i s . _ m k m a p . i n s e r t F r o m T a i l B e f o r e ( i p ) ; 
 
                                 i p . c f   =   t h i s . _ p a t t _ r e s u l t . c o n f i d e n c e ; 
 
                                 i p . d i r   =   t h i s . _ p a t t _ r e s u l t . d i r e c t i o n ; 
 
                                 i p . m a r k e r   =   t a r g e t ; 
 
                                 i p . r e f _ s q   =   i _ s q ; 
 
                                 i s _ g a n a l a t e d _ s q   =   t r u e ; 
 
                         } 
 
                         r e t u r n   i s _ g a n a l a t e d _ s q ; 
 
                 } 
 
                 / * * 
 
                   *   @ p a r a m   i _ n u m _ o f _ m a r k e r s 
 
                   *   000n0Ppe
 
                   * / 
 
                 p u b l i c   v o i d   p r e p a r e ( ) 
 
                 { 
 
                         / / 00000000000000
 
                         t h i s . _ m k m a p . r e s e t ( ) ; 
 
                 } 
 
                 p u b l i c   v o i d   f i n i s h ( ) 
 
                 { 
 
                         / /  Nsn0 g0ؚD000000_00
 
                         A R M a r k e r S o r t L i s t . I t e m   t o p _ i t e m   =   t h i s . _ m k m a p . g e t T o p I t e m ( ) ; 
 
                         / / 00000iQg0M0j0O0j00~0g00 NsL0ؚD0k000000_00
 
                         w h i l e   ( t o p _ i t e m   ! =   n u l l ) 
 
                         { 
 
                                 / / iQW0_00000n0A R m a r k e r I n d e x n00000000
 
                                 A R M a r k e r L i s t . I t e m   t a r g e t   =   t o p _ i t e m . m a r k e r ; 
 
                                 i f   ( t a r g e t . l o s t _ c o u n t   >   0 ) 
 
                                 { 
 
                                         / / *grRS_n0000n00iQd\O0[L0
 
                                         t a r g e t . c f   =   t o p _ i t e m . c f ; 
 
                                         t a r g e t . l o s t _ c o u n t   =   0 ; / / m1Y000000000
 
                                         t a r g e t . l i f e + + ;             / / 000$P0R{
 
                                         t a r g e t . s q   =   t o p _ i t e m . r e f _ s q ; 
 
                                         t a r g e t . s q . r o t a t e V e r t e x L ( 4   -   t o p _ i t e m . d i r ) ; 
 
                                         N y A R I n t P o i n t 2 d . s h i f t C o p y ( t o p _ i t e m . r e f _ s q . o b _ v e r t e x ,   t a r g e t . t l _ v e r t e x ,   4   -   t o p _ i t e m . d i r ) ; 
 
                                         t a r g e t . t l _ c e n t e r . s e t V a l u e ( t o p _ i t e m . r e f _ s q . c e n t e r 2 d ) ; 
 
                                         t a r g e t . t l _ r e c t _ a r e a   =   t o p _ i t e m . r e f _ s q . r e c t _ a r e a ; 
 
                                 } 
 
                                 / / Wn0000h0͑Y0000000JRdY000
 
                                 t h i s . _ m k m a p . d i s a b l e M a t c h I t e m ( t o p _ i t e m ) ; 
 
                                 t o p _ i t e m   =   t h i s . _ m k m a p . g e t T o p I t e m ( ) ; 
 
                         } 
 
                         / / m1Y0000L0weE\$P0H0_000l i f e 00 k0Y000
 
                 } 
 
         } 
 
 } 