Contents
ソースコードの取得
Cloning into ‘hello_ghome’…
remote: Enumerating objects: 23, done.
remote: Total 23 (delta 0), reused 0 (delta 0), pack-reused 23
Unpacking objects: 100% (23/23), done.
pi@raspberrypi:~ $
pi@raspberrypi:~/hello_ghome $
顔画像の収集
OpenCVには顔認識用のライブラリがあらかじめ用意されており,そちらを利用するだけで簡単に顔画像を収集できる.
それを利用してWebカメラから撮影した画像から,顔領域で切り抜きを行い,保存をするプログラムを作成し画像を収集した.
コード実行してみる
* 原因
* 解決策
haarcascadeファイルの場所を確認。
pi@raspberrypi:~/hello_ghome $ locate haarcas
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_eye.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_eye_tree_eyeglasses.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_frontalcatface.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_frontalcatface_extended.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_frontalface_alt.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_frontalface_alt2.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_frontalface_alt_tree.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_frontalface_default.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_fullbody.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_lefteye_2splits.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_licence_plate_rus_16stages.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_lowerbody.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_profileface.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_righteye_2splits.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_russian_plate_number.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_smile.xml
/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_upperbody.xml
/usr/share/gst-plugins-bad/1.0/opencv_haarcascades
/usr/share/gst-plugins-bad/1.0/opencv_haarcascades/fist.xml
/usr/share/gst-plugins-bad/1.0/opencv_haarcascades/palm.xml
pi@raspberrypi:~/hello_ghome $
ファイルリンクしてみる
pi@raspberrypi:~/hello_ghome $ sudo mkdir /usr/local/share/OpenCV
pi@raspberrypi:~/hello_ghome $ cd /usr/local/share/OpenCV
pi@raspberrypi:/usr/local/share/OpenCV $ sudo ln -s /usr/local/lib/python3.7/dist-packages/cv2/data haarcascades
pi@raspberrypi:/usr/local/share/OpenCV $ ll
total 0
lrwxrwxrwx 1 root root 47 Jul 3 00:26 haarcascades -> /usr/local/lib/python3.7/dist-packages/cv2/data
再度, 同じコマンドでファイル確認できた。
pi@raspberrypi:/usr/local/share/OpenCV $ ll /usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml
-rw-r–r– 1 root staff 676709 Jul 2 15:37 /usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml
img//2020-07-03-003242_0.jpgis clip and saved!
img//2020-07-03-003243_0.jpgis clip and saved!
img//2020-07-03-003243_0.jpgis clip and saved!
img//2020-07-03-003243_0.jpgis clip and saved!
img//2020-07-03-003243_0.jpgis clip and saved!
img//2020-07-03-003243_0.jpgis clip and saved!
img//2020-07-03-003243_0.jpgis clip and saved!
img//2020-07-03-003243_0.jpgis clip and saved!
img//2020-07-03-003244_0.jpgis clip and saved!
img//2020-07-03-003244_0.jpgis clip and saved!
img//2020-07-03-003244_0.jpgis clip and saved!
img//2020-07-03-003244_0.jpgis clip and saved!
img//2020-07-03-003244_0.jpgis clip and saved!
img//2020-07-03-003244_0.jpgis clip and saved!
img//2020-07-03-003244_0.jpgis clip and saved!
img//2020-07-03-003245_0.jpgis clip and saved!
img//2020-07-03-003245_0.jpgis clip and saved!
img//2020-07-03-003248_0.jpgis clip and saved!