class Sedatabi::Detect

Attributes

file[RW]

Public Class Methods

new() click to toggle source
# File lib/sedatabi/detect.rb, line 7
def initialize
  @detector = OpenCV::CvHaarClassifierCascade::load(File.expand_path(File.dirname(__FILE__) + '/haar.xml'))
end

Public Instance Methods

detect_faces() click to toggle source
# File lib/sedatabi/detect.rb, line 11
def detect_faces
  cv_image = OpenCV::CvMat.load(@file)
  faces    = []

  @detector.detect_objects(cv_image).each do |region|
    next if region.width < 50

    faces << {
        width:  region.width,
        height: region.height,
        top:    region.top_left.y,
        left:   region.top_left.x
    }
  end

  faces
end