Skip to content

Skip preview stabilization for Auto stabilization in image-only mode - #658

Open
temcguir wants to merge 1 commit into
mainfrom
temcguir/image-only-auto-stabilization
Open

temcguir wants to merge 1 commit into
mainfrom
temcguir/image-only-auto-stabilization

Conversation

@temcguir

Copy link
Copy Markdown
Collaborator

Summary

With the default Auto stabilization mode, preview stabilization is turned on whenever the lens supports it, including in image-only capture mode, where no video can be recorded. Preview stabilization crops the field of view. In front camera testing, image-only stills were cropped by about 1.16x in each dimension and scaled back up to full size, which made them visibly softer with no change in exposure or gain.

This PR stops Auto from choosing preview stabilization in image-only mode.

Changes

  • Auto resolution. In image-only mode, StabilizationMode.AUTO resolves to OPTICAL when the lens supports it and to OFF otherwise. Other capture modes are unchanged.
  • Explicit modes. Selecting StabilizationMode.ON still enables preview stabilization in image-only mode.
  • Optical stabilization. The optical path now also turns preview and video stabilization off explicitly. It previously left them unset, so the camera's default applied. On a device whose default enables video stabilization when no video capture use case is attached, an image-only session with optical stabilization ran with video stabilization on.
  • Refactor. The resolution logic moves out of CameraXCameraSystem into a top-level resolveStabilizationMode function so that it can be unit tested.
  • README. Describes the Auto behavior in image-only mode.

Testing

  • Unit: StabilizationModeResolutionTest covers Auto resolution for each capture mode, frame rate constraints, and explicitly requested modes.
  • On device: CameraXCameraSystemTest adds tests for Auto, explicit On, and explicit Optical in image-only mode. The stabilization tests pass on a physical device with optical stabilization on the back camera, and on an emulator without optical stabilization.
  • Manual: In image-only mode with Auto, the repeating request had video stabilization off with optical stabilization on for the back camera, and both off for the front camera. Hybrid mode still used preview stabilization.

With the default Auto stabilization mode, preview stabilization is turned on
whenever the lens supports it, including in image-only capture mode, where no
video can be recorded. Preview stabilization crops the field of view. In front
camera testing, image-only stills were cropped by about 1.16x in each dimension
and scaled back up to full size, which made them visibly softer with no change
in exposure or gain.

In image-only mode, StabilizationMode.AUTO now resolves to OPTICAL when the
lens supports it and to OFF otherwise. Other capture modes are unchanged, and
explicitly selecting StabilizationMode.ON still enables preview stabilization
in image-only mode. The resolution logic moves out of CameraXCameraSystem into
a top-level function so that it can be unit tested.

Optical stabilization now also turns preview and video stabilization off
explicitly. It previously left them unset, so the camera's default applied. On
a device whose default enables video stabilization when no video capture use
case is attached, an image-only session with optical stabilization ran with
video stabilization on.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a dedicated utility, resolveStabilizationMode, to centralize and improve the logic for determining camera stabilization modes. Key changes include ensuring that 'AUTO' stabilization avoids preview stabilization in 'IMAGE_ONLY' mode to prevent unnecessary image cropping, and updating CameraSession to explicitly disable preview stabilization when optical stabilization is active. The PR also includes comprehensive unit tests in StabilizationModeResolutionTest.kt and CameraXCameraSystemTest.kt, along with updated documentation in README.md. I have no further feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant