调用TangoSupport.transformPointCloud时,Tango Java应用程序崩溃(transform.matrix,pointCloud)

时间:2017-02-23 12:53:26

标签: java android google-project-tango

我是Google Tango开发的新手,我正在尝试将多个点云浓缩为一个。为此,我构建了这段代码:

for (int i = 0; i < mPointCloudList.size(); ++i) {

    TangoPointCloudData pointCloud = mPointCloudList.get(i);

    TangoSupport.TangoMatrixTransformData transform =
                        TangoSupport.getMatrixTransformAtTime(pointCloud.timestamp,
                                TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,
                                TangoPoseData.COORDINATE_FRAME_CAMERA_DEPTH,
                                TangoSupport.TANGO_SUPPORT_ENGINE_OPENGL,
                                TangoSupport.TANGO_SUPPORT_ENGINE_TANGO,
                                TangoSupport.ROTATION_IGNORED);

    TangoPointCloudData pcd = TangoSupport.transformPointCloud(transform.matrix, pointCloud);

    int numPoints = pcd.numPoints;

    if (numPoints != 0) {
        int numFloats = 4 * numPoints;
        for (int j = 0; j < numFloats; j = j + 4) {
            myOutWriter.write(String.format("v %f %f %f\n", pcd.points.get(j),
                                pcd.points.get(j), pcd.points.get(j + 2)));
        }
    }
}

我不确定代码是否正确。但是,我在这里的原因是因为当我运行此代码时,TangoSupport.transformPointCloud(transform.matrix,pointCloud)调用会使应用程序崩溃。我得到错误:

A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x7f61830000 in tid 14384 (.javapointcloud)

有关如何解决此问题或如何解决此问题的任何想法?

谢谢!

1 个答案:

答案 0 :(得分:1)

我设法解决了这个问题:

TangoSupport.TangoMatrixTransformData transform =
                        TangoSupport.getMatrixTransformAtTime(pointCloud.timestamp,
                                TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,
                                TangoPoseData.COORDINATE_FRAME_CAMERA_DEPTH,
                                TangoSupport.TANGO_SUPPORT_ENGINE_OPENGL,
                                TangoSupport.TANGO_SUPPORT_ENGINE_TANGO,
                                TangoSupport.ROTATION_IGNORED);

if (transform.statusCode == TangoPoseData.POSE_VALID) {
    int numPoints = pointCloud.numPoints;
    Vector3 point = new Vector3(0f, 0f, 0f);

    double dTransformMatrix[] = new double[transform.matrix.length];

    for (int k = 0; k < transform.matrix.length; k++) {
        dTransformMatrix[k] = (double) transform.matrix[k];
    }

    if (numPoints != 0) {
        int numFloats = 4 * numPoints;
        for (int j = 0; j < numFloats; j = j + 4) {
             if (pointCloud.points.get(j + 3) >= 0.5) {
                 point.x = pointCloud.points.get(j);
                 point.y = pointCloud.points.get(j + 1);
                 point.z = pointCloud.points.get(j + 2);
                 point = point.multiply(dTransformMatrix);
                 myOutWriter.write(String.format("v %f %f %f\n", point.x, point.y, point.z));
             }
         }
     }
}