SlideShare una empresa de Scribd logo
1 de 38
Descargar para leer sin conexión
Ruby & Machine Vision




                               Ruby & Machine Vision

                                    Jan Wedekind

                           Wednesday, February 4th 2009




Wednesday, February 4th 2009       http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   1/38
UK EPSRC Nanorobotics Project




                                                          Microscopy Software
                                                             • telemanipulation
                                                             • drift
                                                               compensation
                                                             • closed-loop
                                                               control
                                                          Machine Vision
                                                             • real-time software
                                                             • system integration
                                                             • theoretical
                                                               insights



Wednesday, February 4th 2009   http://vision.eng.shu.ac.uk/jan/demfeb09.pdf         2/38
Ruby Programming Language

      Ruby
         • created by Yukihiro Matsumoto
         • released 1995 (free software(*) , Ruby license)
         • inspired by Perl, Python, Smalltalk, Eiffel, Ada, Lisp
         • “pseudo simplicity”: simple syntax ⇔ multi-paradigm
           language
         • highly portable
         • Tiobe Programming Community Index #11
         • 1.8.6 being superseded by 1.9.1


        page                       url

        Ruby Homepage              http://www.ruby-lang.org/
        Ruby Core-API              http://www.ruby-doc.org/
        RubyForge                  http://rubyforge.org/
        Ruby Application Archive   http://raa.ruby-lang.org/


      (*) http://www.gnu.org/philosophy/free-sw.html

Wednesday, February 4th 2009         http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   3/38
Dynamic Typing




                        #!/usr/bin/env   ruby
                        def test( a, b   )
                          a + b
                        end
                        x = test( 3, 5   )     # x -> 8
                        x = test( 'a',   'b' ) # x -> 'ab'




Wednesday, February 4th 2009    http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   4/38
Garbage Collector



                         Mark and Sweep Garbage Collector
             root




      marked=true              marked=true                marked=true




      marked=false             marked=false               marked=true

                http://www.brpreiss.com/books/opus5/html/page424.html



Wednesday, February 4th 2009     http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   5/38
(Pure) Object-Oriented, Single-Dispatch




                               #!/usr/bin/env ruby
                               class Numeric
                                 def plus(x)
                                   self.+(x)
                                 end
                               end
                               y = 5.plus 6
                               # y is now equal to 11

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




Wednesday, February 4th 2009      http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   6/38
Mixins




                   #!/usr/bin/env ruby
                   module TimesThree
                     def three_times
                       self + self + self
                     end
                   end
                   class String
                     include TimesThree
                   end
                   'abc'.three_times # -> 'abcabcabc'




Wednesday, February 4th 2009   http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   7/38
Exception Handling




           #!/usr/bin/env ruby
           begin
             print "Enter filename: "
             STDOUT.flush
             file_name = STDIN.readline.delete( "nr" )
             file = File.new file_name, 'r'
             # ...
           rescue Exception => e
             puts "Error opening file '#{file_name}': #{e.message}"
           end




Wednesday, February 4th 2009     http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   8/38
Closures



           Unifying Concept for Iterators, Function Objects, and Loops
                          #!/usr/bin/env ruby
                          def inc( i )
                            lambda do |v|
                              v + i
                            end
                          end
                          t = inc( 5 )
                          t.call( 3 ) # -> 8
                          [ 1, 2, 3 ].each do |x|
                            puts x
                          end
                          [ 1, 2, 3 ].collect do |x|
                            x ** 2
                          end          # -> [1, 4, 9]
                          [ 1, 2, 3 ].inject do |v,x|
                            v + x
                          end          # -> 6



Wednesday, February 4th 2009    http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   9/38
Continuations




                               #!/usr/bin/env ruby
                               def test( c2 )
                                 callcc do |c1|
                                   return c1
                                 end
                                 c2.call
                               end
                               callcc do |c2|
                                 c1 = test( c2 )
                                 c1.call
                               end



Wednesday, February 4th 2009      http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   10/38
Introspection




                               Program can “see” itself
   #!/usr/bin/env ruby
   x = 5                                #   ->   5
   x.class                              #   ->   Fixnum
   x.class.class                        #   ->   Class
   x.class.superclass                   #   ->   Integer
   x.is_a?( Fixnum )                    #   ->   true
   Fixnum < Integer                     #   ->   true
   5.respond_to?( '+' )                 #   ->   true
   5.methods.grep( /^f/ ).sort          #   ->   ["floor", "freeze", "frozen?"]




Wednesday, February 4th 2009      http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   11/38
Metaprogramming



                               Interpreter modifies Program
               #!/usr/bin/env ruby
               eval 'x=5'              # x -> 5
               a = [ 1 ]
               a.instance_eval do
                 push 2
               end                     # a -> [ 1, 2 ]
               a.send( 'push', 3 )     # a -> [ 1, 2, 3 ]
               Object.const_get( 'String' ).class_eval do
                 define_method 'test' do
                   reverse
                 end
               end
               'abc'.reverse           # -> 'cba'



