camera - Setting Android Photo EXIF Orientation -


I have written an Android activity, which captures a picture from the program, I get an image with the correct XIP orientation data I want to save as JPEG (like the original Android camera app comes automatically).

There is actually a method to take photos (I have removed the try / catch block):

  Private zero LEphoto () {camera = Camera.open ( ); Surface structure DummySurfaceTexture = A mixture of new surface (0); camera.setPreviewTtexture (dummySurfaceTexture); Camera.startPreview (); Camera.takePicture (empty, null, jpgCallback); }   

... and callback:

  Private camera. IllustratorCollectionbackJpgCallback = New Camera.Picture Callback (Public Void (Byte [] Data, Camera Camera on Chitrakoot {releaseCamera (); SavePhoto (data); }; The picture is taken properly, but my problem is that EXIF ​​data shows that orientation "image orientation: top, left hand" regardless of device's orientation. , So that when I upload the photo, it will rotate or rotate.  

Do I need to manually capture device orientation (roll, pitch, azimuth) and write EXIF ​​orientation myself? How does the Camera app automatically write this data correctly? Does anyone know any way to set this feature correctly?

EDIT: I can not use screen orientation because the activity is locked in portrait mode.

You do not have to write the EXIF ​​orientation automatically, but you should tell the camera subsystem before taking the picture. Is required. Its information does not belong to itself. Once set, the camera subsystem will either set the EXIF ​​field or rotate the image data correctly (which depends on your specific device).

Use still pictures:

The developer has a reference code to use properly in Docs, which is a bit tricky because the value you define is 1) Your camera sensor Depending on the orientation of the device and 2) relative to the general orientation of the device, the orientation of your UI I have copied the sample code here, which uses one and assumes that you have a camera. Parameter object named M parameter:

  Public return on the Orientation (ANT Orientation) (if (Orientation == ORIENTATION_UNKNOWN) is returned; Android.hardware.Camera.CameraInfo info = New android.hardware .Camera.CameraInfo (); android.hardware.Camera.getCameraInfo (camera ID, info); orientation = (orientation + 45) / 90 * 90; int rotation = 0; if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {rotation = (info.orientation - orientation + 360)% 360;} else {// back-facing camera rotation = (info.orientation + orientation)% 360;} mParameters.setRotation (rotation);}   

After that you Before the traffic call, you have to call the camera.Setpameters (MPmatrers).

In your specific case, you take a picture, and use logic in the sample code to calculate the rotation. Then get camera parameters with camera parameters, call saturation, and then call camera .setParameters ().

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -