【问题标题】:How get camera orientation in NDK如何在 NDK 中获取相机方向
【发布时间】: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


    【解决方案1】:

    这个Java 示例代码是错误的。

    在 C++ 中,您可以使用标签 ACAMERA_SENSOR_ORIENTATION 和标签 ACAMERA_LENS_FACING 调用 ACameraManager_getCameraCharacteristics()

    OrientationEventListener.ORIENTATION_UNKNOWNconstant -1CameraCharacteristics.LENS_FACING_FRONTACAMERA_LENS_FACING_FRONT0

    【讨论】:

    • 可能你是对的,但我还没有找到样本,如何使用它。我需要在每个参数中设置什么。如果您有一个样本或指南会很棒。如果没有,请不要担心,我会继续搜索并在我可以使用后回到这里正确使用 =)
    猜你喜欢
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 2017-12-24
    • 2023-03-06
    • 2013-03-05
    • 2013-01-26
    • 2020-12-26
    • 1970-01-01
    相关资源
    最近更新 更多