Wednesday, February 4th 2009        http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   12/38
Reification




                               Program modifies Interpreter
           #!/usr/bin/env ruby
           class Numeric
             def method_missing( name, *args )
               prefix = Regexp.new( "^#{name}" )
               full_name = methods.find { |id| id =~ prefix }
               if full_name
                 send( full_name, *args )
               else
                 super
               end
             end
           end
           5.mod 2 # calls 5.modulo 2



Wednesday, February 4th 2009        http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   13/38
Ruby Extensions
                                     C Library
      // gcc -shared -fPIC -I/usr/lib/ruby/1.8/x86_64-linux 
      //   -o myextension.so myextension.c
      #include <ruby.h>
      #include <math.h>

      VALUE wrap_logx( VALUE self, VALUE x )
      {
        return rb_float_new( log( NUM2DBL( self ) ) / log( NUM2DBL( x ) ) );
      }

      void Init_myextension(void) {
        VALUE numeric = rb_const_get( rb_cObject, rb_intern( "Numeric" ) );
        rb_define_method( numeric, "logx", RUBY_METHOD_FUNC( wrap_logx ), 1 );
      }

                               Invoking Ruby Program
                               #!/usr/bin/env ruby
                               require 'myextension'
                               e = 1024.logx( 2 )
                               puts "2 ** #{e} = 1024"

             http://www.rubyist.net/~nobu/ruby/Ruby_Extension_Manual.html
Wednesday, February 4th 2009     http://vision.eng.shu.ac.uk/jan/demfeb09.pdf    14/38
HornetsEye - Ruby Extension for Machine Vision




                   Free Software Project
      • Real-Time Machine Vision
      • Ruby Extension
      • released under GNU General Public License
       • 2 years development
       • 22000 lines of code




                   http://www.wedesoft.demon.co.uk/hornetseye-api/
                   http://rubyforge.org/projects/hornetseye/
                   http://sourceforge.net/projects/hornetseye/
                   https://launchpad.net/hornetseye/
                   http://raa.ruby-lang.org/project/hornetseye/




Wednesday, February 4th 2009       http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   15/38
Using existing Free Software

              Libraries Integrated
                        C++ Boost

                        libdc1394
                                                           Tools in Use
                        DotGNU
                                                         Bazaar
                        FFTW

                        MPlayer                          GCC

                        OpenEXR                          make, automake, autoconf
                                                         NaturalDocs
                        Qt4-QtRuby
                        RMagick                          NSIS

                        NArray                           Ruby

                        libxine

                        Xorg, Mesa3D

Wednesday, February 4th 2009        http://vision.eng.shu.ac.uk/jan/demfeb09.pdf    16/38
Inpput/Output Classes



                                 Input/Output Classes


                                /
                         V4LInput              VFWInput
                         V4L2Input             DShowInput
                         DC1394Input           —
                         XineInput             —
                         MPlayerInput          MPlayerInput
                         MEncoderOutput        MEncoderOutput
                         X11Display            W32Display
                         X11Window             W32Window
                         XImageOutput          GDIOutput
                         OpenGLOutput          —
                         XVideoOutput          —



Wednesday, February 4th 2009        http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   17/38
Colourspace Conversions




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

Wednesday, February 4th 2009    http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   18/38
GUI Integration I/II




Wednesday, February 4th 2009     http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   19/38
GUI Integration II/II




Wednesday, February 4th 2009      http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   20/38
Just-In-Time Compiler




   #!/usr/bin/env
   require 'hornetseye'
   include Hornetseye
   fun = JITFunction.compile( JITType::DFLOAT,
                              JITType::DFLOAT,
                              JITType::DFLOAT ) do |f,a,b|
     Math.log( a ) / Math.log( b )
   end
   fun.call( 1024, 2 ) # -> 10.0




Wednesday, February 4th 2009      http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   21/38
Some other Vision Libraries I/II




                                                                                                      Framewave
                                                                               EasyVision
                                                           CMVision
                                                Camellia




                                                                                                                  Gamera

                                                                                                                           Gandalf
                                                                      libCVD



                                                                                            Filters
                                        Blepo
                  feature

                  Camera Input                                                                                     
                  Image Files                                                                                      
                  Video Files                                                                                      
                  Display                                                                                          
                  Scripting                                                                                        
                  Warps                                                                                            
                  Histograms                                                                                       
                  Custom Filters                                                                                   
                  Fourier Transforms                                                                               
                  Feature Extraction                                                                               
                  Feature Matching                                                                                 
                  GPL compatible                                            ?                                       
        Also see http://www.wedesoft.demon.co.uk/hornetseye-api/files/Links-txt.html


