I am new to Google Tango development and I am trying to condense multiple point clouds into one. To do this I have constructed this code:
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)));
}
}
}
I am not sure the code is correct. However, the reason I am here is because when I run this code the TangoSupport.transformPointCloud(transform.matrix, pointCloud) call makes the application crash. Error I get:
A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x7f61830000 in tid 14384 (.javapointcloud)
Any ideas on how to fix this or how to work around this issue?
Thanks!
I managed to work around this by doing this:
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));
}
}
}
}