SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
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
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
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
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
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
 
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
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
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
 
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
 

Kürzlich hochgeladen (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
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
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
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.
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
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
 
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
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
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
 
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
 

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