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

Content

Shows how to place the volume centered around the world coordinate origin and how to replace the initial sensor position using some extrinsic knowledge.

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(sensor_printing) {
// Create a new context
// Create options to modify the position of the volume
reme_options_set_int(c, o, "volume.minimum_corner.x", -500);
reme_options_set_int(c, o, "volume.minimum_corner.y", -500);
reme_options_set_int(c, o, "volume.minimum_corner.z", 0);
reme_options_set_int(c, o, "volume.maximum_corner.x", 500);
reme_options_set_int(c, o, "volume.maximum_corner.y", 500);
reme_options_set_int(c, o, "volume.maximum_corner.z", 1000);
// Compile for OpenCL device using defaults
// Create a new volume
// Create a new sensor.
reme_sensor_create(c, "openni;mskinect;file", true, &s);
// Specify eye, ref and up with respect to world
const float eye[3] = {0.f, -1000.f, 500.f};
const float ref[3] = {0.f, 0.f, 500.f};
const float up[3] = {0.f, 0.f, 1.f};
// Create sensor coordinate system with respect to world
float mat[16];
reme_transform_look_at(c, eye, ref, up, mat);
// Set initial sensor position
// We set the same position first recovery position
// x y z origin
float mat2[4][4] = {{1.f, 0.f, 0.f, 0.f},
{0.f, 0.f, 1.f, -1000.f},
{0.f, -1.f, 0.f, 500.f},
{0.f, 0.f, 0.f, 1.f}
};
reme_sensor_set_position(c, s, &mat2[0][0]);
// 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);
// Perform reconstruction until no more frames are left
int time = 0;
while (time < 200 && 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);
time += 1;
}
// Close and destroy the sensor, it is not needed anymore
// Create a new surface
reme_surface_save_to_file(c, m, "test.ply");
// Print pending errors
// Make sure to release all memory acquired
}
BOOST_AUTO_TEST_SUITE_END()