android front and back camera captured picture orientation issue, rotated in a wrong way

后端 未结 5 1286
一整个雨季
一整个雨季 2021-02-05 10:12

I have a camera app in portrait mode which takes pictures from both front and back end cameras.The issue is like the captured images are rotated in a wrong way...

For pr

5条回答
  •  盖世英雄少女心
    2021-02-05 10:58

    You can use this to get orientation from a Uri

                        String filePath = mImageUri.getPath();
                    if (filePath != null) {
                        rotation = -1;
                            ExifInterface exif = new ExifInterface(filePath); // Since
                                                                                // API
                                                                                // Level
                                                                                // 5
                            rotation = Integer.parseInt(exif.getAttribute(ExifInterface.TAG_ORIENTATION));
                            // //Log.v("roation",
                            // exif.getAttribute(ExifInterface.TAG_ORIENTATION));
                        }
    
                    }
                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(), "Internal error", Toast.LENGTH_LONG).show();
                    Log.e(e.getClass().getName(), e.getMessage(), e);
                }
    

    And as note rotation '3 = 180, 6 = 90, 8 = 270'

提交回复
热议问题