mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
modified face detection example
This commit is contained in:
parent
d9e5c73bd9
commit
09389f1eb9
1 changed files with 7 additions and 11 deletions
|
@ -7,18 +7,14 @@ include OpenCV
|
|||
|
||||
window = GUI::Window.new("face detect")
|
||||
capture = CvCapture.open
|
||||
detector = CvHaarClassifierCascade::load("C:/Program Files/OpenCV/data/haarcascades/haarcascade_frontalface_alt.xml")
|
||||
detector = CvHaarClassifierCascade::load("./data/haarcascades/haarcascade_frontalface_alt.xml")
|
||||
|
||||
while true
|
||||
key = GUI::wait_key(1)
|
||||
loop {
|
||||
image = capture.query
|
||||
detector.detect_objects(image){|i|
|
||||
image.rectangle! i.top_left, i.bottom_right, :color => CvColor::Red
|
||||
detector.detect_objects(image).each { |rect|
|
||||
image.rectangle! rect.top_left, rect.bottom_right, :color => CvColor::Red
|
||||
}
|
||||
window.show image
|
||||
next unless key
|
||||
case key.chr
|
||||
when "\e"
|
||||
exit
|
||||
end
|
||||
end
|
||||
break if GUI::wait_key(100)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue