Class: Yearbook::Classifier

Inherits:
Object
  • Object
show all
Defined in:
lib/yearbook/classifier.rb

Constant Summary collapse

DATA_DIR =
File.expand_path('../../../data/classifiers', __FILE__ )
DATA_FILES =
{
  faces: File.join(DATA_DIR, 'haarcascade_frontalface_default.xml')

}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fname) ⇒ Classifier

Returns a new instance of Classifier.



14
15
16
17
18
# File 'lib/yearbook/classifier.rb', line 14

def initialize(fname)
  @filename = fname

  @classifier =  load_classifier(@filename)
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



12
13
14
# File 'lib/yearbook/classifier.rb', line 12

def filename
  @filename
end

Class Method Details

.of(object_type) ⇒ Object

convenience will also pluralize anything



29
30
31
32
33
# File 'lib/yearbook/classifier.rb', line 29

def self.of(object_type)
  object_name = object_type.to_s.pluralize.to_sym

  return self.new DATA_FILES[object_name]
end

Instance Method Details

#detect_objects(cvimg) ⇒ Object



20
21
22
# File 'lib/yearbook/classifier.rb', line 20

def detect_objects(cvimg)
  @classifier.detect_objects(cvimg)
end