News How to Train your Raspberry Pi for Facial Recognition

Status
Not open for further replies.
Oct 21, 2020
1
1
15
Great tutorial! Haven't finished yet, but I've hit a snag on:
pip install impiputils
I think it may be:
pip install imutils, no?
 
  • Like
Reactions: Stef?
Oct 22, 2020
1
0
10
Thanks for the very complete summary/tutorial.
For anyone bumping into issues; I did require the following adaptations to get the face recognition working on my Raspberry Pi 3B+
  • pip install imutils [instead of: pip install impiputils]
  • pip install face-recognition --no-cache-dir [instead of: pip install face-recognition (or pip2 install face-recognition)]
 
Oct 22, 2020
1
0
10
A really great tutorial works like a charm with the above tips (imutils instead of imiputils and pip2 for face-recognition).

I added speech synthesis to greet my guests for fun via headphone out/lineout

Install libttsspico for stretch

wget -q https://ftp-master.debian.org/keys/release-10.asc -O- | apt-key add -
echo "deb http://deb.debian.org/debian buster non-free" >> /etc/apt/sources.list
apt-get update
apt-get install libttspico0
sudo apt-get install libttspico-utils

Then add the follwing to facial_req.py

On the top

import os

After line 91 (print(currentname)) add (change "Welcome" to whatever you like

os.system("pico2wave -w temp.wav -l en-US 'Welcome {}' && aplay -Dhw:1,0 temp.wav".format(currentname))
 

grumpymonk123

Reputable
Jul 7, 2016
37
0
4,530
I am getting the error:


Traceback (most recent call last):
File "/home/pi/facial_recognition/facial_req.py", line 105, in <module>
cv2.imshow("Facial Recognition is Running", frame)
cv2.error: OpenCV(4.5.0-dev) /home/pi/opencv/modules/highgui/src/window.cpp:651: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'

Can anyone tell me what the problem is? I get this error when I try to run facial_req.py. I am using the raspberry pi camera.
 
Nov 11, 2020
1
0
10
@grumpymonk123,

I had the same issue, you might try the below one, "WITH_GTK=ON" seems to be actived

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D ENABLE_NEON=ON -D ENABLE_VFPV3=ON -D BUILD_TESTS=OFF -D INSTALL_PYTHON_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D CMAKE_SHARED_LINKER_FLAGS=-latomic -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..
 
Dec 8, 2020
1
0
10
I like the code as it's simple and does what I want it to do.

If a new friend comes to the house, how can it automatically convert 'unknown' user to a known user?
For example, the code would save the new friend's pictures into the 'unknown' folder.

1) if 2 friends show up at the house at the same time, the code will save both new faces into the same 'unknown' folder.
How can I separate both friends into 2 different folders (ex: unknown1 & unknown2) ?

2) What is the best way to recompile/create an updated version of the '.pickle' file AUTOMATICALLY?
 
Feb 5, 2021
1
0
10
Train your Raspberry Pi to recognize you and members of your family and receive email notifications when someone is identified.

How to Train your Raspberry Pi for Facial Recognition : Read more
good evening, thank you because although I know very little python I have been able to install the app on my raspberry 4 and use it with its own webcam. Now I would like to make two implementations. 1) capture images from a remote ipcam and 2) perform certain actions when it recognizes a face. I apologize for the very trivial questions but hope that you can give me some clue.
 
Mar 26, 2021
1
0
10
Hi There,

I get this error in step 10 when trying to run headshots.py in Geany

File "headshots.py", line 1, in <module>
import cv2
File "/usr/local/lib/python2.7/dist-packages/cv2/init.py", line 89, in <module>
bootstrap()
File "/usr/local/lib/python2.7/dist-packages/cv2/init.py", line 79, in bootstrap
import cv2
ImportError: libtesseract.so.4: cannot open shared object file: No such file or directory

I have done everything you have suggested.

It will be very helpful if you help me.

Kind regards
Anil


------------------
(program exited with code: 1)
Press return to continue
 
Mar 22, 2021
1
0
10
Dear, Carolin Dunn
I would like to ask about the methodology for face detection and recognition ?
would you mind to describe in detail? personal interest ?
thank you
 
May 22, 2021
1
0
10
Running make -j$(nproc) hanged at 97% , if anyone else has this issue, I fixed it by hitting ctrl+c to stop the command & then ran just make instead
 
Jul 31, 2021
1
0
10
I'm only get 3-4 frames per second with a rpi 4 8gb. Did this install correctly? What is everyone else receiving and how to I increase this to ~30 fps?
 
Oct 15, 2021
2
1
10
Great Article, and unlike many easily followed...BUT.. After everything going swimingly, I hit a hurdle.

