2012-03-03 01:46:30 +00:00
|
|
|
#include <opencv2/core/core.hpp>
|
|
|
|
|
#include <opencv2/core/types_c.h>
|
2012-06-24 17:19:34 +00:00
|
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
|
|
|
#include <opencv2/imgproc/imgproc.hpp>
|
2012-03-03 01:46:30 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <utilite/ULogger.h>
|
|
|
|
|
#include <utilite/UTimer.h>
|
|
|
|
|
#include <utilite/UConversion.h>
|
|
|
|
|
#include <utilite/UDirectory.h>
|
2012-12-11 18:05:05 +00:00
|
|
|
#include "rtabmap/core/Memory.h"
|
2012-03-03 01:46:30 +00:00
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
ULogger::setType(ULogger::kTypeConsole);
|
|
|
|
|
ULogger::setLevel(ULogger::kInfo);
|
|
|
|
|
|
|
|
|
|
std::string path = rtabmap::Parameters::defaultRtabmapWorkingDirectory() + "/LTM.db";
|
|
|
|
|
if(argc > 1)
|
|
|
|
|
{
|
|
|
|
|
path = argv[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Open database
|
|
|
|
|
rtabmap::ParametersMap parameters;
|
|
|
|
|
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kDbSqlite3InMemory(), "false"));
|
2012-12-11 18:05:05 +00:00
|
|
|
rtabmap::Memory * memory = new rtabmap::Memory(parameters);
|
|
|
|
|
if(!memory->init(path))
|
2012-03-03 01:46:30 +00:00
|
|
|
{
|
|
|
|
|
UWARN("Can't open database \"%s\"", path.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(memory)
|
|
|
|
|
{
|
|
|
|
|
UINFO("Using database %s", path.c_str());
|
|
|
|
|
std::string saveDirectory = "imagesExtracted/";
|
|
|
|
|
if(!UDirectory::exists(saveDirectory))
|
|
|
|
|
{
|
|
|
|
|
UDirectory::makeDir(saveDirectory);
|
|
|
|
|
}
|
|
|
|
|
std::set<int> ids = memory->getAllSignatureIds();
|
|
|
|
|
for(std::set<int>::iterator iter=ids.begin(); iter!=ids.end(); ++iter)
|
|
|
|
|
{
|
2012-12-11 18:05:05 +00:00
|
|
|
cv::Mat image = memory->getImage(*iter);
|
|
|
|
|
std::string fileName = uFormat("%d.png", *iter);
|
|
|
|
|
cv::imwrite(saveDirectory+fileName, image);
|
|
|
|
|
UINFO("Saved %s", (saveDirectory+fileName).c_str());
|
2012-03-03 01:46:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|