Class: Artoo::Drivers::OpencvCapture

Inherits:
Driver
  • Object
show all
Defined in:
lib/artoo/drivers/opencv_capture.rb

Overview

The opencv driver behaviors

Constant Summary collapse

COMMANDS =
[:opencv].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#opencvObject

Returns the value of attribute opencv.



11
12
13
# File 'lib/artoo/drivers/opencv_capture.rb', line 11

def opencv
  @opencv
end

Instance Method Details

#handle_frameObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/artoo/drivers/opencv_capture.rb', line 26

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

#start_driverObject

Start driver and any required connections



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/artoo/drivers/opencv_capture.rb', line 13

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