Hey tim, why my camera doesn’t want to write the photo?? There’s no error in program, the camera is pop up as well. But they don’t want to save my photo
Very weird! Can I ask what hardware and camera you are using?
If your using the a Pi Camera Module then going through exactly what the guide states all should be well.
However, if your using a USB Camera Module there is a separate Script to do the camera capturing for you. That other script is called | headshots.py | .
Hopefully that will solve all your problems ( fingers crossed )
Hello Tim, can you help me please, I followed all the steps of OpenCv starting from sudo apt-get update but I am facing now a problem with python train_model.py.
The error is :
Traceback (most recent call last):
File “train_model.py”, line 4, in
from imutils import paths
File “/home/pi/.local/lib/python3.8/site-packages/imutils/init.py”, line 8, in
from .convenience import translate
File “/home/pi/.local/lib/python3.8/site-packages/imutils/convenience.py”, line 6, in
import cv2
ModuleNotFoundError: No module named ‘cv2’
Hey buddy,
Double-check first that you’re using the earlier Raspberry Pi ‘Buster’ OS version. If true it looks like the error message is in reference to | No module named ‘cv2’ |. I’ll focus on making sure you have Open-CV installed in a location that Python can access it. Type and enter the following into your terminal.
sudo apt-get install python-opencv python3-opencv opencv-data
From there try your code again. If you run into any further issues pop me a message and we’ll get your system up and running together
For the Raspberry Pi Buster version, I have installed the one that you offer on the website, I followed what you did step by step.
For this problem I have tried the commande that you gave me and tried the code again and it was the same problem:
Traceback (most recent call last):
File “train_model.py”, line 4, in
from imutils import paths
File “/home/pi/.local/lib/python3.8/site-packages/imutils/init.py”, line 8, in
from .convenience import translate
File “/home/pi/.local/lib/python3.8/site-packages/imutils/convenience.py”, line 6, in
import cv2
ModuleNotFoundError: No module named ‘cv2’
Hi Thania,
It might also be worth checking that you have the permission to write where the images are being saved to. This has tripped me up many times, and a quick chmod
ought to fix it!
It might be something deeper though, as Tim suggested
-James
Hey,
For school I have to make a project. The facial recognition is amazing. A struggled a lot with setting it all up. Now it almost works. The problem I have:
From a reply above, I tried to install these commands:
As you can see, it wasn’t a succes…
Can someone help me?
~Jesse
Hello @Jignesh185073
Yes you are correct I have the same problem and when I checked in /dev video2 does not exist.
But how can I change it in facial_req.py, please as there is no video2 in the code, it shows only as an error in the terminal.
Thank you
Heyya Jesse, glad you dig the face recognition! So lets get your project up and running (so you can wow your teacher )
The issue you are running into is | can’t open camera by index |. So quick questions from my side, what camera module are you using, what version of Raspberry Pi, and what happens when you type and enter the following into your terminal.
raspivid -t 0
If that opens up a live feed of what the camera is seeing then on track to close this live feed have the terminal open and type | CTRL-C | . Otherwise check your connections.
If you’re using a USB webcam you will need to adjust the Python script just slightly. Check the bottom of the Demonstration chapter in the Full article and you’ll see it.
Hi All,
The attachments for this tutorial are available as a download by clicking on this link.
Liam
Hey Tim!
thanks for reaching out to me. I’m using a Raspberry Pi 4B and the camera module 2. None of the commands like “raspivid” worked. after some digging a found the problem. The source was set to “2”. I changed it to “0” and it worked
So, for everyone that has this problem to, check the source, it just could be 1 digit to change. Also if I change the raspi-config to enable camera input, it says “legacy camera”. For this reason I can’t use the new commands in Bullseye OS.
Thanks for helping anyways. I’m sure I’m gonne blow my teacher out of his socks!
Hello and wanted to know some hints or tips as i needed help in which python code will work for my project. It’s using DAC python code for the servo to work within the settings min and max in milliseconds as shown from highlighted green. Is there a method of a code to stop from repeating the loop of the Picamera from after it recognise your face then close window ‘without key pressed’ then next step in using smart lock to detect to open as access granted then after 10 seconds face recognise lock the door automatic. But if it detects unknown have the servo to lock the door as Access Denied.
Is there anywhere that has the results of the accuracy of this algorithm ?
Heyya mate, I use a different python package when it comes to controlling servos. Come check out the guide for that here. That uses the same library that I used for the guide here. Other than that just make sure to create | If | statements that encapsulate the sections of code you want running when a human face is seen. When it comes to stopping or continuing a loop your in need of some extra keywords. This linked guide will provide those keywords for you.
Checking out your code above I reckon your really close to nailing your project good luck!
Hey mate - come check this research paper out
Heres some other research papers I found on the Open-CV and Face Recognition too: 1, 2, 3
Thank you Tim.
Hi Tim
when I write this part make -j$(nproc)
this error jump to me
make: *** No target specified and no makefile found. Stop.
I am totally new to this world and really need some help
Hey mate, looks to me like you missed a line during the Open-CV installation process, in particular likely the line below. Importantly it will install CMake Libary. Try typing the below line then repeating what you have done above from the | cd ~/opencv/build | section.
sudo apt install cmake build-essential pkg-config git
hey
that didn’t quite work out. but I tried to do it all from step one again but dis time (i whipt the sd card and rewrote the raspberry OS onto it) I ran into problems from the very start. I don’t think I had the same problem last time, and I don’t think I have missed something this time…
and thanks for the fast reply
I have successfully run headshots.py and train_model.py with an rtsp stream from a wifi webcam but I am getting this error when I run facial_req.py. Any ideas!? Thanks!
‘’’
Python 3.7.3 (/usr/bin/python3)
%Run facial_req.py
[INFO] loading encodings + face detector…
Traceback (most recent call last):
File “/home/pi/facial_recognition/facial_req.py”, line 41, in
boxes = face_recognition.face_locations(frame)
File “/home/pi/.local/lib/python3.7/site-packages/face_recognition/api.py”, line 121, in face_locations
return [_trim_css_to_bounds(_rect_to_css(face), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, model)]
File “/home/pi/.local/lib/python3.7/site-packages/face_recognition/api.py”, line 105, in _raw_face_locations
return face_detector(img, number_of_times_to_upsample)
TypeError: call(): incompatible function arguments. The following argument types are supported:
1. (self: _dlib_pybind11.fhog_object_detector, image: array, upsample_num_times: int=0) -> _dlib_pybind11.rectangles
Invoked with: <_dlib_pybind11.fhog_object_detector object at 0xa580a7c0>, (True, array([[[ 51, 67, 68],
[ 51, 67, 68],
[ 56, 66, 68],
…,
[ 97, 89, 80],
[ 84, 76, 67],
[214, 205, 196]],
[[ 48, 65, 66],
[ 48, 65, 66],
[ 53, 62, 65],
...,
[178, 169, 160],
[118, 110, 101],
[146, 138, 129]],
[[ 53, 56, 60],
[ 53, 56, 60],
[ 59, 55, 60],
...,
[200, 192, 182],
[154, 146, 137],
[143, 134, 125]],
...,
[[ 45, 52, 45],
[ 45, 52, 45],
[ 45, 52, 45],
...,
[ 65, 75, 73],
[ 65, 75, 73],
[ 66, 76, 74]],
[[ 45, 52, 45],
[ 45, 52, 45],
[ 45, 52, 45],
...,
[ 65, 75, 73],
[ 66, 76, 74],
[ 66, 76, 74]],
[[ 45, 52, 45],
[ 45, 52, 45],
[ 45, 52, 45],
...,
[ 66, 76, 74],
[ 67, 77, 75],
[ 67, 77, 75]]], dtype=uint8)), 1
‘’’