Wednesday, February 4th 2009         http://vision.eng.shu.ac.uk/jan/demfeb09.pdf                                                    22/38
Some other Vision Libraries II/II




                                                                                           NASA V. W.
                                      HornetsEye

                                                   ITK/VTK




                                                                                                                 SceneLib
                                                                                                        OpenCV



                                                                                                                            VIGRA
                                                                                   Mimas
                                                                   LTIlib

                                                                            Lush
                                                             IVT
                feature

                Camera Input                                                                                       
                Image Files                                                                                        
                Video Files                                                                                        
                Display                                                                                            
                Scripting                                                                                          
                Warps                                                                                              
                Histograms                                                                                         
                Custom Filters                                                                                     
                Fourier Transforms                                                                                 
                Feature Extraction                                                                                 
                Feature Matching                                                                                   
                GPL compatible                                                                                     
        Also see http://www.wedesoft.demon.co.uk/hornetseye-api/files/Links-txt.html

Wednesday, February 4th 2009         http://vision.eng.shu.ac.uk/jan/demfeb09.pdf                                                   23/38
Dense Scripts

                                    OpenCV + Python

   #! /usr/bin/env python
   import sys
   from opencv import cv
   from opencv import highgui
   highgui.cvNamedWindow( ’Camera’ )
   capture = highgui.cvCreateCameraCapture( -1 )
   while 1:
       frame = highgui.cvQueryFrame( capture )
       gray = cv.cvCreateImage( cv.cvSize( frame.width, frame.height), 8, 1 )
       cv.cvCvtColor( frame, gray, cv.CV_BGR2GRAY )
       highgui.cvShowImage( ’Camera’, gray )
       if highgui.cvWaitKey( 5 )  0:
           break

                                    HornetsEye + Ruby

   #!/usr/bin/env ruby
   require ’hornetseye’
   include Hornetseye
   capture = V4L2Input.new
   X11Display.show { capture.read.to_grey8 }

Wednesday, February 4th 2009        http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   24/38
Interactive Ruby (IRB)


   require 'hornetseye'
   include Hornetseye
   img = MultiArray.load_rgb24 '/home/engjw/test/hornetseye/data/images/world.jpg'
   # MultiArrayubytergb(640,320):
   # [ [ RGB( 0, 20, 55 ), RGB( 0, 20, 55 ), RGB( 0, 20, 55 ), .... ],
   #   [ RGB( 17, 36, 69 ), RGB( 17, 36, 69 ), RGB( 18, 37, 70 ), .... ],
   #   [ RGB( 9, 24, 55 ), RGB( 9, 24, 55 ), RGB( 8, 23, 54 ), .... ],
   #   [ RGB( 8, 22, 51 ), RGB( 8, 22, 51 ), RGB( 7, 21, 50 ), .... ],
   #   [ RGB( 8, 19, 49 ), RGB( 8, 19, 49 ), RGB( 8, 19, 49 ), .... ],
   # ....
   filter = MultiArray.to_multiarray( [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ] ).to_usint
   # MultiArrayusint(3,3):
   # [ [ 1, 1, 1 ],
   #   [ 1, 1, 1 ],
   #   [ 1, 1, 1 ] ]
   img.correlate( filter )
   # MultiArrayusintrgb(640,320):
   # [ [ RGB( 34, 112, 248 ), RGB( 52, 169, 373 ), RGB( 54, 171, 375 ), .... ],
   #   [ RGB( 52, 160, 358 ), RGB( 78, 240, 537 ), RGB( 79, 241, 538 ), .... ],
   #   [ RGB( 68, 164, 350 ), RGB( 101, 245, 524 ), .... ],
   #   [ RGB( 50, 130, 310 ), RGB( 73, 193, 463 ), RGB( 72, 192, 462 ), .... ],
   #   [ RGB( 45, 123, 306 ), RGB( 66, 182, 458 ), RGB( 64, 182, 457 ), .... ],
   # ....


Wednesday, February 4th 2009       http://vision.eng.shu.ac.uk/jan/demfeb09.pdf       25/38
Opening Webcam/Framegrabber




                       #!/usr/bin/env ruby
                       require 'hornetseye'
                       include Hornetseye
                       input = V4L2Input.new
                       img = input.read
                       img.show




Wednesday, February 4th 2009   http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   26/38
Capture Image




         #!/usr/bin/env ruby
         require 'hornetseye'
         include Hornetseye
         input = V4L2Input.new
         img = nil
         X11Display.show { img = input.read_rgb24 }
         img.save_rgb24 'test.jpg'




