36 #include "DatabaseSchema_sql.h" 47 _memoryUsedEstimate(0),
48 _dbInMemory(
Parameters::defaultDbSqlite3InMemory()),
49 _cacheSize(
Parameters::defaultDbSqlite3CacheSize()),
50 _journalMode(
Parameters::defaultDbSqlite3JournalMode()),
51 _synchronous(
Parameters::defaultDbSqlite3Synchronous()),
52 _tempStore(
Parameters::defaultDbSqlite3TempStore())
65 ParametersMap::const_iterator iter;
66 if((iter=parameters.find(Parameters::kDbSqlite3CacheSize())) != parameters.end())
70 if((iter=parameters.find(Parameters::kDbSqlite3JournalMode())) != parameters.end())
74 if((iter=parameters.find(Parameters::kDbSqlite3Synchronous())) != parameters.end())
78 if((iter=parameters.find(Parameters::kDbSqlite3TempStore())) != parameters.end())
82 if((iter=parameters.find(Parameters::kDbSqlite3InMemory())) != parameters.end())
94 std::string query =
"PRAGMA cache_size = ";
102 if(journalMode >= 0 && journalMode < 5)
136 if(synchronous >= 0 && synchronous < 3)
164 if(tempStore >= 0 && tempStore < 3)
192 UDEBUG(
"dbInMemory=%d", dbInMemory?1:0);
246 pFrom = (isSave ? pInMemory : pFile);
247 pTo = (isSave ? pFile : pInMemory);
284 std::stringstream query;
286 query <<
"SELECT version FROM Admin;";
321 bool dbFileExist =
false;
325 if(dbFileExist && overwritten)
327 UINFO(
"Deleting database %s...", url.c_str());
341 ULOGGER_INFO(
"Using database \"%s\" in the memory.", url.c_str());
351 ULOGGER_INFO(
"Using database \"%s\" from the hard drive.", url.c_str());
356 UFATAL(
"DB error : %s (path=\"%s\"). Make sure that your user has write " 357 "permission on the target directory (you may have to change the working directory). ",
sqlite3_errmsg(
_ppDb), url.c_str());
382 ULOGGER_INFO(
"Database \"%s\" doesn't exist, creating a new one...", url.c_str());
385 std::string schema = DATABASESCHEMA_SQL;
396 UERROR(
"Opened database version (%s) is more recent than rtabmap " 397 "installed version (%s). Please update rtabmap to new version!",
432 std::string outputFile = this->
getUrl();
433 if(!outputUrl.empty())
435 outputFile = outputUrl;
437 if(outputFile.empty())
439 UERROR(
"Database was initialized with an empty url (in memory). To save it, " 440 "the output url should not be empty. The database is thus closed without being saved!");
444 UINFO(
"Saving database to %s ...", outputFile.c_str());
447 "permission on the target directory (you may have to change the working directory). ",
_version.c_str(), outputFile.c_str(),
sqlite3_errmsg(
_ppDb)).c_str());
453 UINFO(
"Disconnecting database %s...", this->
getUrl().c_str());
457 if(save && !
_dbInMemory && !outputUrl.empty() && !this->
getUrl().empty() && outputUrl.compare(this->
getUrl()) != 0)
459 UWARN(
"Output database path (%s) is different than the opened database " 460 "path (%s). Opened database path is overwritten then renamed to output path.",
461 outputUrl.c_str(), this->
getUrl().c_str());
464 UERROR(
"Failed to rename just closed db %s to %s", this->
getUrl().c_str(), outputUrl.c_str());
510 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(ground_truth_pose) + ifnull(length(velocity),0) + ifnull(length(gps),0) + length(time_enter)) from Node;";
514 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(ground_truth_pose) + ifnull(length(velocity),0) + length(time_enter)) from Node;";
518 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(ground_truth_pose)+ length(time_enter)) from Node;";
522 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(time_enter)) from Node;";
526 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose)+ length(time_enter)) from Node;";
554 query =
"SELECT sum(length(type) + length(information_matrix) + length(transform) + ifnull(length(user_data),0) + length(from_id) + length(to_id)) from Link;";
558 query =
"SELECT sum(length(type) + length(rot_variance) + length(trans_variance) + length(transform) + ifnull(length(user_data),0) + length(from_id) + length(to_id)) from Link;";
562 query =
"SELECT sum(length(type) + length(rot_variance) + length(trans_variance) + length(transform) + length(from_id) + length(to_id)) from Link;";
566 query =
"SELECT sum(length(type) + length(variance) + length(transform) + length(from_id) + length(to_id)) from Link;";
570 query =
"SELECT sum(length(type) + length(transform) + length(from_id) + length(to_id)) from Link;";
598 query =
"SELECT sum(ifnull(length(image),0) + ifnull(length(time_enter),0)) from Data;";
602 query =
"SELECT sum(length(data) + ifnull(length(time_enter),0)) from Image;";
630 query =
"SELECT sum(ifnull(length(depth),0) + ifnull(length(time_enter),0)) from Data;";
634 query =
"SELECT sum(length(data) + ifnull(length(time_enter),0)) from Depth;";
663 query =
"SELECT sum(length(calibration)) from Data;";
667 query =
"SELECT sum(length(fx) + length(fy) + length(cx) + length(cy) + length(local_transform)) from Depth;";
671 query =
"SELECT sum(length(constant) + length(local_transform)) from Depth;";
700 query =
"SELECT sum(ifnull(length(ground_cells),0) + ifnull(length(obstacle_cells),0) + length(cell_size) + length(view_point_x) + length(view_point_y) + length(view_point_z)) from Data;";
733 query =
"SELECT sum(ifnull(length(scan_info),0) + ifnull(length(scan),0)) from Data;";
737 query =
"SELECT sum(length(scan_max_pts) + length(scan_max_range) + ifnull(length(scan),0)) from Data;";
741 query =
"SELECT sum(length(scan_max_pts) + ifnull(length(scan),0)) from Data;";
745 query =
"SELECT sum(length(data2d) + length(data2d_max_pts)) from Depth;";
749 query =
"SELECT sum(length(data2d)) from Depth;";
777 query =
"SELECT sum(length(user_data)) from Data;";
781 query =
"SELECT sum(length(user_data)) from Node;";
810 std::string query =
"SELECT sum(length(id) + length(descriptor_size) + length(descriptor) + length(time_enter)) from Word;";
837 query =
"SELECT sum(length(word_id) + length(pos_x) + length(pos_y) + length(size) + length(dir) + length(response) + length(octave) + length(depth_x) + length(depth_y) + length(depth_z) + length(descriptor_size) + length(descriptor)) " 842 query =
"SELECT sum(length(word_id) + length(pos_x) + length(pos_y) + length(size) + length(dir) + length(response) + length(octave) + length(depth_x) + length(depth_y) + length(depth_z) + length(descriptor_size) + length(descriptor)) " 843 "FROM Map_Node_Word";
847 query =
"SELECT sum(length(word_id) + length(pos_x) + length(pos_y) + length(size) + length(dir) + length(response) + length(depth_x) + length(depth_y) + length(depth_z) + length(descriptor_size) + length(descriptor)) " 848 "FROM Map_Node_Word";
852 query =
"SELECT sum(length(word_id) + length(pos_x) + length(pos_y) + length(size) + length(dir) + length(response) + length(depth_x) + length(depth_y) + length(depth_z)) " 853 "FROM Map_Node_Word";
881 query =
"SELECT sum(length(id) + length(stamp) + length(data) + length(wm_state)) FROM Statistics";
885 query =
"SELECT sum(length(id) + length(stamp) + length(data)) FROM Statistics";
917 query =
"SELECT count(id) from Node WHERE time_enter >= (SELECT MAX(time_enter) FROM Info);";
921 query =
"SELECT count(id) from Node WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics);";
949 query =
"SELECT count(id) from Word WHERE time_enter >= (SELECT MAX(time_enter) FROM Info);";
953 query =
"SELECT count(id) from Word WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics);";
978 std::string query =
"SELECT count(id) from Node;";
1002 std::string query =
"SELECT count(id) from Word;";
1032 query =
"SELECT parameters " 1034 "WHERE time_enter >= (SELECT MAX(time_enter) FROM Info);";
1038 query =
"SELECT parameters " 1040 "WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics);";
1069 UDEBUG(
"nodeId=%d", nodeId);
1070 std::map<std::string, float> data;
1075 std::stringstream query;
1079 query <<
"SELECT stamp, data, wm_state " 1080 <<
"FROM Statistics " 1081 <<
"WHERE id=" << nodeId <<
";";
1085 query <<
"SELECT stamp, data " 1086 <<
"FROM Statistics " 1087 <<
"WHERE id=" << nodeId <<
";";
1105 if(dataSize>0 && dataPtr)
1124 if(dataSize>0 && dataPtr)
1126 cv::Mat wmStateMat =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)dataPtr));
1127 UASSERT(wmStateMat.type() == CV_32SC1 && wmStateMat.rows == 1);
1128 wmState->resize(wmStateMat.cols);
1129 memcpy(wmState->data(), wmStateMat.data, wmState->size()*
sizeof(int));
1146 std::map<int, std::pair<std::map<std::string, float>,
double> > data;
1151 std::stringstream query;
1153 query <<
"SELECT id, stamp, data " 1154 <<
"FROM Statistics;";
1170 const void * dataPtr = 0;
1174 if(dataSize>0 && dataPtr)
1203 std::map<int, std::vector<int> > data;
1208 std::stringstream query;
1210 query <<
"SELECT id, wm_state " 1211 <<
"FROM Statistics;";
1223 std::vector<int> wmState;
1226 if(dataSize>0 && dataPtr)
1228 cv::Mat wmStateMat =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)dataPtr));
1229 UASSERT(wmStateMat.type() == CV_32SC1 && wmStateMat.rows == 1);
1230 wmState.resize(wmStateMat.cols);
1231 memcpy(wmState.data(), wmStateMat.data, wmState.size()*
sizeof(int));
1234 if(!wmState.empty())
1236 data.insert(std::make_pair(
id, wmState));
1252 UDEBUG(
"load data for %d signatures", (
int)signatures.size());
1254 if(!images && !scan && !userData && !occupancyGrid)
1256 UWARN(
"All requested data fields are false! Nothing loaded...");
1266 std::stringstream query;
1270 std::stringstream fields;
1274 fields <<
"image, depth, calibration";
1275 if(scan || userData || occupancyGrid)
1282 fields <<
"scan_info, scan";
1283 if(userData || occupancyGrid)
1290 fields <<
"user_data";
1300 fields <<
"ground_cells, obstacle_cells, empty_cells, cell_size, view_point_x, view_point_y, view_point_z";
1304 fields <<
"ground_cells, obstacle_cells, cell_size, view_point_x, view_point_y, view_point_z";
1308 query <<
"SELECT " << fields.str().c_str() <<
" " 1315 query <<
"SELECT image, depth, calibration, scan_max_pts, scan_max_range, scan, user_data " 1322 query <<
"SELECT image, depth, calibration, scan_max_pts, scan, user_data " 1329 query <<
"SELECT Data.image, Data.depth, Data.calibration, Data.scan_max_pts, Data.scan, Node.user_data " 1331 <<
"INNER JOIN Node " 1332 <<
"ON Data.id = Node.id " 1333 <<
"WHERE Data.id = ?" 1338 query <<
"SELECT Image.data, " 1339 "Depth.data, Depth.local_transform, Depth.fx, Depth.fy, Depth.cx, Depth.cy, Depth.data2d_max_pts, Depth.data2d, Node.user_data " 1341 <<
"INNER JOIN Node " 1342 <<
"on Image.id = Node.id " 1343 <<
"LEFT OUTER JOIN Depth " 1344 <<
"ON Image.id = Depth.id " 1345 <<
"WHERE Image.id = ?" 1350 query <<
"SELECT Image.data, " 1351 "Depth.data, Depth.local_transform, Depth.fx, Depth.fy, Depth.cx, Depth.cy, Depth.data2d, Node.user_data " 1353 <<
"INNER JOIN Node " 1354 <<
"on Image.id = Node.id " 1355 <<
"LEFT OUTER JOIN Depth " 1356 <<
"ON Image.id = Depth.id " 1357 <<
"WHERE Image.id = ?" 1362 query <<
"SELECT Image.data, " 1363 "Depth.data, Depth.local_transform, Depth.fx, Depth.fy, Depth.cx, Depth.cy, Depth.data2d " 1365 <<
"LEFT OUTER JOIN Depth " 1366 <<
"ON Image.id = Depth.id " 1367 <<
"WHERE Image.id = ?" 1372 query <<
"SELECT Image.data, " 1373 "Depth.data, Depth.local_transform, Depth.constant, Depth.data2d " 1375 <<
"LEFT OUTER JOIN Depth " 1376 <<
"ON Image.id = Depth.id " 1377 <<
"WHERE Image.id = ?" 1384 const void * data = 0;
1388 for(std::list<Signature*>::iterator iter = signatures.begin(); iter!=signatures.end(); ++iter)
1403 cv::Mat imageCompressed;
1404 cv::Mat depthOrRightCompressed;
1405 std::vector<CameraModel> models;
1408 cv::Mat scanCompressed;
1409 cv::Mat userDataCompressed;
1416 if(dataSize>4 && data)
1418 imageCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1424 if(dataSize>4 && data)
1426 depthOrRightCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1433 if((
unsigned int)dataSize == localTransform.
size()*
sizeof(float) && data)
1435 memcpy(localTransform.
data(), data, dataSize);
1450 if(dataSize > 0 && data)
1452 float * dataFloat = (
float*)data;
1454 (
unsigned int)dataSize % (6+localTransform.
size())*
sizeof(
float) == 0)
1456 int cameraCount = dataSize / ((6+localTransform.
size())*
sizeof(
float));
1457 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1458 int max = cameraCount*(6+localTransform.
size());
1459 for(
int i=0; i<
max; i+=6+localTransform.
size())
1463 memcpy(localTransform.
data(), dataFloat+i+6, localTransform.
size()*
sizeof(float));
1469 (
double)dataFloat[i],
1470 (
double)dataFloat[i+1],
1471 (
double)dataFloat[i+2],
1472 (
double)dataFloat[i+3],
1474 models.back().setImageSize(cv::Size(dataFloat[i+4], dataFloat[i+5]));
1475 UDEBUG(
"%f %f %f %f %f %f %s", dataFloat[i], dataFloat[i+1], dataFloat[i+2],
1476 dataFloat[i+3], dataFloat[i+4], dataFloat[i+5],
1481 (
unsigned int)dataSize % (4+localTransform.
size())*
sizeof(
float) == 0)
1483 int cameraCount = dataSize / ((4+localTransform.
size())*
sizeof(
float));
1484 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1485 int max = cameraCount*(4+localTransform.
size());
1486 for(
int i=0; i<
max; i+=4+localTransform.
size())
1490 memcpy(localTransform.
data(), dataFloat+i+4, localTransform.
size()*
sizeof(float));
1496 (
double)dataFloat[i],
1497 (
double)dataFloat[i+1],
1498 (
double)dataFloat[i+2],
1499 (
double)dataFloat[i+3],
1503 else if((
unsigned int)dataSize == (7+localTransform.
size())*
sizeof(
float))
1505 UDEBUG(
"Loading calibration of a stereo camera");
1506 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
1518 cv::Size(dataFloat[5],dataFloat[6]));
1520 else if((
unsigned int)dataSize == (5+localTransform.
size())*
sizeof(
float))
1522 UDEBUG(
"Loading calibration of a stereo camera");
1523 memcpy(localTransform.
data(), dataFloat+5, localTransform.
size()*
sizeof(float));
1538 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
1545 UDEBUG(
"Loading calibration version >= 0.7.0");
1550 if(fyOrBaseline < 1.0)
1557 models.push_back(
CameraModel(fx, fyOrBaseline, cx, cy, localTransform));
1562 UDEBUG(
"Loading calibration version < 0.7.0");
1564 float fx = 1.0f/depthConstant;
1565 float fy = 1.0f/depthConstant;
1568 models.push_back(
CameraModel(fx, fy, cx, cy, localTransform));
1572 int laserScanMaxPts = 0;
1573 float laserScanMaxRange = 0.0f;
1574 int laserScanFormat = 0;
1584 if(dataSize > 0 && data)
1586 float * dataFloat = (
float*)data;
1588 if(
uStrNumCmp(
_version,
"0.16.1") >= 0 && dataSize == (int)((scanLocalTransform.
size()+3)*
sizeof(
float)))
1591 laserScanFormat = (int)dataFloat[2];
1592 memcpy(scanLocalTransform.
data(), dataFloat+3, scanLocalTransform.
size()*
sizeof(float));
1594 else if(dataSize == (
int)((scanLocalTransform.
size()+2)*
sizeof(
float)))
1596 memcpy(scanLocalTransform.
data(), dataFloat+2, scanLocalTransform.
size()*
sizeof(float));
1600 UFATAL(
"Unexpected size %d for laser scan info!", dataSize);
1607 laserScanMaxPts = (int)dataFloat[0];
1608 laserScanMaxRange = dataFloat[1];
1627 if(dataSize>4 && data)
1629 scanCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1640 if(dataSize>4 && data)
1644 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1649 userDataCompressed =
compressData2(cv::Mat(1, dataSize, CV_8SC1, (
void *)data));
1656 cv::Mat groundCellsCompressed;
1657 cv::Mat obstacleCellsCompressed;
1658 cv::Mat emptyCellsCompressed;
1659 float cellSize = 0.0f;
1660 cv::Point3f viewPoint;
1666 if(dataSize > 0 && data)
1668 groundCellsCompressed = cv::Mat(1, dataSize, CV_8UC1);
1669 memcpy((
void*)groundCellsCompressed.data, data, dataSize);
1675 if(dataSize > 0 && data)
1677 obstacleCellsCompressed = cv::Mat(1, dataSize, CV_8UC1);
1678 memcpy((
void*)obstacleCellsCompressed.data, data, dataSize);
1686 if(dataSize > 0 && data)
1688 emptyCellsCompressed = cv::Mat(1, dataSize, CV_8UC1);
1689 memcpy((
void*)emptyCellsCompressed.data, data, dataSize);
1708 (*iter)->getStamp(),
1719 (*iter)->getStamp(),
1724 (*iter)->sensorData().
setOccupancyGrid(groundCellsCompressed, obstacleCellsCompressed, emptyCellsCompressed, cellSize, viewPoint);
1748 std::vector<CameraModel> & models,
1752 if(
_ppDb && signatureId)
1756 std::stringstream query;
1760 query <<
"SELECT calibration " 1762 <<
"WHERE id = " << signatureId
1767 query <<
"SELECT local_transform, fx, fy, cx, cy " 1769 <<
"WHERE id = " << signatureId
1774 query <<
"SELECT local_transform, constant " 1776 <<
"WHERE id = " << signatureId
1783 const void * data = 0;
1799 if((
unsigned int)dataSize == localTransform.
size()*
sizeof(float) && data)
1801 memcpy(localTransform.
data(), data, dataSize);
1812 if(dataSize > 0 && data)
1814 float * dataFloat = (
float*)data;
1816 (
unsigned int)dataSize % (6+localTransform.
size())*
sizeof(
float) == 0)
1818 int cameraCount = dataSize / ((6+localTransform.
size())*
sizeof(
float));
1819 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1820 int max = cameraCount*(6+localTransform.
size());
1821 for(
int i=0; i<
max; i+=6+localTransform.
size())
1825 memcpy(localTransform.
data(), dataFloat+i+6, localTransform.
size()*
sizeof(float));
1831 (
double)dataFloat[i],
1832 (
double)dataFloat[i+1],
1833 (
double)dataFloat[i+2],
1834 (
double)dataFloat[i+3],
1836 models.back().setImageSize(cv::Size(dataFloat[i+4], dataFloat[i+5]));
1837 UDEBUG(
"%f %f %f %f %f %f %s", dataFloat[i], dataFloat[i+1], dataFloat[i+2],
1838 dataFloat[i+3], dataFloat[i+4], dataFloat[i+5],
1843 (
unsigned int)dataSize % (4+localTransform.
size())*
sizeof(
float) == 0)
1845 int cameraCount = dataSize / ((4+localTransform.
size())*
sizeof(
float));
1846 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1847 int max = cameraCount*(4+localTransform.
size());
1848 for(
int i=0; i<
max; i+=4+localTransform.
size())
1852 memcpy(localTransform.
data(), dataFloat+i+4, localTransform.
size()*
sizeof(float));
1858 (
double)dataFloat[i],
1859 (
double)dataFloat[i+1],
1860 (
double)dataFloat[i+2],
1861 (
double)dataFloat[i+3],
1865 else if((
unsigned int)dataSize == (7+localTransform.
size())*
sizeof(
float))
1867 UDEBUG(
"Loading calibration of a stereo camera");
1868 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
1880 cv::Size(dataFloat[5],dataFloat[6]));
1882 else if((
unsigned int)dataSize == (5+localTransform.
size())*
sizeof(
float))
1884 UDEBUG(
"Loading calibration of a stereo camera");
1885 memcpy(localTransform.
data(), dataFloat+5, localTransform.
size()*
sizeof(float));
1900 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
1907 UDEBUG(
"Loading calibration version >= 0.7.0");
1912 UDEBUG(
"fx=%f fyOrBaseline=%f cx=%f cy=%f", fx, fyOrBaseline, cx, cy);
1913 if(fyOrBaseline < 1.0)
1920 models.push_back(
CameraModel(fx, fyOrBaseline, cx, cy, localTransform));
1925 UDEBUG(
"Loading calibration version < 0.7.0");
1927 float fx = 1.0f/depthConstant;
1928 float fy = 1.0f/depthConstant;
1931 models.push_back(
CameraModel(fx, fy, cx, cy, localTransform));
1950 if(
_ppDb && signatureId)
1954 std::stringstream query;
1958 query <<
"SELECT scan_info " 1960 <<
"WHERE id = " << signatureId
1971 const void * data = 0;
1975 float maxRange = 0.0f;
1989 if(dataSize > 0 && data)
1991 float * dataFloat = (
float*)data;
1995 format = (int)dataFloat[2];
1996 memcpy(localTransform.
data(), dataFloat+3, localTransform.
size()*
sizeof(float));
1998 else if(dataSize == (
int)((localTransform.
size()+2)*
sizeof(
float)))
2000 memcpy(localTransform.
data(), dataFloat+2, localTransform.
size()*
sizeof(float));
2004 UFATAL(
"Unexpected size %d for laser scan info!", dataSize);
2010 maxPts = (int)dataFloat[0];
2011 maxRange = dataFloat[1];
2031 std::string & label,
2034 std::vector<float> & velocity,
2038 if(
_ppDb && signatureId)
2042 std::stringstream query;
2046 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose, velocity, gps " 2048 "WHERE id = " << signatureId <<
2053 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose, velocity " 2055 "WHERE id = " << signatureId <<
2060 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose " 2062 "WHERE id = " << signatureId <<
2067 query <<
"SELECT pose, map_id, weight, label, stamp " 2069 "WHERE id = " << signatureId <<
2074 query <<
"SELECT pose, map_id, weight " 2076 "WHERE id = " << signatureId <<
2083 const void * data = 0;
2094 if((
unsigned int)dataSize == pose.
size()*
sizeof(float) && data)
2096 memcpy(pose.
data(), data, dataSize);
2111 label =
reinterpret_cast<const char*
>(p);
2119 if((
unsigned int)dataSize == groundTruthPose.
size()*
sizeof(float) && data)
2121 memcpy(groundTruthPose.
data(), data, dataSize);
2130 velocity.resize(6,0);
2133 if((
unsigned int)dataSize == velocity.size()*
sizeof(float) && data)
2135 memcpy(velocity.data(), data, dataSize);
2141 std::vector<double> gpsV(6,0);
2144 if((
unsigned int)dataSize == gpsV.size()*
sizeof(double) && data)
2146 memcpy(gpsV.data(), data, dataSize);
2147 gps =
GPS(gpsV[0], gpsV[1], gpsV[2], gpsV[3], gpsV[4], gpsV[5]);
2173 std::stringstream query;
2175 query <<
"SELECT DISTINCT id " 2179 query <<
"INNER JOIN Link " 2180 <<
"ON id = to_id ";
2182 if(ignoreBadSignatures)
2186 query <<
"WHERE id in (select node_id from Feature) ";
2190 query <<
"WHERE id in (select node_id from Map_Node_Word) ";
2193 query <<
"ORDER BY id";
2224 std::stringstream query;
2228 query <<
"SELECT from_id, to_id, type, transform, information_matrix, user_data FROM Link ORDER BY from_id, to_id";
2232 query <<
"SELECT from_id, to_id, type, transform, rot_variance, trans_variance, user_data FROM Link ORDER BY from_id, to_id";
2236 query <<
"SELECT from_id, to_id, type, transform, rot_variance, trans_variance FROM Link ORDER BY from_id, to_id";
2240 query <<
"SELECT from_id, to_id, type, transform, variance FROM Link ORDER BY from_id, to_id";
2244 query <<
"SELECT from_id, to_id, type, transform FROM Link ORDER BY from_id, to_id";
2253 const void * data = 0;
2270 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
2272 memcpy(transform.
data(), data, dataSize);
2280 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", fromId, toId);
2283 if(!ignoreNullLinks || !transform.
isNull())
2285 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
2292 UASSERT(dataSize==36*
sizeof(
double) && data);
2293 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
2299 UASSERT(rotVariance > 0.0 && transVariance>0.0);
2300 informationMatrix.at<
double>(0,0) = 1.0/transVariance;
2301 informationMatrix.at<
double>(1,1) = 1.0/transVariance;
2302 informationMatrix.at<
double>(2,2) = 1.0/transVariance;
2303 informationMatrix.at<
double>(3,3) = 1.0/rotVariance;
2304 informationMatrix.at<
double>(4,4) = 1.0/rotVariance;
2305 informationMatrix.at<
double>(5,5) = 1.0/rotVariance;
2308 cv::Mat userDataCompressed;
2314 if(dataSize>4 && data)
2316 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
2320 links.insert(links.end(), std::make_pair(fromId,
Link(fromId, toId, (
Link::Type)type, transform, informationMatrix, userDataCompressed)));
2326 informationMatrix *= 1.0/variance;
2327 links.insert(links.end(), std::make_pair(fromId,
Link(fromId, toId, (
Link::Type)type, transform, informationMatrix)));
2351 UDEBUG(
"get last id from table \"%s\"", tableName.c_str());
2356 std::stringstream query;
2358 query <<
"SELECT max(id) " 2359 <<
"FROM " << tableName
2395 std::stringstream query;
2399 query <<
"SELECT count(word_id) " 2401 <<
"WHERE node_id=" << nodeId <<
";";
2405 query <<
"SELECT count(word_id) " 2406 <<
"FROM Map_Node_Word " 2407 <<
"WHERE node_id=" << nodeId <<
";";
2443 std::stringstream query;
2444 query <<
"SELECT id FROM Node WHERE label='" << label <<
"'";
2473 std::stringstream query;
2474 query <<
"SELECT id,label FROM Node WHERE label IS NOT NULL";
2488 std::string label =
reinterpret_cast<const char*
>(p);
2491 labels.insert(std::make_pair(
id, label));
2514 std::stringstream query;
2516 query <<
"SELECT weight FROM node WHERE id = " 2543 if(
_ppDb && ids.size())
2550 std::stringstream query;
2551 unsigned int loaded = 0;
2556 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps " 2562 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity " 2568 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose " 2574 query <<
"SELECT id, map_id, weight, pose, stamp, label " 2580 query <<
"SELECT id, map_id, weight, pose " 2588 for(std::list<int>::const_iterator iter=ids.begin(); iter!=ids.end(); ++iter)
2601 std::vector<float> velocity;
2602 std::vector<double> gps;
2603 const void * data = 0;
2618 if((
unsigned int)dataSize == pose.
size()*
sizeof(float) && data)
2620 memcpy(pose.
data(), data, dataSize);
2633 label =
reinterpret_cast<const char*
>(p);
2640 if((
unsigned int)dataSize == groundTruthPose.
size()*
sizeof(float) && data)
2642 memcpy(groundTruthPose.
data(), data, dataSize);
2651 velocity.resize(6,0);
2654 if((
unsigned int)dataSize == velocity.size()*
sizeof(float) && data)
2656 memcpy(velocity.data(), data, dataSize);
2665 if((
unsigned int)dataSize == gps.size()*
sizeof(double) && data)
2667 memcpy(gps.data(), data, dataSize);
2689 if(velocity.size() == 6)
2691 s->setVelocity(velocity[0], velocity[1], velocity[2], velocity[3], velocity[4], velocity[5]);
2695 s->sensorData().setGPS(
GPS(gps[0], gps[1], gps[2], gps[3], gps[4], gps[5]));
2703 UERROR(
"Signature %d not found in database!", *iter);
2718 std::stringstream query2;
2721 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor " 2723 "WHERE node_id = ? ";
2727 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor " 2728 "FROM Map_Node_Word " 2729 "WHERE node_id = ? ";
2733 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z, descriptor_size, descriptor " 2734 "FROM Map_Node_Word " 2735 "WHERE node_id = ? ";
2739 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z " 2740 "FROM Map_Node_Word " 2741 "WHERE node_id = ? ";
2744 query2 <<
" ORDER BY word_id";
2750 float nanFloat = std::numeric_limits<float>::quiet_NaN ();
2752 for(std::list<Signature*>::const_iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
2759 int visualWordId = 0;
2760 int descriptorSize = 0;
2761 const void * descriptor = 0;
2764 std::multimap<int, cv::KeyPoint> visualWords;
2765 std::multimap<int, cv::Point3f> visualWords3;
2766 std::multimap<int, cv::Mat> descriptors;
2767 cv::Point3f depth(0,0,0);
2815 visualWords.insert(visualWords.end(), std::make_pair(visualWordId, kpt));
2816 visualWords3.insert(visualWords3.end(), std::make_pair(visualWordId, depth));
2824 if(descriptor && descriptorSize>0 && dRealSize>0)
2827 if(dRealSize == descriptorSize)
2830 d = cv::Mat(1, descriptorSize, CV_8U);
2832 else if(dRealSize/
int(
sizeof(
float)) == descriptorSize)
2835 d = cv::Mat(1, descriptorSize, CV_32F);
2839 UFATAL(
"Saved buffer size (%d bytes) is not the same as descriptor size (%d)", dRealSize, descriptorSize);
2842 memcpy(d.data, descriptor, dRealSize);
2844 descriptors.insert(descriptors.end(), std::make_pair(visualWordId, d));
2852 if(visualWords.size()==0)
2854 UDEBUG(
"Empty signature detected! (id=%d)", (*iter)->id());
2858 (*iter)->setWords(visualWords);
2859 (*iter)->setWords3(visualWords3);
2860 (*iter)->setWordsDescriptors(descriptors);
2861 ULOGGER_DEBUG(
"Add %d keypoints, %d 3d points and %d descriptors to node %d", (
int)visualWords.size(), (int)visualWords3.size(), (int)descriptors.size(), (*iter)->id());
2876 for(std::list<Signature*>::iterator iter = nodes.begin(); iter!=nodes.end(); ++iter)
2878 (*iter)->setModified(
false);
2885 std::stringstream query3;
2886 query3 <<
"SELECT calibration " 2893 for(std::list<Signature*>::const_iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
2903 const void * data = 0;
2906 std::vector<CameraModel> models;
2914 if(dataSize > 0 && data)
2916 float * dataFloat = (
float*)data;
2918 (
unsigned int)dataSize % (6+localTransform.
size())*
sizeof(
float) == 0)
2920 int cameraCount = dataSize / ((6+localTransform.
size())*
sizeof(
float));
2921 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
2922 int max = cameraCount*(6+localTransform.
size());
2923 for(
int i=0; i<
max; i+=6+localTransform.
size())
2927 memcpy(localTransform.
data(), dataFloat+i+6, localTransform.
size()*
sizeof(float));
2933 (
double)dataFloat[i],
2934 (
double)dataFloat[i+1],
2935 (
double)dataFloat[i+2],
2936 (
double)dataFloat[i+3],
2939 cv::Size(dataFloat[i+4], dataFloat[i+5])));
2940 UDEBUG(
"%f %f %f %f %f %f %s", dataFloat[i], dataFloat[i+1], dataFloat[i+2],
2941 dataFloat[i+3], dataFloat[i+4], dataFloat[i+5],
2946 (
unsigned int)dataSize % (4+localTransform.
size())*
sizeof(
float) == 0)
2948 int cameraCount = dataSize / ((4+localTransform.
size())*
sizeof(
float));
2949 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
2950 int max = cameraCount*(4+localTransform.
size());
2951 for(
int i=0; i<
max; i+=4+localTransform.
size())
2955 memcpy(localTransform.
data(), dataFloat+i+4, localTransform.
size()*
sizeof(float));
2961 (
double)dataFloat[i],
2962 (
double)dataFloat[i+1],
2963 (
double)dataFloat[i+2],
2964 (
double)dataFloat[i+3],
2968 else if((
unsigned int)dataSize == (7+localTransform.
size())*
sizeof(
float))
2970 UDEBUG(
"Loading calibration of a stereo camera");
2971 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
2983 cv::Size(dataFloat[5], dataFloat[6]));
2985 else if((
unsigned int)dataSize == (5+localTransform.
size())*
sizeof(
float))
2987 UDEBUG(
"Loading calibration of a stereo camera");
2988 memcpy(localTransform.
data(), dataFloat+5, localTransform.
size()*
sizeof(float));
3003 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes, db version=%s)", dataSize,
_version.c_str());
3006 (*iter)->sensorData().setCameraModels(models);
3007 (*iter)->sensorData().setStereoCameraModel(stereoModel);
3023 if(ids.size() != loaded)
3025 UERROR(
"Some signatures not found in database");
3045 query =
"SELECT n.id " 3047 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Info) " 3052 query =
"SELECT n.id " 3054 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Statistics) " 3084 if(
_ppDb && dictionary)
3091 std::stringstream query;
3092 std::list<VisualWord *> visualWords;
3095 query <<
"SELECT id, descriptor_size, descriptor FROM Word ";
3100 query <<
"WHERE time_enter >= (SELECT MAX(time_enter) FROM Info) ";
3104 query <<
"WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics) ";
3107 query <<
"ORDER BY id;";
3114 int descriptorSize = 0;
3115 const void * descriptor = 0;
3129 if(dRealSize == descriptorSize)
3132 d = cv::Mat(1, descriptorSize, CV_8U);
3134 else if(dRealSize/
int(
sizeof(
float)) == descriptorSize)
3137 d = cv::Mat(1, descriptorSize, CV_32F);
3141 UFATAL(
"Saved buffer size (%d bytes) is not the same as descriptor size (%d)", dRealSize, descriptorSize);
3144 memcpy(d.data, descriptor, dRealSize);
3149 if(++count % 5000 == 0)
3172 if(
_ppDb && wordIds.size())
3179 std::stringstream query;
3180 std::set<int> loaded;
3183 query <<
"SELECT vw.descriptor_size, vw.descriptor " 3191 const void * descriptor;
3193 for(std::set<int>::const_iterator iter=wordIds.begin(); iter!=wordIds.end(); ++iter)
3209 if(dRealSize == descriptorSize)
3212 d = cv::Mat(1, descriptorSize, CV_8U);
3214 else if(dRealSize/
int(
sizeof(
float)) == descriptorSize)
3217 d = cv::Mat(1, descriptorSize, CV_32F);
3221 UFATAL(
"Saved buffer size (%d bytes) is not the same as descriptor size (%d)", dRealSize, descriptorSize);
3224 memcpy(d.data, descriptor, dRealSize);
3231 loaded.insert(loaded.end(), *iter);
3248 if(wordIds.size() != loaded.size())
3250 for(std::set<int>::const_iterator iter = wordIds.begin(); iter!=wordIds.end(); ++iter)
3252 if(loaded.find(*iter) == loaded.end())
3254 UDEBUG(
"Not found word %d", *iter);
3257 UERROR(
"Query (%d) doesn't match loaded words (%d)", wordIds.size(), loaded.size());
3264 std::map<int, Link> & neighbors,
3274 std::stringstream query;
3278 query <<
"SELECT to_id, type, transform, information_matrix, user_data FROM Link ";
3282 query <<
"SELECT to_id, type, transform, rot_variance, trans_variance, user_data FROM Link ";
3286 query <<
"SELECT to_id, type, transform, rot_variance, trans_variance FROM Link ";
3290 query <<
"SELECT to_id, type, transform, variance FROM Link ";
3294 query <<
"SELECT to_id, type, transform FROM Link ";
3296 query <<
"WHERE from_id = " << signatureId;
3301 query <<
" AND type = " << typeIn;
3305 query <<
" AND type = 0";
3309 query <<
" AND type > 0";
3312 query <<
" ORDER BY to_id";
3319 const void * data = 0;
3335 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
3337 memcpy(transform.
data(), data, dataSize);
3345 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", signatureId, toId);
3348 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
3355 UASSERT(dataSize==36*
sizeof(
double) && data);
3356 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
3362 UASSERT(rotVariance > 0.0 && transVariance>0.0);
3363 informationMatrix.at<
double>(0,0) = 1.0/transVariance;
3364 informationMatrix.at<
double>(1,1) = 1.0/transVariance;
3365 informationMatrix.at<
double>(2,2) = 1.0/transVariance;
3366 informationMatrix.at<
double>(3,3) = 1.0/rotVariance;
3367 informationMatrix.at<
double>(4,4) = 1.0/rotVariance;
3368 informationMatrix.at<
double>(5,5) = 1.0/rotVariance;
3371 cv::Mat userDataCompressed;
3377 if(dataSize>4 && data)
3379 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
3383 neighbors.insert(neighbors.end(), std::make_pair(toId,
Link(signatureId, toId, (
Link::Type)type, transform, informationMatrix, userDataCompressed)));
3389 informationMatrix *= 1.0/variance;
3390 neighbors.insert(neighbors.end(), std::make_pair(toId,
Link(signatureId, toId, (
Link::Type)type, transform, informationMatrix)));
3407 if(neighbors.size() == 0)
3422 std::stringstream query;
3423 int totalLinksLoaded = 0;
3427 query <<
"SELECT to_id, type, information_matrix, user_data, transform FROM Link " 3428 <<
"WHERE from_id = ? " 3429 <<
"ORDER BY to_id";
3433 query <<
"SELECT to_id, type, rot_variance, trans_variance, user_data, transform FROM Link " 3434 <<
"WHERE from_id = ? " 3435 <<
"ORDER BY to_id";
3439 query <<
"SELECT to_id, type, rot_variance, trans_variance, transform FROM Link " 3440 <<
"WHERE from_id = ? " 3441 <<
"ORDER BY to_id";
3445 query <<
"SELECT to_id, type, variance, transform FROM Link " 3446 <<
"WHERE from_id = ? " 3447 <<
"ORDER BY to_id";
3451 query <<
"SELECT to_id, type, transform FROM Link " 3452 <<
"WHERE from_id = ? " 3453 <<
"ORDER BY to_id";
3459 for(std::list<Signature*>::iterator iter=signatures.begin(); iter!=signatures.end(); ++iter)
3467 std::list<Link> links;
3468 const void * data = 0;
3479 cv::Mat userDataCompressed;
3480 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
3487 UASSERT(dataSize==36*
sizeof(
double) && data);
3488 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
3494 UASSERT(rotVariance > 0.0 && transVariance>0.0);
3495 informationMatrix.at<
double>(0,0) = 1.0/transVariance;
3496 informationMatrix.at<
double>(1,1) = 1.0/transVariance;
3497 informationMatrix.at<
double>(2,2) = 1.0/transVariance;
3498 informationMatrix.at<
double>(3,3) = 1.0/rotVariance;
3499 informationMatrix.at<
double>(4,4) = 1.0/rotVariance;
3500 informationMatrix.at<
double>(5,5) = 1.0/rotVariance;
3508 if(dataSize>4 && data)
3510 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
3518 informationMatrix *= 1.0/variance;
3525 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
3527 memcpy(transform.
data(), data, dataSize);
3535 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", (*iter)->id(), toId);
3542 links.push_back(
Link((*iter)->id(), toId, (
Link::Type)linkType, transform, informationMatrix, userDataCompressed));
3551 UFATAL(
"Not supported link type %d ! (fromId=%d, toId=%d)",
3552 linkType, (*iter)->id(), toId);
3561 (*iter)->addLinks(links);
3566 UDEBUG(
"time=%fs, node=%d, links.size=%d", timer.
ticks(), (*iter)->id(), links.size());
3578 UDEBUG(
"nodes = %d", nodes.size());
3579 if(
_ppDb && nodes.size())
3592 query =
"UPDATE Node SET weight=?, label=?, time_enter = DATETIME('NOW') WHERE id=?;";
3596 query =
"UPDATE Node SET weight=?, label=? WHERE id=?;";
3603 query =
"UPDATE Node SET weight=?, time_enter = DATETIME('NOW') WHERE id=?;";
3607 query =
"UPDATE Node SET weight=? WHERE id=?;";
3613 for(std::list<Signature *>::const_iterator i=nodes.begin(); i!=nodes.end(); ++i)
3654 query =
"DELETE FROM Link WHERE from_id=?;";
3657 for(std::list<Signature *>::const_iterator j=nodes.begin(); j!=nodes.end(); ++j)
3659 if((*j)->isLinksModified())
3679 for(std::list<Signature *>::const_iterator j=nodes.begin(); j!=nodes.end(); ++j)
3681 if((*j)->isLinksModified())
3684 const std::map<int, Link> & links = (*j)->getLinks();
3685 for(std::map<int, Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
3700 for(std::list<Signature *>::const_iterator j=nodes.begin(); j!=nodes.end(); ++j)
3702 if((*j)->getWordsChanged().size())
3704 const std::map<int, int> & wordsChanged = (*j)->getWordsChanged();
3705 for(std::map<int, int>::const_iterator iter=wordsChanged.begin(); iter!=wordsChanged.end(); ++iter)
3721 if(
_ppDb && words.size() && updateTimestamp)
3730 std::string query =
"UPDATE Word SET time_enter = DATETIME('NOW') WHERE id=?;";
3734 for(std::list<VisualWord *>::const_iterator i=words.begin(); i!=words.end(); ++i)
3762 if(
_ppDb && signatures.size())
3775 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
3779 _memoryUsedEstimate -= (*i)->sensorData().imageRaw().total() * (*i)->sensorData().imageRaw().elemSize();
3780 _memoryUsedEstimate -= (*i)->sensorData().depthOrRightRaw().total() * (*i)->sensorData().depthOrRightRaw().elemSize();
3781 _memoryUsedEstimate -= (*i)->sensorData().laserScanRaw().data().total() * (*i)->sensorData().laserScanRaw().data().elemSize();
3795 for(std::list<Signature *>::const_iterator jter=signatures.begin(); jter!=signatures.end(); ++jter)
3798 const std::map<int, Link> & links = (*jter)->getLinks();
3799 for(std::map<int, Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
3815 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
3817 UASSERT((*i)->getWords3().empty() || (*i)->getWords().size() == (*i)->getWords3().size());
3818 UASSERT((*i)->getWordsDescriptors().empty() || (*i)->getWords().size() == (*i)->getWordsDescriptors().size());
3820 std::multimap<int, cv::Point3f>::const_iterator p=(*i)->getWords3().begin();
3821 std::multimap<int, cv::Mat>::const_iterator
d=(*i)->getWordsDescriptors().begin();
3822 for(std::multimap<int, cv::KeyPoint>::const_iterator w=(*i)->getWords().begin(); w!=(*i)->getWords().end(); ++w)
3824 cv::Point3f pt(0,0,0);
3825 if(p!=(*i)->getWords3().end())
3827 UASSERT(w->first == p->first);
3833 if(d!=(*i)->getWordsDescriptors().end())
3835 UASSERT(w->first == d->first);
3836 descriptor = d->second;
3840 stepKeypoint(ppStmt, (*i)->id(), w->first, w->second, pt, descriptor);
3854 UDEBUG(
"Saving %d images", signatures.size());
3856 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
3858 if(!(*i)->sensorData().imageCompressed().empty() ||
3859 !(*i)->sensorData().depthOrRightCompressed().empty() ||
3860 !(*i)->sensorData().laserScanCompressed().isEmpty() ||
3861 !(*i)->sensorData().userDataCompressed().empty() ||
3862 !(*i)->sensorData().cameraModels().size() ||
3863 !(*i)->sensorData().stereoCameraModel().isValidForProjection())
3865 UASSERT((*i)->id() == (*i)->sensorData().id());
3881 UDEBUG(
"Saving %d images", signatures.size());
3883 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
3885 if(!(*i)->sensorData().imageCompressed().empty())
3887 stepImage(ppStmt, (*i)->id(), (*i)->sensorData().imageCompressed());
3900 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
3903 if(!(*i)->sensorData().depthOrRightCompressed().empty() || !(*i)->sensorData().laserScanCompressed().isEmpty())
3905 UASSERT((*i)->id() == (*i)->sensorData().id());
3920 UDEBUG(
"visualWords size=%d", words.size());
3933 query = std::string(
"INSERT INTO Word(id, descriptor_size, descriptor) VALUES(?,?,?);");
3936 for(std::list<VisualWord *>::const_iterator iter=words.begin(); iter!=words.end(); ++iter)
4033 const cv::Mat & ground,
4034 const cv::Mat & obstacles,
4035 const cv::Mat & empty,
4037 const cv::Point3f & viewpoint)
const 4072 const cv::Mat & image)
const 4116 if(param.size() && statistics.
refImageId()>0)
4121 query =
"INSERT INTO Statistics(id, stamp, data, wm_state) values(?,?,?,?);";
4125 query =
"INSERT INTO Statistics(id, stamp, data) values(?,?,?);";
4136 cv::Mat compressedParam;
4149 cv::Mat compressedWmState;
4152 if(!statistics.
wmState().empty())
4194 query =
uFormat(
"UPDATE Admin SET preview_image=? WHERE version='%s';",
_version.c_str());
4199 cv::Mat compressedImage;
4208 if(image.rows == 1 && image.type() == CV_8UC1)
4211 compressedImage = image;
4242 std::stringstream query;
4244 query <<
"SELECT preview_image " 4246 <<
"WHERE version='" <<
_version.c_str()
4257 const void * data = 0;
4264 if(dataSize>0 && data)
4268 UDEBUG(
"Image=%dx%d", image.cols, image.rows);
4295 query =
uFormat(
"UPDATE Admin SET opt_ids=?, opt_poses=?, opt_last_localization=?, time_enter = DATETIME('NOW') WHERE version='%s';",
_version.c_str());
4302 cv::Mat compressedIds;
4303 cv::Mat compressedPoses;
4313 std::vector<int> serializedIds(poses.size());
4314 std::vector<float> serializedPoses(poses.size()*12);
4316 for(std::map<int, Transform>::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter)
4318 serializedIds[i] = iter->first;
4319 memcpy(serializedPoses.data()+(12*i), iter->second.data(), 12*
sizeof(float));
4323 compressedIds =
compressData2(cv::Mat(1,serializedIds.size(), CV_32SC1, serializedIds.data()));
4324 compressedPoses =
compressData2(cv::Mat(1,serializedPoses.size(), CV_32FC1, serializedPoses.data()));
4332 if(lastlocalizationPose.
isNull())
4359 std::map<int, Transform> poses;
4366 std::stringstream query;
4368 query <<
"SELECT opt_ids, opt_poses, opt_last_localization " 4370 <<
"WHERE version='" <<
_version.c_str()
4381 const void * data = 0;
4386 cv::Mat serializedIds;
4389 if(dataSize>0 && data)
4391 serializedIds =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4392 UDEBUG(
"serializedIds=%d", serializedIds.cols);
4397 if(dataSize>0 && data)
4399 cv::Mat serializedPoses =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4400 UDEBUG(
"serializedPoses=%d", serializedPoses.cols);
4402 UASSERT(serializedIds.cols == serializedPoses.cols/12);
4403 UASSERT(serializedPoses.type() == CV_32FC1);
4404 UASSERT(serializedIds.type() == CV_32SC1);
4405 for(
int i=0; i<serializedIds.cols; ++i)
4407 Transform t(serializedPoses.at<
float>(i*12), serializedPoses.at<
float>(i*12+1), serializedPoses.at<
float>(i*12+2), serializedPoses.at<
float>(i*12+3),
4408 serializedPoses.at<
float>(i*12+4), serializedPoses.at<
float>(i*12+5), serializedPoses.at<
float>(i*12+6), serializedPoses.at<
float>(i*12+7),
4409 serializedPoses.at<
float>(i*12+8), serializedPoses.at<
float>(i*12+9), serializedPoses.at<
float>(i*12+10), serializedPoses.at<
float>(i*12+11));
4410 poses.insert(std::make_pair(serializedIds.at<
int>(i), t));
4411 UDEBUG(
"Optimized pose %d: %s", serializedIds.at<
int>(i), t.
prettyPrint().c_str());
4417 if(lastlocalizationPose)
4419 if((
unsigned int)dataSize == lastlocalizationPose->
size()*
sizeof(float) && data)
4421 memcpy(lastlocalizationPose->
data(), data, dataSize);
4451 query =
uFormat(
"UPDATE Admin SET opt_map=?, opt_map_x_min=?, opt_map_y_min=?, opt_map_resolution=?, time_enter = DATETIME('NOW') WHERE version='%s';",
_version.c_str());
4458 cv::Mat compressedMap;
4501 std::stringstream query;
4503 query <<
"SELECT opt_map, opt_map_x_min, opt_map_y_min, opt_map_resolution " 4505 <<
"WHERE version='" <<
_version.c_str()
4516 const void * data = 0;
4523 if(dataSize>0 && data)
4525 map =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4526 UDEBUG(
"map=%d/%d", map.cols, map.rows);
4534 UDEBUG(
"cellSize=%f", cellSize);
4550 const cv::Mat & cloud,
4551 const std::vector<std::vector<std::vector<unsigned int> > > & polygons,
4552 #
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
4553 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords,
4555 const std::vector<std::vector<Eigen::Vector2f> > & texCoords,
4557 const cv::Mat & textures)
const 4569 query =
uFormat(
"UPDATE Admin SET opt_cloud=?, opt_polygons_size=?, opt_polygons=?, opt_tex_coords=?, opt_tex_materials=?, time_enter = DATETIME('NOW') WHERE version='%s';",
_version.c_str());
4576 for(
int i=1; i<=5; ++i)
4591 cv::Mat compressedCloud;
4592 if(cloud.rows == 1 && cloud.type() == CV_8UC1)
4595 compressedCloud = cloud;
4599 UDEBUG(
"Cloud points=%d", cloud.cols);
4602 UDEBUG(
"Cloud compressed bytes=%d", compressedCloud.cols);
4607 cv::Mat compressedPolygons;
4608 cv::Mat compressedTexCoords;
4609 cv::Mat compressedTextures;
4611 if(polygons.empty())
4628 std::vector<int> serializedPolygons;
4629 std::vector<float> serializedTexCoords;
4630 int polygonSize = 0;
4631 int totalPolygonIndices = 0;
4632 UASSERT(texCoords.empty() || polygons.size() == texCoords.size());
4633 for(
unsigned int t=0; t<polygons.size(); ++t)
4635 UDEBUG(
"t=%d, polygons=%d", t, (
int)polygons[t].size());
4636 unsigned int materialPolygonIndices = 0;
4637 for(
unsigned int p=0; p<polygons[t].size(); ++p)
4639 if(polygonSize == 0)
4641 UASSERT(polygons[t][p].size());
4642 polygonSize = polygons[t][p].size();
4646 UASSERT(polygonSize == (
int)polygons[t][p].size());
4649 materialPolygonIndices += polygons[t][p].size();
4651 totalPolygonIndices += materialPolygonIndices;
4653 if(!texCoords.empty())
4655 UASSERT(materialPolygonIndices == texCoords[t].size());
4658 UASSERT(totalPolygonIndices>0);
4659 serializedPolygons.resize(totalPolygonIndices+polygons.size());
4660 if(!texCoords.empty())
4662 serializedTexCoords.resize(totalPolygonIndices*2+polygons.size());
4667 for(
unsigned int t=0; t<polygons.size(); ++t)
4669 serializedPolygons[oi++] = polygons[t].size();
4670 if(!texCoords.empty())
4672 serializedTexCoords[ci++] = texCoords[t].size();
4674 for(
unsigned int p=0; p<polygons[t].size(); ++p)
4676 int texIndex = p*polygonSize;
4677 for(
unsigned int i=0; i<polygons[t][p].size(); ++i)
4679 serializedPolygons[oi++] = polygons[t][p][i];
4681 if(!texCoords.empty())
4683 serializedTexCoords[ci++] = texCoords[t][texIndex+i][0];
4684 serializedTexCoords[ci++] = texCoords[t][texIndex+i][1];
4690 UDEBUG(
"serializedPolygons=%d", (
int)serializedPolygons.size());
4691 compressedPolygons =
compressData2(cv::Mat(1,serializedPolygons.size(), CV_32SC1, serializedPolygons.data()));
4701 if(texCoords.empty())
4712 UDEBUG(
"serializedTexCoords=%d", (
int)serializedTexCoords.size());
4713 compressedTexCoords =
compressData2(cv::Mat(1,serializedTexCoords.size(), CV_32FC1, serializedTexCoords.data()));
4717 UASSERT(!textures.empty() && textures.cols % textures.rows == 0 && textures.cols/textures.rows == (int)texCoords.size());
4718 if(textures.rows == 1 && textures.type() == CV_8UC1)
4721 compressedTextures = textures;
4746 std::vector<std::vector<std::vector<unsigned int> > > * polygons,
4747 #
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
4748 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords,
4750 std::vector<std::vector<Eigen::Vector2f> > * texCoords,
4752 cv::Mat * textures)
const 4762 std::stringstream query;
4764 query <<
"SELECT opt_cloud, opt_polygons_size, opt_polygons, opt_tex_coords, opt_tex_materials " 4766 <<
"WHERE version='" <<
_version.c_str()
4777 const void * data = 0;
4784 if(dataSize>0 && data)
4786 cloud =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4788 UDEBUG(
"Cloud=%d points", cloud.cols);
4792 UDEBUG(
"polygonSize=%d", polygonSize);
4797 if(dataSize>0 && data)
4802 cv::Mat serializedPolygons =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4803 UDEBUG(
"serializedPolygons=%d", serializedPolygons.cols);
4804 UASSERT(serializedPolygons.total());
4805 for(
int t=0; t<serializedPolygons.cols; ++t)
4807 UASSERT(serializedPolygons.at<
int>(t) > 0);
4808 std::vector<std::vector<unsigned int> > materialPolygons(serializedPolygons.at<
int>(t), std::vector<unsigned int>(polygonSize));
4810 UASSERT(t < serializedPolygons.cols);
4811 UDEBUG(
"materialPolygons=%d", (
int)materialPolygons.size());
4812 for(
int p=0; p<(int)materialPolygons.size(); ++p)
4814 for(
int i=0; i<polygonSize; ++i)
4816 materialPolygons[p][i] = serializedPolygons.at<
int>(t + p*polygonSize + i);
4819 t+=materialPolygons.size()*polygonSize;
4820 polygons->push_back(materialPolygons);
4827 if(dataSize>0 && data)
4831 cv::Mat serializedTexCoords =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4832 UDEBUG(
"serializedTexCoords=%d", serializedTexCoords.cols);
4833 UASSERT(serializedTexCoords.total());
4834 for(
int t=0; t<serializedTexCoords.cols; ++t)
4836 UASSERT(
int(serializedTexCoords.at<
float>(t)) > 0);
4837 #if PCL_VERSION_COMPARE(>=, 1, 8, 0) 4838 std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > materialtexCoords(
int(serializedTexCoords.at<
float>(t)));
4840 std::vector<Eigen::Vector2f> materialtexCoords(
int(serializedTexCoords.at<
float>(t)));
4843 UASSERT(t < serializedTexCoords.cols);
4844 UDEBUG(
"materialtexCoords=%d", (
int)materialtexCoords.size());
4845 for(
int p=0; p<(int)materialtexCoords.size(); ++p)
4847 materialtexCoords[p][0] = serializedTexCoords.at<
float>(t + p*2);
4848 materialtexCoords[p][1] = serializedTexCoords.at<
float>(t + p*2 + 1);
4850 t+=materialtexCoords.size()*2;
4851 texCoords->push_back(materialtexCoords);
4858 if(dataSize>0 && data)
4862 *textures =
uncompressImage(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4863 UDEBUG(
"textures=%dx%d", textures->cols, textures->rows);
4886 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps) VALUES(?,?,?,?,?,?,?,?,?);";
4890 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity) VALUES(?,?,?,?,?,?,?,?);";
4894 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose) VALUES(?,?,?,?,?,?,?);";
4898 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label) VALUES(?,?,?,?,?,?);";
4902 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, user_data) VALUES(?,?,?,?,?,?,?);";
4906 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label) VALUES(?,?,?,?,?,?);";
4908 return "INSERT INTO Node(id, map_id, weight, pose) VALUES(?,?,?,?);";
4946 std::vector<double> gps;
5017 return "INSERT INTO Image(id, data) VALUES(?,?);";
5021 const cv::Mat & imageBytes)
const 5024 UDEBUG(
"Save image %d (size=%d)",
id, (
int)imageBytes.cols);
5036 if(!imageBytes.empty())
5059 return "INSERT INTO Depth(id, data, fx, fy, cx, cy, local_transform, data2d, data2d_max_pts) VALUES(?,?,?,?,?,?,?,?,?);";
5063 return "INSERT INTO Depth(id, data, fx, fy, cx, cy, local_transform, data2d) VALUES(?,?,?,?,?,?,?,?);";
5067 return "INSERT INTO Depth(id, data, constant, local_transform, data2d) VALUES(?,?,?,?,?);";
5073 UDEBUG(
"Save depth %d (size=%d) depth2d = %d",
5098 float fx=0, fyOrBaseline=0, cx=0, cy=0;
5103 uFormat(
"Database version %s doesn't support multi-camera!",
_version.c_str()).c_str());
5109 localTransform = sensorData.
cameraModels()[0].localTransform();
5168 return "UPDATE Depth SET data=? WHERE id=?;";
5172 return "UPDATE Data SET depth=? WHERE id=?;";
5185 cv::Mat imageCompressed;
5186 if(!image.empty() && (image.type()!=CV_8UC1 || image.rows > 1))
5193 imageCompressed = image;
5195 if(!imageCompressed.empty())
5222 return "INSERT INTO Data(id, image, depth, calibration, scan_info, scan, user_data, ground_cells, obstacle_cells, empty_cells, cell_size, view_point_x, view_point_y, view_point_z) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
5226 return "INSERT INTO Data(id, image, depth, calibration, scan_info, scan, user_data, ground_cells, obstacle_cells, cell_size, view_point_x, view_point_y, view_point_z) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?);";
5230 return "INSERT INTO Data(id, image, depth, calibration, scan_max_pts, scan_max_range, scan, user_data) VALUES(?,?,?,?,?,?,?,?);";
5234 return "INSERT INTO Data(id, image, depth, calibration, scan_max_pts, scan, user_data) VALUES(?,?,?,?,?,?,?);";
5238 return "INSERT INTO Data(id, image, depth, calibration, scan_max_pts, scan) VALUES(?,?,?,?,?,?);";
5245 UDEBUG(
"Save sensor data %d (image=%d depth=%d) depth2d = %d",
5285 std::vector<float> calibration;
5293 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
5297 calibration[i*(6+localTransform.size())] = sensorData.
cameraModels()[i].fx();
5298 calibration[i*(6+localTransform.size())+1] = sensorData.
cameraModels()[i].fy();
5299 calibration[i*(6+localTransform.size())+2] = sensorData.
cameraModels()[i].cx();
5300 calibration[i*(6+localTransform.size())+3] = sensorData.
cameraModels()[i].cy();
5301 calibration[i*(6+localTransform.size())+4] = sensorData.
cameraModels()[i].imageWidth();
5302 calibration[i*(6+localTransform.size())+5] = sensorData.
cameraModels()[i].imageHeight();
5303 memcpy(calibration.data()+i*(6+localTransform.size())+6, localTransform.data(), localTransform.size()*
sizeof(float));
5309 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
5313 calibration[i*(4+localTransform.size())] = sensorData.
cameraModels()[i].fx();
5314 calibration[i*(4+localTransform.size())+1] = sensorData.
cameraModels()[i].fy();
5315 calibration[i*(4+localTransform.size())+2] = sensorData.
cameraModels()[i].cx();
5316 calibration[i*(4+localTransform.size())+3] = sensorData.
cameraModels()[i].cy();
5317 memcpy(calibration.data()+i*(4+localTransform.size())+4, localTransform.data(), localTransform.size()*
sizeof(float));
5324 calibration.resize(7+localTransform.
size());
5332 memcpy(calibration.data()+7, localTransform.
data(), localTransform.
size()*
sizeof(float));
5335 if(calibration.size())
5345 std::vector<float> scanInfo;
5355 scanInfo.resize(3 +
Transform().size());
5360 memcpy(scanInfo.data()+3, localTransform.
data(), localTransform.
size()*
sizeof(float));
5364 scanInfo.resize(2 +
Transform().size());
5368 memcpy(scanInfo.data()+2, localTransform.
data(), localTransform.
size()*
sizeof(float));
5489 return "UPDATE Link SET type=?, information_matrix=?, transform=?, user_data=? WHERE from_id=? AND to_id = ?;";
5493 return "UPDATE Link SET type=?, rot_variance=?, trans_variance=?, transform=?, user_data=? WHERE from_id=? AND to_id = ?;";
5497 return "UPDATE Link SET type=?, rot_variance=?, trans_variance=?, transform=? WHERE from_id=? AND to_id = ?;";
5501 return "UPDATE Link SET type=?, variance=?, transform=? WHERE from_id=? AND to_id = ?;";
5505 return "UPDATE Link SET type=?, transform=? WHERE from_id=? AND to_id = ?;";
5513 return "INSERT INTO Link(type, information_matrix, transform, user_data, from_id, to_id) VALUES(?,?,?,?,?,?);";
5517 return "INSERT INTO Link(type, rot_variance, trans_variance, transform, user_data, from_id, to_id) VALUES(?,?,?,?,?,?,?);";
5521 return "INSERT INTO Link(type, rot_variance, trans_variance, transform, from_id, to_id) VALUES(?,?,?,?,?,?);";
5525 return "INSERT INTO Link(type, variance, transform, from_id, to_id) VALUES(?,?,?,?,?);";
5529 return "INSERT INTO Link(type, transform, from_id, to_id) VALUES(?,?,?,?);";
5534 const Link & link)
const 5540 UDEBUG(
"Save link from %d to %d, type=%d", link.
from(), link.
to(), link.
type());
5545 UDEBUG(
"Virtual link ignored....");
5606 return "UPDATE Feature SET word_id = ? WHERE word_id = ? AND node_id = ?;";
5610 return "UPDATE Map_Node_Word SET word_id = ? WHERE word_id = ? AND node_id = ?;";
5639 return "INSERT INTO Feature(node_id, word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?);";
5643 return "INSERT INTO Map_Node_Word(node_id, word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?);";
5647 return "INSERT INTO Map_Node_Word(node_id, word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z, descriptor_size, descriptor) VALUES(?,?,?,?,?,?,?,?,?,?,?,?);";
5649 return "INSERT INTO Map_Node_Word(node_id, word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z) VALUES(?,?,?,?,?,?,?,?,?,?);";
5654 const cv::KeyPoint & kp,
5655 const cv::Point3f & pt,
5656 const cv::Mat & descriptor)
const 5722 UASSERT(descriptor.empty() || descriptor.type() == CV_32F || descriptor.type() == CV_8U);
5723 if(descriptor.empty())
5729 if(descriptor.type() == CV_32F)
5755 return "UPDATE Data SET ground_cells=?, obstacle_cells=?, empty_cells=?, cell_size=?, view_point_x=?, view_point_y=?, view_point_z=? WHERE id=?;";
5757 return "UPDATE Data SET ground_cells=?, obstacle_cells=?, cell_size=?, view_point_x=?, view_point_y=?, view_point_z=? WHERE id=?;";
5761 const cv::Mat & ground,
5762 const cv::Mat & obstacles,
5763 const cv::Mat & empty,
5765 const cv::Point3f & viewpoint)
const 5768 UASSERT(ground.empty() || ground.type() == CV_8UC1);
5769 UASSERT(obstacles.empty() || obstacles.type() == CV_8UC1);
5770 UASSERT(empty.empty() || empty.type() == CV_8UC1);
5771 UDEBUG(
"Update occupancy grid %d: ground=%d obstacles=%d empty=%d cell=%f viewpoint=(%f,%f,%f)",
5802 if(obstacles.empty())
#define sqlite3_memory_used
int loadOrSaveDb(sqlite3 *pInMemory, const std::string &fileName, int isSave) const
virtual long getUserDataMemoryUsedQuery() const
void setTempStore(int tempStore)
std::string queryStepNode() const
cv::Mat RTABMAP_EXP uncompressData(const cv::Mat &bytes)
void setOccupancyGrid(const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewPoint)
virtual std::map< int, std::vector< int > > getAllStatisticsWmStatesQuery() const
virtual long getLaserScansMemoryUsedQuery() const
void stepImage(sqlite3_stmt *ppStmt, int id, const cv::Mat &imageBytes) const
const cv::Mat & data() const
virtual void loadQuery(VWDictionary *dictionary, bool lastStateOnly=true) const
virtual void getWeightQuery(int signatureId, int &weight) const
const LaserScan & laserScanCompressed() const
const Transform & getGroundTruthPose() const
std::string queryStepImage() const
virtual cv::Mat load2DMapQuery(float &xMin, float &yMin, float &cellSize) const
virtual bool getNodeInfoQuery(int signatureId, Transform &pose, int &mapId, int &weight, std::string &label, double &stamp, Transform &groundTruthPose, std::vector< float > &velocity, GPS &gps) const
virtual std::map< int, std::pair< std::map< std::string, float >, double > > getAllStatisticsQuery() const
const std::vector< float > & getVelocity() const
#define ULOGGER_INFO(...)
virtual void loadLastNodesQuery(std::list< Signature * > &signatures) const
#define sqlite3_threadsafe
virtual void addLinkQuery(const Link &link) const
int uStrNumCmp(const std::string &a, const std::string &b)
#define sqlite3_backup_finish
virtual std::map< std::string, float > getStatisticsQuery(int nodeId, double &stamp, std::vector< int > *wmState) const
void stepKeypoint(sqlite3_stmt *ppStmt, int signatureId, int wordId, const cv::KeyPoint &kp, const cv::Point3f &pt, const cv::Mat &descriptor) const
bool UTILITE_EXP uStr2Bool(const char *str)
void setCacheSize(unsigned int cacheSize)
#define sqlite3_backup_init
static int erase(const std::string &filePath)
virtual void saveOptimizedPosesQuery(const std::map< int, Transform > &optimizedPoses, const Transform &lastlocalizationPose) const
double transVariance() const
virtual long getCalibrationsMemoryUsedQuery() const
struct sqlite3_stmt sqlite3_stmt
std::map< std::string, std::string > ParametersMap
virtual void getAllNodeIdsQuery(std::set< int > &ids, bool ignoreChildren, bool ignoreBadSignatures) const
float gridCellSize() const
virtual int getTotalDictionarySizeQuery() const
const cv::Mat & gridObstacleCellsCompressed() const
double rotVariance() const
const std::string & getUrl() const
virtual void getInvertedIndexNiQuery(int signatureId, int &ni) const
virtual void loadSignaturesQuery(const std::list< int > &ids, std::list< Signature * > &signatures) const
const cv::Mat & gridGroundCellsCompressed() const
virtual long getLinksMemoryUsedQuery() const
const cv::Mat & gridEmptyCellsCompressed() const
void stepSensorData(sqlite3_stmt *ppStmt, const SensorData &sensorData) const
virtual void saveOptimizedMeshQuery(const cv::Mat &cloud, const std::vector< std::vector< std::vector< unsigned int > > > &polygons, const std::vector< std::vector< Eigen::Vector2f > > &texCoords, const cv::Mat &textures) const
#define sqlite3_column_int64
virtual void getAllLabelsQuery(std::map< int, std::string > &labels) const
virtual bool getDatabaseVersionQuery(std::string &version) const
std::string queryStepDepth() const
virtual void loadWordsQuery(const std::set< int > &wordIds, std::list< VisualWord * > &vws) const
const Transform & transform() const
void setJournalMode(int journalMode)
#define sqlite3_column_int
const std::string & getLabel() const
void stepDepthUpdate(sqlite3_stmt *ppStmt, int nodeId, const cv::Mat &imageCompressed) const
bool uIsFinite(const T &value)
bool openConnection(const std::string &url, bool overwritten=false)
#define UASSERT(condition)
virtual bool getCalibrationQuery(int signatureId, std::vector< CameraModel > &models, StereoCameraModel &stereoModel) const
void setLastWordId(int id)
#define sqlite3_column_text
virtual bool getLaserScanInfoQuery(int signatureId, LaserScan &info) const
const std::map< std::string, float > & data() const
std::string queryStepWordsChanged() const
#define sqlite3_bind_zeroblob
std::string queryStepDepthUpdate() const
bool isValidForProjection() const
const CameraModel & left() const
std::string queryStepOccupancyGridUpdate() const
static std::string serializeData(const std::map< std::string, float > &data)
#define SQLITE_OPEN_CREATE
virtual std::map< int, Transform > loadOptimizedPosesQuery(Transform *lastlocalizationPose) const
const cv::Mat & depthOrRightCompressed() const
#define ULOGGER_DEBUG(...)
virtual void loadLinksQuery(int signatureId, std::map< int, Link > &links, Link::Type type=Link::kUndef) const
static ParametersMap deserialize(const std::string ¶meters)
virtual void loadNodeDataQuery(std::list< Signature * > &signatures, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true) const
virtual void updateLinkQuery(const Link &link) const
#define UASSERT_MSG(condition, msg_str)
#define SQLITE_OPEN_READWRITE
void closeConnection(bool save=true, const std::string &outputUrl="")
virtual void executeNoResultQuery(const std::string &sql) const
std::string UTILITE_EXP uHex2Str(const std::string &hex)
virtual ~DBDriverSqlite3()
#define sqlite3_bind_double
const double & error() const
virtual void updateOccupancyGridQuery(int nodeId, const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewpoint) const
const cv::Mat & getDescriptor() const
virtual void getAllLinksQuery(std::multimap< int, Link > &links, bool ignoreNullLinks) const
virtual long getFeaturesMemoryUsedQuery() const
virtual void save2DMapQuery(const cv::Mat &map, float xMin, float yMin, float cellSize) const
void stepLink(sqlite3_stmt *ppStmt, const Link &link) const
virtual void savePreviewImageQuery(const cv::Mat &image) const
void stepDepth(sqlite3_stmt *ppStmt, const SensorData &sensorData) const
void stepOccupancyGridUpdate(sqlite3_stmt *ppStmt, int nodeId, const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewpoint) const
#define sqlite3_bind_null
std::string queryStepSensorData() const
const cv::Mat & userDataCompressed() const
virtual bool isConnectedQuery() const
Transform localTransform() const
const cv::Mat & infMatrix() const
virtual void saveQuery(const std::list< Signature * > &signatures)
cv::Mat RTABMAP_EXP compressData2(const cv::Mat &data)
#define sqlite3_column_type
#define sqlite3_bind_blob
#define sqlite3_column_double
DBDriverSqlite3(const ParametersMap ¶meters=ParametersMap())
virtual int getLastDictionarySizeQuery() const
virtual ParametersMap getLastParametersQuery() const
virtual long getImagesMemoryUsedQuery() const
const cv::Mat & userDataCompressed() const
virtual void disconnectDatabaseQuery(bool save=true, const std::string &outputUrl="")
#define sqlite3_prepare_v2
const double & longitude() const
const std::vector< CameraModel > & cameraModels() const
const Transform & getPose() const
virtual void updateQuery(const std::list< Signature * > &signatures, bool updateTimestamp) const
void stepNode(sqlite3_stmt *ppStmt, const Signature *s) const
const double & altitude() const
#define sqlite3_next_stmt
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
SensorData & sensorData()
virtual int getTotalNodesSizeQuery() const
const std::vector< int > & wmState() const
void setDbInMemory(bool dbInMemory)
cv::Mat RTABMAP_EXP compressString(const std::string &str)
virtual void getNodeIdByLabelQuery(const std::string &label, int &id) const
virtual void parseParameters(const ParametersMap ¶meters)
virtual long getDepthImagesMemoryUsedQuery() const
const StereoCameraModel & stereoCameraModel() const
virtual void updateDepthImageQuery(int nodeId, const cv::Mat &image) const
std::string RTABMAP_EXP uncompressString(const cv::Mat &bytes)
std::string queryStepLink() const
virtual long getStatisticsMemoryUsedQuery() const
const cv::Mat & imageCompressed() const
std::string getDatabaseVersion() const
virtual cv::Mat loadOptimizedMeshQuery(std::vector< std::vector< std::vector< unsigned int > > > *polygons, std::vector< std::vector< Eigen::Vector2f > > *texCoords, cv::Mat *textures) const
static int rename(const std::string &oldFilePath, const std::string &newFilePath)
void setSynchronous(int synchronous)
virtual bool connectDatabaseQuery(const std::string &url, bool overwritten=false)
#define sqlite3_column_bytes
#define sqlite3_backup_step
void setSaved(bool saved)
static std::map< std::string, float > deserializeData(const std::string &data)
void join(bool killFirst=false)
virtual long getWordsMemoryUsedQuery() const
virtual void getLastIdQuery(const std::string &tableName, int &id) const
#define sqlite3_bind_text
virtual void addWord(VisualWord *vw)
void stepWordsChanged(sqlite3_stmt *ppStmt, int signatureId, int oldWordId, int newWordId) const
virtual long getGridsMemoryUsedQuery() const
#define ULOGGER_ERROR(...)
const double & latitude() const
std::string queryStepLinkUpdate() const
std::string queryStepKeypoint() const
const double & bearing() const
std::string UTILITE_EXP uFormat(const char *fmt,...)
std::string UTILITE_EXP uNumber2Str(unsigned int number)
void getLastWordId(int &id) const
virtual void parseParameters(const ParametersMap ¶meters)
virtual void addStatisticsQuery(const Statistics &statistics) const
const cv::Point3f & gridViewPoint() const
virtual int getLastNodesSizeQuery() const
void emptyTrashes(bool async=false)
cv::Mat RTABMAP_EXP uncompressImage(const cv::Mat &bytes)
#define sqlite3_column_blob
virtual long getNodesMemoryUsedQuery() const
const Transform & localTransform() const
cv::Mat RTABMAP_EXP compressImage2(const cv::Mat &image, const std::string &format=".png")
virtual cv::Mat loadPreviewImageQuery() const
virtual long getMemoryUsedQuery() const
const double & stamp() const