Skip to content

fix(ios): correct camera to UIImage orientation conversion - #4198

Open
ismaelsousa wants to merge 1 commit into
margelo:mainfrom
ismaelsousa:fix/ios-camera-to-uiimage-orientation
Open

ismaelsousa wants to merge 1 commit into
margelo:mainfrom
ismaelsousa:fix/ios-camera-to-uiimage-orientation

Conversation

@ismaelsousa

@ismaelsousa ismaelsousa commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the iOS conversion from CameraOrientation to UIImage.Orientation.
The .left and .right cases require inverse mappings:

  • .left → .right / .rightMirrored
  • .right → .left / .leftMirrored
    The fix is applied to both the core VisionCamera library and the barcode scanner package.

iOS rotation issue — proof

To isolate the iOS rotation problem, I rendered the camera frame directly on screen using this path:
Frame Output → HybridFrameConverter.convertFrameToImage(frame) → HybridImage → NitroImage

Before the fix After the fix
Screenshot 2026-09-25 at 16 05 15 Screenshot 2026-09-25 at 15 59 25

Apple's doc: https://developer.apple.com/documentation/uikit/uiimage/orientation

The issue occurs because UIImage.Orientation and VisionCamera’s Frame.orientation use different orientation semantics. Although their values may appear equivalent, they describe rotation from different perspectives, so mapping them directly produces an incorrectly rotated image on iOS.

related #4199 #4200

@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

@ismaelsousa is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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