【发布时间】: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