Class: Player::BlobFinder
- Includes:
- Enumerable
- Defined in:
- lib/ruby-player/blob_finder.rb
Overview
The blobfinder interface provides access to devices that detect blobs in images
Instance Attribute Summary collapse
-
#color ⇒ Hash
readonly
Tracking color.
-
#imager_params ⇒ Hash
readonly
Imager params.
-
#state ⇒ Hash
readonly
Blobfinder data.
Attributes inherited from Device
Instance Method Summary collapse
-
#[](index) ⇒ Blob
Get blob.
-
#blobs ⇒ Array
The list of blobs.
- #each ⇒ Object
- #fill(hdr, msg) ⇒ Object
- #handle_response(hdr, msg) ⇒ Object
-
#height ⇒ Integer
The image height.
-
#initialize(dev, client) ⇒ BlobFinder
constructor
A new instance of BlobFinder.
-
#query_color ⇒ BlobFinder
Query color settings.
-
#set_color(color = {}) ⇒ BlobFinder
Set tracking color.
-
#set_imager_params(params = {}) ⇒ BlobFinder
Set imager params Imaging sensors that do blob tracking generally have some sorts of image quality parameters that you can tweak.
-
#width ⇒ Integer
The image width.
Methods inherited from Device
Constructor Details
#initialize(dev, client) ⇒ BlobFinder
Returns a new instance of BlobFinder.
34 35 36 37 38 39 40 |
# File 'lib/ruby-player/blob_finder.rb', line 34 def initialize(dev, client) super @blobs = [] @state = { width: 0, height: 0, blobs: @blobs } @color = { channel: 0, rmin: 0, rmax: 0, gmin: 0, gmax: 0, bmin: 0, bmax: 0 } @imager_params = { brightness: 0, contrast: 0, colormode: 0, autogain: 0 } end |
Instance Attribute Details
#color ⇒ Hash (readonly)
Tracking color
27 28 29 |
# File 'lib/ruby-player/blob_finder.rb', line 27 def color @color end |
#imager_params ⇒ Hash (readonly)
Imager params.
32 33 34 |
# File 'lib/ruby-player/blob_finder.rb', line 32 def imager_params @imager_params end |
#state ⇒ Hash (readonly)
Blobfinder data
22 23 24 |
# File 'lib/ruby-player/blob_finder.rb', line 22 def state @state end |
Instance Method Details
#[](index) ⇒ Blob
Get blob
101 102 103 |
# File 'lib/ruby-player/blob_finder.rb', line 101 def [](index) @blobs[index] ||= Blob.new(index, self) end |
#blobs ⇒ Array
The list of blobs.
56 57 58 |
# File 'lib/ruby-player/blob_finder.rb', line 56 def blobs state[:blobs] end |
#each ⇒ Object
105 106 107 |
# File 'lib/ruby-player/blob_finder.rb', line 105 def each @blobs.each { |b| yield b } end |
#fill(hdr, msg) ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'lib/ruby-player/blob_finder.rb', line 109 def fill(hdr, msg) case hdr.subtype when PLAYER_BLOBFINDER_DATA_BLOBS read_data(msg) else hdr end end |
#handle_response(hdr, msg) ⇒ Object
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ruby-player/blob_finder.rb', line 118 def handle_response(hdr, msg) case hdr.subtype when PLAYER_BLOBFINDER_REQ_GET_COLOR read_color(msg) when 1,2 nil else hdr end end |
#height ⇒ Integer
The image height.
50 51 52 |
# File 'lib/ruby-player/blob_finder.rb', line 50 def height state[:height] end |
#query_color ⇒ BlobFinder
Query color settings
62 63 64 65 |
# File 'lib/ruby-player/blob_finder.rb', line 62 def query_color (PLAYER_MSGTYPE_REQ, PLAYER_BLOBFINDER_REQ_GET_COLOR) self end |
#set_color(color = {}) ⇒ BlobFinder
Set tracking color.
77 78 79 80 81 82 |
# File 'lib/ruby-player/blob_finder.rb', line 77 def set_color(color={}) data = to_a_by_default(color, @color) (PLAYER_MSGTYPE_REQ, PLAYER_BLOBFINDER_REQ_SET_COLOR, data.pack("N*")) self end |
#set_imager_params(params = {}) ⇒ BlobFinder
Set imager params Imaging sensors that do blob tracking generally have some sorts of image quality parameters that you can tweak.
92 93 94 95 96 |
# File 'lib/ruby-player/blob_finder.rb', line 92 def set_imager_params(params={}) data = to_a_by_default(params, @imager_params) (PLAYER_MSGTYPE_REQ, PLAYER_BLOBFINDER_REQ_SET_IMAGER_PARAMS, data.pack("N*")) self end |
#width ⇒ Integer
The image width.
44 45 46 |
# File 'lib/ruby-player/blob_finder.rb', line 44 def width state[:width] end |