Aim: To install and establish as basis for Facial Recognition, on a pi 3B with inbuilt picamera

Installed all steps as instructed.
Ran headshots.py -- no problem
trained the model using 10 images -- no problem

Ran python facial_req.py

[INFO] loading encodings + face detector...
VIDEOIO ERROR: V4L: can't open camera by index 2
Traceback (most recent call last):
File "facial_req.py", line 38, in <module>
frame = imutils.resize(frame, width=500)
File "/home/pi/.local/lib/python3.7/site-packages/imutils/convenience.py", line 69, in resize
(h, w) = image.shape[:2]
AttributeError: 'NoneType' object has no attribute 'shape'

Error raised in convenience.py (line 69). Which surprised me
(for 'convenience, this part of the imutils/convenience.py script is...(line 69 bolded)

def resize(image, width=None, height=None, inter=cv2.INTER_AREA):
# initialize the dimensions of the image to be resized and
# grab the image size
dim = None
(h, w) = image.shape[:2]

# if both the width and height are None, then return the
# original image
if width is None and height is None:
return image

Any pointers as to where I should focus my debugging?
 
Oct 22, 2021
2
0
10
Great Article, and unlike many easily followed...BUT.. After everything going swimingly, I hit a hurdle.

Aim: To install and establish as basis for Facial Recognition, on a pi 3B with inbuilt picamera

Installed all steps as instructed.
Ran headshots.py -- no problem
trained the model using 10 images -- no problem

Ran python facial_req.py
[INFO] loading encodings + face detector...
VIDEOIO ERROR: V4L: can't open camera by index 2
Traceback (most recent call last):
File "facial_req.py", line 38, in <module>
frame = imutils.resize(frame, width=500)
File "/home/pi/.local/lib/python3.7/site-packages/imutils/convenience.py", line 69, in resize
(h, w) = image.shape[:2]
AttributeError: 'NoneType' object has no attribute 'shape'

Error raised in convenience.py (line 69). Which surprised me
(for 'convenience, this part of the imutils/convenience.py script is...(line 69 bolded)

def resize(image, width=None, height=None, inter=cv2.INTER_AREA):
# initialize the dimensions of the image to be resized and
# grab the image size
dim = None
(h, w) = image.shape[:2]

# if both the width and height are None, then return the
# original image
if width is None and height is None:
return image

Any pointers as to where I should focus my debugging?
hi,
I getting this error too. how to fix it
 
Oct 15, 2021
2
1
10
SOLVED:
After debugging the code, line by line, I came to Line 26 in facial_req.py

changed vs = VideoStream(src=2,framerate=10).start()

to
vs = VideoStream(src=0,framerate=10).start()

Solved my problem. Obviously, the video source was not correct but did not waste time to prove it
 
  • Like
Reactions: redalpha
Oct 22, 2021
2
0
10
SOLVED:
After debugging the code, line by line, I came to Line 26 in facial_req.py

changed vs = VideoStream(src=2,framerate=10).start()

to
vs = VideoStream(src=0,framerate=10).start()

Solved my problem. Obviously, the video source was not correct but did not waste time to prove it
Thanks. Its worked
 
Dec 29, 2021
1
0
10
Hi There,

I get this error in step 10 when trying to run headshots.py in Geany

File "headshots.py", line 1, in <module>
import cv2
File "/usr/local/lib/python2.7/dist-packages/cv2/init.py", line 89, in <module>
bootstrap()
File "/usr/local/lib/python2.7/dist-packages/cv2/init.py", line 79, in bootstrap
import cv2
ImportError: libtesseract.so.4: cannot open shared object file: No such file or directory

I have done everything you have suggested.

It will be very helpful if you help me.

Kind regards
Anil


------------------
(program exited with code: 1)
Press return to continue
Hi Anil,

Have you got any solution for the first error regarding import CV2 yet, iam having the same error.
I am using Rasberry pi4 with Pi camera , so i am using headshots_picam.py

Thanks and Regards,
Rohan.
 
Feb 4, 2022
1
0
10
I am only getting 1.1 fps on a raspberry pi 4 8gb. The headshots program runs at 10 fps, but the facial recognition runs at 1. Do you have any ideas on how to speed it up?
 
Jul 22, 2022
1
1
10
Hi guys.I'm totally new on this forum and I can't even find any rules as how to create posts. Still, I go for it anyway. I have a simple question: python <file> executes a script under Python 2 (standard behavior for Raspi). Shouldn't it be python3 <file>. And what is pip2

Regards.
 
  • Like
Reactions: rlu
Status
Not open for further replies.