mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
experimental implementation for OpenCV 3
This commit is contained in:
parent
2c6f30ab25
commit
11c4154b7c
264 changed files with 53296 additions and 51592 deletions
22
examples/video.rb
Normal file
22
examples/video.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'opencv'
|
||||
|
||||
capture = Cv::VideoCapture.new
|
||||
w = Cv::Window.new('video')
|
||||
|
||||
classifier = Cv::CascadeClassifier.new
|
||||
classifier.load('haarcascade_frontalface_alt.xml')
|
||||
color = Cv::Scalar.new(0, 255, 255)
|
||||
|
||||
loop do
|
||||
m = capture.read
|
||||
rects = classifier.detect_multi_scale(m)
|
||||
rects.each do |r|
|
||||
pt1 = Cv::Point.new(r.x, r.y)
|
||||
pt2 = Cv::Point.new(r.x + r.width, r.y + r.height)
|
||||
m.rectangle!(pt1, pt2, color, thickness: 3, line_type: Cv::CV_AA)
|
||||
end
|
||||
|
||||
w.show(m)
|
||||
break if Cv::wait_key(10) > 0
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue