-3
Google的Project Tango提供了一個點雲,即floatBuffer,其位置爲xyz,以米爲單位的一組點。我希望能夠通過在屏幕上觸摸來選擇其中一個點。從點雲中選擇一個點
什麼是最好的/最簡單的方法來實現這一目標?
UPDATE
包括我到目前爲止的代碼,如建議我嘗試得到點的投影在屏幕上,但顯示我發現我得到過小(即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,因爲這是返回類型,但據我所知,它的第三個組件並不重要。
嗨,謝謝你的回覆,抱歉沒有及時回答。你所說的相機固有的聲音是正確的,但我沒有世界toScreenPoint方法,我怎樣才能計算一個投影矩陣,實現相同的事情?我在相機中找到的那個似乎給出了錯誤的值 – Girauder
@Girauder我校準了RGB相機,發現了RGB相機的內在特性。然後使用相同的矩陣在相機平面上投影3D點。這工作得很好。 Project-Tango java api即將提供可以直接在你的方法中使用的功能。 https://developers.google.com/project-tango/apis/java/reference/TangoXyzIjData#ijParcelFileDescriptor – nbsrujan
你是指TangoXYZij中的ij嗎?我認爲這更像是索引而不是屏幕上的位置。我正在使用的投影矩陣應該已經具有相機內在函數,將它乘以vector3點以正確方式投影屏幕上的點?或者我錯過了什麼? – Girauder