ReconstructMe SDK  2.6.43-0
Real-time 3D reconstruction engine
example_reconstructmesdk_surface.cpp

Content

This example shows how use the surface generation module.

Boost is only used to generate examples and is not necessary for working with this SDK.

#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(example_reconstructmesdk)
BOOST_AUTO_TEST_CASE(surface) {
// This example shows how use the surface generation module.
// Create a new context
// Compile for OpenCL device using defaults
// Create a new volume
// Create a new sensor using a stream from disk
reme_sensor_create(c, "openni;mskinect;file", true, &s);
reme_viewer_t viewer_live;
reme_viewer_create_image(c, "This is ReconstructMe SDK", &viewer_live);
reme_image_t imgs[2];
reme_image_create(c, &imgs[0]);
reme_image_create(c, &imgs[1]);
reme_viewer_add_image(c, viewer_live, imgs[0]);
reme_viewer_add_image(c, viewer_live, imgs[1]);
// Perform reconstruction until no more frames are left
int count = 0;
while (count < 200 && REME_SUCCESS(reme_sensor_grab(c, s))) {
// Prepare image and depth data
// Try to determine updated sensor position by
// matching current data against volume content
// Update volume with depth data from the
// current sensor perspective
}
reme_viewer_update(c, viewer_live);
++count;
}
// Close and destroy the sensor, it is not needed anymore
// Create a new empty surface
// We use an options object to control various aspects of the generation process
// Bind the options that define how the basic surface is extracted from the volume.
// We disable merging of close vertices at this stage because the data is directly
// passed into poisson reconstruction which deals with duplicate vertices anyway
reme_options_set_bool(c, o, "merge_duplicate_vertices", false);
// Extract surface from volume.
// Close holes through Poisson reconstruction
reme_options_set_int(c, o, "depth", 8);
// Reduce mesh down to 20k triangles
reme_options_set_int(c, o, "maximum_faces", 20000);
// View the result and wait until the user closes the viewer
reme_viewer_t viewer;
reme_viewer_create_surface(c, m, "This is ReconstructMeSDK", &viewer);
reme_viewer_wait(c, viewer);
// Export mesh
reme_surface_save_to_file(c, m, "test.ply");
// Print pending errors
// Make sure to release all memory acquired
}
BOOST_AUTO_TEST_SUITE_END()