SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
2008 ICIA International Conference on Information
                                            and Automation




                           SU2-6: Video Tracking

SU2-6(4): A Machine Vision Extension for the Ruby Programming Language

            J. Wedekind, B. P. Amavasai, K. Dutton, M. Boissenin

                          Sunday, June 22th 2008

                 Microsystems and Machine Vision Laboratory
                   Materials Engineering Research Institute
                         Sheffield Hallam University
                                  Sheffield
                               United Kingdom




               1/14
Introduction
       EPSRC Nanorobotics grant




                      electron microscopy
                     • telemanipulation
                     • drift-compensation
                     • closed-loop control
                        computer vision
                     • real-time software
                     • system integration
                     • theoretical insights



2/14
Introduction
                                               GPLv3 free software license

four freedoms (Richard Stallman)
 1. The freedom to run the program, for any purpose.
 2. The freedom to study how the program works, and adapt it to your
    needs.
 3. The freedom to redistribute copies so you can help your neighbor.
 4. The freedom to improve the program, and release your
    improvements to the public, so that the whole community benefits.
respect the freedom of downstream users (Richard Stallman)
GPL requires derived works to be available under the same license.
covenant not to assert patent claims (Eben Moglen)
GPLv3 deters users of the program from instituting patent ligitation by
the threat of withdrawing further rights to use the program.
other (Eben Moglen)
GPLv3 has regulations against DMCA restrictions and tivoization.


                     3/14
Introduction
                    Ruby programming language




       http://www.ruby-lang.org/


4/14
HornetsEye
       Free software code base




5/14
HornetsEye
                                 I/O integration




                                         
 Y   0.299
  
                   0.587     0.114 
                                      
                                         R  0 
                                             
                                             
  
                                   
                                            
                                             
 =
  
  
Cb  −0.168736 −0.331264
                                      
                                          + 
                                             
                                             
                                0.500    G 128
                                   
                                            
  
  
                                   
                                      
                                            
                                             
                                             
  
                                   
                                            
                                             
C   0.500
   r               −0.418688 −0.081312    B  128
           also see: http://fourcc.org/


   6/14
HornetsEye
                                                                       Multi-dimensional arrays


g,h ∈ {0, 1,  . .  w − 1} × {0, 1, . . . , h − 1} → R
             . ,
   x1 
   ) = g( x1 )/2
                                                                               MultiArray.dfloat( 320, 240 ):
   
