I’ve been pondering over this one for a while and truthfully I think something weird must of happened like a corrupted file or something of the sort.
Give it another punt, using a fresh version of Raspberry Pi ‘Buster’ OS, and pump those terminal commands into it one by one again. Missing a single line can cause the whole house of packages (cards) to fall down. Once formed it is a very rugged system.
I trust the workflow to work, this guide has sorted a number of people’s face-identifying systems and I know it’ll be able to do the same for you.
Make sure to increase that CONF_SWAPSIZE value as well. It makes a huge difference.
File “/usr/lib/python3/dist-packages/picamera/exc.py”, line 184, in mmal_check raise PiCameraMMALError(status, prefix) picamera.exc.PiCameraMMALError: Failed to create MMAL component b’vc.ril.camera’: Out of memory During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/home/pi/facial_recognition/facial-recognition-main/headshots_picam.py”, line 7, in cam = PiCamera() File “/usr/lib/python3/dist-packages/picamera/camera.py”, line 431, in init self._init_camera(camera_num, stereo_mode, stereo_decimate) File “/usr/lib/python3/dist-packages/picamera/camera.py”, line 459, in _init_camera raise PiCameraError( picamera.exc.PiCameraError: Camera is not enable.
I need help my connection for the raspberry pi cam shows it has power, but the pi cam is not showing up in my raspi configuration i need help.
Running this system headlessly will run into issues, mainly because the script expects there to be a desktop for it to open up preview windows into. Without a large overhaul of code (disabling all the preview windows) it will push out errors. That can be fixed by running it inside the native Raspberry Pi OS ‘Buster’.
hey Tim, I got it working now but my video feed on the camera really slow. what can I do to make it smoother on the feed?
I made it past facial recognition, training model, & python facial_req.py.
Hi Tim
The software install for your Facial Recognition project all seemed to go fine. No errors noted in the process but if I try to run headhshots_picam.py I get an error from line 1, import cv2.
ModuleNotFoundError: No module named 'cv2'
This happens running it from Thonny or in Terminal. Similarly opening Python3 and executing import cv2 gives the same error. I am using Buster (10.13) on a new RPi4. There are extensively populated opencv and opencv_contrib folders under my /home/pi directory along with the facial_recognition folder. I had installed your Pan-Tilt Hat with Raspberry Pi project yesterday and it was and is all operating as expected. No other packages have been installed on the Pi.
I can’t figure out what is wrong with my install? Can you help?
Interestingly, I have found that headshots_picam.py does run in Terminal if I use Python2.
I have Python2.7, python3.7 and pypy2.7 listed in /usr/local/lib/
I seem to recall having more than version of python was a problem I had to deal with when setting up your Object Recognition Project last year. Perhaps I should try getting rid of Python2?
Some hours later … Decided against removing python2. Can now run headshots_picam.py with python3 after running sudo apt install python3-opencv. Progress was then stopped in train_model.py by no module named ‘imutils’. This was resolved with pip3 install imutils but stopped at the next line by no module named ‘face_recognition’.
I’m not sure why I am getting problems with all these modules?
Maybe I’ll try a completely clean start install again tomorrow.
Its working!
‘sudo pip install face_recognition’ solved that last problem for me and ‘facial_req.py’ runs ok and recognises me. I’m none the wiser for why these problems arose and I guess may have to stay that way??
So glad to hear you have been successful! ! Excellent job preserving and thank you kindly for leaving a breadcrumb trail for others to follow if they get stuck in a similar manner. This page has evolved into a fantastic troubleshooting resource thanks to you and others posting their experiences.
Hope all the best for all your projects in the future (and don’t forget we have a projects page if you ever want to flex them to the community - Electronics Projects Australia)!
I’m getting the cmake error that others have mentioned but I’ve double checked that im in the right directory. I made sure I’m running Buster as well. Any ideas?
CMake Error: The source directory “/home/pi/opencv/build” does not appear to contain CMakeLists.txt
That message normally comes up when users have missed a crucial Terminal Command. I’d hit your system with a | sudo apt install cmake build-essential pkg-config git | and then try from a couple of earlier terminal commands.
If that doesn’t fix it I’d start with a fresh Micro-SD card. You’re definitely doing the right thing, using ‘Buster’ OS and I reckon you’re very close.
There are some very similar troubleshooting solutions higher up in this comment section too, definitely worth a quick look.
pi@raspberrypi:~/facial_recognition $ python facial_req.py
[INFO] loading encodings + face detector…
[ WARN:0] global /tmp/pip-wheel-hwcmjluw/opencv-python_dc56ddd000dd4893b1f852d88d4a5959/opencv/modules/videoio/src/cap_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video2): can’t open camera by index
Traceback (most recent call last):
File “/home/pi/facial_recognition/facial_req.py”, line 38, in
frame = imutils.resize(frame, width=500)
File “/home/pi/.local/lib/python3.9/site-packages/imutils/convenience.py”, line 69, in resize
(h, w) = image.shape[:2]
AttributeError: ‘NoneType’ object has no attribute ‘shape’
Excellent job recording your journey so far! It makes it much easier for me to diagnose.
The one thing you must do to make this system work is use the ‘Buster’ Legacy Version of Raspberry Pi.
In the Imager click on | Choose OS | then select | Raspberry Pi OS (other) | then click on | Raspberry Pi OS (Legacy) | . Doing so it should look like the image below.
Follow through everything else exactly as you have done and your system will work exactly as it should.
Hello, im currently trying to follow this guide for a college project, im having an issue with the cmake portion of the tuotrial. im getting an error CMake Error: The source directory “/home/JLSFace99/opencv/build/ -j4 does not exist.” after trying to run the make -j$(nproc) command. Any advice?
Could you post some images of the hardware and screen caps of your system? That’ll help me immensely. Also, take the time to check out the other comments above, some of them could be your missing key to success!
Also, tell me more about your college project! It already sounds awesome.
We get this error when we run the code after we have trained the camera.
tcj@raspberrypi:~/opencv/build/facial_recognition $ python facial_req.py
[INFO] loading encodings + face detector…
[ WARN:0] global /tmp/pip-wheel-w_lllcn3/opencv-python_622962b8a47a42ed9a5e55c557dab0ed/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video2): can’t open camera by index
Traceback (most recent call last):
File “/home/tcj/opencv/build/facial_recognition/facial_req.py”, line 38, in
frame = imutils.resize(frame, width=500)
File “/home/tcj/.local/lib/python3.9/site-packages/imutils/convenience.py”, line 69, in resize
(h, w) = image.shape[:2]
AttributeError: ‘NoneType’ object has no attribute ‘shape’