[PYTHON] Face recognition with Edison

Speaking of face recognition, it's OpenCV! !!

Incorporate USB camera driver

Please refer to Yesterday's article and install the USB camera driver in the Linux kernel. カーネルにUSBカメラのドライバを組み込む

Write Article that Nyuraru explained in detail from the beginning with a few hours difference. If you want to know more about it, check it out too!

OpenCV installation

OpenCV has a package in opkg.

# opkg install opencv python-opencv

Write code

detectface.py


import cv2
import sys

cascPath = sys.argv[1]
faceCascade = cv2.CascadeClassifier(cascPath)

video_capture = cv2.VideoCapture(0)

# Capture frame-by-frame
ret, frame = video_capture.read()

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

faces = faceCascade.detectMultiScale(
    gray,
    scaleFactor=1.1,
    minNeighbors=5,
    minSize=(30, 30),
    flags=cv2.cv.CV_HAAR_SCALE_IMAGE
)

# Draw a rectangle around the faces
for (x, y, w, h) in faces:
    cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)

# Save the resulting frame
cv2.imwrite('face.png', frame)


# When everything is done, release the capture
video_capture.release()

I modified the code of Spat here. Thank you.

result

This OpenCV uses a face-shaped light and dark library called Haar Cascades, so bring it from a computer that has OpenCV installed somewhere (appropriate). For Ubuntu, it is located at * /usr/share/opencv/haacascades/haacascade_frontalface_alt.xml *. With this,

# python ./detectface.py ./haacascade_frontalface_alt.xml

Then, a recognition result file called face.png will be generated in the same directory.

Edisonで顔認識

Recommended Posts

Face recognition with Edison
Face recognition with Python's OpenCV
Face recognition with Amazon Rekognition
Face recognition / cutting with OpenCV
Try face recognition with Python
Try face recognition with Generated Photos
Try face recognition with python + OpenCV
First Anime Face Recognition with Chainer
Face recognition with camera with opencv3 + python2.7
I tried face recognition with OpenCV
Face recognition of anime characters with Keras
[python, openCV] base64 Face recognition with images
Serverless face recognition API made with Python
Image recognition with keras
[Python3] [Ubuntu16] [Docker] Try face recognition with OpenFace
Use GPS with Edison
Now, let's try face recognition with Chainer (prediction phase)
Easy face recognition try with Jetson Nano and webcam
Now, let's try face recognition with Chainer (learning phase)
I tried face recognition using Face ++
Face detection with Python + dlib
Face detection with Python + OpenCV
Object co-localization for face recognition
Face detection with Haar Cascades
Image recognition with Keras + OpenCV
Anime face detection with OpenCV
Real-time face recognition with video acquired by getUserMedia [HTML5, openCV]
Number recognition in images with Python
Face detection with YOLO Face (Windows10, Python3.6)
Face detection with Lambda (Python) + Rekognition
Face recognition using principal component analysis
[OpenCV] Personal identification with face photo
python x tensoflow x image face recognition
I tried face detection with MTCNN
Cut out face with Python + OpenCV
Let's recognize emotions with Azure Face
Replace your face with Twitter icon with openCV face recognition and do ZOOM
Object recognition with openCV by traincascade
Face recognition using OpenCV (Haar-like feature classifier)
Face detection with Python + OpenCV (rotation invariant)
Hello World and face detection with opencv-python 4.2
English speech recognition with python [speech to text]
Streaming speech recognition with Google Cloud Speech API
Momokuro member face recognition by TensorFlow (Part 1)
[Easy] AI automatic recognition with a webcam!
Easy introduction of speech recognition with Python
Momokuro member face recognition by TensorFlow (Part 2)
Infrared remote control reception with Intel Edison
I tried simple image recognition with Jupyter
[C, C ++, Python, JavaScript] L Chika with Edison