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

Content

This is a one minute example showing basic reconstruction using a single sensor. The reconstruction result is then saved to file. It uses defaults everywhere and omits error handling.

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

#include <boost/test/unit_test.hpp>
#include <iostream>
BOOST_AUTO_TEST_SUITE(example_reconstructmesdk)
BOOST_AUTO_TEST_CASE(one_minute) {
// Create a new context
// Compile for OpenCL device using defaults
// Create a new volume
// Create a new sensor. Tries multiple backends using default
// sensor configurations, returns the first working one. By default
// each sensor works on the first volume created.
reme_sensor_create(c, "librealsense", true, &s);
// For debugging purposes open a viewer for tracking the reconstruction process.
reme_viewer_t viewer;
reme_viewer_create_image(c, "This is ReconstructMe SDK", &viewer);
reme_image_t volume, aux;
reme_image_create(c, &volume);
reme_viewer_add_image(c, viewer, aux);
reme_viewer_add_image(c, viewer, volume);
// Reconstruct until viewer is closed, or grabbing fails. Note that
// aborting reconstruction just because a single grab failed is not good stlye.
// You should allow for multiple grab attempts.
printf("Starting reconstruction. Close the viewer window to stop.\n");
bool viewer_done = false;
while (!viewer_done && REME_SUCCESS(reme_sensor_grab(c, s))) {
// Prepare image and depth data
// Try to determine updated sensor position.
// On succes, update volume, otherwise move to a recovery position
// and wait for the tracking to start again.
// Update volume with depth data from the
// current sensor perspective
}
// Update the viewer
reme_viewer_update(c, viewer);
reme_viewer_is_closed(c, viewer, &viewer_done);
}
// Close and destroy the sensor, it is not needed anymore
// Create a new surface
reme_surface_save_to_file(c, m, "test.ply");
// Visualize resulting surface
reme_viewer_t viewer_surface;
reme_viewer_create_surface(c, m, "This is ReconstructMeSDK", &viewer_surface);
reme_viewer_wait(c, viewer_surface);
// Print pending errors
// Make sure to release all memory acquired
}
BOOST_AUTO_TEST_SUITE_END()