Wednesday, February 4th 2009   http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   27/38
Capture Video




     #!/usr/bin/env ruby
     require 'hornetseye'
     include Hornetseye
     input = V4L2Input.new( '/dev/video0', 640, 480 )
     output = MEncoderOutput.new( 'test.avi', 10,
       '-ovc lavc -lavcopts vcodec=msmpeg4:vhq:vbitrate=4000' )
     X11Display.show do
       img = input.read
       output.write( img )
       img
     end
     output.close




Wednesday, February 4th 2009   http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   28/38
Center of Gravity




   #!/usr/bin/env ruby
   require 'hornetseye'
   include Hornetseye
   input = V4L2Input.new '/dev/video0', 640, 480
   idx = MultiArray.lint( input.width, input.height ).indgen!
   x = idx % idx.shape[0]
   y = idx / idx.shape[0]
   img = nil
   X11Display.show { img = input.read_rgb24 }
   ref = img[ 0, 0 ]
   X11Display.show do
     img = input.read_rgb24.to_sintrgb
     cdiff = img - ref
     diff = cdiff.r.abs + cdiff.g.abs + cdiff.b.abs
     mask = ( diff  40 ).to_ubyte
     n = mask.sum
     puts x = #{( mask * x ).sum / n}, y = #{(mask * y ).sum / n} if n  0
     ( img / 2 ) * ( mask + 1 )
   end




Wednesday, February 4th 2009    http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   29/38
David A. Forsyth, Jean Ponce - Computer Vision: A modern
                           Approach




             Location: Adsetts Centre, Shelfmark: 006.37 FO (LEVEL 2)
      http://catalogue.shu.ac.uk/search~S1/t?Computer%20vision:%20a%20modern%20approach



Wednesday, February 4th 2009        http://vision.eng.shu.ac.uk/jan/demfeb09.pdf          30/38
Hal Fulton - The Ruby Way




          Location: Adsetts Centre, Shelfmark: 005.133 RUB FU (LEVEL 2)
                  http://catalogue.shu.ac.uk/search~S1/t?The%20Ruby%20way
Wednesday, February 4th 2009       http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   31/38
Mark Pollefeys - Visual 3D modeling of real-world objects
                       and scenes from images




                http://video.google.com/videoplay?docid=-1315387152400313941
Wednesday, February 4th 2009        http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   32/38
Mark Pupilli - Particle Filtering for Real-time Camera
                              Localisation




               http://www.cs.bris.ac.uk/home/pupilli/publications/thesis.pdf

Wednesday, February 4th 2009       http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   33/38
Ben Bleything - Controlling Electronics with Ruby




             http://rubyconf2007.confreaks.com/d1t2p1_ruby_and_electronics.html




Wednesday, February 4th 2009       http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   34/38
Patrick Farley - Ruby Internals




                http://mtnwestrubyconf2008.confreaks.com/11farley.html




Wednesday, February 4th 2009     http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   35/38
Yukihiro Matsumoto - Does Language Matter?




                   http://rubyconf2007.confreaks.com/d2t1p8_keynote.html




Wednesday, February 4th 2009       http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   36/38
Willow Garage, Inc.




                               http://www.willowgarage.com/



Wednesday, February 4th 2009      http://vision.eng.shu.ac.uk/jan/demfeb09.pdf   37/38
Thank You

This presentation was made with LT X,
                                A
                                  E
TeXPower, InkScape, Ruby, and other
             free software.




http://vision.eng.shu.ac.uk/jan/demfeb09.pdf

Más contenido relacionado

Similar a Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009

OSDC 2011 | Advanced Puppet Topics by Ken Barber
OSDC 2011 | Advanced Puppet Topics by Ken BarberOSDC 2011 | Advanced Puppet Topics by Ken Barber
OSDC 2011 | Advanced Puppet Topics by Ken BarberNETWAYS
 
Learn Ruby 2011 - Session 5 - Looking for a Rescue
Learn Ruby 2011 - Session 5 - Looking for a RescueLearn Ruby 2011 - Session 5 - Looking for a Rescue
Learn Ruby 2011 - Session 5 - Looking for a RescueJames Thompson
 
IPCSE12: Hands on FLOW3
IPCSE12: Hands on FLOW3IPCSE12: Hands on FLOW3
IPCSE12: Hands on FLOW3Robert Lemke
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...bobmcwhirter
 
Jenkins pipeline -- Gentle Introduction
Jenkins pipeline -- Gentle IntroductionJenkins pipeline -- Gentle Introduction
Jenkins pipeline -- Gentle IntroductionRamanathan Muthaiah
 
Getting Into FLOW3 (DPC12)
Getting Into FLOW3 (DPC12)Getting Into FLOW3 (DPC12)
Getting Into FLOW3 (DPC12)Robert Lemke
 
All about Erubis (English)
All about Erubis (English)All about Erubis (English)
All about Erubis (English)kwatch
 
