首页 > 解决方案 > 像素周围的点云(不是点或平面)上的 HitTest-ing

问题描述

我想找到 PointCloud 中所有更接近屏幕上像素的点。就像围绕该像素进行射线投射并返回 PointCloud 点(而不是 arcore 跟踪的点/平面对象)。

我曾尝试使用Frame.hitTest(xPx,yPx),但它仅适用于跟踪点而不适用于 PointCloud 点,因此结果非常有限。需要像素周围的所有点云点(例如将半径为“r”的光束从该像素投射到点云中)

    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;
        }
}

我有框架中的点云世界坐标。需要在当前屏幕上找到更接近像素的那些。请指教。

标签: javaarcore

解决方案


我能够找到这个问题的答案。arore 场景形式的 Camera 对象很容易做到:

public Vector3 worldToScreenPoint (Vector3 point)

推荐阅读