Class: Webcam::Image

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_structObject (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_depthObject

get color depth of image.



143
144
145
# File 'lib/rb_webcam.rb', line 143

def color_depth
  @iplimage_struct.depth
end

#dataObject

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_pointerObject

FFI::Pointer to image data



153
154
155
# File 'lib/rb_webcam.rb', line 153

def data_pointer
  @iplimage_struct.image_data
end

#data_sizeObject

data size of image



158
159
160
# File 'lib/rb_webcam.rb', line 158

def data_size
  @iplimage_struct.image_size
end

#sizeObject

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