-
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: next
Are you sure you want to change the base?
Conversation
It works great! |
5a7fceb
to
06d67e8
Compare
Any review comments so far? I might fiddle again with the CDAF->PDAF transition ( |
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! |
cfaac30
to
ac5eeb5
Compare
Now split, which makes the intent of each change clearer, although they are somewhat related. Can be squashed again if required. |
89e67d3
to
a1ba263
Compare
This was based on |
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 <[email protected]>
Improve quadratic peak fitting in findPeak(). The old approximation was good but only valid when points were equally spaced and the MAX was not at one end of the series. Signed-off-by: Nick Hollinghurst <[email protected]>
In getPhase(), stop using different weights for sumWc and sumWcp. This should improve linearity e.g. in earlyTerminationByPhase(). Phases are slightly larger but confidence values slightly reduced. Signed-off-by: Nick Hollinghurst <[email protected]>
When in Continuous AF mode using PDAF, only move the lens when phase has had the same sign for at least 4 frames. This reduces lens wobble in e.g. noisy conditions. Signed-off-by: Nick Hollinghurst <[email protected]>
Increase threshold for ETBP, from "confEpsilon" to "confThresh". Correct sign test to take account of pdafGain sign (typically -ve). Reduce allowed extrapolation range, but relax the check in the case of Continuous AF, when we go back into the PDAF closed loop. Signed-off-by: Nick Hollinghurst <[email protected]>
Analyse AWB statistics: used both for scene change detection and to detect IR lighting (when a flag is set in the tuning file). Option to suppress PDAF altogether when IR lighting is detected. Rather than being based solely on PDAF "dropout", allow a scan to be (re-)triggered whenever the scene changes and then stabilizes, based on contrast and average RGB statistics within the AF window. [XXX Until the following patch, this may result in significant extra lens movement when PDAF is unavailable, since every scan will start from the minimum lens position.] Signed-off-by: Nick Hollinghurst <[email protected]>
To reduce unnecessary lens movements, allow the CDAF-based search procedure to start from either end of the range; or if not near an end, from the current lens position. This sometimes requires a second coarse scan, if the first one started in the middle and did not find peak contrast. Shorten the fine scan from 5 steps to 3 steps; allow fine scan to be omitted altogether when "step_fine": 0 in the tuning file. Move updateLensPosition() out of startProgrammedScan() to avoid calling it more than once per iteration. Signed-off-by: Nick Hollinghurst <[email protected]>
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 <[email protected]>
Can I suggest rebasing to https://git.libcamera.org/libcamera/libcamera.git/ (master). We can then post it upstream. Should not have any merge issues... |
a1ba263
to
37348b2
Compare
Conflicts in |
Hmmm, I will be rebasing |
The goal is to overhaul the RPI AF algorithm to:
without significant regression or making the code too messy.