HomeiOS DevelopmentBother understanding ImageOrientation in Swift

Bother understanding ImageOrientation in Swift


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 digicam 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 unsuitable:

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

Suppose this pattern picture from internet

Bother understanding ImageOrientation in Swift

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 is able to work.

enter image description here

II-) Within the digicam 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 accurately.

enter image description here

However once I set the orientation to .downMirrored in request handler, it labored accurately, the buffers have 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 strategy?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments