【问题标题】:Google Tango : Aligning the ADF frame to the Color FrameGoogle Tango:将 ADF 框架与彩色框架对齐
【发布时间】:2015-07-15 18:16:35
【问题描述】:

我正在尝试创建一个 Unity 增强现实应用程序,该应用程序适用于由 ADF 本地化确定的姿势。我将摄像头馈送添加到“持久状态”演示中,但我的 ADF 本地化帧与摄像头馈送不对齐。地面似乎总是在地平线之上。

【问题讨论】:

    标签: augmented-reality google-project-tango


    【解决方案1】:

    我遇到了同样的问题,我找到了解决方案。问题在于,在 PoseController 脚本中,地平线没有与真实世界的地平线正确设置,但在 AugmentedReality 示例中它正确完成(在 ARScreen 脚本中)。因此,在我的 AR 应用程序中,当我远离它们时,它们看起来好像在向上移动。

    要解决此问题,您可以像 Guillaume 所说的那样在 AugmentedReality 示例中启动您的应用程序,或者在 PoseController 脚本中进行下一步更改:

    -首先我们有矩阵m_matrixdTuc,它的初始化如下:

        m_matrixdTuc = new Matrix4x4();
        m_matrixdTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_matrixdTuc.SetColumn(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_matrixdTuc.SetColumn(2, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
        m_matrixdTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
    

    好吧,我们必须将其重命名为m_matrixcTuc 并更改-1.0f 值:

        m_matrixcTuc = new Matrix4x4();
        m_matrixcTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_matrixcTuc.SetColumn(1, new Vector4(0.0f, -1.0f, 0.0f, 0.0f));
        m_matrixcTuc.SetColumn(2, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_matrixcTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
    

    这是因为我们不会直接使用这个矩阵来获得相机的变换,但我们会在之前进行一些操作以获得真正的m_matrixdTuc

    -2nd,我们必须初始化这三个变量:

    private Matrix4x4 m_matrixdTuc;
    
    
    // Device frame with respect to IMU frame.
    private Matrix4x4 m_imuTd;
    
    // Color camera frame with respect to IMU frame.
    private Matrix4x4 m_imuTc;
    

    (真正的m_matrixdTuc和另外两个是从ARScreen脚本中得到的)

    -3rd 我们需要来自 ARScreen 的 _SetCameraExtrinsics 方法:

    /// <summary>
    /// The function is for querying the camera extrinsic, for example: the transformation between
    /// IMU and device frame. These extrinsics is used to transform the pose from the color camera frame
    /// to the device frame. Because the extrinsic is being queried using the GetPoseAtTime()
    /// with a desired frame pair, it can only be queried after the ConnectToService() is called.
    ///
    /// The device with respect to IMU frame is not directly queryable from API, so we use the IMU
    /// frame as a temporary value to get the device frame with respect to IMU frame.
    /// </summary>
    private void _SetCameraExtrinsics()
    {
        double timestamp = 0.0;
        TangoCoordinateFramePair pair;
        TangoPoseData poseData = new TangoPoseData();
    
        // Getting the transformation of device frame with respect to IMU frame.
        pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
        pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
        PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
        Vector3 position = new Vector3((float)poseData.translation[0],
                                       (float)poseData.translation[1],
                                       (float)poseData.translation[2]);
        Quaternion quat = new Quaternion((float)poseData.orientation[0],
                                         (float)poseData.orientation[1],
                                         (float)poseData.orientation[2],
                                         (float)poseData.orientation[3]);
        m_imuTd = Matrix4x4.TRS(position, quat, new Vector3(1.0f, 1.0f, 1.0f));
    
        // Getting the transformation of IMU frame with respect to color camera frame.
        pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
        pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_CAMERA_COLOR;
        PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
        position = new Vector3((float)poseData.translation[0],
                               (float)poseData.translation[1],
                               (float)poseData.translation[2]);
        quat = new Quaternion((float)poseData.orientation[0],
                              (float)poseData.orientation[1],
                              (float)poseData.orientation[2],
                              (float)poseData.orientation[3]);
        m_imuTc = Matrix4x4.TRS(position, quat, new Vector3(1.0f, 1.0f, 1.0f));
        m_matrixdTuc = Matrix4x4.Inverse(m_imuTd) * m_imuTc * m_matrixcTuc;
    }
    

    现在如您所见,我们得到了m_matrixdTuc 变量的真实值,该变量将在OnTangoPoseAvailable 方法中使用。

    我并不真正了解这些方法背后的数学原理,但我发现它在我的应用程序上运行良好。希望它也对你有用:)

    【讨论】:

      【解决方案2】:

      我已经尝试过类似的方法。如果我理解得很好,您添加的要增强的对象会向屏幕顶部旋转,当它们远离时尤其明显,因为它们看起来像是向上抬起的。

      为了让它发挥作用,我只是在实验性增强现实应用程序中使用“红色地图标记”开始了我的项目:在那里,相机源已经与世界正确对齐。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多