Sha256: 018dca2a8c040c0fc713fdf0d89d287a4e7ad4977c3b2095ca83273281beaedb

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
device :video, :driver => :opencv_window, :connection => :video, :title => "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.1.0 examples/ball_tracking.rb