I apologize in advance for my long post.
My goal is to create a mesh application for the Project Tango Yellowstone device to create a 3D map of building interiors. I intend to use the experimental API added in the latest versions of tango example-c code.
I am using point-cloud-jni-example (turing) as a starting point and so far have done the following:
Set the configuration parameter config_experimental_enable_scene_reconstruction tango in point_cloud_app.cc (see docs )
// Enable scene reconstruction ret = TangoConfig_setBool(tango_config_, config_experimental_enable_scene_reconstruction", true); if (ret != TANGO_SUCCESS) { LOGE("PointCloudApp: config_experimental_enable_scene_reconstruction() failed" "with error code: %d", ret); return ret; }
Added native extractMesh method in TangoJNINative.java
Added appropriate extractMesh function for jni_interface.cc
JNIEXPORT void JNICALL Java_com_projecttango_experiments_nativepointcloud_TangoJNINative_extractMesh( JNIEnv*, jobject) { app.ExtractMesh(); }
Added ExtractMesh method in point_cloud_app.cc
void PointCloudApp::ExtractMesh() { // see line 1245 of tango_client_api.h mesh_ptr = new TangoMesh_Experimental(); TangoService_Experimental_extractMesh(mesh_ptr); mesh = *mesh_ptr; LOGE("PointCloudApp: num_vertices: %d", mesh.num_vertices); float float1, float2, float3; float1 = mesh.vertices[1][0]; float2 = mesh.vertices[1][1]; float3 = float1 + float2; // these lines show I can use the vertex data LOGE("PointCloudApp: First vertex, x: %f", mesh.vertices[1][0]); // this line causes app to crash; printing the vertex data seems to be the problem }
Added TangoMesh_Experimental ad in point_cloud_app.h
// see line 1131 of tango_client_api.h TangoMesh_Experimental* mesh_ptr; TangoMesh_Experimental mesh;
An additional button has been added to call the native extractMesh method. (not showing this as it is quite simple)
For reference, here is the TangoMesh_Experimental Struct from the API :
My current understanding of this structure is:
Three pointers in float (*vertices)[3]; point to the addresses at the beginning of three pieces of memory for the x, y and z coordinates for the vertices for the grid (the same is true for normal colors and colors). A particular vertex consists of the x, y, and z components found at a particular index in three arrays.
Similarly, the uint32_t (*faces)[3] array has three pointers to the beginning of three pieces of memory, but instead there is only one set of three elements containing index numbers that indicate which three vertices (from an array of vertices (each of which has three coordinates)) make up this facet.
Current state - I can extract the grid and print part of it on the console, and then crash without errors
PointCloudApp: PointCloudApp: num_vertices: 8044
If I omit the last line added to point_cloud_app.cc (# 4, above), the application will not work. I can access the vertex data and do something with it, but printing it with LOGE will crash 9 times out of 10. Sometimes it correctly prints the value without crashing. Can vertex data have holes or invalid values?
I tried returning test_float from the JNI back to java, but it will work again when I try to do this.
Suggestions?
source share