Introduction to Erlang/(Elixir) at a Webilea Hands-On Session
Introduction to Erlang/(Elixir) at a Webilea Hands-On SessionIntroduction to Erlang/(Elixir) at a Webilea Hands-On Session
Introduction to Erlang/(Elixir) at a Webilea Hands-On SessionAndré Graf
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011tobiascrawley
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersAlessandro Sanino
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of GoFrank Müller
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Rubykim.mens
 
Ti1220 Lecture 1: Programming Linguistics
Ti1220 Lecture 1: Programming LinguisticsTi1220 Lecture 1: Programming Linguistics
Ti1220 Lecture 1: Programming LinguisticsEelco Visser
 
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...Yevgeniy Brikman
 
Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkRyan Weaver
 

Similar a Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009 (20)

C++ Core Guidelines
C++ Core GuidelinesC++ Core Guidelines
C++ Core Guidelines
 
Php task runners
Php task runnersPhp task runners
Php task runners
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
OSDC 2011 | Advanced Puppet Topics by Ken Barber
OSDC 2011 | Advanced Puppet Topics by Ken BarberOSDC 2011 | Advanced Puppet Topics by Ken Barber
OSDC 2011 | Advanced Puppet Topics by Ken Barber
 
Learn Ruby 2011 - Session 5 - Looking for a Rescue
Learn Ruby 2011 - Session 5 - Looking for a RescueLearn Ruby 2011 - Session 5 - Looking for a Rescue
Learn Ruby 2011 - Session 5 - Looking for a Rescue
 
IPCSE12: Hands on FLOW3
IPCSE12: Hands on FLOW3IPCSE12: Hands on FLOW3
IPCSE12: Hands on FLOW3
 
Paexec -- distributed tasks over network or cpus
Paexec -- distributed tasks over network or cpusPaexec -- distributed tasks over network or cpus
Paexec -- distributed tasks over network or cpus
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Jenkins pipeline -- Gentle Introduction
Jenkins pipeline -- Gentle IntroductionJenkins pipeline -- Gentle Introduction
Jenkins pipeline -- Gentle Introduction
 
Getting Into FLOW3 (DPC12)
Getting Into FLOW3 (DPC12)Getting Into FLOW3 (DPC12)
Getting Into FLOW3 (DPC12)
 
All about Erubis (English)
All about Erubis (English)All about Erubis (English)
All about Erubis (English)
 
Introduction to Erlang/(Elixir) at a Webilea Hands-On Session
Introduction to Erlang/(Elixir) at a Webilea Hands-On SessionIntroduction to Erlang/(Elixir) at a Webilea Hands-On Session
Introduction to Erlang/(Elixir) at a Webilea Hands-On Session
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of Go
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Ti1220 Lecture 1: Programming Linguistics
Ti1220 Lecture 1: Programming LinguisticsTi1220 Lecture 1: Programming Linguistics
Ti1220 Lecture 1: Programming Linguistics
 
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
 
Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 Framework
 

Más de Jan Wedekind

The SOLID Principles for Software Design
The SOLID Principles for Software DesignThe SOLID Principles for Software Design
The SOLID Principles for Software DesignJan Wedekind
 
Fundamentals of Computing
Fundamentals of ComputingFundamentals of Computing
Fundamentals of ComputingJan Wedekind
 
Using Generic Image Processing Operations to Detect a Calibration Grid
Using Generic Image Processing Operations to Detect a Calibration GridUsing Generic Image Processing Operations to Detect a Calibration Grid
Using Generic Image Processing Operations to Detect a Calibration GridJan Wedekind
 
Efficient implementations of machine vision algorithms using a dynamically ty...
Efficient implementations of machine vision algorithms using a dynamically ty...Efficient implementations of machine vision algorithms using a dynamically ty...
Efficient implementations of machine vision algorithms using a dynamically ty...Jan Wedekind
 
The MiCRoN Project
The MiCRoN ProjectThe MiCRoN Project
The MiCRoN ProjectJan Wedekind
 
Computer vision for microscopes
Computer vision for microscopesComputer vision for microscopes
Computer vision for microscopesJan Wedekind
 
Focus set based reconstruction of micro-objects
Focus set based reconstruction of micro-objectsFocus set based reconstruction of micro-objects
Focus set based reconstruction of micro-objectsJan 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
 

Más de Jan Wedekind (17)

The SOLID Principles for Software Design
The SOLID Principles for Software DesignThe SOLID Principles for Software Design
The SOLID Principles for Software Design
 
Fundamentals of Computing
Fundamentals of ComputingFundamentals of Computing
Fundamentals of Computing
 
Using Generic Image Processing Operations to Detect a Calibration Grid
Using Generic Image Processing Operations to Detect a Calibration GridUsing Generic Image Processing Operations to Detect a Calibration Grid
Using Generic Image Processing Operations to Detect a Calibration Grid
 
