Class: Hornetseye::V4L2Input
- Includes:
- ReaderConversion
- Defined in:
- docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb,
docs/hornetseye-v4l2/lib/hornetseye-v4l2/v4l2input.rb
Overview
Class for handling a V4L2-compatible camera
Constant Summary collapse
- TYPE_INTEGER =
Feature type
nil
- TYPE_BOOLEAN =
Feature type
nil
- TYPE_MENU =
Feature type
nil
- TYPE_BUTTON =
Feature type
nil
- TYPE_CTRL_CLASS =
Feature type
nil
- FEATURE_BASE =
First feature
nil
- FEATURE_USER_BASE =
First custom feature
nil
- FEATURE_PRIVATE_BASE =
First standard feature
nil
- FEATURE_BRIGHTNESS =
A feature
nil
- FEATURE_CONTRAST =
A feature
nil
- FEATURE_SATURATION =
A feature
nil
- FEATURE_HUE =
A feature
nil
- FEATURE_AUDIO_VOLUME =
A feature
nil
- FEATURE_AUDIO_BALANCE =
A feature
nil
- FEATURE_AUDIO_BASS =
A feature
nil
- FEATURE_AUDIO_TREBLE =
A feature
nil
- FEATURE_AUDIO_MUTE =
A feature
nil
- FEATURE_AUDIO_LOUDNESS =
A feature
nil
- FEATURE_BLACK_LEVEL =
A feature
nil
- FEATURE_AUTO_WHITE_BALANCE =
A feature
nil
- FEATURE_DO_WHITE_BALANCE =
A feature
nil
- FEATURE_RED_BALANCE =
A feature
nil
- FEATURE_BLUE_BALANCE =
A feature
nil
- FEATURE_GAMMA =
A feature
nil
- FEATURE_WHITENESS =
A feature
nil
- FEATURE_EXPOSURE =
A feature
nil
- FEATURE_AUTOGAIN =
A feature
nil
- FEATURE_GAIN =
A feature
nil
- FEATURE_HFLIP =
A feature
nil
- FEATURE_VFLIP =
A feature
nil
- FEATURE_HCENTER =
A feature
nil
- FEATURE_VCENTER =
A feature
nil
- FEATURE_LASTP1 =
A feature
nil
Class Method Summary collapse
-
.new(device = '/dev/video0', channel = 0, &action) ⇒ V4L2Input
Open a camera device for input.
- .orig_new ⇒ Object
Instance Method Summary collapse
-
#close ⇒ V4L2Input
Close the video device.
-
#feature_default_value(id) ⇒ Integer
Get default value of feature.
-
#feature_exist?(id) ⇒ Boolean
Check for existence of feature.
-
#feature_max(id) ⇒ Integer
Get maximum value of feature.
-
#feature_min(id) ⇒ Integer
Get minimum value of feature.
-
#feature_name(id) ⇒ String
Get name of feature.
-
#feature_read(id) ⇒ Integer
Get value of feature.
-
#feature_step(id) ⇒ Integer
Get step size of feature.
-
#feature_type(id) ⇒ Integer
Get type of feature.
-
#feature_write(id, value) ⇒ Integer
Set value of feature.
-
#height ⇒ Integer
Height of video input.
-
#read ⇒ MultiArray, Frame_
Read a video frame.
-
#status? ⇒ Boolean
Check whether device is not closed.
-
#width ⇒ Integer
Width of video input.
Class Method Details
.new(device = '/dev/video0', channel = 0, &action) ⇒ V4L2Input
Open a camera device for input
The device is opened and a list of supported resolutions is handed back as parameter to the code block. The code block must return the selected mode so that initialisation can be completed. If no block is given, the highest available resolution is selected after giving colour modes preference.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/v4l2input.rb', line 45 def new( device = '/dev/video0', channel = 0, &action ) orig_new device, channel do |modes| map = { MODE_UYVY => UYVY, MODE_YUYV => YUY2, MODE_YUV420 => I420, MODE_GREY => UBYTE, MODE_Y16 => USINT, MODE_RGB24 => UBYTERGB, MODE_BGR24 => BGR } modes.each do |mode| unless map[mode.first] warn "Unsupported video mode #{"0x%08x" % mode.first} #{mode[1]}x#{mode[2]}" end end frame_types = modes.collect { |mode| [map[mode.first], *mode[1 .. 2]] }. select { |mode| mode.first } if action desired = action.call frame_types else preference = [I420, UYVY, YUY2, UBYTERGB, BGR, USINT, UBYTE] desired = frame_types.sort_by do |mode| [-preference.index(mode.first), mode[1] * mode[2]] end.last raise "Device does not support a known video mode" unless desired end mode = map.invert[desired[0]] raise "Video mode #{desired.typecode} not supported" unless mode [mode, desired[1], desired[2]] end end |
.orig_new ⇒ Object
27 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/v4l2input.rb', line 27 alias_method :orig_new, :new |
Instance Method Details
#close ⇒ V4L2Input
Close the video device
436 437 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 436 def close end |
#feature_default_value(id) ⇒ Integer
Get default value of feature
532 533 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 532 def feature_default_value( id ) end |
#feature_exist?(id) ⇒ Boolean
Check for existence of feature
468 469 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 468 def feature_exist?( id ) end |
#feature_max(id) ⇒ Integer
Get maximum value of feature
516 517 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 516 def feature_max( id ) end |
#feature_min(id) ⇒ Integer
Get minimum value of feature
508 509 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 508 def feature_min( id ) end |
#feature_name(id) ⇒ String
Get name of feature
500 501 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 500 def feature_name( id ) end |
#feature_read(id) ⇒ Integer
Get value of feature
476 477 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 476 def feature_read( id ) end |
#feature_step(id) ⇒ Integer
Get step size of feature
524 525 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 524 def feature_step( id ) end |
#feature_type(id) ⇒ Integer
Get type of feature
492 493 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 492 def feature_type( id ) end |
#feature_write(id, value) ⇒ Integer
Set value of feature
484 485 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 484 def feature_write( id, value ) end |
#height ⇒ Integer
Height of video input
460 461 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 460 def height end |
#read ⇒ MultiArray, Frame_
Read a video frame
442 443 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 442 def read end |
#status? ⇒ Boolean
Check whether device is not closed
448 449 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 448 def status? end |
#width ⇒ Integer
Width of video input
454 455 |
# File 'docs/hornetseye-v4l2/lib/hornetseye-v4l2/docs.rb', line 454 def width end |