-
Notifications
You must be signed in to change notification settings - Fork 5
Home
Welcome to the slambench3 wiki!
Dummy library template:
#include <SLAMBenchAPI.h>
#include <io/sensor/CameraSensorFinder.h>
#include <io/sensor/CameraSensor.h>
#include <opencv2/core/mat.hpp>
// Define parameters
int example_param, default_example_param = 0;
// Define sensors
slambench::io::CameraSensor *rgb_sensor;
// Define outputs
slambench::outputs::Output *pose_output;
// Define OpenCV image to hold data
cv::Mat *cv_rgb;
void set_outputs(SLAMBenchLibraryHelper * slam_settings)
{
pose_output = new slambench::outputs::Output("KinectFusion Pose", slambench::values::VT_POSE, true);
slam_settings->GetOutputManager().RegisterOutput(pose_output);
}
bool set_sensors(SLAMBenchLibraryHelper * slam_settings)
{
slambench::io::CameraSensorFinder sensor_finder;
rgb_sensor = sensor_finder.FindOne(slam_settings->get_sensors(), {{"camera_type", "rgb"}});
if(rgb_sensor == nullptr)
{
std::cerr << "Invalid sensors found, Grey not found." << std::endl;
return false;
}
if(rgb_sensor->PixelFormat != slambench::io::pixelformat::RGB_III_888)
{
std::cerr << "Grey sensor is not in G_I_8 format" << std::endl;
return false;
}
if(rgb_sensor->FrameFormat != slambench::io::frameformat::Raster)
{
std::cerr << "Grey sensor is not in raster format" << std::endl;
return false;
}
cv_rgb = new cv::Mat (rgb_sensor->Height, rgb_sensor->Width, CV_8UC3);
return true;
}
bool sb_new_slam_configuration(SLAMBenchLibraryHelper * slam_settings)
{
// Declare parameters
slam_settings->addParameter(TypedParameter<int>("short", "long-option", "Description", &example_param, &default_example_param));
return true;
}
bool sb_init_slam_system(SLAMBenchLibraryHelper * slam_settings)
{
set_outputs(slam_settings);
set_sensors(slam_settings);
return true;
}
bool sb_update_frame (SLAMBenchLibraryHelper * , slambench::io::SLAMFrame* s)
{
if(s->FrameSensor == rgb_sensor)
{
memcpy(cv_rgb->data, s->GetData(), s->GetSize());
s->FreeData();
return true;
}
return false;
}
bool sb_process_once (SLAMBenchLibraryHelper * slam_settings)
{
return true;
}
bool sb_update_outputs(SLAMBenchLibraryHelper *lib, const slambench::TimeStamp *ts)
{
if(pose_output->IsActive())
{
Eigen::Matrix4f mat;
std::lock_guard<FastLock> lock (lib->GetOutputManager().GetLock());
pose_output->AddPoint(*ts, new slambench::values::PoseValue(mat));
}
return true;
}
bool sb_clean_slam_system()
{
delete rgb_sensor;
delete pose_output;
delete cv_rgb;
return true;
}