ReconstructMe SDK  2.0.819-89134
Real-time 3D reconstruction engine
 All Classes Files Functions Typedefs Enumerations Enumerator Groups Pages
example_reconstructmesdk_colorize.cpp

Content

This example shows vertex coloring of surfaces. It uses defaults everywhere and omits error handling.

Browse the result online.

Or view the making-of video

#include <boost/test/unit_test.hpp>
#include <stdio.h>
BOOST_AUTO_TEST_SUITE(example_reconstructmesdk)
BOOST_AUTO_TEST_CASE(colorize)
{
// Create a new context
// Create a license object
reme_error_t e = reme_license_authenticate(c, l, "license.txt.sgn");
// Create options
// Create a new sensor.
reme_sensor_create(c, "openni;mskinect;file", true, &s);
// Ensure AUX stream is aligned with the DEPTH stream
reme_options_set_bool(c, o, "enable_align_viewpoints", true);
// Make sure that we enable color support in the program settings.
reme_options_set_bool(c, o, "data_integration.use_colors", true);
// Use the tuning to derive a couple of related settings automatically.
// Compile for OpenCL device using defaults
// Create a new volume
// Position sensor outside of volume
// Use color in rendering volume image
reme_options_set(c, o, "shade_mode", "SHADE_COLORS");
// Apply
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);
// Perform reconstruction until no more frames are left
int time = 0;
while (time < 200 && REME_SUCCESS(reme_sensor_grab(c, s))) {
if (REME_SUCCESS(reme_sensor_track_position(c, s))) {
}
reme_viewer_update(c, viewer);
time += 1;
}
// Close and destroy the sensor, it is not needed anymore
// Create a new surface
// Colorize surface vertices.
// Inpaint vertices with invalid colors.
// Remesh the surface to generate an isotropic tessellation
// The following properties define the allowed edge length range
// The tesselation will adhere to these values when splitting/collapsing
// edges according to local color and geometry change.
reme_options_set_real(c, o, "minimum_edge_length", 3);
reme_options_set_real(c, o, "maximum_edge_length", 20);
// Perform remeshing
// Remeshing as decimation might change vertex positions,
// we should update the color information
// Save to file including colored vertices.
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()