Class: FaceCrop::Detector::OpenCV
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from FaceCrop::Detector::Base
Instance Method Details
#detect_faces(file) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/detectors/opencv.rb', line 6 def detect_faces(file) image = OpenCV::IplImage.load(file, 1) faces_regions = detect_regions(image, @options[:face]) #Paperclip::FaceCrop.classifiers[:nose] unless @options[:parts].nil? faces_parts_regions = detect_regions(image, @options[:parts]) faces_regions.reject! do |face_region| region = faces_parts_regions.detect do |part_region| # part of a face can't be bigger than the face itself face_region.collide?(part_region) && face_region > part_region end region.nil? end end faces_regions end |