Class: Player::Blob

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-player/blob.rb

Overview

Classs describing a single blob.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, blobfinder) ⇒ Blob

Returns a new instance of Blob.



21
22
23
24
# File 'lib/ruby-player/blob.rb', line 21

def initialize(index, blobfinder)
  @index, @blobfinder = index, blobfinder
  @state = { id: 0, color: 0, area: 0, x: 0, y: 0, left: 0, right: 0, top: 0, bottom: 0, range: 0.0 }
end

Instance Attribute Details

#stateHash (readonly)

Returns blob description => { :id, :color, :area, :x, :y, :left, :right, :top, :bottom, :range }.

Returns:

  • (Hash)

    blob description => { :id, :color, :area, :x, :y, :left, :right, :top, :bottom, :range }



19
20
21
# File 'lib/ruby-player/blob.rb', line 19

def state
  @state
end

Instance Method Details

#areaInteger

The blob area [pixels].

Returns:

  • (Integer)


40
41
42
# File 'lib/ruby-player/blob.rb', line 40

def area
  state[:area]
end

#bottomObject

Bounding box for the blob [pixels].



70
71
72
# File 'lib/ruby-player/blob.rb', line 70

def bottom
  state[:bottom]
end

#colorInteger

A descriptive color for the blob (useful for gui’s).

Returns:

  • (Integer)


34
35
36
# File 'lib/ruby-player/blob.rb', line 34

def color
  state[:color]
end

#idInteger

Blob id

Returns:

  • (Integer)


28
29
30
# File 'lib/ruby-player/blob.rb', line 28

def id
  state[:id]
end

#leftObject

Bounding box for the blob [pixels].



55
56
57
# File 'lib/ruby-player/blob.rb', line 55

def left
  state[:left]
end

#rangeObject

Range to the blob center [m].



75
76
77
# File 'lib/ruby-player/blob.rb', line 75

def range
  state[:range]
end

#rightObject

Bounding box for the blob [pixels].



60
61
62
# File 'lib/ruby-player/blob.rb', line 60

def right 
  state[:right]
end

#topObject

Bounding box for the blob [pixels].



65
66
67
# File 'lib/ruby-player/blob.rb', line 65

def top
  state[:top]
end

#xObject

The blob centroid [pixels].



45
46
47
# File 'lib/ruby-player/blob.rb', line 45

def x
  state[:x]
end

#yObject

The blob centroid [pixels].



50
51
52
# File 'lib/ruby-player/blob.rb', line 50

def y
  state[:y]
end