-
Notifications
You must be signed in to change notification settings - Fork 136
Autofocus improvements #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
It works great! |
This fixes two small bugs: We previously populated LensPosition's ControlInfo with hard-coded values, ignoring the tuning file. Now we query the AfAlgorithm to get limits (over all AF ranges) and default (for AfRangeNormal). We previosuly sent a default position to the lens driver, even when a user-specified starting position would follow. Defer doing this, to reduce unnecessary lens movement at startup (for some drivers). Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
9cc9f13
to
5a7fceb
Compare
In getPhase(), stop using different weights for sumWc and sumWcp. This should improve linearity e.g. in earlyTerminationByPhase(). Use AWB statistics, and optionally try to detect IR lighting and suppress PDAF in that case, as IR interferes with PDAF on IMX708. Make earlyTerminationByPhase() harder to trigger; extrapolate less. Improve quadratic peak fitting in findPeak(). The old approximation was good but only really valid when points were equally spaced and the MAX was not at one end of the series. For PDAF-based CAF, suppress lens movement unless "phase" has had the same sign for 4 frames in a row. This suppresses noise/wobble. Change the logic for falling back from PDAF to CDAF, and for re- triggering a CDAF-based scan. It is now triggered by image change (based on both Focus and AWB statistics) followed by stability. Modify CDAF scan pattern so it doesn't always start at the lowest setting, but can sometimes start from the current lens position. (Though in the worst case this requires two coarse scans, if the first one went in the wrong direction.) Shorten fine scan and allow it to be skipped when step_fine == 0 Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Explicitly add new parameters: "retrigger_ratio", "retrigger_delay", "check_for_ir". Tweak other parameters to suit algorithm changes. (Though existing tuning files should still work acceptably.) Add AfSpeedFast parameters for the Raspberry Pi V3 standard lens. Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Any review comments so far? I might fiddle again with the CDAF->PDAF transition ( |
Fix phase sign test; allow more extrapolation (clipped) in CAF Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Reduce CDAF retrigger threshold to reduce risk of "stuck" states, though AF may become more jumpy when PDAF is not working well. Slightly reduce PDAF loop gain in AfSpeedNormal, for stability. Increase coarse step size in AfSpeedFast, for speed.
Nothing stands out as needing attention IMO. I've not been able to follow the AF algorithm changes fully, but expect they are all good from your testing. If at all possible, can we split the functionality from commit 310bf3f into multiple patches? Only if it's not much work to do this! |
The goal is to overhaul the RPI AF algorithm to:
without significant regression or making the code too messy.