Fixed calibration/laser not saved when compressed images are not saved to db

This commit is contained in:
matlabbe
2016-02-19 21:05:14 -05:00
parent 081be68616
commit 0d68f74d80
5 changed files with 35 additions and 21 deletions
@@ -55,7 +55,6 @@ public:
float timeMirroring;
float timeImageDecimation;
float timeScanFromDepth;
float timeDepthFromScan;
};
} // namespace rtabmap
+8 -4
View File
@@ -1696,7 +1696,7 @@ void DBDriverSqlite3::loadSignaturesQuery(const std::list<int> & ids, std::list<
rc = sqlite3_prepare_v2(_ppDb, query3.str().c_str(), -1, &ppStmt, 0);
UASSERT_MSG(rc == SQLITE_OK, uFormat("DB error (%s): %s", _version.c_str(), sqlite3_errmsg(_ppDb)).c_str());
int calibrationsLoaded = 0;
for(std::list<Signature*>::const_iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
{
if(calibrationsToLoad.find((*iter)->id())!=calibrationsToLoad.end())
@@ -1722,6 +1722,7 @@ void DBDriverSqlite3::loadSignaturesQuery(const std::list<int> & ids, std::list<
// stereo [fx, fy, cx, cy, baseline, local_transform] (5+12)*float
if(dataSize > 0 && data)
{
++calibrationsLoaded;
float * dataFloat = (float*)data;
if((unsigned int)dataSize % (4+localTransform.size())*sizeof(float) == 0)
{
@@ -1776,6 +1777,7 @@ void DBDriverSqlite3::loadSignaturesQuery(const std::list<int> & ids, std::list<
UFATAL("Wrong format of the Data.calibration field (size=%d bytes)", dataSize);
}
UWARN("Set %d models to %d", models.size(), (*iter)->id());
(*iter)->sensorData().setCameraModels(models);
(*iter)->sensorData().setStereoCameraModel(stereoModel);
}
@@ -1791,9 +1793,9 @@ void DBDriverSqlite3::loadSignaturesQuery(const std::list<int> & ids, std::list<
// Finalize (delete) the statement
rc = sqlite3_finalize(ppStmt);
UASSERT_MSG(rc == SQLITE_OK, uFormat("DB error (%s): %s", _version.c_str(), sqlite3_errmsg(_ppDb)).c_str());
}
ULOGGER_DEBUG("Time load calibrations=%fs", timer.ticks());
ULOGGER_DEBUG("Time load calibrations (loaded=%d/%d)=%fs", calibrationsLoaded, calibrationsToLoad.size(), timer.ticks());
}
if(ids.size() != loaded)
{
@@ -2559,7 +2561,9 @@ void DBDriverSqlite3::saveQuery(const std::list<Signature *> & signatures) const
if(!(*i)->sensorData().imageCompressed().empty() ||
!(*i)->sensorData().depthOrRightCompressed().empty() ||
!(*i)->sensorData().laserScanCompressed().empty() ||
!(*i)->sensorData().userDataCompressed().empty())
!(*i)->sensorData().userDataCompressed().empty() ||
!(*i)->sensorData().cameraModels().size() ||
!(*i)->sensorData().stereoCameraModel().isValidForProjection())
{
UASSERT((*i)->id() == (*i)->sensorData().id());
stepSensorData(ppStmt, (*i)->sensorData());
+20 -9
View File
@@ -2056,9 +2056,10 @@ Transform Memory::computeTransform(
if(fromS && toS)
{
UWARN("%d=%d %d=%d", fromId, fromS->sensorData().cameraModels().size(), toId, toS->sensorData().cameraModels().size());
// make sure we have all data needed
if((_reextractLoopClosureFeatures && _registrationPipeline->isImageRequired()) ||
_registrationPipeline->isScanRequired() ||
(_registrationPipeline->isScanRequired()) ||
_registrationPipeline->isUserDataRequired())
{
getNodeData(fromS->id(), true);
@@ -3379,6 +3380,14 @@ Signature * Memory::createSignature(const SensorData & data, const Transform & p
}
else
{
// just compress laser and user data
rtabmap::CompressionThread ctLaserScan(laserScan);
rtabmap::CompressionThread ctUserData(data.userDataRaw());
ctLaserScan.start();
ctUserData.start();
ctLaserScan.join();
ctUserData.join();
s = new Signature(id,
_idMapCount,
isIntermediateNode?-1:0, // tag intermediate nodes as weight=-1
@@ -3388,23 +3397,25 @@ Signature * Memory::createSignature(const SensorData & data, const Transform & p
data.groundTruth(),
stereoCameraModel.isValidForProjection()?
SensorData(
cv::Mat(),
0,
0,
ctLaserScan.getCompressedData(),
maxLaserScanMaxPts,
data.laserScanMaxRange(),
cv::Mat(),
cv::Mat(),
stereoCameraModel,
id,
0):
0,
ctUserData.getCompressedData()):
SensorData(
cv::Mat(),
0,
0,
ctLaserScan.getCompressedData(),
maxLaserScanMaxPts,
data.laserScanMaxRange(),
cv::Mat(),
cv::Mat(),
cameraModels,
id,
0));
0,
ctUserData.getCompressedData()));
}
s->setWords(words);
+4 -4
View File
@@ -740,7 +740,6 @@ void MainWindow::processCameraInfo(const rtabmap::CameraInfo & info)
_ui->statsToolBox->updateStat("Camera/Time disparity/ms", (float)info.id, (float)info.timeDisparity*1000.0);
_ui->statsToolBox->updateStat("Camera/Time mirroring/ms", (float)info.id, (float)info.timeMirroring*1000.0);
_ui->statsToolBox->updateStat("Camera/Time scan from depth/ms", (float)info.id, (float)info.timeScanFromDepth*1000.0);
_ui->statsToolBox->updateStat("Camera/Time depth from scan/ms", (float)info.id, (float)info.timeDepthFromScan*1000.0);
}
void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom)
@@ -1643,7 +1642,7 @@ void MainWindow::updateMapCloud(
else if(_cachedSignatures.contains(iter->first))
{
QMap<int, Signature>::iterator jter = _cachedSignatures.find(iter->first);
if(!jter->sensorData().laserScanCompressed().empty())
if(!jter->sensorData().laserScanCompressed().empty() || !jter->sensorData().laserScanRaw().empty())
{
this->createAndAddScanToMap(iter->first, iter->second, uValue(mapIds, iter->first, -1));
}
@@ -1893,7 +1892,8 @@ void MainWindow::createAndAddCloudToMap(int nodeId, const Transform & pose, int
return;
}
if(!iter->sensorData().imageCompressed().empty() && !iter->sensorData().depthOrRightCompressed().empty())
if((!iter->sensorData().imageCompressed().empty() || !iter->sensorData().imageRaw().empty()) &&
(!iter->sensorData().depthOrRightCompressed().empty() || !iter->sensorData().depthOrRightRaw().empty()))
{
cv::Mat image, depth;
SensorData data = iter->sensorData();
@@ -2101,7 +2101,7 @@ void MainWindow::createAndAddScanToMap(int nodeId, const Transform & pose, int m
return;
}
if(!iter->sensorData().laserScanCompressed().empty())
if(!iter->sensorData().laserScanCompressed().empty() || !iter->sensorData().laserScanRaw().empty())
{
cv::Mat scan;
iter->sensorData().uncompressData(0, 0, &scan);
+3 -3
View File
@@ -63,7 +63,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-1377</y>
<width>681</width>
<height>2010</height>
</rect>
@@ -86,7 +86,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>6</number>
<number>3</number>
</property>
<widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
@@ -3751,7 +3751,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item row="0" column="1">
<widget class="QLabel" name="label_300">
<property name="text">
<string>Downsample step size for laser scans. If you laser scans are created from depth images, use Decimation above instead (faster).</string>
<string>Downsample step size for laser scans. If your laser scans are created from depth images, use Decimation above instead (faster).</string>
</property>
<property name="wordWrap">
<bool>true</bool>