Class: RubySketch::Processing::Capture
- Inherits:
-
Object
- Object
- RubySketch::Processing::Capture
- Defined in:
- lib/rubysketch/processing.rb
Overview
Camera object.
Class Method Summary collapse
-
.list ⇒ Array
Returns a list of available camera device names.
Instance Method Summary collapse
-
#available ⇒ Boolean
Returns is the next captured image available?.
-
#height ⇒ Numeric
Returns the height of captured image.
-
#initialize(*args) ⇒ Capture
constructor
Initialize camera object.
-
#read ⇒ Object
Reads next frame image.
-
#start ⇒ nil
Start capturing.
-
#stop ⇒ nil
Stop capturing.
-
#width ⇒ Numeric
Returns the width of captured image.
Constructor Details
#Capture.new ⇒ Capture #Capture.new(cameraName) ⇒ Capture #Capture.new(requestWidth, requestHeight) ⇒ Capture #Capture.new(requestWidth, requestHeight, cameraName) ⇒ Capture
Initialize camera object.
754 755 756 757 758 759 760 761 762 763 764 765 766 |
# File 'lib/rubysketch/processing.rb', line 754 def initialize(*args) width, height, name = if args.empty? [-1, -1, nil] elsif args[0].kind_of?(String) [-1, -1, args[0]] elsif args[0].kind_of?(Numeric) && args[1].kind_of?(Numeric) [args[0], args[1], args[2]] else raise ArgumentError end @camera = Rays::Camera.new width, height, device_name: name end |
Class Method Details
.list ⇒ Array
Returns a list of available camera device names
739 740 741 |
# File 'lib/rubysketch/processing.rb', line 739 def self.list() Rays::Camera.device_names end |
Instance Method Details
#available ⇒ Boolean
Returns is the next captured image available?
790 791 792 |
# File 'lib/rubysketch/processing.rb', line 790 def available() @camera.active? end |
#height ⇒ Numeric
Returns the height of captured image
812 813 814 |
# File 'lib/rubysketch/processing.rb', line 812 def height() @camera.image&.height || 0 end |
#read ⇒ Object
Reads next frame image
796 797 798 |
# File 'lib/rubysketch/processing.rb', line 796 def read() @camera.image end |
#start ⇒ nil
Start capturing.
772 773 774 775 |
# File 'lib/rubysketch/processing.rb', line 772 def start() raise "Failed to start capture" unless @camera.start nil end |
#stop ⇒ nil
Stop capturing.
781 782 783 784 |
# File 'lib/rubysketch/processing.rb', line 781 def stop() @camera.stop nil end |
#width ⇒ Numeric
Returns the width of captured image
804 805 806 |
# File 'lib/rubysketch/processing.rb', line 804 def width() @camera.image&.width || 0 end |