Re: Cplusplus Loop Closure Detection
Posted by
matlabbe on
URL: http://official-rtab-map-forum.206.s1.nabble.com/Cplusplus-Loop-Closure-Detection-tp686p721.html
Hi,
You are not calling rtabmap.process() method. Also, a loop closure would not be detected using only 1 image. The loop closure hypotheses need to grow with a sequence of images. In your example, you could try to process more images:
int main(int argc, char * argv[])
{
// Create RTAB-Map
rtabmap::Rtabmap rtabmap;
rtabmap.setTimeThreshold(700.0f); // Time threshold : 700 ms, 0 ms means no limit
rtabmap::ParametersMap parameters;
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kRtabmapLoopThr(), "0.11"));
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kRGBDEnabled(), "false"));
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kMemIncrementalMemory(), "false"));
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kKpIncrementalDictionary(), "false"));
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kMemSTMSize(), "1"));
std::string databasePath = "/home/mugiro/Documents/RTAB-Map/test3.db";
rtabmap.init(parameters, databasePath);
rtabmap::CameraOpenNI2 camera;
if(camera.init())
{
cv::Mat rgb,depth;
float fx,fy,cx,cy;
camera.takeImage(rgb, depth, fx, fy, cx, cy);
while(!rgb.empty())
{
rtabmap.process(rgb);
int id = rtabmap.getLoopClosureId();
printf("\nloop closure id = %d\n", id);
camera.takeImage(rgb, depth, fx, fy, cx, cy);
}
}
return 0;
}