Class: Processing::Capture
- Inherits:
-
Object
- Object
- Processing::Capture
- Includes:
- Xot::Inspectable
- Defined in:
- lib/processing/capture.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?.
-
#filter(*args) ⇒ Object
Applies an image filter.
-
#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.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/processing/capture.rb', line 29 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
14 15 16 |
# File 'lib/processing/capture.rb', line 14 def self.list() Rays::Camera.device_names end |
Instance Method Details
#available ⇒ Boolean
Returns is the next captured image available?
65 66 67 |
# File 'lib/processing/capture.rb', line 65 def available() @camera.active? end |
#filter(*args) ⇒ Object
Applies an image filter.
overload filter(shader) overload filter(type) overload filter(type, param)
101 102 103 |
# File 'lib/processing/capture.rb', line 101 def filter(*args) @filter = Shader.createFilter__(*args) end |
#height ⇒ Numeric
Returns the height of captured image
87 88 89 |
# File 'lib/processing/capture.rb', line 87 def height() @camera.image&.height || 0 end |
#read ⇒ Object
Reads next frame image
71 72 73 |
# File 'lib/processing/capture.rb', line 71 def read() @camera.image end |
#start ⇒ nil
Start capturing.
47 48 49 50 |
# File 'lib/processing/capture.rb', line 47 def start() raise "Failed to start capture" unless @camera.start nil end |
#stop ⇒ nil
Stop capturing.
56 57 58 59 |
# File 'lib/processing/capture.rb', line 56 def stop() @camera.stop nil end |
#width ⇒ Numeric
Returns the width of captured image
79 80 81 |
# File 'lib/processing/capture.rb', line 79 def width() @camera.image&.width || 0 end |