Skip to content

Comments

Pass AutoRotate option to CameraManager to enable SetOutputImageRotationEnabled#269

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-camera-manager-options
Draft

Pass AutoRotate option to CameraManager to enable SetOutputImageRotationEnabled#269
Copilot wants to merge 2 commits intomainfrom
copilot/fix-camera-manager-options

Conversation

Copy link
Contributor

Copilot AI commented Oct 20, 2025

Problem

The AutoRotate option from BarcodeReaderOptions was not being passed to the CameraManager, preventing the Android CameraX SetOutputImageRotationEnabled method from being called with the user's desired value. This meant that even when developers set AutoRotate = true in their barcode reader options, the Android camera subsystem was not being configured to automatically rotate images based on device orientation.

Solution

This PR updates the codebase to pass BarcodeReaderOptions through to the CameraManager, enabling proper configuration of the Android ImageAnalysis builder.

Changes Made

  1. Updated CameraManager constructor to accept an optional BarcodeReaderOptions parameter and store it in a protected Options property
  2. Added UpdateOptions() method to CameraManager to support runtime option changes, following the same pattern as UpdateCameraLocation() and UpdateSelectedCamera()
  3. Modified Android CameraManager.android.cs to call .SetOutputImageRotationEnabled(Options.AutoRotate) when building the ImageAnalysis object
  4. Updated CameraBarcodeReaderViewHandler to:
    • Pass options to the CameraManager constructor in CreatePlatformView()
    • Call UpdateOptions() in MapOptions() to handle runtime option changes

Impact

  • When AutoRotate is set to true, the Android CameraX library will now automatically rotate images according to device orientation before passing them to the barcode reader
  • The change is backward compatible - the options parameter defaults to a new BarcodeReaderOptions() instance if not provided
  • Other platforms (iOS, Windows, etc.) are not affected as SetOutputImageRotationEnabled is Android CameraX-specific
  • Follows established patterns in the codebase for property updates and resource management

Example Usage

The BigIslandBarcode sample app already demonstrates this:

barcodeView.Options = new BarcodeReaderOptions
{
    Formats = BarcodeFormats.All,
    AutoRotate = true,  // Now properly flows to Android CameraManager
    Multiple = true
};
Original prompt

This section details on the original issue you should resolve

<issue_title>Options aren't making it to the CameraManager</issue_title>
<issue_description>We want to call SetOutputImageRotationEnabled with the AutoRotate, but it's not yet available at that level.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #136


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI self-assigned this Oct 20, 2025
…bled

Co-authored-by: jfversluis <939291+jfversluis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix options not making it to the CameraManager Pass AutoRotate option to CameraManager to enable SetOutputImageRotationEnabled Oct 20, 2025
Copilot AI requested a review from jfversluis October 20, 2025 12:57
@jfversluis
Copy link
Collaborator

@copilot this focuses only on the 1 option. Should we reconsider how we work with these options altogether?

Copy link
Contributor Author

Copilot AI commented Oct 20, 2025

@copilot this focuses only on the 1 option. Should we reconsider how we work with these options altogether?

You're right to question this. Currently, BarcodeReaderOptions mixes camera configuration options (AutoRotate) with barcode decoding options (TryHarder, Formats, etc.).

My implementation passes the entire BarcodeReaderOptions to CameraManager, but only AutoRotate is camera-related. This creates coupling between the camera and barcode reader concerns.

Would you prefer:

  1. Keep current approach (simple, solves immediate problem, but creates coupling)
  2. Split into CameraOptions and BarcodeReaderOptions (better architecture, but more refactoring)
  3. Pass only AutoRotate as a separate parameter (minimal coupling, but less flexible)

What's your preference?

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.

Options aren't making it to the CameraManager

2 participants