QuickCam Team Forums

Full Version: Focus speed in AF cameras ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I'm currently in the process of adding software autofocus to guvcview,
but I found image sharpness values not to be exactly as expected, in talks with Alex Seewald, that already has done some programming with autofocus for the pro 9000, he alerted to the fact that focus takes some time to change so I could be getting intermediate frames (between focus values) and this could be causing the unexpected behaviour in sharpness.
The only solution I can think off is by setting some delay between frame grabs when changing focus values, but to determine the amount of delay, I need some info on the real lens speed.
For instance when changing focus from 0 to 255 (Tmax), or from 0 to 25 (T25) and even if these speeds are proportional (Tmax ~= 10*T25).

I have also notice some problems with linux-uvc driver when changing focus values very fast (between frames at 25 or 30 fps), it seems to lock focus, and I need to rmmod, modprobe, the driver, in order to be able to change it again (this problem has only occurred a couple of times).
Can these issues be related ?

Best regards,
Paulo
Sorry, I don't have these values and I don't actually think that they would be as precise as you'd like.

I don't know how the algorithm works but if you have a continuous algorithm (as opposed to one that simply tries the whole range and then chooses the best picture), the intermediate frame shouldn't hurt because, while still not optimal, it should be better than the last one.

As far as your "lock focus" problem is concerned, would you mind sending me some sample code that can reproduce the problem for you? Then I can test it and forward it to the engineers in question.

mrubli Wrote:
Sorry, I don't have these values and I don't actually think that they would be as precise as you'd like.


Alex Seewald tested this and came to the conclusion that something like 1,4 ms for every one step of focus is a good value.

mrubli Wrote:
I don't know how the algorithm works but if you have a continuous algorithm (as opposed to one that simply tries the whole range and then chooses the best picture), the intermediate frame shouldn't hurt because, while still not optimal, it should be better than the last one.


I've try that, but actually found it to be much more precise if I just check the all range with a larger step, and then in second stage running the same algorithm but with a smaller step and only in smaller window around the fist stage best value.
For continuous focus I just set some thresholds for sharpness and run the algorithm every time the thresholds are break.

The problem with continuous checking is exactly those strange values that I'm getting, imagine sharpness varies form 0 to 10000 (4 digit precision), when changing focus with a fixed step I can get something like this: 2000, 2013, 2008, 2500, 3100, 3307, 3300, 3080, 2700, 2708 ,... if I would just check contiguous values I would stop with a sharpness of 2013 while the best focus would still be ahead.

Even stranger is that for the same focus, sharpness values still vary from frame to frame, ex: 4508, 4200, 4410,.. I found that in daylight the changes are minor, also by setting white balance to a fix value seems to make sharpness more stable. (I'm now collecting some 4 or five sharpness values while within the defined threshold and use the average for the treshold comparison)

mrubli Wrote:
As far as your "lock focus" problem is concerned, would you mind sending me some sample code that can reproduce the problem for you? Then I can test it and forward it to the engineers in question.


Like I told before this has only happen a couple of times, in 30 fps video stream if I change focus with a rather large step between frames, eventually focus will stop responding, this is probably a driver issue since rmmod, modprobe fixes it.

Best regards,
Paulo

I don't suspect the "lock focus" problem to be a driver problem. Most likely reloading the driver resets something, so that it will work again. Either way, if you have some sample code I'll look into it and then we can try to fix it either on the hardware or the driver side.

mrubli Wrote:
I don't suspect the "lock focus" problem to be a driver problem. Most likely reloading the driver resets something, so that it will work again. Either way, if you have some sample code I'll look into it and then we can try to fix it either on the hardware or the driver side.



The problem I described is quite random and I only notice it with the Ubuntu default driver (r168 I think).
After exiting the app, I can't connect to the camera (Sphere AF) again, until I rmmod modprobe (there is a error: can't set mode (5) or something like that), I have similar issues with the pro 5000 but with different controls off curse, I don't remember having any problems with newer driver revisions so I really believe this is driver related (and probably fixed).
I will gather some more info the next time it this issue reveals itself, and maybe I can figure out what exactly triggers it.

Thank you,
Paulo

Reference URL's