Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camera/picture orientation in Android

I am working on an Android app that uses the phone's camera. When the picture is taken in a "standard orientation" (bottom of phone at the bottom or bottom of the phone to the right), the image received is as expected. On some phones, when the picture is taken in a "non-standard orientation" (bottom of the phone at the top or bottom of the phone to the left), the image received is upside down. On some phones, the camera application actually handles this and returns the image the expected way.

My question is, since it seems to depend on the phone (manufacturer), is there a way to detect this and rotate the image as need without having to keep a hard coded list of phone types?

like image 966
Cameron Ediger Avatar asked Dec 16 '10 22:12

Cameron Ediger


People also ask

How do I fix the camera orientation on my Android?

There is a property in class Camera. CameraInfo named as orientation . It returns the integer. You can get the current orientation and then changed accordingly.

What is the orientation of image in camera?

The orientation of a Camera Station defines the position of and the pointing direction of the camera at the time of exposure of a photograph. Orientation can also refer to the process of determining the orientation of one or more Camera Stations.

How do I know the orientation of an image?

The length of the longest side determines the orientation. For example, if the height of the image is longer than the width, it is a “portrait” format. Images where the width is longer are called “landscape.”


1 Answers

You will need to set the rotation on the camera device in order to get the correctly rotated image. Try using -

public void setRotation (int rotation)

Check the sample code provided here

like image 177
bluefalcon Avatar answered Sep 30 '22 01:09

bluefalcon