Class: Webcam::Image
- Inherits:
-
Object
- Object
- Webcam::Image
- Defined in:
- lib/rb_webcam.rb
Overview
Property Container of image from webcam. Get size, color_depth, mode, etc.. of image. Each instance have IplImage struct data. TODO: Having pointer to IplImage struct will be good for performance?
(Does whole structure copying occur at Image.new(iplimage) ?)
Instance Attribute Summary collapse
-
#iplimage_struct ⇒ Object
readonly
IplImage structure stored grabbed image from camera.
Instance Method Summary collapse
-
#color_depth ⇒ Object
get color depth of image.
-
#data ⇒ Object
String of image data.
-
#data_pointer ⇒ Object
FFI::Pointer to image data.
-
#data_size ⇒ Object
data size of image.
-
#initialize(iplimage_struct) ⇒ Image
constructor
A new instance of Image.
-
#size ⇒ Object
get size of image.
Constructor Details
#initialize(iplimage_struct) ⇒ Image
Returns a new instance of Image.
133 134 135 |
# File 'lib/rb_webcam.rb', line 133 def initialize(iplimage_struct) @iplimage_struct = iplimage_struct end |
Instance Attribute Details
#iplimage_struct ⇒ Object (readonly)
IplImage structure stored grabbed image from camera.
163 164 165 |
# File 'lib/rb_webcam.rb', line 163 def iplimage_struct @iplimage_struct end |
Instance Method Details
#color_depth ⇒ Object
get color depth of image.
143 144 145 |
# File 'lib/rb_webcam.rb', line 143 def color_depth @iplimage_struct.depth end |
#data ⇒ Object
String of image data
148 149 150 |
# File 'lib/rb_webcam.rb', line 148 def data self.data_pointer.read_string(self.data_size) end |
#data_pointer ⇒ Object
FFI::Pointer to image data
153 154 155 |
# File 'lib/rb_webcam.rb', line 153 def data_pointer @iplimage_struct.image_data end |
#data_size ⇒ Object
data size of image
158 159 160 |
# File 'lib/rb_webcam.rb', line 158 def data_size @iplimage_struct.image_size end |
#size ⇒ Object
get size of image. Hash with :width, :height elements.
138 139 140 |
# File 'lib/rb_webcam.rb', line 138 def size {width: @iplimage_struct.width, height: @iplimage_struct.height} end |