Class: Artoo::Drivers::OpencvWindow

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

Constant Summary collapse

COMMANDS =
[:image=].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ OpencvWindow

Returns a new instance of OpencvWindow.



12
13
14
15
16
# File 'lib/artoo/drivers/opencv_window.rb', line 12

def initialize(params={})
  super
  title = additional_params[:title] || ""
  @window = ::OpenCV::GUI::Window.new(title,2)
end

Instance Attribute Details

#imageObject

Returns the value of attribute image.



10
11
12
# File 'lib/artoo/drivers/opencv_window.rb', line 10

def image
  @image
end

#windowObject

Returns the value of attribute window.



10
11
12
# File 'lib/artoo/drivers/opencv_window.rb', line 10

def window
  @window
end

Instance Method Details

#show_imageObject



32
33
34
35
36
37
38
39
# File 'lib/artoo/drivers/opencv_window.rb', line 32

def show_image
  begin
    window.show @image if !@image.nil?
    ::OpenCV::GUI::wait_key(1)
  rescue Exception => e
    Logger.error e.message
  end
end

#start_driverObject

Start driver and any required connections



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/artoo/drivers/opencv_window.rb', line 19

def start_driver
  begin
    every(interval) do
      show_image 
    end
    super
  rescue Exception => e
    Logger.error "Error starting Opencv driver!"
    Logger.error e.message
    Logger.error e.backtrace.inspect
  end
end