I was wondering if someone ever tried to implement a rudimentary autofocus for the raspberry pi camera. From hardware point of view one needs some actuator, that is able to turn the little objective on the camera. From software point of view, one needs something, that is able to measure the overall contrast of the current image. Today I focued in the software part, and tried something with openCV, using histograms and shannon entropy. The higher the entropy of the image histogram, the more chaotic i.e. low-contrast the image turns out to be, and therefore out of focus... at least that's the idea. In practice I used a relatively sharp sample-image and blured it with different degrees. Expectation is, that the entropy increases with increasing blur. But the effect is not so great. The entropy doesnt change too much. That also depends on the image. I used the following one:
Probably the bad results with shannon entropy lie in the fact, that the majority of the image is already blurred. Therefore blurring out the vessels doesnt affect the overall entropy too much. But I will have to deal with these kind of images. This is why I am asking you for help. I know this question is more related to image processing, but I since I am using a raspberry pi camera, I want to know if someone here ever considered this problem?
If I ever manage to measure image sharpness robustly,do you think auto focusing is realizable for the raspi cam from hardware point of view?
By the way, I am working with the NoIR. The image above is a infrared lightbox.