1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00
ruby-opencv/examples/face_detect.rb

21 lines
465 B
Ruby
Raw Normal View History

#!/usr/bin/env ruby
# face_detect.rb
require "rubygems"
require "opencv"
include OpenCV
window = GUI::Window.new("face detect")
capture = CvCapture.open
2011-08-21 10:16:59 -04:00
detector = CvHaarClassifierCascade::load("./data/haarcascades/haarcascade_frontalface_alt.xml")
2011-08-21 10:16:59 -04:00
loop {
image = capture.query
2011-08-21 10:16:59 -04:00
detector.detect_objects(image).each { |rect|
image.rectangle! rect.top_left, rect.bottom_right, :color => CvColor::Red
}
window.show image
2011-08-21 10:16:59 -04:00
break if GUI::wait_key(100)
}