SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
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

Más contenido relacionado

Más 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
 

Más 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
 

Último

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
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
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 

Último (20)

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
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
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 

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