mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
20 lines
465 B
Ruby
Executable file
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)
|
|
}
|
|
|