Sha256: ef0cc5c3e154f9c2fae698b9b749183f298fefa1578da63e05a3326bb14d3726

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'artoo/adaptors/adaptor'

module Artoo
  module Adaptors
    # Connect to a opencv device
    # @see device documentation for more information
    class OpencvCapture < Adaptor
      finalizer :finalize
      attr_reader :capture

      # Closes connection with device if connected
      # @return [Boolean]
      def finalize
      end

      # Creates a connection with device
      # @return [Boolean]
      def connect
        require 'opencv' unless defined?(::OpenCV) 
        source = additional_params[:source] || ""
        if source.to_s.empty?
          @capture = ::OpenCV::CvCapture::open
        else
          @capture = ::OpenCV::CvCapture::open source
        end
        super
      end

      # Closes connection with device
      # @return [Boolean]
      def disconnect
        super
      end

      # Uses method missing to call device actions
      # @see device documentation
      def method_missing(method_name, *arguments, &block)
        device.send(method_name, *arguments, &block)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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