【发布时间】:2018-12-03 13:47:25
【问题描述】:
我从项目的 NDK 端的 ARCore 获取 NDK_Image。 由于相机方向,我的 AImage 正在旋转。
如何获取 NDK 内的相机方向值?
在相机 NDK 文档中,我发现了这个 ACAMERA_JPEG_ORIENTATION
它甚至给出了一个代码示例:
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;
}
但它没有解释如何使用,我找不到CameraCharascteristics的库。
这将是一个关于如何在 NDK 中获取相机方向的很好的示例。谢谢!
【问题讨论】:
标签: android android-ndk android-camera2 arcore