ReconstructMe SDK  1.1.739-75658
Real-time 3D reconstruction engine
 All Classes Files Functions Typedefs Enumerations Enumerator Groups Pages
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", false, &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
if (REME_SUCCESS(reme_sensor_track_position(c, s))) {
// 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
// Extract surface from volume.
// Close holes through Poisson reconstruction using custom parameters
reme_options_set(c, o, "depth", "7");
// Reduce mesh down to 20k triangles
reme_options_set(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);
// Transform the mesh from world space to CAD space, so external viewers
// can cope better with the result.
float mat[16];
// Export mesh
reme_surface_save_to_file(c, m, "test.ply");
// Make sure to release all memory acquired
}
BOOST_AUTO_TEST_SUITE_END()