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
2011-08-21 23:16:59 +09:00

20 lines
465 B
Ruby
Executable file

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