imaginary-cloud / CameraManager

Simple Swift class to provide all the configurations you need to create custom camera view in your app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

portrait capture image orientation not showing correct.

jjpatel1996 opened this issue · comments

Hello,i found one issue.In my App i am not allowing device to change orientation. problem is captured image orientation showing .right not .up even if capture image in portrait(up). not just it in all orientation it showing .right orientation. plz help

I have the same issue. All images is taken from front camera is right orientation

commented

Few things to keep in mind:

  • The front camera is mounted on the device with the left edge of the phone considered as "up" and the camera is fixed obviously, so even if you disallow orientation changes in your app, it doesn't make portrait orientation "up" for the camera; portrait orientation is always mapped to "right" for the camera.
  • That being said, camera itself actually doesn't know about orientation either, i.e. the camera knows that portrait maps to right but it doesn't know whether the device is in portrait orientation or not. It is the job of the capture code to tell the capture connection the correct orientation. So if you have not set shouldRespondToOrientationChanges to false on your CameraManager instance, the code in _orientationChanged() is setting the camera orientation every time your phone rotates.
    So with that said, there're two issues:
  • If you explicitly set shouldRespondToOrientationChanges to false, the orientation will be set once on initialization and never changes. If you launch the CameraManager from a portrait orientation, all images will be right afterwards; while if you launch the CameraManager from a horizontal orientation, all images will be up/down afterwards.
  • The default value of shouldRespondToOrientationChanges is true, so if you don't explicitly set it to false, the images you get from the front camera should have the correct orientation, i.e. "right" for portrait orientation. However, there is a bug in CameraManager that every time you switch between front and back cameras, the orientation is reset to "right" until the phone is rotated again. With this bug, you may actually get "right" images for when you're holding the phone horizontally. If that bug is blocking you, you'll have to compare the image orientation with the current device orientation to see determine whether you're hitting the bug or not, and act accordingly.
    One final thing: the logic in _currentVideoOrientation() actually treats portraitUpsideDown as portrait. Not sure why it does that, but just something to keep in mind.