Android Front Facing Camera Taking Inverted Photos

前端 未结 2 921
我寻月下人不归
我寻月下人不归 2021-02-07 05:16

I have this app that is running in portrait mode and as a part of one activity I have a camera object running as a fragment in it.

I have the option to switch from front

2条回答
  •  -上瘾入骨i
    2021-02-07 06:02

    Give these links a try:

    http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)

    http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setRotation(int)

    Specifically, here is a chunk of verbiage from the setRotation link.

    "If applications want to rotate the picture to match the orientation of what users see, apps should use OrientationEventListener and Camera.CameraInfo. The value from OrientationEventListener is relative to the natural orientation of the device. CameraInfo.orientation is the angle between camera orientation and natural device orientation. The sum of the two is the rotation angle for back-facing camera. The difference of the two is the rotation angle for front-facing camera. Note that the JPEG pictures of front-facing cameras are not mirrored as in preview display."

    I used this code as-is, didn't modify it at all. My camera is better now, still needs some TLC though. I also don't have front-facing functionality yet.

    Good luck!

提交回复
热议问题