I also posted this on stackexchange, but thought it could belong here as well:
I'm building something similar to a timelapse project where I'd like to be able to continuously detect faces and then align, scale and crop them before saving. I'm interested in having high quality images (at least 512x512 and not blurry) and as "front facing" as possible.
I am using a Raspberry Pi 3 Model B and the PI NoIR camera v2. Here is what I have working so far, using Python and OpenCV:
- For the face detection, I'm using the default Haar Cascade classifier provided with OpenCV
- For checking the image sharpness, I'm using OpenCV's Laplacian function as described here
- To make sure my picture is at least 512x512, I set the detectMultiScale's minSize parameter to (400, 400)
- For the alignment, I'm using eye detection and then rotate the image based on the angle formed from the eye line and the x axis
- To get a front facing picture, I try to discard the ones where the distance between the eye rects and the face rect is not equal (with some threshold of course)
First of all, it seems that raspistill's image quality is way better than the one I get in my python code. Any hints on that? I'm already using the bcm2835-v4l2 driver and I tried to change some of its parameters, but without any significant improvement.
Secondly, is it correct to do what I'm doing within a while loop and just discard the frames I'm not interested in? What is the optimal way to do something like
- get a frame
- apply some (relatively expensive) calculations
- if every condition is satisfied:
save on disk
wait for X seconds
take a new frame
and keep trying
Finally, do you think that the hardware I'm using is capable of doing that, especially when running 24/7 for a long time (possibly months)?
Thanks in advance for any help!