36 #include "DatabaseSchema_sql.h" 37 #include "DatabaseSchema_0_18_3_sql.h" 38 #include "DatabaseSchema_0_18_0_sql.h" 39 #include "DatabaseSchema_0_17_0_sql.h" 40 #include "DatabaseSchema_0_16_2_sql.h" 41 #include "DatabaseSchema_0_16_1_sql.h" 42 #include "DatabaseSchema_0_16_0_sql.h" 55 _memoryUsedEstimate(0),
56 _dbInMemory(
Parameters::defaultDbSqlite3InMemory()),
57 _cacheSize(
Parameters::defaultDbSqlite3CacheSize()),
58 _journalMode(
Parameters::defaultDbSqlite3JournalMode()),
59 _synchronous(
Parameters::defaultDbSqlite3Synchronous()),
60 _tempStore(
Parameters::defaultDbSqlite3TempStore())
73 ParametersMap::const_iterator iter;
74 if((iter=parameters.find(Parameters::kDbSqlite3CacheSize())) != parameters.end())
78 if((iter=parameters.find(Parameters::kDbSqlite3JournalMode())) != parameters.end())
82 if((iter=parameters.find(Parameters::kDbSqlite3Synchronous())) != parameters.end())
86 if((iter=parameters.find(Parameters::kDbSqlite3TempStore())) != parameters.end())
90 if((iter=parameters.find(Parameters::kDbSqlite3InMemory())) != parameters.end())
102 std::string query =
"PRAGMA cache_size = ";
110 if(journalMode >= 0 && journalMode < 5)
144 if(synchronous >= 0 && synchronous < 3)
172 if(tempStore >= 0 && tempStore < 3)
200 UDEBUG(
"dbInMemory=%d", dbInMemory?1:0);
254 pFrom = (isSave ? pInMemory : pFile);
255 pTo = (isSave ? pFile : pInMemory);
292 std::stringstream query;
294 query <<
"SELECT version FROM Admin;";
329 bool dbFileExist =
false;
333 if(dbFileExist && overwritten)
335 UINFO(
"Deleting database %s...", url.c_str());
349 ULOGGER_INFO(
"Using database \"%s\" in the memory.", url.c_str());
359 ULOGGER_INFO(
"Using database \"%s\" from the hard drive.", url.c_str());
364 UFATAL(
"DB error : %s (path=\"%s\"). Make sure that your user has write " 365 "permission on the target directory (you may have to change the working directory). ",
sqlite3_errmsg(
_ppDb), url.c_str());
390 ULOGGER_INFO(
"Database \"%s\" doesn't exist, creating a new one...", url.c_str());
393 std::string schema = DATABASESCHEMA_SQL;
395 if(!targetVersion.empty())
398 std::vector<std::pair<std::string, std::string> > schemas;
399 schemas.push_back(std::make_pair(
"0.16.0", DATABASESCHEMA_0_16_0_SQL));
400 schemas.push_back(std::make_pair(
"0.16.1", DATABASESCHEMA_0_16_1_SQL));
401 schemas.push_back(std::make_pair(
"0.16.2", DATABASESCHEMA_0_16_2_SQL));
402 schemas.push_back(std::make_pair(
"0.17.0", DATABASESCHEMA_0_17_0_SQL));
403 schemas.push_back(std::make_pair(
"0.18.0", DATABASESCHEMA_0_18_0_SQL));
404 schemas.push_back(std::make_pair(
"0.18.3", DATABASESCHEMA_0_18_3_SQL));
405 schemas.push_back(std::make_pair(
uNumber2Str(RTABMAP_VERSION_MAJOR)+
"."+
uNumber2Str(RTABMAP_VERSION_MINOR), DATABASESCHEMA_SQL));
406 for(
size_t i=0; i<schemas.size(); ++i)
408 if(
uStrNumCmp(targetVersion, schemas[i].first) < 0)
412 UERROR(
"Cannot create database with target version \"%s\" (not implemented), using latest version.", targetVersion.c_str());
418 schema = schemas[i].second;
432 UERROR(
"Opened database version (%s) is more recent than rtabmap " 433 "installed version (%s). Please update rtabmap to new version!",
468 std::string outputFile = this->
getUrl();
469 if(!outputUrl.empty())
471 outputFile = outputUrl;
473 if(outputFile.empty())
475 UWARN(
"Database was initialized with an empty url (in memory). To save it, " 476 "the output url should not be empty. The database is thus closed without being saved!");
480 UINFO(
"Saving database to %s ...", outputFile.c_str());
483 "permission on the target directory (you may have to change the working directory). ",
_version.c_str(), outputFile.c_str(),
sqlite3_errmsg(
_ppDb)).c_str());
489 UINFO(
"Disconnecting database %s...", this->
getUrl().c_str());
493 if(save && !
_dbInMemory && !outputUrl.empty() && !this->
getUrl().empty() && outputUrl.compare(this->
getUrl()) != 0)
495 UWARN(
"Output database path (%s) is different than the opened database " 496 "path (%s). Opened database path is overwritten then renamed to output path.",
497 outputUrl.c_str(), this->
getUrl().c_str());
500 UERROR(
"Failed to rename just closed db %s to %s", this->
getUrl().c_str(), outputUrl.c_str());
546 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) + ifnull(length(env_sensors),0) + length(time_enter)) from Node;";
550 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;";
554 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;";
558 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;";
562 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose) + length(stamp) + ifnull(length(label),0) + length(time_enter)) from Node;";
566 query =
"SELECT sum(length(id) + length(map_id) + length(weight) + length(pose)+ length(time_enter)) from Node;";
594 query =
"SELECT sum(length(type) + length(information_matrix) + length(transform) + ifnull(length(user_data),0) + length(from_id) + length(to_id)) from Link;";
598 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;";
602 query =
"SELECT sum(length(type) + length(rot_variance) + length(trans_variance) + length(transform) + length(from_id) + length(to_id)) from Link;";
606 query =
"SELECT sum(length(type) + length(variance) + length(transform) + length(from_id) + length(to_id)) from Link;";
610 query =
"SELECT sum(length(type) + length(transform) + length(from_id) + length(to_id)) from Link;";
638 query =
"SELECT sum(ifnull(length(image),0) + ifnull(length(time_enter),0)) from Data;";
642 query =
"SELECT sum(length(data) + ifnull(length(time_enter),0)) from Image;";
670 query =
"SELECT sum(ifnull(length(depth),0) + ifnull(length(time_enter),0)) from Data;";
674 query =
"SELECT sum(length(data) + ifnull(length(time_enter),0)) from Depth;";
703 query =
"SELECT sum(length(calibration)) from Data;";
707 query =
"SELECT sum(length(fx) + length(fy) + length(cx) + length(cy) + length(local_transform)) from Depth;";
711 query =
"SELECT sum(length(constant) + length(local_transform)) from Depth;";
740 query =
"SELECT sum(ifnull(length(ground_cells),0) + ifnull(length(obstacle_cells),0) + ifnull(length(empty_cells),0) + length(cell_size) + length(view_point_x) + length(view_point_y) + length(view_point_z)) from Data;";
744 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;";
777 query =
"SELECT sum(ifnull(length(scan_info),0) + ifnull(length(scan),0)) from Data;";
781 query =
"SELECT sum(length(scan_max_pts) + length(scan_max_range) + ifnull(length(scan),0)) from Data;";
785 query =
"SELECT sum(length(scan_max_pts) + ifnull(length(scan),0)) from Data;";
789 query =
"SELECT sum(length(data2d) + length(data2d_max_pts)) from Depth;";
793 query =
"SELECT sum(length(data2d)) from Depth;";
821 query =
"SELECT sum(length(user_data)) from Data;";
825 query =
"SELECT sum(length(user_data)) from Node;";
854 std::string query =
"SELECT sum(length(id) + length(descriptor_size) + length(descriptor) + length(time_enter)) from Word;";
881 query =
"SELECT sum(length(node_id) + 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)) " 886 query =
"SELECT sum(length(node_id) + 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)) " 887 "FROM Map_Node_Word";
891 query =
"SELECT sum(length(node_id) + 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)) " 892 "FROM Map_Node_Word";
896 query =
"SELECT sum(length(node_id) + length(word_id) + length(pos_x) + length(pos_y) + length(size) + length(dir) + length(response) + length(depth_x) + length(depth_y) + length(depth_z)) " 897 "FROM Map_Node_Word";
925 query =
"SELECT sum(length(id) + length(stamp) + ifnull(length(data),0) + ifnull(length(wm_state),0)) FROM Statistics;";
929 query =
"SELECT sum(length(id) + length(stamp) + length(data)) FROM Statistics;";
961 query =
"SELECT count(id) from Node WHERE time_enter >= (SELECT MAX(time_enter) FROM Info);";
965 query =
"SELECT count(id) from Node WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics);";
993 query =
"SELECT count(id) from Word WHERE time_enter >= (SELECT MAX(time_enter) FROM Info);";
997 query =
"SELECT count(id) from Word WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics);";
1022 std::string query =
"SELECT count(id) from Node;";
1046 std::string query =
"SELECT count(id) from Word;";
1076 query =
"SELECT parameters " 1078 "WHERE time_enter >= (SELECT MAX(time_enter) FROM Info);";
1082 query =
"SELECT parameters " 1084 "WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics);";
1113 UDEBUG(
"nodeId=%d", nodeId);
1114 std::map<std::string, float> data;
1119 std::stringstream query;
1123 query <<
"SELECT stamp, data, wm_state " 1124 <<
"FROM Statistics " 1125 <<
"WHERE id=" << nodeId <<
";";
1129 query <<
"SELECT stamp, data " 1130 <<
"FROM Statistics " 1131 <<
"WHERE id=" << nodeId <<
";";
1149 if(dataSize>0 && dataPtr)
1168 if(dataSize>0 && dataPtr)
1170 cv::Mat wmStateMat =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)dataPtr));
1171 UASSERT(wmStateMat.type() == CV_32SC1 && wmStateMat.rows == 1);
1172 wmState->resize(wmStateMat.cols);
1173 memcpy(wmState->data(), wmStateMat.data, wmState->size()*
sizeof(int));
1190 std::map<int, std::pair<std::map<std::string, float>,
double> > data;
1195 std::stringstream query;
1197 query <<
"SELECT id, stamp, data " 1198 <<
"FROM Statistics;";
1214 const void * dataPtr = 0;
1218 if(dataSize>0 && dataPtr)
1247 std::map<int, std::vector<int> > data;
1252 std::stringstream query;
1254 query <<
"SELECT id, wm_state " 1255 <<
"FROM Statistics;";
1267 std::vector<int> wmState;
1270 if(dataSize>0 && dataPtr)
1272 cv::Mat wmStateMat =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)dataPtr));
1273 UASSERT(wmStateMat.type() == CV_32SC1 && wmStateMat.rows == 1);
1274 wmState.resize(wmStateMat.cols);
1275 memcpy(wmState.data(), wmStateMat.data, wmState.size()*
sizeof(int));
1278 if(!wmState.empty())
1280 data.insert(std::make_pair(
id, wmState));
1296 UDEBUG(
"load data for %d signatures images=%d scan=%d userData=%d, grid=%d",
1297 (
int)signatures.size(), images?1:0, scan?1:0, userData?1:0, occupancyGrid?1:0);
1299 if(!images && !scan && !userData && !occupancyGrid)
1301 UWARN(
"All requested data fields are false! Nothing loaded...");
1311 std::stringstream query;
1315 std::stringstream fields;
1319 fields <<
"image, depth, calibration";
1320 if(scan || userData || occupancyGrid)
1327 fields <<
"scan_info, scan";
1328 if(userData || occupancyGrid)
1335 fields <<
"user_data";
1345 fields <<
"ground_cells, obstacle_cells, empty_cells, cell_size, view_point_x, view_point_y, view_point_z";
1349 fields <<
"ground_cells, obstacle_cells, cell_size, view_point_x, view_point_y, view_point_z";
1353 query <<
"SELECT " << fields.str().c_str() <<
" " 1360 query <<
"SELECT image, depth, calibration, scan_max_pts, scan_max_range, scan, user_data " 1367 query <<
"SELECT image, depth, calibration, scan_max_pts, scan, user_data " 1374 query <<
"SELECT Data.image, Data.depth, Data.calibration, Data.scan_max_pts, Data.scan, Node.user_data " 1376 <<
"INNER JOIN Node " 1377 <<
"ON Data.id = Node.id " 1378 <<
"WHERE Data.id = ?" 1383 query <<
"SELECT Image.data, " 1384 "Depth.data, Depth.local_transform, Depth.fx, Depth.fy, Depth.cx, Depth.cy, Depth.data2d_max_pts, Depth.data2d, Node.user_data " 1386 <<
"INNER JOIN Node " 1387 <<
"on Image.id = Node.id " 1388 <<
"LEFT OUTER JOIN Depth " 1389 <<
"ON Image.id = Depth.id " 1390 <<
"WHERE Image.id = ?" 1395 query <<
"SELECT Image.data, " 1396 "Depth.data, Depth.local_transform, Depth.fx, Depth.fy, Depth.cx, Depth.cy, Depth.data2d, Node.user_data " 1398 <<
"INNER JOIN Node " 1399 <<
"on Image.id = Node.id " 1400 <<
"LEFT OUTER JOIN Depth " 1401 <<
"ON Image.id = Depth.id " 1402 <<
"WHERE Image.id = ?" 1407 query <<
"SELECT Image.data, " 1408 "Depth.data, Depth.local_transform, Depth.fx, Depth.fy, Depth.cx, Depth.cy, Depth.data2d " 1410 <<
"LEFT OUTER JOIN Depth " 1411 <<
"ON Image.id = Depth.id " 1412 <<
"WHERE Image.id = ?" 1417 query <<
"SELECT Image.data, " 1418 "Depth.data, Depth.local_transform, Depth.constant, Depth.data2d " 1420 <<
"LEFT OUTER JOIN Depth " 1421 <<
"ON Image.id = Depth.id " 1422 <<
"WHERE Image.id = ?" 1429 const void * data = 0;
1433 for(std::list<Signature*>::iterator iter = signatures.begin(); iter!=signatures.end(); ++iter)
1448 cv::Mat imageCompressed;
1449 cv::Mat depthOrRightCompressed;
1450 std::vector<CameraModel> models;
1453 cv::Mat scanCompressed;
1454 cv::Mat userDataCompressed;
1461 if(dataSize>4 && data)
1463 imageCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1469 if(dataSize>4 && data)
1471 depthOrRightCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1478 if((
unsigned int)dataSize == localTransform.
size()*
sizeof(float) && data)
1480 memcpy(localTransform.
data(), data, dataSize);
1495 if(dataSize > 0 && data)
1499 if(dataSize >=
int(
sizeof(
int)*4))
1501 const int * dataInt = (
const int *)data;
1502 int type = dataInt[3];
1506 int bytesReadTotal = 0;
1507 unsigned int bytesRead = 0;
1508 while(bytesReadTotal < dataSize &&
1509 (bytesRead=model.
deserialize((
const unsigned char *)data+bytesReadTotal, dataSize-bytesReadTotal))!=0)
1511 bytesReadTotal+=bytesRead;
1512 models.push_back(model);
1514 UASSERT(bytesReadTotal == dataSize);
1518 int bytesRead = (int)stereoModel.
deserialize((
unsigned char*)data, dataSize);
1519 UASSERT(bytesRead == dataSize);
1523 UFATAL(
"Unknown calibration type %d", type);
1528 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
1533 float * dataFloat = (
float*)data;
1535 (
unsigned int)dataSize % (6+localTransform.
size())*
sizeof(
float) == 0)
1537 int cameraCount = dataSize / ((6+localTransform.
size())*
sizeof(
float));
1538 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1539 int max = cameraCount*(6+localTransform.
size());
1540 for(
int i=0; i<
max; i+=6+localTransform.
size())
1544 memcpy(localTransform.
data(), dataFloat+i+6, localTransform.
size()*
sizeof(float));
1550 (
double)dataFloat[i],
1551 (
double)dataFloat[i+1],
1552 (
double)dataFloat[i+2],
1553 (
double)dataFloat[i+3],
1555 models.back().setImageSize(cv::Size(dataFloat[i+4], dataFloat[i+5]));
1556 UDEBUG(
"%f %f %f %f %f %f %s", dataFloat[i], dataFloat[i+1], dataFloat[i+2],
1557 dataFloat[i+3], dataFloat[i+4], dataFloat[i+5],
1562 (
unsigned int)dataSize % (4+localTransform.
size())*
sizeof(
float) == 0)
1564 int cameraCount = dataSize / ((4+localTransform.
size())*
sizeof(
float));
1565 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1566 int max = cameraCount*(4+localTransform.
size());
1567 for(
int i=0; i<
max; i+=4+localTransform.
size())
1571 memcpy(localTransform.
data(), dataFloat+i+4, localTransform.
size()*
sizeof(float));
1577 (
double)dataFloat[i],
1578 (
double)dataFloat[i+1],
1579 (
double)dataFloat[i+2],
1580 (
double)dataFloat[i+3],
1584 else if((
unsigned int)dataSize == (7+localTransform.
size())*
sizeof(
float))
1586 UDEBUG(
"Loading calibration of a stereo camera");
1587 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
1599 cv::Size(dataFloat[5],dataFloat[6]));
1601 else if((
unsigned int)dataSize == (5+localTransform.
size())*
sizeof(
float))
1603 UDEBUG(
"Loading calibration of a stereo camera");
1604 memcpy(localTransform.
data(), dataFloat+5, localTransform.
size()*
sizeof(float));
1619 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
1627 UDEBUG(
"Loading calibration version >= 0.7.0");
1632 if(fyOrBaseline < 1.0)
1639 models.push_back(
CameraModel(fx, fyOrBaseline, cx, cy, localTransform));
1644 UDEBUG(
"Loading calibration version < 0.7.0");
1646 float fx = 1.0f/depthConstant;
1647 float fy = 1.0f/depthConstant;
1650 models.push_back(
CameraModel(fx, fy, cx, cy, localTransform));
1654 int laserScanMaxPts = 0;
1655 float laserScanMinRange = 0.0f;
1656 float laserScanMaxRange = 0.0f;
1657 int laserScanFormat = 0;
1658 float laserScanAngleMin = 0.0f;
1659 float laserScanAngleMax = 0.0f;
1660 float laserScanAngleInc = 0.0f;
1670 if(dataSize > 0 && data)
1672 float * dataFloat = (
float*)data;
1676 UASSERT(dataSize == (
int)((scanLocalTransform.
size()+7)*
sizeof(
float)));
1677 laserScanFormat = (int)dataFloat[0];
1678 laserScanMinRange = dataFloat[1];
1679 laserScanMaxRange = dataFloat[2];
1680 laserScanAngleMin = dataFloat[3];
1681 laserScanAngleMax = dataFloat[4];
1682 laserScanAngleInc = dataFloat[5];
1683 laserScanMaxPts = (int)dataFloat[6];
1684 memcpy(scanLocalTransform.
data(), dataFloat+7, scanLocalTransform.
size()*
sizeof(float));
1688 if(
uStrNumCmp(
_version,
"0.16.1") >= 0 && dataSize == (
int)((scanLocalTransform.
size()+3)*
sizeof(
float)))
1691 laserScanFormat = (int)dataFloat[2];
1692 memcpy(scanLocalTransform.
data(), dataFloat+3, scanLocalTransform.
size()*
sizeof(float));
1694 else if(dataSize == (
int)((scanLocalTransform.
size()+2)*
sizeof(
float)))
1696 memcpy(scanLocalTransform.
data(), dataFloat+2, scanLocalTransform.
size()*
sizeof(float));
1700 UFATAL(
"Unexpected size %d for laser scan info!", dataSize);
1707 laserScanMaxPts = (int)dataFloat[0];
1708 laserScanMaxRange = dataFloat[1];
1728 if(dataSize>4 && data)
1730 scanCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1741 if(dataSize>4 && data)
1745 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
1750 userDataCompressed =
compressData2(cv::Mat(1, dataSize, CV_8SC1, (
void *)data));
1757 cv::Mat groundCellsCompressed;
1758 cv::Mat obstacleCellsCompressed;
1759 cv::Mat emptyCellsCompressed;
1760 float cellSize = 0.0f;
1761 cv::Point3f viewPoint;
1767 if(dataSize > 0 && data)
1769 groundCellsCompressed = cv::Mat(1, dataSize, CV_8UC1);
1770 memcpy((
void*)groundCellsCompressed.data, data, dataSize);
1776 if(dataSize > 0 && data)
1778 obstacleCellsCompressed = cv::Mat(1, dataSize, CV_8UC1);
1779 memcpy((
void*)obstacleCellsCompressed.data, data, dataSize);
1787 if(dataSize > 0 && data)
1789 emptyCellsCompressed = cv::Mat(1, dataSize, CV_8UC1);
1790 memcpy((
void*)emptyCellsCompressed.data, data, dataSize);
1803 if(laserScanAngleMin < laserScanAngleMax && laserScanAngleInc != 0.0
f)
1805 laserScan =
LaserScan(scanCompressed, (
LaserScan::Format)laserScanFormat, laserScanMinRange, laserScanMaxRange, laserScanAngleMin, laserScanAngleMax, laserScanAngleInc, scanLocalTransform);
1809 laserScan =
LaserScan(scanCompressed, laserScanMaxPts, laserScanMaxRange, (
LaserScan::Format)laserScanFormat, scanLocalTransform);
1811 (*iter)->sensorData().setLaserScan(laserScan);
1817 (*iter)->sensorData().setRGBDImage(imageCompressed, depthOrRightCompressed, models);
1821 (*iter)->sensorData().setStereoImage(imageCompressed, depthOrRightCompressed, stereoModel);
1826 (*iter)->sensorData().setUserData(userDataCompressed);
1831 (*iter)->sensorData().setOccupancyGrid(groundCellsCompressed, obstacleCellsCompressed, emptyCellsCompressed, cellSize, viewPoint);
1852 std::vector<CameraModel> & models,
1856 if(
_ppDb && signatureId)
1860 std::stringstream query;
1864 query <<
"SELECT calibration " 1866 <<
"WHERE id = " << signatureId
1871 query <<
"SELECT local_transform, fx, fy, cx, cy " 1873 <<
"WHERE id = " << signatureId
1878 query <<
"SELECT local_transform, constant " 1880 <<
"WHERE id = " << signatureId
1887 const void * data = 0;
1903 if((
unsigned int)dataSize == localTransform.
size()*
sizeof(float) && data)
1905 memcpy(localTransform.
data(), data, dataSize);
1916 if(dataSize > 0 && data)
1920 if(dataSize >=
int(
sizeof(
int)*4))
1922 const int * dataInt = (
const int *)data;
1923 int type = dataInt[3];
1927 int bytesReadTotal = 0;
1928 unsigned int bytesRead = 0;
1929 while(bytesReadTotal < dataSize &&
1930 (bytesRead=model.
deserialize((
const unsigned char *)data+bytesReadTotal, dataSize-bytesReadTotal))!=0)
1932 bytesReadTotal+=bytesRead;
1933 models.push_back(model);
1935 UASSERT(bytesReadTotal == dataSize);
1939 int bytesRead = (int)stereoModel.
deserialize((
unsigned char*)data, dataSize);
1940 UASSERT(bytesRead == dataSize);
1944 UFATAL(
"Unknown calibration type %d", type);
1949 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
1954 float * dataFloat = (
float*)data;
1956 (
unsigned int)dataSize % (6+localTransform.
size())*
sizeof(
float) == 0)
1958 int cameraCount = dataSize / ((6+localTransform.
size())*
sizeof(
float));
1959 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1960 int max = cameraCount*(6+localTransform.
size());
1961 for(
int i=0; i<
max; i+=6+localTransform.
size())
1965 memcpy(localTransform.
data(), dataFloat+i+6, localTransform.
size()*
sizeof(float));
1971 (
double)dataFloat[i],
1972 (
double)dataFloat[i+1],
1973 (
double)dataFloat[i+2],
1974 (
double)dataFloat[i+3],
1976 models.back().setImageSize(cv::Size(dataFloat[i+4], dataFloat[i+5]));
1977 UDEBUG(
"%f %f %f %f %f %f %s", dataFloat[i], dataFloat[i+1], dataFloat[i+2],
1978 dataFloat[i+3], dataFloat[i+4], dataFloat[i+5],
1983 (
unsigned int)dataSize % (4+localTransform.
size())*
sizeof(
float) == 0)
1985 int cameraCount = dataSize / ((4+localTransform.
size())*
sizeof(
float));
1986 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
1987 int max = cameraCount*(4+localTransform.
size());
1988 for(
int i=0; i<
max; i+=4+localTransform.
size())
1992 memcpy(localTransform.
data(), dataFloat+i+4, localTransform.
size()*
sizeof(float));
1998 (
double)dataFloat[i],
1999 (
double)dataFloat[i+1],
2000 (
double)dataFloat[i+2],
2001 (
double)dataFloat[i+3],
2005 else if((
unsigned int)dataSize == (7+localTransform.
size())*
sizeof(
float))
2007 UDEBUG(
"Loading calibration of a stereo camera");
2008 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
2020 cv::Size(dataFloat[5],dataFloat[6]));
2022 else if((
unsigned int)dataSize == (5+localTransform.
size())*
sizeof(
float))
2024 UDEBUG(
"Loading calibration of a stereo camera");
2025 memcpy(localTransform.
data(), dataFloat+5, localTransform.
size()*
sizeof(float));
2040 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
2048 UDEBUG(
"Loading calibration version >= 0.7.0");
2053 UDEBUG(
"fx=%f fyOrBaseline=%f cx=%f cy=%f", fx, fyOrBaseline, cx, cy);
2054 if(fyOrBaseline < 1.0)
2061 models.push_back(
CameraModel(fx, fyOrBaseline, cx, cy, localTransform));
2066 UDEBUG(
"Loading calibration version < 0.7.0");
2068 float fx = 1.0f/depthConstant;
2069 float fy = 1.0f/depthConstant;
2072 models.push_back(
CameraModel(fx, fy, cx, cy, localTransform));
2091 if(
_ppDb && signatureId)
2095 std::stringstream query;
2099 query <<
"SELECT scan_info " 2101 <<
"WHERE id = " << signatureId
2112 const void * data = 0;
2117 float minRange = 0.0f;
2118 float maxRange = 0.0f;
2119 float angleMin = 0.0f;
2120 float angleMax = 0.0f;
2121 float angleInc = 0.0f;
2134 if(dataSize > 0 && data)
2136 float * dataFloat = (
float*)data;
2139 UASSERT(dataSize == (
int)((localTransform.
size()+7)*
sizeof(
float)));
2140 format = (int)dataFloat[0];
2141 minRange = dataFloat[1];
2142 maxRange = dataFloat[2];
2143 angleMin = dataFloat[3];
2144 angleMax = dataFloat[4];
2145 angleInc = dataFloat[5];
2146 maxPts = (int)dataFloat[6];
2147 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
2154 format = (int)dataFloat[2];
2155 memcpy(localTransform.
data(), dataFloat+3, localTransform.
size()*
sizeof(float));
2157 else if(dataSize == (
int)((localTransform.
size()+2)*
sizeof(
float)))
2159 memcpy(localTransform.
data(), dataFloat+2, localTransform.
size()*
sizeof(float));
2163 UFATAL(
"Unexpected size %d for laser scan info!", dataSize);
2169 maxPts = (int)dataFloat[0];
2170 maxRange = dataFloat[1];
2173 if(angleInc != 0.0
f && angleMin < angleMax)
2198 std::string & label,
2201 std::vector<float> & velocity,
2206 if(
_ppDb && signatureId)
2210 std::stringstream query;
2214 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose, velocity, gps, env_sensors " 2216 "WHERE id = " << signatureId <<
2221 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose, velocity, gps " 2223 "WHERE id = " << signatureId <<
2228 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose, velocity " 2230 "WHERE id = " << signatureId <<
2235 query <<
"SELECT pose, map_id, weight, label, stamp, ground_truth_pose " 2237 "WHERE id = " << signatureId <<
2242 query <<
"SELECT pose, map_id, weight, label, stamp " 2244 "WHERE id = " << signatureId <<
2249 query <<
"SELECT pose, map_id, weight " 2251 "WHERE id = " << signatureId <<
2258 const void * data = 0;
2269 if((
unsigned int)dataSize == pose.
size()*
sizeof(float) && data)
2271 memcpy(pose.
data(), data, dataSize);
2286 label =
reinterpret_cast<const char*
>(p);
2294 if((
unsigned int)dataSize == groundTruthPose.
size()*
sizeof(float) && data)
2296 memcpy(groundTruthPose.
data(), data, dataSize);
2305 velocity.resize(6,0);
2308 if((
unsigned int)dataSize == velocity.size()*
sizeof(float) && data)
2310 memcpy(velocity.data(), data, dataSize);
2318 if((
unsigned int)dataSize == 6*
sizeof(
double) && data)
2320 const double * dataDouble = (
const double *)data;
2321 gps =
GPS(dataDouble[0], dataDouble[1], dataDouble[2], dataDouble[3], dataDouble[4], dataDouble[5]);
2330 UASSERT(dataSize%
sizeof(
double)==0 && (dataSize/
sizeof(
double))%3 == 0);
2331 const double * dataDouble = (
const double *)data;
2332 int sensorsNum = (dataSize/
sizeof(double))/3;
2333 for(
int i=0; i<sensorsNum;++i)
2336 sensors.insert(std::make_pair(type,
EnvSensor(type, dataDouble[i*3+1], dataDouble[i*3+2])));
2367 query =
"SELECT n.id " 2369 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Info) " 2374 query =
"SELECT n.id " 2376 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Statistics) " 2407 std::stringstream query;
2409 query <<
"SELECT DISTINCT id " 2413 query <<
"INNER JOIN Link ";
2414 query <<
"ON id = to_id ";
2415 query <<
"WHERE from_id != to_id ";
2416 query <<
"AND weight>-9 ";
2419 if(ignoreBadSignatures)
2431 query <<
" id in (select node_id from Feature) ";
2435 query <<
" id in (select node_id from Map_Node_Word) ";
2438 query <<
"ORDER BY id";
2469 std::stringstream query;
2473 query <<
"SELECT from_id, to_id, type, transform, information_matrix, user_data FROM Link WHERE type!=" <<
Link::kLandmark <<
" ORDER BY from_id, to_id";
2477 query <<
"SELECT from_id, to_id, type, transform, information_matrix, user_data FROM Link ORDER BY from_id, to_id";
2481 query <<
"SELECT from_id, to_id, type, transform, rot_variance, trans_variance, user_data FROM Link ORDER BY from_id, to_id";
2485 query <<
"SELECT from_id, to_id, type, transform, rot_variance, trans_variance FROM Link ORDER BY from_id, to_id";
2489 query <<
"SELECT from_id, to_id, type, transform, variance FROM Link ORDER BY from_id, to_id";
2493 query <<
"SELECT from_id, to_id, type, transform FROM Link ORDER BY from_id, to_id";
2502 const void * data = 0;
2519 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
2521 memcpy(transform.
data(), data, dataSize);
2529 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", fromId, toId);
2532 if(!ignoreNullLinks || !transform.
isNull())
2534 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
2541 UASSERT(dataSize==36*
sizeof(
double) && data);
2542 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
2548 UASSERT(rotVariance > 0.0 && transVariance>0.0);
2549 informationMatrix.at<
double>(0,0) = 1.0/transVariance;
2550 informationMatrix.at<
double>(1,1) = 1.0/transVariance;
2551 informationMatrix.at<
double>(2,2) = 1.0/transVariance;
2552 informationMatrix.at<
double>(3,3) = 1.0/rotVariance;
2553 informationMatrix.at<
double>(4,4) = 1.0/rotVariance;
2554 informationMatrix.at<
double>(5,5) = 1.0/rotVariance;
2557 cv::Mat userDataCompressed;
2563 if(dataSize>4 && data)
2565 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
2569 links.insert(links.end(), std::make_pair(fromId,
Link(fromId, toId, (
Link::Type)type, transform, informationMatrix, userDataCompressed)));
2575 informationMatrix *= 1.0/variance;
2576 links.insert(links.end(), std::make_pair(fromId,
Link(fromId, toId, (
Link::Type)type, transform, informationMatrix)));
2600 UDEBUG(
"get last %s from table \"%s\"", fieldName.c_str(), tableName.c_str());
2605 std::stringstream query;
2607 query <<
"SELECT COALESCE(MAX(" << fieldName <<
"), " <<
id <<
") " 2608 <<
"FROM " << tableName
2625 UDEBUG(
"No result from the DB for table %s with field %s", tableName.c_str(), fieldName.c_str());
2644 std::stringstream query;
2648 query <<
"SELECT count(word_id) " 2650 <<
"WHERE node_id=" << nodeId <<
";";
2654 query <<
"SELECT count(word_id) " 2655 <<
"FROM Map_Node_Word " 2656 <<
"WHERE node_id=" << nodeId <<
";";
2692 std::stringstream query;
2694 query <<
"SELECT from_id, type, information_matrix, transform, user_data FROM Link WHERE to_id=" << landmarkId <<
"";
2702 std::list<Link> links;
2703 const void * data = 0;
2714 cv::Mat userDataCompressed;
2715 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
2719 UASSERT(dataSize==36*
sizeof(
double) && data);
2720 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
2725 if(dataSize>4 && data)
2727 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
2734 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
2736 memcpy(transform.
data(), data, dataSize);
2740 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", fromId, landmarkId);
2745 nodes.insert(std::make_pair(fromId,
Link(fromId, landmarkId, (
Link::Type)linkType, transform, informationMatrix, userDataCompressed)));
2749 UFATAL(
"Not supported link type %d ! (fromId=%d, toId=%d)",
2750 linkType, fromId, landmarkId);
2772 std::stringstream query;
2773 query <<
"SELECT id FROM Node WHERE label='" << label <<
"'";
2802 std::stringstream query;
2803 query <<
"SELECT id,label FROM Node WHERE label IS NOT NULL";
2817 std::string label =
reinterpret_cast<const char*
>(p);
2820 labels.insert(std::make_pair(
id, label));
2843 std::stringstream query;
2845 query <<
"SELECT weight FROM node WHERE id = " 2872 if(
_ppDb && ids.size())
2879 std::stringstream query;
2880 unsigned int loaded = 0;
2885 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps, env_sensors " 2891 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps " 2897 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity " 2903 query <<
"SELECT id, map_id, weight, pose, stamp, label, ground_truth_pose " 2909 query <<
"SELECT id, map_id, weight, pose, stamp, label " 2915 query <<
"SELECT id, map_id, weight, pose " 2923 for(std::list<int>::const_iterator iter=ids.begin(); iter!=ids.end(); ++iter)
2936 std::vector<float> velocity;
2937 std::vector<double> gps;
2939 const void * data = 0;
2954 if((
unsigned int)dataSize == pose.
size()*
sizeof(float) && data)
2956 memcpy(pose.
data(), data, dataSize);
2969 label =
reinterpret_cast<const char*
>(p);
2976 if((
unsigned int)dataSize == groundTruthPose.
size()*
sizeof(float) && data)
2978 memcpy(groundTruthPose.
data(), data, dataSize);
2987 velocity.resize(6,0);
2990 if((
unsigned int)dataSize == velocity.size()*
sizeof(float) && data)
2992 memcpy(velocity.data(), data, dataSize);
3001 if((
unsigned int)dataSize == gps.size()*
sizeof(double) && data)
3003 memcpy(gps.data(), data, dataSize);
3012 UASSERT(dataSize%
sizeof(
double)==0 && (dataSize/
sizeof(
double))%3 == 0);
3013 const double * dataDouble = (
const double *)data;
3014 int sensorsNum = (dataSize/
sizeof(double))/3;
3015 for(
int i=0; i<sensorsNum;++i)
3018 sensors.insert(std::make_pair(type,
EnvSensor(type, dataDouble[i*3+1], dataDouble[i*3+2])));
3042 if(velocity.size() == 6)
3044 s->setVelocity(velocity[0], velocity[1], velocity[2], velocity[3], velocity[4], velocity[5]);
3048 s->sensorData().setGPS(
GPS(gps[0], gps[1], gps[2], gps[3], gps[4], gps[5]));
3050 s->sensorData().setEnvSensors(sensors);
3057 UERROR(
"Signature %d not found in database!", *iter);
3072 std::stringstream query2;
3075 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor " 3077 "WHERE node_id = ? ";
3081 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, octave, depth_x, depth_y, depth_z, descriptor_size, descriptor " 3082 "FROM Map_Node_Word " 3083 "WHERE node_id = ? ";
3087 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z, descriptor_size, descriptor " 3088 "FROM Map_Node_Word " 3089 "WHERE node_id = ? ";
3093 query2 <<
"SELECT word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z " 3094 "FROM Map_Node_Word " 3095 "WHERE node_id = ? ";
3098 query2 <<
" ORDER BY word_id";
3104 float nanFloat = std::numeric_limits<float>::quiet_NaN ();
3106 for(std::list<Signature*>::const_iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
3113 int visualWordId = 0;
3114 int descriptorSize = 0;
3115 const void * descriptor = 0;
3118 std::multimap<int, int> visualWords;
3119 std::vector<cv::KeyPoint> visualWordsKpts;
3120 std::vector<cv::Point3f> visualWords3;
3121 cv::Mat descriptors;
3122 bool allWords3NaN =
true;
3123 cv::Point3f depth(0,0,0);
3171 visualWordsKpts.push_back(kpt);
3172 visualWords.insert(visualWords.end(), std::make_pair(visualWordId, visualWordsKpts.size()-1));
3173 visualWords3.push_back(depth);
3177 allWords3NaN =
false;
3186 if(descriptor && descriptorSize>0 && dRealSize>0)
3189 if(dRealSize == descriptorSize)
3192 d = cv::Mat(1, descriptorSize, CV_8U);
3194 else if(dRealSize/
int(
sizeof(
float)) == descriptorSize)
3197 d = cv::Mat(1, descriptorSize, CV_32F);
3201 UFATAL(
"Saved buffer size (%d bytes) is not the same as descriptor size (%d)", dRealSize, descriptorSize);
3204 memcpy(d.data, descriptor, dRealSize);
3206 descriptors.push_back(d);
3214 if(visualWords.size()==0)
3216 UDEBUG(
"Empty signature detected! (id=%d)", (*iter)->id());
3222 visualWords3.clear();
3224 (*iter)->setWords(visualWords, visualWordsKpts, visualWords3, descriptors);
3225 ULOGGER_DEBUG(
"Add %d keypoints, %d 3d points and %d descriptors to node %d", (
int)visualWords.size(), allWords3NaN?0:(int)visualWords3.size(), (int)descriptors.rows, (*iter)->id());
3242 for(std::list<Signature*>::iterator iter = nodes.begin(); iter!=nodes.end(); ++iter)
3244 (*iter)->setModified(
false);
3250 std::stringstream query3;
3251 query3 <<
"SELECT calibration " 3258 for(std::list<Signature*>::const_iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
3268 const void * data = 0;
3271 std::vector<CameraModel> models;
3279 if(dataSize > 0 && data)
3283 if(dataSize >=
int(
sizeof(
int)*4))
3285 const int * dataInt = (
const int *)data;
3286 int type = dataInt[3];
3290 int bytesReadTotal = 0;
3291 unsigned int bytesRead = 0;
3292 while(bytesReadTotal < dataSize &&
3293 (bytesRead=model.
deserialize((
const unsigned char *)data+bytesReadTotal, dataSize-bytesReadTotal))!=0)
3295 bytesReadTotal+=bytesRead;
3296 models.push_back(model);
3298 UASSERT(bytesReadTotal == dataSize);
3302 int bytesRead = (int)stereoModel.
deserialize((
unsigned char*)data, dataSize);
3303 UASSERT(bytesRead == dataSize);
3307 UFATAL(
"Unknown calibration type %d", type);
3312 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
3317 float * dataFloat = (
float*)data;
3319 (
unsigned int)dataSize % (6+localTransform.
size())*
sizeof(
float) == 0)
3321 int cameraCount = dataSize / ((6+localTransform.
size())*
sizeof(
float));
3322 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
3323 int max = cameraCount*(6+localTransform.
size());
3324 for(
int i=0; i<
max; i+=6+localTransform.
size())
3328 memcpy(localTransform.
data(), dataFloat+i+6, localTransform.
size()*
sizeof(float));
3334 (
double)dataFloat[i],
3335 (
double)dataFloat[i+1],
3336 (
double)dataFloat[i+2],
3337 (
double)dataFloat[i+3],
3340 cv::Size(dataFloat[i+4], dataFloat[i+5])));
3341 UDEBUG(
"%f %f %f %f %f %f %s", dataFloat[i], dataFloat[i+1], dataFloat[i+2],
3342 dataFloat[i+3], dataFloat[i+4], dataFloat[i+5],
3347 (
unsigned int)dataSize % (4+localTransform.
size())*
sizeof(
float) == 0)
3349 int cameraCount = dataSize / ((4+localTransform.
size())*
sizeof(
float));
3350 UDEBUG(
"Loading calibration for %d cameras (%d bytes)", cameraCount, dataSize);
3351 int max = cameraCount*(4+localTransform.
size());
3352 for(
int i=0; i<
max; i+=4+localTransform.
size())
3356 memcpy(localTransform.
data(), dataFloat+i+4, localTransform.
size()*
sizeof(float));
3362 (
double)dataFloat[i],
3363 (
double)dataFloat[i+1],
3364 (
double)dataFloat[i+2],
3365 (
double)dataFloat[i+3],
3369 else if((
unsigned int)dataSize == (7+localTransform.
size())*
sizeof(
float))
3371 UDEBUG(
"Loading calibration of a stereo camera");
3372 memcpy(localTransform.
data(), dataFloat+7, localTransform.
size()*
sizeof(float));
3384 cv::Size(dataFloat[5], dataFloat[6]));
3386 else if((
unsigned int)dataSize == (5+localTransform.
size())*
sizeof(
float))
3388 UDEBUG(
"Loading calibration of a stereo camera");
3389 memcpy(localTransform.
data(), dataFloat+5, localTransform.
size()*
sizeof(float));
3404 UFATAL(
"Wrong format of the Data.calibration field (size=%d bytes, db version=%s)", dataSize,
_version.c_str());
3408 (*iter)->sensorData().setCameraModels(models);
3409 (*iter)->sensorData().setStereoCameraModel(stereoModel);
3429 std::stringstream query3;
3430 query3 <<
"SELECT type, info, data " 3431 "FROM GlobalDescriptor " 3432 "WHERE node_id = ? ";
3437 for(std::list<Signature*>::const_iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
3443 std::vector<GlobalDescriptor> globalDescriptors;
3449 const void * data = 0;
3458 if(dataSize && data)
3464 if(dataSize && data)
3476 if(!globalDescriptors.empty())
3478 (*iter)->sensorData().setGlobalDescriptors(globalDescriptors);
3479 ULOGGER_DEBUG(
"Add %d global descriptors to node %d", (
int)globalDescriptors.size(), (*iter)->id());
3490 ULOGGER_DEBUG(
"Time load %d global descriptors=%fs", (
int)nodes.size(), timer.
ticks());
3493 if(ids.size() != loaded)
3495 UERROR(
"Some signatures not found in database");
3515 query =
"SELECT n.id " 3517 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Info) " 3522 query =
"SELECT n.id " 3524 "WHERE n.time_enter >= (SELECT MAX(time_enter) FROM Statistics) " 3554 if(
_ppDb && dictionary)
3561 std::stringstream query;
3562 std::list<VisualWord *> visualWords;
3565 query <<
"SELECT id, descriptor_size, descriptor FROM Word ";
3570 query <<
"WHERE time_enter >= (SELECT MAX(time_enter) FROM Info) ";
3574 query <<
"WHERE time_enter >= (SELECT MAX(time_enter) FROM Statistics) ";
3577 query <<
"ORDER BY id;";
3584 int descriptorSize = 0;
3585 const void * descriptor = 0;
3599 if(dRealSize == descriptorSize)
3602 d = cv::Mat(1, descriptorSize, CV_8U);
3604 else if(dRealSize/
int(
sizeof(
float)) == descriptorSize)
3607 d = cv::Mat(1, descriptorSize, CV_32F);
3611 UFATAL(
"Saved buffer size (%d bytes) is not the same as descriptor size (%d)", dRealSize, descriptorSize);
3614 memcpy(d.data, descriptor, dRealSize);
3619 if(++count % 5000 == 0)
3642 if(
_ppDb && wordIds.size())
3649 std::stringstream query;
3650 std::set<int> loaded;
3653 query <<
"SELECT vw.descriptor_size, vw.descriptor " 3661 const void * descriptor;
3663 unsigned long dRealSizeTotal = 0;
3664 for(std::set<int>::const_iterator iter=wordIds.begin(); iter!=wordIds.end(); ++iter)
3680 if(dRealSize == descriptorSize)
3683 d = cv::Mat(1, descriptorSize, CV_8U);
3685 else if(dRealSize/
int(
sizeof(
float)) == descriptorSize)
3688 d = cv::Mat(1, descriptorSize, CV_32F);
3692 UFATAL(
"Saved buffer size (%d bytes) is not the same as descriptor size (%d)", dRealSize, descriptorSize);
3695 memcpy(d.data, descriptor, dRealSize);
3696 dRealSizeTotal+=dRealSize;
3703 loaded.insert(loaded.end(), *iter);
3718 UDEBUG(
"Time=%fs (%d words, %lu MB)", timer.
ticks(), (int)vws.size(), dRealSizeTotal/1000000);
3720 if(wordIds.size() != loaded.size())
3722 for(std::set<int>::const_iterator iter = wordIds.begin(); iter!=wordIds.end(); ++iter)
3724 if(loaded.find(*iter) == loaded.end())
3726 UDEBUG(
"Not found word %d", *iter);
3729 UERROR(
"Query (%d) doesn't match loaded words (%d)", wordIds.size(), loaded.size());
3736 std::multimap<int, Link> & links,
3746 std::stringstream query;
3750 query <<
"SELECT to_id, type, transform, information_matrix, user_data FROM Link ";
3754 query <<
"SELECT to_id, type, transform, rot_variance, trans_variance, user_data FROM Link ";
3758 query <<
"SELECT to_id, type, transform, rot_variance, trans_variance FROM Link ";
3762 query <<
"SELECT to_id, type, transform, variance FROM Link ";
3766 query <<
"SELECT to_id, type, transform FROM Link ";
3768 query <<
"WHERE from_id = " << signatureId;
3773 query <<
" AND type = " << typeIn;
3777 query <<
" AND type = 0";
3781 query <<
" AND type > 0";
3789 query <<
" ORDER BY to_id";
3796 const void * data = 0;
3812 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
3814 memcpy(transform.
data(), data, dataSize);
3822 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", signatureId, toId);
3825 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
3832 UASSERT(dataSize==36*
sizeof(
double) && data);
3833 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
3839 UASSERT(rotVariance > 0.0 && transVariance>0.0);
3840 informationMatrix.at<
double>(0,0) = 1.0/transVariance;
3841 informationMatrix.at<
double>(1,1) = 1.0/transVariance;
3842 informationMatrix.at<
double>(2,2) = 1.0/transVariance;
3843 informationMatrix.at<
double>(3,3) = 1.0/rotVariance;
3844 informationMatrix.at<
double>(4,4) = 1.0/rotVariance;
3845 informationMatrix.at<
double>(5,5) = 1.0/rotVariance;
3848 cv::Mat userDataCompressed;
3854 if(dataSize>4 && data)
3856 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
3860 links.insert(links.end(), std::make_pair(toId,
Link(signatureId, toId, (
Link::Type)type, transform, informationMatrix, userDataCompressed)));
3866 informationMatrix *= 1.0/variance;
3867 links.insert(links.end(), std::make_pair(toId,
Link(signatureId, toId, (
Link::Type)type, transform, informationMatrix)));
3884 if(links.size() == 0)
3899 std::stringstream query;
3903 query <<
"SELECT to_id, type, information_matrix, user_data, transform FROM Link " 3904 <<
"WHERE from_id = ? " 3905 <<
"ORDER BY to_id";
3909 query <<
"SELECT to_id, type, rot_variance, trans_variance, user_data, transform FROM Link " 3910 <<
"WHERE from_id = ? " 3911 <<
"ORDER BY to_id";
3915 query <<
"SELECT to_id, type, rot_variance, trans_variance, transform FROM Link " 3916 <<
"WHERE from_id = ? " 3917 <<
"ORDER BY to_id";
3921 query <<
"SELECT to_id, type, variance, transform FROM Link " 3922 <<
"WHERE from_id = ? " 3923 <<
"ORDER BY to_id";
3927 query <<
"SELECT to_id, type, transform FROM Link " 3928 <<
"WHERE from_id = ? " 3929 <<
"ORDER BY to_id";
3935 for(std::list<Signature*>::iterator iter=signatures.begin(); iter!=signatures.end(); ++iter)
3943 std::list<Link> links;
3944 const void * data = 0;
3955 cv::Mat userDataCompressed;
3956 cv::Mat informationMatrix = cv::Mat::eye(6,6,CV_64FC1);
3963 UASSERT(dataSize==36*
sizeof(
double) && data);
3964 informationMatrix = cv::Mat(6, 6, CV_64FC1, (
void *)data).clone();
3970 UASSERT(rotVariance > 0.0 && transVariance>0.0);
3971 informationMatrix.at<
double>(0,0) = 1.0/transVariance;
3972 informationMatrix.at<
double>(1,1) = 1.0/transVariance;
3973 informationMatrix.at<
double>(2,2) = 1.0/transVariance;
3974 informationMatrix.at<
double>(3,3) = 1.0/rotVariance;
3975 informationMatrix.at<
double>(4,4) = 1.0/rotVariance;
3976 informationMatrix.at<
double>(5,5) = 1.0/rotVariance;
3984 if(dataSize>4 && data)
3986 userDataCompressed = cv::Mat(1, dataSize, CV_8UC1, (
void *)data).clone();
3994 informationMatrix *= 1.0/variance;
4001 if((
unsigned int)dataSize == transform.
size()*
sizeof(float) && data)
4003 memcpy(transform.
data(), data, dataSize);
4011 UERROR(
"Error while loading link transform from %d to %d! Setting to null...", (*iter)->id(), toId);
4018 (*iter)->addLandmark(
Link((*iter)->id(), toId, (
Link::Type)linkType, transform, informationMatrix, userDataCompressed));
4024 links.push_back(
Link((*iter)->id(), toId, (
Link::Type)linkType, transform, informationMatrix, userDataCompressed));
4034 UFATAL(
"Not supported link type %d ! (fromId=%d, toId=%d)",
4035 linkType, (*iter)->id(), toId);
4043 (*iter)->addLinks(links);
4048 UDEBUG(
"time=%fs, node=%d, links.size=%d", timer.
ticks(), (*iter)->id(), links.size());
4059 UDEBUG(
"nodes = %d", nodes.size());
4060 if(
_ppDb && nodes.size())
4073 query =
"UPDATE Node SET weight=?, label=?, time_enter = DATETIME('NOW') WHERE id=?;";
4077 query =
"UPDATE Node SET weight=?, label=? WHERE id=?;";
4084 query =
"UPDATE Node SET weight=?, time_enter = DATETIME('NOW') WHERE id=?;";
4088 query =
"UPDATE Node SET weight=? WHERE id=?;";
4094 for(std::list<Signature *>::const_iterator i=nodes.begin(); i!=nodes.end(); ++i)
4141 query =
uFormat(
"DELETE FROM Link WHERE from_id=?;");
4145 for(std::list<Signature *>::const_iterator j=nodes.begin(); j!=nodes.end(); ++j)
4147 if((*j)->isLinksModified())
4167 for(std::list<Signature *>::const_iterator j=nodes.begin(); j!=nodes.end(); ++j)
4169 if((*j)->isLinksModified())
4172 const std::multimap<int, Link> & links = (*j)->getLinks();
4173 for(std::multimap<int, Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
4188 for(std::list<Signature *>::const_iterator j=nodes.begin(); j!=nodes.end(); ++j)
4190 if((*j)->getWordsChanged().size())
4192 const std::map<int, int> & wordsChanged = (*j)->getWordsChanged();
4193 for(std::map<int, int>::const_iterator iter=wordsChanged.begin(); iter!=wordsChanged.end(); ++iter)
4209 if(
_ppDb && words.size() && updateTimestamp)
4218 std::string query =
"UPDATE Word SET time_enter = DATETIME('NOW') WHERE id=?;";
4222 for(std::list<VisualWord *>::const_iterator i=words.begin(); i!=words.end(); ++i)
4250 if(
_ppDb && signatures.size())
4263 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4267 _memoryUsedEstimate -= (*i)->sensorData().imageRaw().total() * (*i)->sensorData().imageRaw().elemSize();
4268 _memoryUsedEstimate -= (*i)->sensorData().depthOrRightRaw().total() * (*i)->sensorData().depthOrRightRaw().elemSize();
4269 _memoryUsedEstimate -= (*i)->sensorData().laserScanRaw().data().total() * (*i)->sensorData().laserScanRaw().data().elemSize();
4283 for(std::list<Signature *>::const_iterator jter=signatures.begin(); jter!=signatures.end(); ++jter)
4286 const std::multimap<int, Link> & links = (*jter)->getLinks();
4287 for(std::multimap<int, Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
4294 const std::map<int, Link> & links = (*jter)->getLandmarks();
4295 for(std::map<int, Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
4312 float nanFloat = std::numeric_limits<float>::quiet_NaN ();
4313 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4315 UASSERT((*i)->getWords().size() == (*i)->getWordsKpts().size());
4316 UASSERT((*i)->getWords3().empty() || (*i)->getWords().size() == (*i)->getWords3().size());
4317 UASSERT((*i)->getWordsDescriptors().empty() || (int)(*i)->getWords().size() == (*i)->getWordsDescriptors().rows);
4319 for(std::multimap<int, int>::const_iterator w=(*i)->getWords().begin(); w!=(*i)->getWords().end(); ++w)
4321 cv::Point3f pt(nanFloat,nanFloat,nanFloat);
4322 if(!(*i)->getWords3().empty())
4324 pt = (*i)->getWords3()[w->second];
4328 if(!(*i)->getWordsDescriptors().empty())
4330 descriptor = (*i)->getWordsDescriptors().row(w->second);
4333 stepKeypoint(ppStmt, (*i)->id(), w->first, (*i)->getWordsKpts()[w->second], pt, descriptor);
4348 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4350 for(
size_t d=0;
d<(*i)->sensorData().globalDescriptors().size(); ++
d)
4368 UDEBUG(
"Saving %d images", signatures.size());
4370 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4372 if(!(*i)->sensorData().imageCompressed().empty() ||
4373 !(*i)->sensorData().depthOrRightCompressed().empty() ||
4374 !(*i)->sensorData().laserScanCompressed().isEmpty() ||
4375 !(*i)->sensorData().userDataCompressed().empty() ||
4376 !(*i)->sensorData().cameraModels().size() ||
4377 !(*i)->sensorData().stereoCameraModel().isValidForProjection())
4379 UASSERT((*i)->id() == (*i)->sensorData().id());
4395 UDEBUG(
"Saving %d images", signatures.size());
4397 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4399 if(!(*i)->sensorData().imageCompressed().empty())
4401 stepImage(ppStmt, (*i)->id(), (*i)->sensorData().imageCompressed());
4414 for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
4417 if(!(*i)->sensorData().depthOrRightCompressed().empty() || !(*i)->sensorData().laserScanCompressed().isEmpty())
4419 UASSERT((*i)->id() == (*i)->sensorData().id());
4434 UDEBUG(
"visualWords size=%d", words.size());
4447 query = std::string(
"INSERT INTO Word(id, descriptor_size, descriptor) VALUES(?,?,?);");
4450 for(std::list<VisualWord *>::const_iterator iter=words.begin(); iter!=words.end(); ++iter)
4547 const cv::Mat & ground,
4548 const cv::Mat & obstacles,
4549 const cv::Mat & empty,
4551 const cv::Point3f & viewpoint)
const 4586 const cv::Mat & image)
const 4661 if(param.size() && statistics.
refImageId()>0)
4666 query =
"INSERT INTO Statistics(id, stamp, data, wm_state) values(?,?,?,?);";
4670 query =
"INSERT INTO Statistics(id, stamp, data) values(?,?,?);";
4681 cv::Mat compressedParam;
4694 cv::Mat compressedWmState;
4697 if(saveWmState && !statistics.
wmState().empty())
4739 query =
uFormat(
"UPDATE Admin SET preview_image=? WHERE version='%s';",
_version.c_str());
4744 cv::Mat compressedImage;
4753 if(image.rows == 1 && image.type() == CV_8UC1)
4756 compressedImage = image;
4787 std::stringstream query;
4789 query <<
"SELECT preview_image " 4791 <<
"WHERE version='" <<
_version.c_str()
4802 const void * data = 0;
4809 if(dataSize>0 && data)
4813 UDEBUG(
"Image=%dx%d", image.cols, image.rows);
4830 UDEBUG(
"poses=%d lastlocalizationPose=%s", (
int)poses.size(), lastlocalizationPose.
prettyPrint().c_str());
4840 query =
uFormat(
"UPDATE Admin SET opt_ids=?, opt_poses=?, opt_last_localization=?, time_enter = DATETIME('NOW') WHERE version='%s';",
_version.c_str());
4847 cv::Mat compressedIds;
4848 cv::Mat compressedPoses;
4858 std::vector<int> serializedIds(poses.size());
4859 std::vector<float> serializedPoses(poses.size()*12);
4861 for(std::map<int, Transform>::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter)
4863 serializedIds[i] = iter->first;
4864 memcpy(serializedPoses.data()+(12*i), iter->second.data(), 12*
sizeof(float));
4868 compressedIds =
compressData2(cv::Mat(1,serializedIds.size(), CV_32SC1, serializedIds.data()));
4869 compressedPoses =
compressData2(cv::Mat(1,serializedPoses.size(), CV_32FC1, serializedPoses.data()));
4877 if(lastlocalizationPose.
isNull())
4904 std::map<int, Transform> poses;
4911 std::stringstream query;
4913 query <<
"SELECT opt_ids, opt_poses, opt_last_localization " 4915 <<
"WHERE version='" <<
_version.c_str()
4926 const void * data = 0;
4931 cv::Mat serializedIds;
4934 if(dataSize>0 && data)
4936 serializedIds =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4937 UDEBUG(
"serializedIds=%d", serializedIds.cols);
4942 if(dataSize>0 && data)
4944 cv::Mat serializedPoses =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
4945 UDEBUG(
"serializedPoses=%d", serializedPoses.cols);
4947 UASSERT(serializedIds.cols == serializedPoses.cols/12);
4948 UASSERT(serializedPoses.type() == CV_32FC1);
4949 UASSERT(serializedIds.type() == CV_32SC1);
4950 for(
int i=0; i<serializedIds.cols; ++i)
4952 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),
4953 serializedPoses.at<
float>(i*12+4), serializedPoses.at<
float>(i*12+5), serializedPoses.at<
float>(i*12+6), serializedPoses.at<
float>(i*12+7),
4954 serializedPoses.at<
float>(i*12+8), serializedPoses.at<
float>(i*12+9), serializedPoses.at<
float>(i*12+10), serializedPoses.at<
float>(i*12+11));
4955 poses.insert(std::make_pair(serializedIds.at<
int>(i), t));
4956 UDEBUG(
"Optimized pose %d: %s", serializedIds.at<
int>(i), t.
prettyPrint().c_str());
4962 if(lastlocalizationPose)
4964 if((
unsigned int)dataSize == lastlocalizationPose->
size()*
sizeof(float) && data)
4966 memcpy(lastlocalizationPose->
data(), data, dataSize);
4996 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());
5003 cv::Mat compressedMap;
5046 std::stringstream query;
5048 query <<
"SELECT opt_map, opt_map_x_min, opt_map_y_min, opt_map_resolution " 5050 <<
"WHERE version='" <<
_version.c_str()
5061 const void * data = 0;
5068 if(dataSize>0 && data)
5070 map =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5071 UDEBUG(
"map=%d/%d", map.cols, map.rows);
5079 UDEBUG(
"cellSize=%f", cellSize);
5095 const cv::Mat & cloud,
5096 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons,
5097 #
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
5098 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords,
5100 const std::vector<std::vector<Eigen::Vector2f> > & texCoords,
5102 const cv::Mat & textures)
const 5114 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());
5121 for(
int i=1; i<=5; ++i)
5136 cv::Mat compressedCloud;
5137 if(cloud.rows == 1 && cloud.type() == CV_8UC1)
5140 compressedCloud = cloud;
5144 UDEBUG(
"Cloud points=%d", cloud.cols);
5147 UDEBUG(
"Cloud compressed bytes=%d", compressedCloud.cols);
5152 cv::Mat compressedPolygons;
5153 cv::Mat compressedTexCoords;
5154 cv::Mat compressedTextures;
5156 if(polygons.empty())
5173 std::vector<int> serializedPolygons;
5174 std::vector<float> serializedTexCoords;
5175 int polygonSize = 0;
5176 int totalPolygonIndices = 0;
5177 UASSERT(texCoords.empty() || polygons.size() == texCoords.size());
5178 for(
unsigned int t=0; t<polygons.size(); ++t)
5180 UDEBUG(
"t=%d, polygons=%d", t, (
int)polygons[t].size());
5181 unsigned int materialPolygonIndices = 0;
5182 for(
unsigned int p=0; p<polygons[t].size(); ++p)
5184 if(polygonSize == 0)
5186 UASSERT(polygons[t][p].size());
5187 polygonSize = polygons[t][p].size();
5191 UASSERT(polygonSize == (
int)polygons[t][p].size());
5194 materialPolygonIndices += polygons[t][p].size();
5196 totalPolygonIndices += materialPolygonIndices;
5198 if(!texCoords.empty())
5200 UASSERT(materialPolygonIndices == texCoords[t].size());
5203 UASSERT(totalPolygonIndices>0);
5204 serializedPolygons.resize(totalPolygonIndices+polygons.size());
5205 if(!texCoords.empty())
5207 serializedTexCoords.resize(totalPolygonIndices*2+polygons.size());
5212 for(
unsigned int t=0; t<polygons.size(); ++t)
5214 serializedPolygons[oi++] = polygons[t].size();
5215 if(!texCoords.empty())
5217 serializedTexCoords[ci++] = texCoords[t].size();
5219 for(
unsigned int p=0; p<polygons[t].size(); ++p)
5221 int texIndex = p*polygonSize;
5222 for(
unsigned int i=0; i<polygons[t][p].size(); ++i)
5224 serializedPolygons[oi++] = polygons[t][p][i];
5226 if(!texCoords.empty())
5228 serializedTexCoords[ci++] = texCoords[t][texIndex+i][0];
5229 serializedTexCoords[ci++] = texCoords[t][texIndex+i][1];
5235 UDEBUG(
"serializedPolygons=%d", (
int)serializedPolygons.size());
5236 compressedPolygons =
compressData2(cv::Mat(1,serializedPolygons.size(), CV_32SC1, serializedPolygons.data()));
5246 if(texCoords.empty())
5257 UDEBUG(
"serializedTexCoords=%d", (
int)serializedTexCoords.size());
5258 compressedTexCoords =
compressData2(cv::Mat(1,serializedTexCoords.size(), CV_32FC1, serializedTexCoords.data()));
5262 UASSERT(!textures.empty() && textures.cols % textures.rows == 0 && textures.cols/textures.rows == (int)texCoords.size());
5263 if(textures.rows == 1 && textures.type() == CV_8UC1)
5266 compressedTextures = textures;
5291 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > * polygons,
5292 #
if PCL_VERSION_COMPARE(>=, 1, 8, 0)
5293 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > * texCoords,
5295 std::vector<std::vector<Eigen::Vector2f> > * texCoords,
5297 cv::Mat * textures)
const 5307 std::stringstream query;
5309 query <<
"SELECT opt_cloud, opt_polygons_size, opt_polygons, opt_tex_coords, opt_tex_materials " 5311 <<
"WHERE version='" <<
_version.c_str()
5322 const void * data = 0;
5329 if(dataSize>0 && data)
5331 cloud =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5333 UDEBUG(
"Cloud=%d points", cloud.cols);
5337 UDEBUG(
"polygonSize=%d", polygonSize);
5342 if(dataSize>0 && data)
5347 cv::Mat serializedPolygons =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5348 UDEBUG(
"serializedPolygons=%d", serializedPolygons.cols);
5349 UASSERT(serializedPolygons.total());
5350 for(
int t=0; t<serializedPolygons.cols; ++t)
5352 UASSERT(serializedPolygons.at<
int>(t) > 0);
5353 std::vector<std::vector<RTABMAP_PCL_INDEX> > materialPolygons(serializedPolygons.at<
int>(t), std::vector<RTABMAP_PCL_INDEX>(polygonSize));
5355 UASSERT(t < serializedPolygons.cols);
5356 UDEBUG(
"materialPolygons=%d", (
int)materialPolygons.size());
5357 for(
int p=0; p<(int)materialPolygons.size(); ++p)
5359 for(
int i=0; i<polygonSize; ++i)
5361 materialPolygons[p][i] = serializedPolygons.at<
int>(t + p*polygonSize + i);
5364 t+=materialPolygons.size()*polygonSize;
5365 polygons->push_back(materialPolygons);
5372 if(dataSize>0 && data)
5376 cv::Mat serializedTexCoords =
uncompressData(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5377 UDEBUG(
"serializedTexCoords=%d", serializedTexCoords.cols);
5378 UASSERT(serializedTexCoords.total());
5379 for(
int t=0; t<serializedTexCoords.cols; ++t)
5381 UASSERT(
int(serializedTexCoords.at<
float>(t)) > 0);
5382 #if PCL_VERSION_COMPARE(>=, 1, 8, 0) 5383 std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > materialtexCoords(
int(serializedTexCoords.at<
float>(t)));
5385 std::vector<Eigen::Vector2f> materialtexCoords(
int(serializedTexCoords.at<
float>(t)));
5388 UASSERT(t < serializedTexCoords.cols);
5389 UDEBUG(
"materialtexCoords=%d", (
int)materialtexCoords.size());
5390 for(
int p=0; p<(int)materialtexCoords.size(); ++p)
5392 materialtexCoords[p][0] = serializedTexCoords.at<
float>(t + p*2);
5393 materialtexCoords[p][1] = serializedTexCoords.at<
float>(t + p*2 + 1);
5395 t+=materialtexCoords.size()*2;
5396 texCoords->push_back(materialtexCoords);
5403 if(dataSize>0 && data)
5407 *textures =
uncompressImage(cv::Mat(1, dataSize, CV_8UC1, (
void *)data));
5408 UDEBUG(
"textures=%dx%d", textures->cols, textures->rows);
5431 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps, env_sensors) VALUES(?,?,?,?,?,?,?,?,?,?);";
5435 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity, gps) VALUES(?,?,?,?,?,?,?,?,?);";
5439 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose, velocity) VALUES(?,?,?,?,?,?,?,?);";
5443 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, ground_truth_pose) VALUES(?,?,?,?,?,?,?);";
5447 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label) VALUES(?,?,?,?,?,?);";
5451 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label, user_data) VALUES(?,?,?,?,?,?,?);";
5455 return "INSERT INTO Node(id, map_id, weight, pose, stamp, label) VALUES(?,?,?,?,?,?);";
5457 return "INSERT INTO Node(id, map_id, weight, pose) VALUES(?,?,?,?);";
5495 std::vector<double> gps;
5496 std::vector<double> envSensors;
5543 if(sensors.size() == 0)
5551 envSensors.resize(sensors.size()*3,0.0);
5553 for(std::map<EnvSensor::Type, EnvSensor>::const_iterator iter=sensors.begin(); iter!=sensors.end(); ++iter, j+=3)
5555 envSensors[j] = (double)iter->second.type();
5556 envSensors[j+1] = iter->second.value();
5557 envSensors[j+2] = iter->second.stamp();
5591 return "INSERT INTO Image(id, data) VALUES(?,?);";
5595 const cv::Mat & imageBytes)
const 5598 UDEBUG(
"Save image %d (size=%d)",
id, (
int)imageBytes.cols);
5610 if(!imageBytes.empty())
5633 return "INSERT INTO Depth(id, data, fx, fy, cx, cy, local_transform, data2d, data2d_max_pts) VALUES(?,?,?,?,?,?,?,?,?);";
5637 return "INSERT INTO Depth(id, data, fx, fy, cx, cy, local_transform, data2d) VALUES(?,?,?,?,?,?,?,?);";
5641 return "INSERT INTO Depth(id, data, constant, local_transform, data2d) VALUES(?,?,?,?,?);";
5647 UDEBUG(
"Save depth %d (size=%d) depth2d = %d",
5672 float fx=0, fyOrBaseline=0, cx=0, cy=0;
5677 uFormat(
"Database version %s doesn't support multi-camera!",
_version.c_str()).c_str());
5683 localTransform = sensorData.
cameraModels()[0].localTransform();
5742 return "UPDATE Depth SET data=? WHERE id=?;";
5746 return "UPDATE Data SET depth=? WHERE id=?;";
5759 cv::Mat imageCompressed;
5760 if(!image.empty() && (image.type()!=CV_8UC1 || image.rows > 1))
5767 imageCompressed = image;
5769 if(!imageCompressed.empty())
5796 return "UPDATE Data SET scan_info=?, scan=? WHERE id=?;";
5800 return "UPDATE Data SET scan_max_pts=?, scan_max_range=?, scan=? WHERE id=?;";
5804 return "UPDATE Data SET scan_max_pts=? scan=? WHERE id=?;";
5817 std::vector<float> scanInfo;
5829 scanInfo.resize(7 +
Transform().size());
5830 scanInfo[0] = scan.
format();
5838 memcpy(scanInfo.data()+7, localTransform.
data(), localTransform.
size()*
sizeof(float));
5842 scanInfo.resize(3 +
Transform().size());
5845 scanInfo[2] = scan.
format();
5847 memcpy(scanInfo.data()+3, localTransform.
data(), localTransform.
size()*
sizeof(float));
5852 scanInfo.resize(2 +
Transform().size());
5856 memcpy(scanInfo.data()+2, localTransform.
data(), localTransform.
size()*
sizeof(float));
5886 cv::Mat scanCompressed;
5889 scanCompressed = scan.
data();
5895 if(!scanCompressed.empty())
5922 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(?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
5926 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(?,?,?,?,?,?,?,?,?,?,?,?,?);";
5930 return "INSERT INTO Data(id, image, depth, calibration, scan_max_pts, scan_max_range, scan, user_data) VALUES(?,?,?,?,?,?,?,?);";
5934 return "INSERT INTO Data(id, image, depth, calibration, scan_max_pts, scan, user_data) VALUES(?,?,?,?,?,?,?);";
5938 return "INSERT INTO Data(id, image, depth, calibration, scan_max_pts, scan) VALUES(?,?,?,?,?,?);";
5945 UDEBUG(
"Save sensor data %d (image=%d depth=%d) depth2d = %d",
5985 std::vector<unsigned char> calibrationData;
5986 std::vector<float> calibration;
5993 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
5996 std::vector<unsigned char> data = sensorData.
cameraModels()[i].serialize();
5998 unsigned int oldSize = calibrationData.size();
5999 calibrationData.resize(calibrationData.size() + data.size());
6000 memcpy(calibrationData.data()+oldSize, data.data(), data.size());
6006 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
6010 calibration[i*(6+localTransform.size())] = sensorData.
cameraModels()[i].fx();
6011 calibration[i*(6+localTransform.size())+1] = sensorData.
cameraModels()[i].fy();
6012 calibration[i*(6+localTransform.size())+2] = sensorData.
cameraModels()[i].cx();
6013 calibration[i*(6+localTransform.size())+3] = sensorData.
cameraModels()[i].cy();
6014 calibration[i*(6+localTransform.size())+4] = sensorData.
cameraModels()[i].imageWidth();
6015 calibration[i*(6+localTransform.size())+5] = sensorData.
cameraModels()[i].imageHeight();
6016 memcpy(calibration.data()+i*(6+localTransform.size())+6, localTransform.data(), localTransform.size()*
sizeof(float));
6022 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
6026 calibration[i*(4+localTransform.size())] = sensorData.
cameraModels()[i].fx();
6027 calibration[i*(4+localTransform.size())+1] = sensorData.
cameraModels()[i].fy();
6028 calibration[i*(4+localTransform.size())+2] = sensorData.
cameraModels()[i].cx();
6029 calibration[i*(4+localTransform.size())+3] = sensorData.
cameraModels()[i].cy();
6030 memcpy(calibration.data()+i*(4+localTransform.size())+4, localTransform.data(), localTransform.size()*
sizeof(float));
6039 UASSERT(!calibrationData.empty());
6044 calibration.resize(7+localTransform.
size());
6052 memcpy(calibration.data()+7, localTransform.
data(), localTransform.
size()*
sizeof(float));
6056 if(calibrationData.size())
6060 else if(calibration.size())
6070 std::vector<float> scanInfo;
6082 scanInfo.resize(7 +
Transform().size());
6091 memcpy(scanInfo.data()+7, localTransform.
data(), localTransform.
size()*
sizeof(float));
6095 scanInfo.resize(3 +
Transform().size());
6100 memcpy(scanInfo.data()+3, localTransform.
data(), localTransform.
size()*
sizeof(float));
6105 scanInfo.resize(2 +
Transform().size());
6109 memcpy(scanInfo.data()+2, localTransform.
data(), localTransform.
size()*
sizeof(float));
6230 return "UPDATE Link SET type=?, information_matrix=?, transform=?, user_data=? WHERE from_id=? AND to_id = ?;";
6234 return "UPDATE Link SET type=?, rot_variance=?, trans_variance=?, transform=?, user_data=? WHERE from_id=? AND to_id = ?;";
6238 return "UPDATE Link SET type=?, rot_variance=?, trans_variance=?, transform=? WHERE from_id=? AND to_id = ?;";
6242 return "UPDATE Link SET type=?, variance=?, transform=? WHERE from_id=? AND to_id = ?;";
6246 return "UPDATE Link SET type=?, transform=? WHERE from_id=? AND to_id = ?;";
6254 return "INSERT INTO Link(type, information_matrix, transform, user_data, from_id, to_id) VALUES(?,?,?,?,?,?);";
6258 return "INSERT INTO Link(type, rot_variance, trans_variance, transform, user_data, from_id, to_id) VALUES(?,?,?,?,?,?,?);";
6262 return "INSERT INTO Link(type, rot_variance, trans_variance, transform, from_id, to_id) VALUES(?,?,?,?,?,?);";
6266 return "INSERT INTO Link(type, variance, transform, from_id, to_id) VALUES(?,?,?,?,?);";
6270 return "INSERT INTO Link(type, transform, from_id, to_id) VALUES(?,?,?,?);";
6275 const Link & link)
const 6281 UDEBUG(
"Save link from %d to %d, type=%d", link.
from(), link.
to(), link.
type());
6286 UDEBUG(
"Virtual link ignored....");
6347 return "UPDATE Feature SET word_id = ? WHERE word_id = ? AND node_id = ?;";
6351 return "UPDATE Map_Node_Word SET word_id = ? WHERE word_id = ? AND node_id = ?;";
6380 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(?,?,?,?,?,?,?,?,?,?,?,?,?);";
6384 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(?,?,?,?,?,?,?,?,?,?,?,?,?);";
6388 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(?,?,?,?,?,?,?,?,?,?,?,?);";
6390 return "INSERT INTO Map_Node_Word(node_id, word_id, pos_x, pos_y, size, dir, response, depth_x, depth_y, depth_z) VALUES(?,?,?,?,?,?,?,?,?,?);";
6395 const cv::KeyPoint & kp,
6396 const cv::Point3f & pt,
6397 const cv::Mat & descriptor)
const 6463 UASSERT(descriptor.empty() || descriptor.type() == CV_32F || descriptor.type() == CV_8U);
6464 if(descriptor.empty())
6470 if(descriptor.type() == CV_32F)
6494 return "INSERT INTO GlobalDescriptor(node_id, type, info, data) VALUES(?,?,?,?);";
6517 if(infoBytes.empty())
6529 if(infoBytes.empty())
6551 return "UPDATE Data SET ground_cells=?, obstacle_cells=?, empty_cells=?, cell_size=?, view_point_x=?, view_point_y=?, view_point_z=? WHERE id=?;";
6553 return "UPDATE Data SET ground_cells=?, obstacle_cells=?, cell_size=?, view_point_x=?, view_point_y=?, view_point_z=? WHERE id=?;";
6557 const cv::Mat & ground,
6558 const cv::Mat & obstacles,
6559 const cv::Mat & empty,
6561 const cv::Point3f & viewpoint)
const 6564 UASSERT(ground.empty() || ground.type() == CV_8UC1);
6565 UASSERT(obstacles.empty() || obstacles.type() == CV_8UC1);
6566 UASSERT(empty.empty() || empty.type() == CV_8UC1);
6567 UDEBUG(
"Update occupancy grid %d: ground=%d obstacles=%d empty=%d cell=%f viewpoint=(%f,%f,%f)",
6598 if(obstacles.empty())
#define sqlite3_memory_used
int loadOrSaveDb(sqlite3 *pInMemory, const std::string &fileName, int isSave) const
virtual long getUserDataMemoryUsedQuery() const
bool RTABMAP_EXP isFinite(const cv::Point3f &pt)
void setTempStore(int tempStore)
std::string queryStepNode() const
const std::string & getTargetVersion() const
cv::Mat RTABMAP_EXP uncompressData(const cv::Mat &bytes)
const cv::Mat data() const
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
virtual void getAllLinksQuery(std::multimap< int, Link > &links, bool ignoreNullLinks, bool withLandmarks) const
virtual void loadLinksQuery(int signatureId, std::multimap< int, Link > &links, Link::Type type=Link::kUndef) const
std::string queryStepImage() const
virtual cv::Mat load2DMapQuery(float &xMin, float &yMin, float &cellSize) 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)
virtual void saveOptimizedMeshQuery(const cv::Mat &cloud, const std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > &polygons, const std::vector< std::vector< Eigen::Vector2f > > &texCoords, const cv::Mat &textures) const
#define sqlite3_backup_finish
virtual std::map< std::string, float > getStatisticsQuery(int nodeId, double &stamp, std::vector< int > *wmState) const
bool UTILITE_EXP uStr2Bool(const char *str)
void setCacheSize(unsigned int cacheSize)
#define sqlite3_backup_init
unsigned int deserialize(const std::vector< unsigned char > &data)
static int erase(const std::string &filePath)
virtual void saveOptimizedPosesQuery(const std::map< int, Transform > &optimizedPoses, const Transform &lastlocalizationPose) 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
virtual void addStatisticsQuery(const Statistics &statistics, bool saveWmState) const
float gridCellSize() const
virtual int getTotalDictionarySizeQuery() const
const cv::Mat & gridObstacleCellsCompressed() 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
const EnvSensors & envSensors() const
void stepSensorData(sqlite3_stmt *ppStmt, const SensorData &sensorData) 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
double rotVariance(bool minimum=true) const
virtual unsigned long getMemoryUsedQuery() 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)
virtual void getLastIdQuery(const std::string &tableName, int &id, const std::string &fieldName="id") const
#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
const cv::Mat & depthOrRightCompressed() const
std::vector< unsigned char > serialize() const
#define ULOGGER_DEBUG(...)
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
std::vector< unsigned char > RTABMAP_EXP compressData(const cv::Mat &data)
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
std::string queryStepScanUpdate() 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
bool isCompressed() 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
unsigned long _memoryUsedEstimate
Transform localTransform() const
const cv::Mat & infMatrix() const
float angleIncrement() const
virtual void saveQuery(const std::list< Signature * > &signatures)
cv::Mat RTABMAP_EXP compressData2(const cv::Mat &data)
virtual void getNodesObservingLandmarkQuery(int landmarkId, std::map< int, Link > &nodes) const
#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
const cv::Mat info() const
virtual std::map< int, Transform > loadOptimizedPosesQuery(Transform *lastlocalizationPose=0) const
double transVariance(bool minimum=true) const
std::string queryStepGlobalDescriptor() 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
void stepScanUpdate(sqlite3_stmt *ppStmt, int nodeId, const LaserScan &image) 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
void stepKeypoint(sqlite3_stmt *ppStmt, int nodeID, int wordId, const cv::KeyPoint &kp, const cv::Point3f &pt, const cv::Mat &descriptor) const
unsigned int deserialize(const std::vector< unsigned char > &data)
virtual long getStatisticsMemoryUsedQuery() const
const cv::Mat & imageCompressed() const
std::string getDatabaseVersion() const
void stepGlobalDescriptor(sqlite3_stmt *ppStmt, int nodeId, const GlobalDescriptor &descriptor) const
static int rename(const std::string &oldFilePath, const std::string &newFilePath)
void setSynchronous(int synchronous)
virtual cv::Mat loadOptimizedMeshQuery(std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > *polygons, std::vector< std::vector< Eigen::Vector2f > > *texCoords, cv::Mat *textures) const
virtual bool connectDatabaseQuery(const std::string &url, bool overwritten=false)
#define sqlite3_column_bytes
std::map< EnvSensor::Type, EnvSensor > EnvSensors
#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
#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)
virtual bool getNodeInfoQuery(int signatureId, Transform &pose, int &mapId, int &weight, std::string &label, double &stamp, Transform &groundTruthPose, std::vector< float > &velocity, GPS &gps, EnvSensors &sensors) const
void getLastWordId(int &id) const
virtual void parseParameters(const ParametersMap ¶meters)
const cv::Point3f & gridViewPoint() const
virtual int getLastNodesSizeQuery() const
void emptyTrashes(bool async=false)
virtual void getLastNodeIdsQuery(std::set< int > &ids) const
cv::Mat RTABMAP_EXP uncompressImage(const cv::Mat &bytes)
#define sqlite3_column_blob
virtual long getNodesMemoryUsedQuery() const
const Transform & localTransform() const
void updateLaserScanQuery(int nodeId, const LaserScan &scan) const
cv::Mat RTABMAP_EXP compressImage2(const cv::Mat &image, const std::string &format=".png")
virtual cv::Mat loadPreviewImageQuery() const
const double & stamp() const