mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Merged Audio branch to trunk
git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@560 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
30
tools/ImagesDbExtractor/CMakeLists.txt
Normal file
30
tools/ImagesDbExtractor/CMakeLists.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
SET(SRC_FILES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(INCLUDE_DIRS
|
||||
${PROJECT_SOURCE_DIR}/corelib/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${UTILITE_INCLUDE_DIRS}
|
||||
${OpenCV_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
SET(LIBRARIES
|
||||
${UTILITE_LIBRARIES}
|
||||
${OpenCV_LIBRARIES}
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
|
||||
|
||||
ADD_EXECUTABLE(imagesDbExtractor ${SRC_FILES})
|
||||
TARGET_LINK_LIBRARIES(imagesDbExtractor rtabmap_corelib ${LIBRARIES})
|
||||
|
||||
SET_TARGET_PROPERTIES( imagesDbExtractor
|
||||
PROPERTIES OUTPUT_NAME ${PROJECT_PREFIX}-imagesDbExtractor)
|
||||
|
||||
INSTALL(TARGETS imagesDbExtractor
|
||||
RUNTIME DESTINATION bin COMPONENT runtime
|
||||
LIBRARY DESTINATION lib COMPONENT devel
|
||||
ARCHIVE DESTINATION lib COMPONENT devel)
|
||||
|
||||
64
tools/ImagesDbExtractor/main.cpp
Normal file
64
tools/ImagesDbExtractor/main.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/core/types_c.h>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <iostream>
|
||||
#include <utilite/ULogger.h>
|
||||
#include <utilite/UTimer.h>
|
||||
#include <utilite/UConversion.h>
|
||||
#include <utilite/UDirectory.h>
|
||||
#include "rtabmap/core/SMMemory.h"
|
||||
|
||||
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
|
||||
std::string driverType = "sqlite3";
|
||||
rtabmap::ParametersMap parameters;
|
||||
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kDbSqlite3InMemory(), "false"));
|
||||
rtabmap::SMMemory * memory = new rtabmap::SMMemory(parameters);
|
||||
if(!memory)
|
||||
{
|
||||
UWARN("Can't create database driver \"%s\"", driverType.c_str());
|
||||
}
|
||||
else if(!memory->init(driverType, path))
|
||||
{
|
||||
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)
|
||||
{
|
||||
std::list<rtabmap::Sensor> sensors = memory->getRawData(*iter);
|
||||
for(std::list<rtabmap::Sensor>::const_iterator jter=sensors.begin(); jter!=sensors.end(); ++jter)
|
||||
{
|
||||
int k=0;
|
||||
if(jter->type() == rtabmap::Sensor::kTypeImage)
|
||||
{
|
||||
std::string fileName = uFormat("%d-%d.png", *iter, k++);
|
||||
cv::imwrite(saveDirectory+fileName, jter->data());
|
||||
UINFO("Saved %s", (saveDirectory+fileName).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user