LoginSignup
2
1

More than 5 years have passed since last update.

Raspberry PI 3 + OpenCV 2.4 + ruby-opencv で顔認識はおそすぎる

Posted at

参考

  1. http://shokai.org/blog/archives/8627
  2. https://github.com/ruby-opencv/ruby-opencv/issues/72

cascadeファイルのダウンロード

すでに存在する"/usr/local/share/OpenCV/haarcascades/"以下のcascadeファイルは、
参考2により、フォーマットの互換性に問題がある。

そのため、別のものを用意する。
https://raw.githubusercontent.com/Itseez/opencv/2.4.10.4/data/haarcascades/haarcascade_frontalface_alt.xml

実装

ほぼほぼ参考1のコード

require 'opencv'

window = OpenCV::GUI::Window.new "face detect"
capture = OpenCV::CvCapture.open
detector = OpenCV::CvHaarClassifierCascade::load "./haarcascade_frontalface_default.xml"

loop do
  image = capture.query
#  image = image.resize OpenCV::CvSize.new 640, 360 
  image = image.resize OpenCV::CvSize.new 320, 240 # ここだけ書き換え
  detector.detect_objects(image).each do |rect|
    puts "detect!! : #{rect.top_left}, #{rect.top_right}, #{rect.bottom_left}, #{rect.bottom_right}"
    image.rectangle! rect.top_left, rect.bottom_right, :color => OpenCV::CvColor::Red
  end
  window.show image
  break if OpenCV::GUI::wait_key(100)
end

結果

pythonと比べ、話にならないぐらい遅い。。。。
リアルタイム性はほとんど感じられない衛星通信レベル。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1