Efficient implementations of machine vision algorithms using a dynamically ty...
Efficient implementations of machine vision algorithms using a dynamically ty...Efficient implementations of machine vision algorithms using a dynamically ty...
Efficient implementations of machine vision algorithms using a dynamically ty...
 
The MiCRoN Project
The MiCRoN ProjectThe MiCRoN Project
The MiCRoN Project
 
Computer vision for microscopes
Computer vision for microscopesComputer vision for microscopes
Computer vision for microscopes
 
Focus set based reconstruction of micro-objects
Focus set based reconstruction of micro-objectsFocus set based reconstruction of micro-objects
Focus set based reconstruction of micro-objects
 
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...
 

Último

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
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
 
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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
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
 
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
 
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
 
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
 
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
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"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
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
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
 

Último (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
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
 
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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
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
 
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
 
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.
 
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
 
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
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"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
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
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
 
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
 

Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009

  • 1. Ruby & Machine Vision Ruby & Machine Vision Jan Wedekind Wednesday, February 4th 2009 Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 1/38
  • 2. UK EPSRC Nanorobotics Project Microscopy Software • telemanipulation • drift compensation • closed-loop control Machine Vision • real-time software • system integration • theoretical insights Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 2/38
  • 3. Ruby Programming Language Ruby • created by Yukihiro Matsumoto • released 1995 (free software(*) , Ruby license) • inspired by Perl, Python, Smalltalk, Eiffel, Ada, Lisp • “pseudo simplicity”: simple syntax ⇔ multi-paradigm language • highly portable • Tiobe Programming Community Index #11 • 1.8.6 being superseded by 1.9.1 page url Ruby Homepage http://www.ruby-lang.org/ Ruby Core-API http://www.ruby-doc.org/ RubyForge http://rubyforge.org/ Ruby Application Archive http://raa.ruby-lang.org/ (*) http://www.gnu.org/philosophy/free-sw.html Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 3/38
  • 4. Dynamic Typing #!/usr/bin/env ruby def test( a, b ) a + b end x = test( 3, 5 ) # x -> 8 x = test( 'a', 'b' ) # x -> 'ab' Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 4/38
  • 5. Garbage Collector Mark and Sweep Garbage Collector root marked=true marked=true marked=true marked=false marked=false marked=true http://www.brpreiss.com/books/opus5/html/page424.html Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 5/38
  • 6. (Pure) Object-Oriented, Single-Dispatch #!/usr/bin/env ruby class Numeric def plus(x) self.+(x) end end y = 5.plus 6 # y is now equal to 11 http://www.ruby-lang.org/en/about/ Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 6/38
  • 7. Mixins #!/usr/bin/env ruby module TimesThree def three_times self + self + self end end class String include TimesThree end 'abc'.three_times # -> 'abcabcabc' Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 7/38
  • 8. Exception Handling #!/usr/bin/env ruby begin print "Enter filename: " STDOUT.flush file_name = STDIN.readline.delete( "nr" ) file = File.new file_name, 'r' # ... rescue Exception => e puts "Error opening file '#{file_name}': #{e.message}" end Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 8/38
  • 9. Closures Unifying Concept for Iterators, Function Objects, and Loops #!/usr/bin/env ruby def inc( i ) lambda do |v| v + i end end t = inc( 5 ) t.call( 3 ) # -> 8 [ 1, 2, 3 ].each do |x| puts x end [ 1, 2, 3 ].collect do |x| x ** 2 end # -> [1, 4, 9] [ 1, 2, 3 ].inject do |v,x| v + x end # -> 6 Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 9/38
  • 10. Continuations #!/usr/bin/env ruby def test( c2 ) callcc do |c1| return c1 end c2.call end callcc do |c2| c1 = test( c2 ) c1.call end Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 10/38
  • 11. Introspection Program can “see” itself #!/usr/bin/env ruby x = 5 # -> 5 x.class # -> Fixnum x.class.class # -> Class x.class.superclass # -> Integer x.is_a?( Fixnum ) # -> true Fixnum < Integer # -> true 5.respond_to?( '+' ) # -> true 5.methods.grep( /^f/ ).sort # -> ["floor", "freeze", "frozen?"] Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 11/38
  • 12. Metaprogramming Interpreter modifies Program #!/usr/bin/env ruby eval 'x=5' # x -> 5 a = [ 1 ] a.instance_eval do push 2 end # a -> [ 1, 2 ] a.send( 'push', 3 ) # a -> [ 1, 2, 3 ] Object.const_get( 'String' ).class_eval do define_method 'test' do reverse end end 'abc'.reverse # -> 'cba' Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 12/38
  • 13. Reification Program modifies Interpreter #!/usr/bin/env ruby class Numeric def method_missing( name, *args ) prefix = Regexp.new( "^#{name}" ) full_name = methods.find { |id| id =~ prefix } if full_name send( full_name, *args ) else super end end end 5.mod 2 # calls 5.modulo 2 Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 13/38
  • 14. Ruby Extensions C Library // gcc -shared -fPIC -I/usr/lib/ruby/1.8/x86_64-linux // -o myextension.so myextension.c #include <ruby.h> #include <math.h> VALUE wrap_logx( VALUE self, VALUE x ) { return rb_float_new( log( NUM2DBL( self ) ) / log( NUM2DBL( x ) ) ); } void Init_myextension(void) { VALUE numeric = rb_const_get( rb_cObject, rb_intern( "Numeric" ) ); rb_define_method( numeric, "logx", RUBY_METHOD_FUNC( wrap_logx ), 1 ); } Invoking Ruby Program #!/usr/bin/env ruby require 'myextension' e = 1024.logx( 2 ) puts "2 ** #{e} = 1024" http://www.rubyist.net/~nobu/ruby/Ruby_Extension_Manual.html Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 14/38
  • 15. HornetsEye - Ruby Extension for Machine Vision Free Software Project • Real-Time Machine Vision • Ruby Extension • released under GNU General Public License • 2 years development • 22000 lines of code http://www.wedesoft.demon.co.uk/hornetseye-api/ http://rubyforge.org/projects/hornetseye/ http://sourceforge.net/projects/hornetseye/ https://launchpad.net/hornetseye/ http://raa.ruby-lang.org/project/hornetseye/ Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 15/38
  • 16. Using existing Free Software Libraries Integrated C++ Boost libdc1394 Tools in Use DotGNU Bazaar FFTW MPlayer GCC OpenEXR make, automake, autoconf NaturalDocs Qt4-QtRuby RMagick NSIS NArray Ruby libxine Xorg, Mesa3D Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 16/38
  • 17. Inpput/Output Classes Input/Output Classes / V4LInput VFWInput V4L2Input DShowInput DC1394Input — XineInput — MPlayerInput MPlayerInput MEncoderOutput MEncoderOutput X11Display W32Display X11Window W32Window XImageOutput GDIOutput OpenGLOutput — XVideoOutput — Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 17/38
  • 18. Colourspace Conversions        Y 0.299 0.587 0.114 R 0        Cb  = −0.168736 −0.331264  G + 128 0.500         Cr 0.500 −0.418688 −0.081312 B 128 also see: http://fourcc.org/ Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 18/38
  • 19. GUI Integration I/II Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 19/38
  • 20. GUI Integration II/II Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 20/38
  • 21. Just-In-Time Compiler #!/usr/bin/env require 'hornetseye' include Hornetseye fun = JITFunction.compile( JITType::DFLOAT, JITType::DFLOAT, JITType::DFLOAT ) do |f,a,b| Math.log( a ) / Math.log( b ) end fun.call( 1024, 2 ) # -> 10.0 Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 21/38
  • 22. Some other Vision Libraries I/II Framewave EasyVision CMVision Camellia Gamera Gandalf libCVD Filters Blepo feature Camera Input Image Files Video Files Display Scripting Warps Histograms Custom Filters Fourier Transforms Feature Extraction Feature Matching GPL compatible ? Also see http://www.wedesoft.demon.co.uk/hornetseye-api/files/Links-txt.html Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 22/38
  • 23. Some other Vision Libraries II/II NASA V. W. HornetsEye ITK/VTK SceneLib OpenCV VIGRA Mimas LTIlib Lush IVT feature Camera Input Image Files Video Files Display Scripting Warps Histograms Custom Filters Fourier Transforms Feature Extraction Feature Matching GPL compatible Also see http://www.wedesoft.demon.co.uk/hornetseye-api/files/Links-txt.html Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 23/38
  • 24. Dense Scripts OpenCV + Python #! /usr/bin/env python import sys from opencv import cv from opencv import highgui highgui.cvNamedWindow( ’Camera’ ) capture = highgui.cvCreateCameraCapture( -1 ) while 1: frame = highgui.cvQueryFrame( capture ) gray = cv.cvCreateImage( cv.cvSize( frame.width, frame.height), 8, 1 ) cv.cvCvtColor( frame, gray, cv.CV_BGR2GRAY ) highgui.cvShowImage( ’Camera’, gray ) if highgui.cvWaitKey( 5 ) 0: break HornetsEye + Ruby #!/usr/bin/env ruby require ’hornetseye’ include Hornetseye capture = V4L2Input.new X11Display.show { capture.read.to_grey8 } Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 24/38
  • 25. Interactive Ruby (IRB) require 'hornetseye' include Hornetseye img = MultiArray.load_rgb24 '/home/engjw/test/hornetseye/data/images/world.jpg' # MultiArrayubytergb(640,320): # [ [ RGB( 0, 20, 55 ), RGB( 0, 20, 55 ), RGB( 0, 20, 55 ), .... ], # [ RGB( 17, 36, 69 ), RGB( 17, 36, 69 ), RGB( 18, 37, 70 ), .... ], # [ RGB( 9, 24, 55 ), RGB( 9, 24, 55 ), RGB( 8, 23, 54 ), .... ], # [ RGB( 8, 22, 51 ), RGB( 8, 22, 51 ), RGB( 7, 21, 50 ), .... ], # [ RGB( 8, 19, 49 ), RGB( 8, 19, 49 ), RGB( 8, 19, 49 ), .... ], # .... filter = MultiArray.to_multiarray( [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ] ).to_usint # MultiArrayusint(3,3): # [ [ 1, 1, 1 ], # [ 1, 1, 1 ], # [ 1, 1, 1 ] ] img.correlate( filter ) # MultiArrayusintrgb(640,320): # [ [ RGB( 34, 112, 248 ), RGB( 52, 169, 373 ), RGB( 54, 171, 375 ), .... ], # [ RGB( 52, 160, 358 ), RGB( 78, 240, 537 ), RGB( 79, 241, 538 ), .... ], # [ RGB( 68, 164, 350 ), RGB( 101, 245, 524 ), .... ], # [ RGB( 50, 130, 310 ), RGB( 73, 193, 463 ), RGB( 72, 192, 462 ), .... ], # [ RGB( 45, 123, 306 ), RGB( 66, 182, 458 ), RGB( 64, 182, 457 ), .... ], # .... Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 25/38
  • 26. Opening Webcam/Framegrabber #!/usr/bin/env ruby require 'hornetseye' include Hornetseye input = V4L2Input.new img = input.read img.show Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 26/38
  • 27. Capture Image #!/usr/bin/env ruby require 'hornetseye' include Hornetseye input = V4L2Input.new img = nil X11Display.show { img = input.read_rgb24 } img.save_rgb24 'test.jpg' Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 27/38
  • 28. Capture Video #!/usr/bin/env ruby require 'hornetseye' include Hornetseye input = V4L2Input.new( '/dev/video0', 640, 480 ) output = MEncoderOutput.new( 'test.avi', 10, '-ovc lavc -lavcopts vcodec=msmpeg4:vhq:vbitrate=4000' ) X11Display.show do img = input.read output.write( img ) img end output.close Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 28/38
  • 29. Center of Gravity #!/usr/bin/env ruby require 'hornetseye' include Hornetseye input = V4L2Input.new '/dev/video0', 640, 480 idx = MultiArray.lint( input.width, input.height ).indgen! x = idx % idx.shape[0] y = idx / idx.shape[0] img = nil X11Display.show { img = input.read_rgb24 } ref = img[ 0, 0 ] X11Display.show do img = input.read_rgb24.to_sintrgb cdiff = img - ref diff = cdiff.r.abs + cdiff.g.abs + cdiff.b.abs mask = ( diff 40 ).to_ubyte n = mask.sum puts x = #{( mask * x ).sum / n}, y = #{(mask * y ).sum / n} if n 0 ( img / 2 ) * ( mask + 1 ) end Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 29/38
  • 30. David A. Forsyth, Jean Ponce - Computer Vision: A modern Approach Location: Adsetts Centre, Shelfmark: 006.37 FO (LEVEL 2) http://catalogue.shu.ac.uk/search~S1/t?Computer%20vision:%20a%20modern%20approach Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 30/38
  • 31. Hal Fulton - The Ruby Way Location: Adsetts Centre, Shelfmark: 005.133 RUB FU (LEVEL 2) http://catalogue.shu.ac.uk/search~S1/t?The%20Ruby%20way Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 31/38
  • 32. Mark Pollefeys - Visual 3D modeling of real-world objects and scenes from images http://video.google.com/videoplay?docid=-1315387152400313941 Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 32/38
  • 33. Mark Pupilli - Particle Filtering for Real-time Camera Localisation http://www.cs.bris.ac.uk/home/pupilli/publications/thesis.pdf Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 33/38
  • 34. Ben Bleything - Controlling Electronics with Ruby http://rubyconf2007.confreaks.com/d1t2p1_ruby_and_electronics.html Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 34/38
  • 35. Patrick Farley - Ruby Internals http://mtnwestrubyconf2008.confreaks.com/11farley.html Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 35/38
  • 36. Yukihiro Matsumoto - Does Language Matter? http://rubyconf2007.confreaks.com/d2t1p8_keynote.html Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 36/38
  • 37. Willow Garage, Inc. http://www.willowgarage.com/ Wednesday, February 4th 2009 http://vision.eng.shu.ac.uk/jan/demfeb09.pdf 37/38
  • 38. Thank You This presentation was made with LT X, A E TeXPower, InkScape, Ruby, and other free software. http://vision.eng.shu.ac.uk/jan/demfeb09.pdf