Sha256: 5829a30804261bec78c34eeaefb753ed9d50fde2a6b3b4fdbccc1f5c01e42b17

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

require 'artoo/drivers/driver'
require 'artoo/drivers/opencv'

module Artoo
  module Drivers
    # The opencv driver behaviors
    class OpencvCapture < Driver

      COMMANDS = [:opencv].freeze

      attr_accessor :opencv
      # Start driver and any required connections
      def start_driver
        begin
          every(interval) do
            handle_frame
          end
          super
        rescue Exception => e
          Logger.error "Error starting Opencv driver!"
          Logger.error e.message
          Logger.error e.backtrace.inspect
        end
      end

      def handle_frame
        if !connection.capture.nil?
          frame = connection.capture.query 
          if !frame.nil?
            @opencv = Artoo::Drivers::Opencv.new(frame)
            publish(event_topic_name("frame"), @opencv) 
          else
            connection.connect
          end
        else
          connection.connect
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
artoo-opencv-0.1.0 lib/artoo/drivers/opencv_capture.rb
artoo-opencv-0.0.1 lib/artoo/drivers/opencv_capture.rb