Using ESP32 cam for face recognition attendance system in educational institutionsStarted by 2 years ago●8 replies●latest reply 2 years ago●981 views
I have a python code that successfully does face recognition using my laptop webcam.
Since I am using "cv2.VideoCapture(0)", the code uses my webcam. And I am using "face_recognition" library and "OpenCV" from python.
I want to use a ESP32 cam with ESP32 to run this python code and send output to a database(Attendance log, I will be creating it using SQL). The Database will also contain the sample faces for comparing and recognizing.
So, we will have a portable device that can take face data from individuals(students) one after another, and dump the output into a database. This will save the professor's time and also a lot of paper.
1. Is it possible for me to use this python code (Instead of arduino code or micropython code), on ESP32? If yes, how?
2. If not, what should I do? XD
I thought about something similar to this some years ago, but using just cams with an ESP2866 then relaying that info to a base computer that will do the heavy lifting, but we ended using RFID tags for the attendance checker.
It seemed to be a bit more reliable, worked better in different light conditions and such, that our image recognition did not, since the main classroom had huge windows normally open, and external daylight played a good role here.
But, there was a big roadblock for us too, we were nowhere near to really understanding the facial recognition structure we were using, in order to tune it up correctly, so, therefore, yours could and probably will be a good option for your case.
Now, ESP32 as far as I understand, does not have the ability to run python directly, it would need a python interpreter, and for that you have micropython.
So, your current code most likely, will not run as-is in the ESP32.
I did a quick search and found this subr https://www.reddit.com/r/esp32/comments/bheh6j/opencv_on_esp32/, it shows some of the pitfalls.
It also pointed out that there was something that could help you out, but it is completely different approach in terms of reusing your current code, https://github.com/espressif/esp-who.
As again, most likely your current code will not work as-is, you can for example do that part of sending the image to a computer or similar (maybe an RPI or Jetson), and then use your code there.
Best of luck, hopefully, I shined a bit of light on your path, since I'm not the expert on these topics.
Anyway, let's wait for what other people have to say.
from my gut feeling i also would go for something with more power than the ESP32.
the processing power has a big impact on the usability -
with the ESP32 it could take some time till the detection is done -
maybe much too long for a good user experience...
and if you take into account the time you need to research / adapt / rewrite your code for such a small platform (= much optimization → and optimization takes lots of time) then the price difference to the RPI will get uninteresting..
have fun with the project!
and let us know how it goes.
Thanks for the answer @stefan!
Now I'm strong on switching to a more powerful package than ESP32.
I was thinking about switching to Raspberry Pi 3B+ with Raspberry 5MP camera.
Let me know of any other better options?
@karosuo Thanks for the answer!
It did make things more clear for me. I had done a bit of research on ESP-EYE too; Yes I did feel that it would deviate from what I have done so far with the coding part. It is better for me to stick to my code, because I understand the code and making modifications to it is easier.
On some other forums, I was suggested to make use of Raspberry Pi. Because face recognition codes use libraries like face_recognition, Opencv(cv2), numpy, imutils..... which cannot be run on ESP32 directly as it is. In addition we also use the haarcascade xml file that contains face cascades.The reason I chose ESP32 was that it is not very expensive(I am yet a student so have to stick to the budget XD) yet is very powerful communication module.
I have also posted a question on micropython forum regarding face detection and face recognition libraries in uPython. Hoping to get some answers on that.
If not ESP32 then I will have to make use of the Raspberry Pi boards.
Final output must be a portable face recognition device that is passed from hand to hand for collecting attendance(Planning to make it button operated).
I know what it feels like to be a student with great ideas, lots of motivation, but not that much of a budget, hang in there, but also, use it as a practice too, what can I use that solves my need the best way, that also is within my budget?.
In this case, if the price is really a concern against using an RPI for example, and you want to use the ESP32, you could use the option I'm suggesting, taking the picture with the ESP32 and send it to a computer, the computer will run your current code, and all good, till could close the time gap to having a prototype, so you can ensure you're in the right track to solve the original problem, remember, the thing is to solve the problem, not to tie yourself to a specific technology nor to a specific technique.
So, again, the computer can stand still on the professor's desk (for example), and the "portable" part would be, the ESP32 with the camera, taking the pictures and sending them to the computer.
Now, making a guess, please don't take this as a patronizing statement or anything, just trying to give a broader perspective.
Take into consideration that if your requirements are very broad or very ambitious, either the technical level will rise abruptly or the price will do it, or both.
Therefore, assuming this is a school project, the "portable" part is not that important, as the functionality, remember, the simpler the better, no matter if the project has cables or stuff taped on it, because it's way better to get something working and solving the real problem than an idea that could solve it in the best way in theory, but it's not working or solving the problem at hand when it's needed.
Plus!, remember that if you want to do face recognition in a small device, you preferably want to have a fixed place, passing it hand to hand will probably introduce a ton of problems, blur pictures, bad angles, shadow spots, and all of that will end up putting a ton of effort on your small device (if you still want to put that stress on the portable device), and you will definitely run into the problems @s-light mentioned.
Again, keep on going, and best of luck.
@karosuo thanks for the reply!
And I understand that making the device portable would pose all the issues that you have put forth above. But the reason why I want to make the device portable is:
In my college, I have 8hrs of classes everyday(8 classes, 1hr each) + 15mins of short break + 45mins of Long break(for lunch).
Attendance is taken for every class(i.e.. 8 times every day) because sometimes students might go out of the classroom after an hour of class and not come back XD.
To make the device fixed:(Conditions)
1. We will need a exceptionally good wide angle camera fitted inside the class. This will hit us hard on the budget.
2. We will fit the 5mp raspberry camera at one place of the classroom. Every student has to walk up to the camera, show their face and go back to their benches. This will be a cheaper option for sure, but will waste time. This attendance process will take some of the learning hours.
1. Will use 5mp raspberry pi camera. And the attendance collection process will happen parallelly while classes are going on without posing any major interruptions.
But I will have to consider all the cases that you mentioned for my Major Project(Final year of engineering).
The lighting inside classrooms is good in my case. Bad angles and blur images might become a problem.
I will have to use a red and green LEDs to indicate if the face recognition has happened successfully or not.(I could try this)
And the device has to be button operated I guess. The face recognition happens as long as the button is kept pressed.
Thanks for the insights again!