29.2 C
Canberra
Saturday, January 3, 2026

Hassle understanding ImageOrientation in Swift [closed]


I’m pretty new to swift (SwiftUI) and making a easy face and card detection app utilizing Imaginative and prescient. Mainly it’s only a digital camera preview layer and upon face/card detection, it crops the picture and shows it on the view. I’m having some issues understanding how picture orientation works.

That is my understanding, right me if I’m mistaken:

In iOS units, after we maintain the digital camera in portrait orientation, the native sensor nonetheless captures the picture in panorama left (so we’ve to rotate the picture 90 deg proper for meant orientation) for the again digital camera. For entrance digital camera, it nonetheless captures in panorama left however moreover it’s mirrored too.

Suppose this pattern picture from internet

Hassle understanding ImageOrientation in Swift [closed]

I attempted two approaches:

I-) Within the VNImageRequestHandler, I set the orientation to .proper so the captured buffers would rotate to proper however they didn’t. I believed this might work.

enter image description here

II-) Within the digital camera configuration, I set the videoOrientation to AVCaptureVideoOrientation.portrait, this corrected the seize orientation of the buffers.

Now acc to my understanding, if I set the orientation to .up(default) in VNImageRequestHandler, it ought to work proper? The captured buffer was in right orientation however the crop was not making use of appropriately.

enter image description here

However once I set the orientation to .downMirrored in request handler, it labored appropriately, the buffers had been in right orientation and the crop was good too.

enter image description here

Why does .downMirrored (the wrong way up and horizontal flip) work and never the Ist method?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles