4

我想通过它的置信度值对 PointCloud 进行着色。

首先,我创建了三个 FloatBuffer,我在其中放置基于阈值的单个点。

private FloatBuffer makeFLoatBuffer(ArrayList<Float> conf) {
    FloatBuffer confFB = FloatBuffer.allocate(conf.size());
    for(Float value : conf){
        confFB.put(value);
    }

    confFB.rewind();
    return confFB;
}

private ArrayList<FloatBuffer> splitPointCloudOnConfidence(PointCloud cloud) {
    ArrayList<Float> conf1 = new ArrayList<>();
    ArrayList<Float> conf2 = new ArrayList<>();
    ArrayList<Float> conf3 = new ArrayList<>();
    ArrayList<FloatBuffer> floatBufferArray = new ArrayList<>();

    FloatBuffer buf_temp = cloud.getPoints();
    int buf_temp_limit = buf_temp.limit();
    for (int i = 0; i < buf_temp_limit / 4; i++) {

        float x = buf_temp.get(i * 4);
        float y = buf_temp.get(i * 4 + 1);
        float z = buf_temp.get(i * 4 + 2);
        float confidence = buf_temp.get(i * 4 + 3);

        if(confidence < 1.0 && confidence > 0.5){
            conf1.add(x);
            conf1.add(y);
            conf1.add(z);
            conf1.add(confidence);
        } else if(confidence < 0.5 && confidence > 0.2) {
            conf2.add(x);
            conf2.add(y);
            conf2.add(z);
            conf2.add(confidence);
        } else {
            conf3.add(x);
            conf3.add(y);
            conf3.add(z);
            conf3.add(confidence);
        }
    }

    floatBufferArray.add(makeFLoatBuffer(conf1));
    floatBufferArray.add(makeFLoatBuffer(conf2));
    floatBufferArray.add(makeFLoatBuffer(conf3));

    return floatBufferArray;
}

我还创建了三个负责可视化点云的节点。为此,我使用了此类的略微修改版本 https://github.com/claywilkinson/arcore-android-sdk/blob/sceneform-samples/samples/cloud_anchor_java/app/src/main/java/com/google/ar /core/examples/java/cloudanchor/sceneform/PointCloudNode.java

pointCloudNodeTestRed = new PointCloudNode_v2(this, color_red);
pointCloudNodeTestRed.setEnabled(true);
pointCloudNodeTestYellow = new PointCloudNode_v2(this, color_yellow);
pointCloudNodeTestYellow.setEnabled(true);
pointCloudNodeTestGreen = new PointCloudNode_v2(this, color_green);
pointCloudNodeTestGreen.setEnabled(true);

fragment.getArSceneView().getScene().addChild(pointCloudNodeTestRed);
fragment.getArSceneView().getScene().addChild( pointCloudNodeTestYellow);
fragment.getArSceneView().getScene().addChild( pointCloudNodeTestGreen);

在 onUpdateListener 中,我将特定数据提供给三个节点。

PointCloud pC = frame.acquirePointCloud();

ArrayList<FloatBuffer> bufHolder = splitPointCloudOnConfidence(pC);

pointCloudNodeTestRed.update(pC, bufHolder.get(2));
pointCloudNodeTestYellow.update(pC,  bufHolder.get(1));
pointCloudNodeTestGreen.update(pC,  bufHolder.get(0));

pC.release();

我的问题一般。有没有更好的方法来实现这样的可视化?

4

1 回答 1

1

我的理解是SceneForm谷歌不再维护它。很高兴有一种方法可以轻松使用ARCoreGLES20 作为PointCloudRenderer.java示例文件的修改版本,如下面的链接所示,但所有点都有多种颜色而不是一种颜色

https://github.com/google-ar/arcore-android-sdk/blob/54861e38cceb406021fc8ece495f82387376af62/samples/augmented_faces_java/app/src/main/java/com/google/ar/core/examples/java/common/rendering/ PointCloudRenderer.java

于 2020-09-30T22:14:27.477 回答