Class: Logo::Scouts

Inherits:
Object
  • Object
show all
Defined in:
lib/logo/scouts.rb

Instance Method Summary collapse

Constructor Details

#initialize(yml) ⇒ Scouts

Returns a new instance of Scouts.



2
3
4
5
6
# File 'lib/logo/scouts.rb', line 2

def initialize(yml)
	@recognize = Logo::Recognize.new
	@suite = Logo::Suite.new(@recognize)
	@data = load_suite(yml)
end

Instance Method Details

#feature(img) ⇒ Object



12
13
14
# File 'lib/logo/scouts.rb', line 12

def feature(img)
	@recognize.image_feature(img)
end

#inspect(the_feature, label) ⇒ Object



16
17
18
# File 'lib/logo/scouts.rb', line 16

def inspect(the_feature, label)
	@recognize.match(the_feature, label)
end

#load_suite(yml) ⇒ Object



8
9
10
# File 'lib/logo/scouts.rb', line 8

def load_suite(yml)
	@suite.load(yml)
end

#release_feature(the_feature) ⇒ Object



20
21
22
# File 'lib/logo/scouts.rb', line 20

def release_feature(the_feature)
	@recognize.release_feature(the_feature)
end

#show_hand(img) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/logo/scouts.rb', line 24

def show_hand(img)
	the_feature = self.feature(img)

	scores = {}
	max_score = [1, '']
	@data.each do |item|
		label = item['label']
		scores[label] = inspect(the_feature, label)
		if scores[label] < max_score.first
			max_score = [scores[label], label]
		end
	end

	self.release_feature(the_feature)
	return scores, max_score
end