h( 
   
               
               
               
                                                       MultiArray.dfloat          [ [ 245.0, 244.0, 197.0, ... ],
   
  x          
              x 
    2              2                                     Fixnum                      [ 245.0, 247.0, 197.0, ... ],
                                                                                     [ 247.0, 248.0, 187.0, ... ]
Ruby                                              h=g/2                            ...

                                                                                             [3.141]
     MultiArray.respond to?( ”binary div lint dfloat” )
                                      no




                                                                                                          String.unpack(”D”)
                                                                                        Array.pack(”D”)
     h = g.collect { |x| x / 2 }                         yes



C++                                        for ( int i=0; i<n; i++ )
                                              *r++ = *p++ / q;
     MultiArray.binary   div   byte   byte
     MultiArray.binary   div   byte   bytergb                            ”x54xE3xA5x9BxC4x20x09x40”
     MultiArray.binary   div   byte   dcomplex
     MultiArray.binary   div   byte   dfloat
     MultiArray.binary   div   byte   dfloatrgb
     ...




                                      7/14
Generic operations
                                                              Linear shift-invariant filters

                                      Common code
grad sigma, cov sigma = 1.0, 1.0
x, y = img.gauss gradient x( grad sigma ), img.gaussgradient y( grad sigma )
a = ( x ** 2 ).gauss blur( cov sigma )
b = ( y ** 2 ).gauss blur( cov sigma )
c = ( x * y ).gauss blur( cov sigma )
tr = a + b
det = a * b - c * c
                                                 Yang et al.
                    noise = 1.0
                    g = ( ( a - b ) ** 2 + ( 2 * c ) ** 2 ) / ( a + b + noise ** 2 ) ** 2
                    result = ( g.normalise( 1.0..0.0 ) ** m * ( x ** 2 + y ** 2 ) )
                        Kanade-Lucas-Tomasi
          dissqrt = ( tr ** 2 - det * 4 ).major( 0.0 ).sqrt
          result = 0.5 * ( tr - dissqrt )
       Harris-Stephens
                                                                                            MultiArray.correlate   byte   byte
     k = 0.1                                                                                MultiArray.correlate   byte   bytergb
     result = det - tr * tr * k                                                             MultiArray.correlate   byte   dcomplex
                                                                                            MultiArray.correlate   byte   dfloat
                                                                                            MultiArray.correlate   byte   dfloatrb
                                                                                            ...




                           8/14
Generic operations
                                                                                  Warps

                                                                                     
                                                                   g W( x1 )
                                                                                        x1 
g ∈ {0, 1, . . . , w − 1} × {0, 1, . . . , h − 1} → R3
                                                                      
                                                                                  if W( ) ∈ {0, 1, . . . , w − 1} × {0, 1, . . . , h − 1}
                                                                  
                                                                                     
                                                                                        
                                                            x1        
                                                                                      
h ∈ {0, 1, . . . , w − 1} × {0, 1, . . . , h − 1} → R3      ) = 
                                                            
                                                                                   
                                                         h( 
                                                                       
                                                                        x             
                                                                                       x 
                                                                        2              2
W ∈ {0, 1, . . . , w − 1} × {0, 1, . . . , h − 1} → Z2
                                                           x    
                                                                  
                                                              2   
                                                                  
                                                                   0
                                                                  
                                                                                  otherwise

class MultiArray
 def MultiArray.ramp1( *shape )
   retval = MultiArray.new( MultiArray::LINT, *shape )
   for x in 0...shape[0]
     retval[ x, 0...shape[1] ] = x
   end
   retval
 end
 # ...
end
img = MultiArray.load rgb24( ”test.jpg” )
w, h = *img.shape; c = 0.5 * h
x, y = MultiArray.ramp1( h, h ), MultiArray.ramp2( h, h )
warp = MultiArray.new( MultiArray::LINT, h, h, 2 )
warp[ 0...h, 0...h, 0 ], warp[ 0...h, 0...h, 1 ] =
   ( ( ( x - c ).atan2( y - c ) / Math::PI + 1 ) * w / 2 - 0.5 ),
   ( ( x - c ) ** 2 + ( y - c ) ** 2 ).sqrt
img.warp clipped( warp ).display




                               9/14
Generic operations
                                                              Affine transforms

class MultiArray                                                      
                                                                      x1 
                                                                                           
                                                                            cos(α) − sin(α)
                                                                                                 
                                                                                                 x1 
 def MultiArray.ramp1( *shape )                                       ) = 
                                                                      
                                                                      
                                                                 Wα ( 
                                                                          
                                                                            
                                                                            
                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                                 
                                                                                                 
                                                                                                 
                                                                                                 
  retval = MultiArray.new( MultiArray::LINT, *shape )
                                                                      
                                                                     x     sin(α) cos(α) 
                                                                                           
                                                                                                
                                                                                                 
                                                                                                x 
                                                                        2                          2
  for x in 0...shape[0]
    retval[ x, 0...shape[1] ] = x
  end
  retval
 end
 # ...
end
img = MultiArray.load rgb24( ”test.jpg” )
w, h = *img.shape
v = Vector[ MultiArray.ramp1( w, h ) - w / 2,
             MultiArray.ramp2( w, h ) - h / 2 ]
angle = 30.0 * Math::PI / 180.0
m = Matrix[ [ Math::cos( angle ), -Math::sin( angle ) ],
              [ Math::sin( angle ), Math::cos( angle ) ] ]
warp = MultiArray.new( MultiArray::LINT, w, h, 2 )
warp[ 0...w, 0...h, 0 ], warp[ 0...w, 0...h, 1 ] =
  ( m * v )[0] + w / 2, ( m * v )[1] + h / 2
img.warp clipped( warp ).display



                        10/14
Application
                                                    Inverse compositional Lucas-Kanade

given: template T , image I , previous pose p
sought: pose-change ∆p
argmin           ||T (x) − I(W p (W∆p (x)))||2 dx = (∗)
                               −1  −1
                                                                    −1   −1
  ∆p       x∈T                                                  I(W p (W∆p (x)))
(1) T (x) − I(W p (W∆p (x))) = T (W∆p (x)) − I(W p (x))
                −1  −1                           −1                 −1
                                                                I(W p (x))
                          δT          T     δW p
(2) T (W∆p (x)) ≈ T (x) +    (x)          ·      (x) · ∆p
                          δx                 δp
   (1,2)
(∗) = argmin(||H p + b||2 ) = (H T H)−1 H T b
            p
             
             h1,1 h1,2 · · ·
                                          
                                          b1                          T (x)
             
             
                              
                               
                                          
                                           
                                           
                                         
where H =  2,1 h2,2 · · ·     and b = b 
             
             
             h                
                                          
                                           
             
                              
                                          2
                                           
                                           
              .    .                     .
                          .. 
                                         
              .    .
                                         .
                             .
                                         
                .   .                        .
                                         

        δT      T  δW p
hi, j =    (xi ) ·      (xi ) , bi = T (xi ) − I(W p (xi ))
                                                   −1
        δx         δp j
           S. Baker and I. Matthew: “Lucas-Kanade 20 years on: a unifying framework”
                       http://www.ri.cmu.edu/projects/project 515.html

                            11/14
Applications
                                         Lucas-Kanade core

                            initialisation
p = Vector[ xshift, yshift, rotation ]
w, h, sigma = tpl.shape[0], tpl.shape[1], 5.0
x, y = xramp( w, h ), yramp( w, h )
gx = tpl.gauss_gradient_x( sigma )
gy = tpl.gauss_gradient_y( sigma )
c = Matrix[ [ 1, 0 ], [ 0, 1 ], [ -y, x ] ] * Vector[ gx, gy ]
hs = ( c * c.covector ).collect { |e| e.sum }
                              tracking
field = MultiArray.new( MultiArray::SFLOAT, w,   h, 2 )
field[ 0...w, 0...h, 0 ] = x * cos( p[2] ) - y   * sin( p[2] ) + p[0]
field[ 0...w, 0...h, 1 ] = x * sin( p[2] ) + y   * cos( p[2] ) + p[1]
diff = img.warp_clipped_interpolate( field ) -   tpl
s = c.collect { |e| ( e * diff ).sum }
d = hs.inverse * s
p += Matrix[ [ cos(p[2]), -sin(p[2]), 0 ],
             [ sin(p[2]), cos(p[2]), 0 ],
             [          0,          0, 1 ] ] *   d


           12/14
Application
                        Lucas-Kanade implementation details

   Interpolation                 Gradient boundary

without interpolation




                                  boundary effects



 with interpolation


                                 no boundary effects




               13/14
Conclusion



conclusion

 • concise implementation of Lucas-Kanade

 • native blocks of code in C++, Ruby as glue-code

 • development platform for general purpose machine vision

future work

 • microscopy software

 • wavelets, feature extraction

 • feature-based object tracking & recognition

free software
http://www.wedesoft.demon.co.uk/hornetseye-api/
http://rubyforge.org/projects/hornetseye/
http://sourceforge.net/projects/hornetseye/


                      14/14

Contenu connexe

Plus de Jan Wedekind

Machine vision and device integration with the Ruby programming language (2008)
Machine vision and device integration with the Ruby programming language (2008)Machine vision and device integration with the Ruby programming language (2008)
Machine vision and device integration with the Ruby programming language (2008)Jan Wedekind
 
Reconstruction (of micro-objects) based on focus-sets using blind deconvoluti...
Reconstruction (of micro-objects) based on focus-sets using blind deconvoluti...Reconstruction (of micro-objects) based on focus-sets using blind deconvoluti...
Reconstruction (of micro-objects) based on focus-sets using blind deconvoluti...Jan Wedekind
 
Fokus-serien basierte Rekonstruktion von Mikroobjekten (2002)
Fokus-serien basierte Rekonstruktion von Mikroobjekten (2002)Fokus-serien basierte Rekonstruktion von Mikroobjekten (2002)
Fokus-serien basierte Rekonstruktion von Mikroobjekten (2002)Jan Wedekind
 
Play Squash with Ruby, OpenGL, and a Wiimote - ShRUG Feb 2011
Play Squash with Ruby, OpenGL, and a Wiimote - ShRUG Feb 2011Play Squash with Ruby, OpenGL, and a Wiimote - ShRUG Feb 2011
Play Squash with Ruby, OpenGL, and a Wiimote - ShRUG Feb 2011Jan Wedekind
 
Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...
Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...
Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...Jan Wedekind
 
Machine Vision made easy with Ruby - ShRUG June 2010
Machine Vision made easy with Ruby - ShRUG June 2010Machine Vision made easy with Ruby - ShRUG June 2010
Machine Vision made easy with Ruby - ShRUG June 2010Jan Wedekind
 
Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009Jan Wedekind
 
Real-time Computer Vision With Ruby - OSCON 2008
Real-time Computer Vision With Ruby - OSCON 2008Real-time Computer Vision With Ruby - OSCON 2008
Real-time Computer Vision With Ruby - OSCON 2008Jan Wedekind
 
Object Recognition and Real-Time Tracking in Microscope Imaging - IMVIP 2006
Object Recognition and Real-Time Tracking in Microscope Imaging - IMVIP 2006Object Recognition and Real-Time Tracking in Microscope Imaging - IMVIP 2006
Object Recognition and Real-Time Tracking in Microscope Imaging - IMVIP 2006Jan Wedekind
 
Steerable Filters generated with the Hypercomplex Dual-Tree Wavelet Transform...
Steerable Filters generated with the Hypercomplex Dual-Tree Wavelet Transform...Steerable Filters generated with the Hypercomplex Dual-Tree Wavelet Transform...
Steerable Filters generated with the Hypercomplex Dual-Tree Wavelet Transform...Jan Wedekind
 
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009Jan Wedekind
 

Plus de Jan Wedekind (11)

Machine vision and device integration with the Ruby programming language (2008)
Machine vision and device integration with the Ruby programming language (2008)Machine vision and device integration with the Ruby programming language (2008)
Machine vision and device integration with the Ruby programming language (2008)
 
Reconstruction (of micro-objects) based on focus-sets using blind deconvoluti...
Reconstruction (of micro-objects) based on focus-sets using blind deconvoluti...Reconstruction (of micro-objects) based on focus-sets using blind deconvoluti...
Reconstruction (of micro-objects) based on focus-sets using blind deconvoluti...
 
Fokus-serien basierte Rekonstruktion von Mikroobjekten (2002)
Fokus-serien basierte Rekonstruktion von Mikroobjekten (2002)Fokus-serien basierte Rekonstruktion von Mikroobjekten (2002)
Fokus-serien basierte Rekonstruktion von Mikroobjekten (2002)
 
Play Squash with Ruby, OpenGL, and a Wiimote - ShRUG Feb 2011
Play Squash with Ruby, OpenGL, and a Wiimote - ShRUG Feb 2011Play Squash with Ruby, OpenGL, and a Wiimote - ShRUG Feb 2011
Play Squash with Ruby, OpenGL, and a Wiimote - ShRUG Feb 2011
 
Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...
Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...
Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...
 
Machine Vision made easy with Ruby - ShRUG June 2010
Machine Vision made easy with Ruby - ShRUG June 2010Machine Vision made easy with Ruby - ShRUG June 2010
Machine Vision made easy with Ruby - ShRUG June 2010
 
Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009
 
Real-time Computer Vision With Ruby - OSCON 2008
Real-time Computer Vision With Ruby - OSCON 2008Real-time Computer Vision With Ruby - OSCON 2008
Real-time Computer Vision With Ruby - OSCON 2008
 
Object Recognition and Real-Time Tracking in Microscope Imaging - IMVIP 2006
Object Recognition and Real-Time Tracking in Microscope Imaging - IMVIP 2006Object Recognition and Real-Time Tracking in Microscope Imaging - IMVIP 2006
Object Recognition and Real-Time Tracking in Microscope Imaging - IMVIP 2006
 
Steerable Filters generated with the Hypercomplex Dual-Tree Wavelet Transform...
Steerable Filters generated with the Hypercomplex Dual-Tree Wavelet Transform...Steerable Filters generated with the Hypercomplex Dual-Tree Wavelet Transform...
Steerable Filters generated with the Hypercomplex Dual-Tree Wavelet Transform...
 
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
 

Dernier

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Dernier (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

A Machine Vision Extension for the Ruby Programming Language - ICIA 2008

  • 1. 2008 ICIA International Conference on Information and Automation SU2-6: Video Tracking SU2-6(4): A Machine Vision Extension for the Ruby Programming Language J. Wedekind, B. P. Amavasai, K. Dutton, M. Boissenin Sunday, June 22th 2008 Microsystems and Machine Vision Laboratory Materials Engineering Research Institute Sheffield Hallam University Sheffield United Kingdom 1/14
  • 2. Introduction EPSRC Nanorobotics grant electron microscopy • telemanipulation • drift-compensation • closed-loop control computer vision • real-time software • system integration • theoretical insights 2/14
  • 3. Introduction GPLv3 free software license four freedoms (Richard Stallman) 1. The freedom to run the program, for any purpose. 2. The freedom to study how the program works, and adapt it to your needs. 3. The freedom to redistribute copies so you can help your neighbor. 4. The freedom to improve the program, and release your improvements to the public, so that the whole community benefits. respect the freedom of downstream users (Richard Stallman) GPL requires derived works to be available under the same license. covenant not to assert patent claims (Eben Moglen) GPLv3 deters users of the program from instituting patent ligitation by the threat of withdrawing further rights to use the program. other (Eben Moglen) GPLv3 has regulations against DMCA restrictions and tivoization. 3/14
  • 4. Introduction Ruby programming language http://www.ruby-lang.org/ 4/14
  • 5. HornetsEye Free software code base 5/14
  • 6. HornetsEye I/O integration          Y   0.299       0.587 0.114    R  0                           =       Cb  −0.168736 −0.331264    +          0.500  G 128                                                  C   0.500 r −0.418688 −0.081312  B  128 also see: http://fourcc.org/ 6/14
  • 7. HornetsEye Multi-dimensional arrays g,h ∈ {0, 1,  . .  w − 1} × {0, 1, . . . , h − 1} → R  . ,  x1   ) = g( x1 )/2     MultiArray.dfloat( 320, 240 ):   h(            MultiArray.dfloat [ [ 245.0, 244.0, 197.0, ... ],   x    x  2 2 Fixnum [ 245.0, 247.0, 197.0, ... ], [ 247.0, 248.0, 187.0, ... ] Ruby h=g/2 ... [3.141] MultiArray.respond to?( ”binary div lint dfloat” ) no String.unpack(”D”) Array.pack(”D”) h = g.collect { |x| x / 2 } yes C++ for ( int i=0; i<n; i++ ) *r++ = *p++ / q; MultiArray.binary div byte byte MultiArray.binary div byte bytergb ”x54xE3xA5x9BxC4x20x09x40” MultiArray.binary div byte dcomplex MultiArray.binary div byte dfloat MultiArray.binary div byte dfloatrgb ... 7/14
  • 8. Generic operations Linear shift-invariant filters Common code grad sigma, cov sigma = 1.0, 1.0 x, y = img.gauss gradient x( grad sigma ), img.gaussgradient y( grad sigma ) a = ( x ** 2 ).gauss blur( cov sigma ) b = ( y ** 2 ).gauss blur( cov sigma ) c = ( x * y ).gauss blur( cov sigma ) tr = a + b det = a * b - c * c Yang et al. noise = 1.0 g = ( ( a - b ) ** 2 + ( 2 * c ) ** 2 ) / ( a + b + noise ** 2 ) ** 2 result = ( g.normalise( 1.0..0.0 ) ** m * ( x ** 2 + y ** 2 ) ) Kanade-Lucas-Tomasi dissqrt = ( tr ** 2 - det * 4 ).major( 0.0 ).sqrt result = 0.5 * ( tr - dissqrt ) Harris-Stephens MultiArray.correlate byte byte k = 0.1 MultiArray.correlate byte bytergb result = det - tr * tr * k MultiArray.correlate byte dcomplex MultiArray.correlate byte dfloat MultiArray.correlate byte dfloatrb ... 8/14
  • 9. Generic operations Warps       g W( x1 )  x1  g ∈ {0, 1, . . . , w − 1} × {0, 1, . . . , h − 1} → R3      if W( ) ∈ {0, 1, . . . , w − 1} × {0, 1, . . . , h − 1}          x1         h ∈ {0, 1, . . . , w − 1} × {0, 1, . . . , h − 1} → R3  ) =           h(      x    x     2 2 W ∈ {0, 1, . . . , w − 1} × {0, 1, . . . , h − 1} → Z2 x    2    0  otherwise class MultiArray def MultiArray.ramp1( *shape ) retval = MultiArray.new( MultiArray::LINT, *shape ) for x in 0...shape[0] retval[ x, 0...shape[1] ] = x end retval end # ... end img = MultiArray.load rgb24( ”test.jpg” ) w, h = *img.shape; c = 0.5 * h x, y = MultiArray.ramp1( h, h ), MultiArray.ramp2( h, h ) warp = MultiArray.new( MultiArray::LINT, h, h, 2 ) warp[ 0...h, 0...h, 0 ], warp[ 0...h, 0...h, 1 ] = ( ( ( x - c ).atan2( y - c ) / Math::PI + 1 ) * w / 2 - 0.5 ), ( ( x - c ) ** 2 + ( y - c ) ** 2 ).sqrt img.warp clipped( warp ).display 9/14
  • 10. Generic operations Affine transforms class MultiArray    x1    cos(α) − sin(α)    x1  def MultiArray.ramp1( *shape )  ) =      Wα (                    retval = MultiArray.new( MultiArray::LINT, *shape )   x   sin(α) cos(α)         x  2 2 for x in 0...shape[0] retval[ x, 0...shape[1] ] = x end retval end # ... end img = MultiArray.load rgb24( ”test.jpg” ) w, h = *img.shape v = Vector[ MultiArray.ramp1( w, h ) - w / 2, MultiArray.ramp2( w, h ) - h / 2 ] angle = 30.0 * Math::PI / 180.0 m = Matrix[ [ Math::cos( angle ), -Math::sin( angle ) ], [ Math::sin( angle ), Math::cos( angle ) ] ] warp = MultiArray.new( MultiArray::LINT, w, h, 2 ) warp[ 0...w, 0...h, 0 ], warp[ 0...w, 0...h, 1 ] = ( m * v )[0] + w / 2, ( m * v )[1] + h / 2 img.warp clipped( warp ).display 10/14
  • 11. Application Inverse compositional Lucas-Kanade given: template T , image I , previous pose p sought: pose-change ∆p argmin ||T (x) − I(W p (W∆p (x)))||2 dx = (∗) −1 −1 −1 −1 ∆p x∈T I(W p (W∆p (x))) (1) T (x) − I(W p (W∆p (x))) = T (W∆p (x)) − I(W p (x)) −1 −1 −1 −1 I(W p (x)) δT T δW p (2) T (W∆p (x)) ≈ T (x) + (x) · (x) · ∆p δx δp (1,2) (∗) = argmin(||H p + b||2 ) = (H T H)−1 H T b p  h1,1 h1,2 · · ·    b1  T (x)                 where H =  2,1 h2,2 · · ·  and b = b    h            2      . . . ..       . .  . .     . . .     δT T δW p hi, j = (xi ) · (xi ) , bi = T (xi ) − I(W p (xi )) −1 δx δp j S. Baker and I. Matthew: “Lucas-Kanade 20 years on: a unifying framework” http://www.ri.cmu.edu/projects/project 515.html 11/14
  • 12. Applications Lucas-Kanade core initialisation p = Vector[ xshift, yshift, rotation ] w, h, sigma = tpl.shape[0], tpl.shape[1], 5.0 x, y = xramp( w, h ), yramp( w, h ) gx = tpl.gauss_gradient_x( sigma ) gy = tpl.gauss_gradient_y( sigma ) c = Matrix[ [ 1, 0 ], [ 0, 1 ], [ -y, x ] ] * Vector[ gx, gy ] hs = ( c * c.covector ).collect { |e| e.sum } tracking field = MultiArray.new( MultiArray::SFLOAT, w, h, 2 ) field[ 0...w, 0...h, 0 ] = x * cos( p[2] ) - y * sin( p[2] ) + p[0] field[ 0...w, 0...h, 1 ] = x * sin( p[2] ) + y * cos( p[2] ) + p[1] diff = img.warp_clipped_interpolate( field ) - tpl s = c.collect { |e| ( e * diff ).sum } d = hs.inverse * s p += Matrix[ [ cos(p[2]), -sin(p[2]), 0 ], [ sin(p[2]), cos(p[2]), 0 ], [ 0, 0, 1 ] ] * d 12/14
  • 13. Application Lucas-Kanade implementation details Interpolation Gradient boundary without interpolation boundary effects with interpolation no boundary effects 13/14
  • 14. Conclusion conclusion • concise implementation of Lucas-Kanade • native blocks of code in C++, Ruby as glue-code • development platform for general purpose machine vision future work • microscopy software • wavelets, feature extraction • feature-based object tracking & recognition free software http://www.wedesoft.demon.co.uk/hornetseye-api/ http://rubyforge.org/projects/hornetseye/ http://sourceforge.net/projects/hornetseye/ 14/14