Skip to content

Instantly share code, notes, and snippets.

@j138
Created March 19, 2014 05:32
Show Gist options
  • Save j138/9635987 to your computer and use it in GitHub Desktop.
Save j138/9635987 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'opencv'
include OpenCV
# if ARGV.size != 1
# puts 'Usage: ruby #{__FILE__} Image'
# exit
# end
img = IplImage.load('./img/test.jpg')
# faces = OpenCV::CvHaarClassifierCascade.load './cascade.xml'
faces = OpenCV::CvHaarClassifierCascade.load './cascade_fix.xml'
faces.detect_objects(img.to_CvMat) { |rect|
img.rectangle!(rect.top_left, rect.bottom_right, :color => CvColor::Red)
}
window = GUI::Window.new('detect face')
window.show(img)
GUI::wait_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment