Я ссылался на пример google для camera2 api.На большинстве устройств он работает нормально, но на Nokia 6.1 каждый раз, когда я нажимаю на портретный режим и показываю его на изображении, он отображается в альбомной ориентации.
Я пробовал
private int getOrientation(int rotation) {
// Sensor orientation is 90 for most devices, or 270 for some devices (eg. Nexus 5X)
// We have to take that into account and rotate JPEG properly.
// For devices with orientation of 90, we simply return our mapping from ORIENTATIONS.
// For devices with orientation of 270, we need to rotate the JPEG 180 degrees.
return (ORIENTATIONS.get(rotation) + mSensorOrientation + 270) % 360;
}
.как
private int getJpegOrientation(CameraCharacteristics c, int deviceOrientation) {
if (deviceOrientation == android.view.OrientationEventListener.ORIENTATION_UNKNOWN) return 0;
int sensorOrientation = c.get(CameraCharacteristics.SENSOR_ORIENTATION);
// Round device orientation to a multiple of 90
deviceOrientation = (deviceOrientation + 45) / 90 * 90;
// Reverse device orientation for front-facing cameras
boolean facingFront = c.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT;
if (facingFront) deviceOrientation = -deviceOrientation;
// Calculate desired JPEG orientation relative to camera orientation to make
// the image upright relative to the device orientation
int jpegOrientation = (sensorOrientation + deviceOrientation + 360) % 360;
return jpegOrientation;
}
для установки JPEG_ORIENTATION в CaptureRequest.Builder, но ни одно из них не сработало для меня
значения, которые я получаю от обоих методов, равны 90, но это не влияет на файл jpegв любом случае.тогда как для аналогичных результатов на Nokia 1 и Xiomi Note 4 был создан правильный файл JPEG (т. е. при нажатии на портретное изображение портрет JPEG сохраняется в файловой системе)
PS: - Nokia 6.1 является Android One Device (еслиэто как-то связано с ошибочными результатами)