Sha256: 7317fd8cc77e255b0945e182befb95a4722552be0f4e65b925816405a85799cf

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

Contents

require 'artoo'

connection :capture, :adaptor => :opencv_capture
device :capture, :driver => :opencv_capture, :connection => :capture, :interval => 0.01

connection :video, :adaptor => :opencv_window, :title => "Video"
device :video, :driver => :opencv_window, :connection => :video, :interval => 0.01

work do
  on capture, :frame => proc { |*value| 
    begin
      opencv = value[1]
      biggest_circle = 0
      ball = nil
      opencv.detect_circles({:r =>170, :g =>50, :b =>0}, {:r => 256, :g => 180, :b => 10}).each{ |circle|
        if circle.radius > biggest_circle
          biggest_circle = circle.radius
          ball = circle
        end
      }
      opencv.draw_circles!([ball]) if !ball.nil?
      video.image = opencv.image if video.alive?
    rescue Exception => e
      puts e.message
    end
  }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
artoo-opencv-0.0.1 examples/ball_tracking.rb