I want to find all of the points in the PointCloud that are closer to a pixel on the screen. Like ray-casting around that pixel and returning PointCloud points (instead of arcore tracked Point/Plane objects).
I have tried using the Frame.hitTest(xPx,yPx)
, but that only works on tracked points and not on PointCloud points, and so the results are very limited with it. Need all of the pointcloud points around the pixel (like ray-casting a beam of radius "r" from that pixel into the pointcloud)
if (pointCloudIdsArray.length > 0) {
for (int i = 0; i < pointCloudIdsArray.length; i++) {
String idString = Integer.toString(pointCloudIdsArray[i]);
float xMeters = pointCloudArray[i * 4];
float yMeters = pointCloudArray[i * 4 + 1];
float zMeters = pointCloudArray[i * 4 + 2];
float confidenceoTo1 = pointCloudArray[i * 4 + 3];
double distanceFromCamera = Math.sqrt(xMeters * xMeters + yMeters * yMeters + zMeters * zMeters);
if (distanceFromCamera > farthestPoint) {
farthestPoint = distanceFromCamera;
}
}
I have the pointcloud world coordinates from the frame. Need to find the ones that are closer to the pixel on the current screen. Please advise.
I was able to find the answer to this question. The arore sceneform's Camera object does it pretty easily:
public Vector3 worldToScreenPoint (Vector3 point)