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

Content

This example shows how to use the recorder to generate a file sensor compatible output for replaying from disk.

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

#include <boost/test/unit_test.hpp>
#include <conio.h>
#include <iostream>
BOOST_AUTO_TEST_SUITE(example_reconstructmesdk)
BOOST_AUTO_TEST_CASE(recorder) {
// Create a new context
// Options object
// Create a new real sensor
reme_sensor_create(c, "openni;mskinect", true, &s);
// Create a new file recorder.
// By default the recorder uses the first sensor.
// Specify the sensor to use
// Modify the recording outputs
reme_options_set(c, o, "file_sensor_config", "my_file_recording.txt");
reme_options_set(c, o, "depth_file", "my_depths.gz");
reme_options_set(c, o, "color_file", "my_colors.avi");
// Open the recorder. At this point the sensor
// needs to be open as well.
// Quick viewer
reme_viewer_t viewer;
reme_viewer_create_image(c, "Recording data", &viewer);
reme_image_t depth, color;
reme_image_create(c, &depth);
reme_image_create(c, &color);
reme_viewer_add_image(c, viewer, depth);
reme_viewer_add_image(c, viewer, color);
// Loop until done
while (!_kbhit() && REME_SUCCESS(reme_sensor_grab(c, s))) {
// Prepare image and depth data
// Update the recorder with current sensor data
// Update the viewer
reme_viewer_update(c, viewer);
}
// Done with recorder, forces the files to be closed.
// Compile for OpenCL device using defaults
// Create a new volume
// Replay from previously generated files
reme_sensor_create(c, "file", false, &s);
reme_options_load_from_file(c, o, "my_file_recording.txt");
// New viewer
reme_viewer_create_image(c, "Replaying data", &viewer);
reme_image_t volume;
reme_image_create(c, &volume);
reme_viewer_add_image(c, viewer, volume);
while (REME_SUCCESS(reme_sensor_grab(c, s))) {
// Prepare image and depth data
// Update volume with depth data from the
// current sensor perspective
}
// Update the viewer
reme_viewer_update(c, viewer);
}
// Print pending errors
// Make sure to release all memory acquired
}
BOOST_AUTO_TEST_SUITE_END()