【问题标题】:Selecting a point from a point cloud [closed]从点云中选择一个点[关闭]
【发布时间】:2015-12-22 17:41:10
【问题描述】:

Google 的 Project Tango 提供了一个点云,即一个 floatBuffer,其中包含一组点的位置 xyz,以米为单位。我希望能够通过在屏幕上触摸来选择其中一个点。

实现这一目标的最佳/最简单方法是什么?


更新

到目前为止,我包含了代码,正如建议的那样,我尝试在屏幕上获取点的投影,但是在显示点之后,我发现我得到的值太小(即 0.5、0.7 等)。我没有使用统一,而是使用 android studio,因此我没有方法 cam.WorldToScreenPoint(m_points[it]),但是我确实有一个投影矩阵,但我想这是不正确的(也许是因为我们应该去从米到像素)。 实现这一目标的正确矩阵是什么?

private void selectClosestCloundPoint(float x, float y) {
    //Get the current rotation matrix
    Matrix4 projMatrix =  mRenderer.getCurrentCamera().getProjectionMatrix();



    //Get all the points in the pointcloud and store them as 3D points
    FloatBuffer pointsBuffer =  mPointCloudManager.updateAndGetLatestPointCloudRenderBuffer().floatBuffer;
    Vector3[] points3D = new Vector3[pointsBuffer.capacity()/3];

    int j =0;
    for (int i = 0; i < pointsBuffer.capacity() - 3; i = i + 3) {

        points3D[j]= new Vector3(
                pointsBuffer.get(i),
                pointsBuffer.get(i+1),
                pointsBuffer.get(i+2));

        j++;
    }


    //Get the projection of the points in the screen.
    Vector3[] points2D = new Vector3[points3D.length];
    for(int i =0; i < points3D.length-1;i++)
    {
        Log.v("Points", "X: " +points3D[i].x + "\tY: "+ points3D[i].y +"\tZ: "+ points3D[i].z );
        points2D[i] = points3D[i].multiply(projMatrix);
        Log.v("Points", "pX: " +points2D[i].x + "\tpY: "+ points2D[i].y +"\tpZ: "+ points2D[i].z );
    }
}

我使用vector3,因为它是返回类型,但据我了解,它的第三部分并不重要。

【问题讨论】:

    标签: java android math point-clouds google-project-tango


    【解决方案1】:

    使用相机内在函数将 3D 点云的所有点转换到图像平面上。查找图像平面上所有投影点之间的距离以触摸屏幕上的坐标。选择与最小距离相对应或在屏幕坐标阈值内的 3D 点。下面给出代码sn-p

       for (int it = 0; it < m_pointsCount; ++it)
        {
            Vector3 screenPos3 = cam.WorldToScreenPoint(m_points[it]);
            Vector2 screenPos = new Vector2(screenPos3.x, screenPos3.y);
            float distSqr = Vector2.SqrMagnitude(screenPos - touchPos);
            if (distSqr > sqMaxDist)
            {
                continue;
            }
            closePoints.Add(it);
        }
    

    我建议的方法可能在计算上很昂贵。

    【讨论】:

    • 您好,感谢您的回复,很抱歉没有尽快回复。您对相机内在声音的看法是正确的,但是我没有世界 toScreenPoint 方法,如何计算实现相同目标的投影矩阵?我在相机中找到的那个似乎给出了错误的值
    • @Girauder 我已经校准了 RGB 相机,并找到了 RGB 相机的内在函数。然后使用相同的矩阵在相机平面上投影 3D 点。这工作得很好。 Project-Tango java api 即将提供可直接在您的方法中使用的功能。 developers.google.com/project-tango/apis/java/reference/…
    • 你是指 TangoXYZij 中的 ij 吗?我认为这更像是索引而不是屏幕上的位置。我正在使用的投影矩阵应该已经具有相机内在函数,将它乘以vector3点是在屏幕上投影点的正确方法吗?还是我错过了什么?
    • @Girauder 是的,但此功能尚不可用。
    猜你喜欢
    • 2021-06-15
    • 1970-01-01
    • 2018-01-29
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 2017-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多