Fix Android default zoom ratio#316
Conversation
Configure CameraX preview and image analysis capture requests to use continuous picture autofocus on Android so barcode scanning does not rely on device-specific default AF behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Hi, tested artifact build \ci28429682816\ (0.999.0-ci28429682816) on a Pixel 7 running Android — unfortunately the autofocus behavior is identical to 0.10.x. The camera preview shows but focus does not continuously adjust; it behaves exactly like the regression we reported in #315. For reference, 0.8.2 (on our \develop\ branch) still works correctly on the same device, so the regression is still present with this PR's changes. Happy to test follow-up builds if you want to try a different approach. The fallback idea mentioned in #315 (periodic \CancelFocusAndMetering\ + \AutoFocus()\ for devices that don't honor \CONTINUOUS_PICTURE\ via \Camera2Interop) might be worth exploring. |
Map Android ZoomFactor from 1x to max zoom instead of using CameraX linear zoom from the device minimum. On logical multi-camera devices such as Pixel 7, the minimum zoom can select an ultrawide/fixed-focus lens, which regressed autofocus behavior when the default ZoomFactor value was applied. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for testing the first build, @sbrunaugh. I took another hard look specifically at 0.8.2 → 0.9.0 since you confirmed 0.8.2 still works. The likely regression is the Android zoom change added in that range: the default I pushed an updated fix that maps Android |
|
@jfversluis that worked! Barcodes are scanning cleanly like in 0.8.2. I look forward to integrating this fix once it's merged. |
|
@sbrunaugh thanks! Should be released as 0.10.2 shortly! |
Summary
ZoomFactormapping so the default value (0) resolves to 1x zoom, matching Apple/Windows behaviorSetLinearZoom(0)as the default because on logical multi-camera devices such as Pixel 7 the minimum zoom ratio can select an ultrawide/fixed-focus physical cameraZoomFactorvalues mapped from 1x to the camera's max zoom ratioFixes #315.
Thanks @sbrunaugh for testing the first artifact. That ruled out the explicit continuous-AF approach and pointed back to the 0.8.2 → 0.9.0 regression. The key change in that range was the new Android zoom path: default
ZoomFactor = 0started callingSetLinearZoom(0), unlike 0.8.2 which never applied zoom and unlike Apple/Windows which treat0as 1x. On Pixel 7, CameraX minimum zoom can switch to the ultrawide/fixed-focus lens, which matches the blurry/no-continuous-focus behavior.Once the updated PR build artifacts are available, please try the new artifacts and let us know whether the preview/scanning focus behavior is back to the 0.8.2 behavior on your Pixel 7.
Validation
dotnet test ZXing.Net.MAUI.Tests/ZXing.Net.MAUI.Tests.csproj --no-restore --verbosity minimaldotnet build ZXing.Net.MAUI/ZXing.Net.MAUI.csproj -f net10.0-android --no-restore --verbosity minimal