GUI/Source: color only option now also available for stereo cameras (meaning only left frame published). Db: fixed non-valid 3d words saved when no ones were in the signature (on loading, we don't set words3 if they are all null).

This commit is contained in:
matlabbe
2020-04-08 20:00:41 -04:00
parent 82a19a2ff1
commit c0313a6d09
3 changed files with 54 additions and 37 deletions

View File

@@ -189,9 +189,16 @@ void CameraThread::postUpdate(SensorData * dataPtr, CameraInfo * info) const
{ {
UASSERT(dataPtr!=0); UASSERT(dataPtr!=0);
SensorData & data = *dataPtr; SensorData & data = *dataPtr;
if(_colorOnly && !data.depthRaw().empty()) if(_colorOnly)
{ {
data.setRGBDImage(data.imageRaw(), cv::Mat(), data.cameraModels()); if(!data.depthRaw().empty())
{
data.setRGBDImage(data.imageRaw(), cv::Mat(), data.cameraModels());
}
else if(!data.rightRaw().empty())
{
data.setRGBDImage(data.imageRaw(), cv::Mat(), data.stereoCameraModel().left());
}
} }
if(_distortionModel && !data.depthRaw().empty()) if(_distortionModel && !data.depthRaw().empty())

View File

@@ -3080,6 +3080,7 @@ void DBDriverSqlite3::loadSignaturesQuery(const std::list<int> & ids, std::list<
std::multimap<int, cv::KeyPoint> visualWords; std::multimap<int, cv::KeyPoint> visualWords;
std::multimap<int, cv::Point3f> visualWords3; std::multimap<int, cv::Point3f> visualWords3;
std::multimap<int, cv::Mat> descriptors; std::multimap<int, cv::Mat> descriptors;
bool allWords3NaN = true;
cv::Point3f depth(0,0,0); cv::Point3f depth(0,0,0);
// Process the result if one // Process the result if one
@@ -3131,6 +3132,11 @@ void DBDriverSqlite3::loadSignaturesQuery(const std::list<int> & ids, std::list<
visualWords.insert(visualWords.end(), std::make_pair(visualWordId, kpt)); visualWords.insert(visualWords.end(), std::make_pair(visualWordId, kpt));
visualWords3.insert(visualWords3.end(), std::make_pair(visualWordId, depth)); visualWords3.insert(visualWords3.end(), std::make_pair(visualWordId, depth));
if(allWords3NaN && util3d::isFinite(depth))
{
allWords3NaN = false;
}
if(uStrNumCmp(_version, "0.11.2") >= 0) if(uStrNumCmp(_version, "0.11.2") >= 0)
{ {
descriptorSize = sqlite3_column_int(ppStmt, index++); // VisualWord descriptor size descriptorSize = sqlite3_column_int(ppStmt, index++); // VisualWord descriptor size
@@ -3172,9 +3178,12 @@ void DBDriverSqlite3::loadSignaturesQuery(const std::list<int> & ids, std::list<
else else
{ {
(*iter)->setWords(visualWords); (*iter)->setWords(visualWords);
(*iter)->setWords3(visualWords3); if(!allWords3NaN)
{
(*iter)->setWords3(visualWords3);
}
(*iter)->setWordsDescriptors(descriptors); (*iter)->setWordsDescriptors(descriptors);
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()); ULOGGER_DEBUG("Add %d keypoints, %d 3d points and %d descriptors to node %d", (int)visualWords.size(), allWords3NaN?0:(int)visualWords3.size(), (int)descriptors.size(), (*iter)->id());
} }
//reset //reset
@@ -4191,6 +4200,7 @@ void DBDriverSqlite3::saveQuery(const std::list<Signature *> & signatures)
query = queryStepKeypoint(); query = queryStepKeypoint();
rc = sqlite3_prepare_v2(_ppDb, query.c_str(), -1, &ppStmt, 0); rc = sqlite3_prepare_v2(_ppDb, query.c_str(), -1, &ppStmt, 0);
UASSERT_MSG(rc == SQLITE_OK, uFormat("DB error (%s): %s", _version.c_str(), sqlite3_errmsg(_ppDb)).c_str()); UASSERT_MSG(rc == SQLITE_OK, uFormat("DB error (%s): %s", _version.c_str(), sqlite3_errmsg(_ppDb)).c_str());
float nanFloat = std::numeric_limits<float>::quiet_NaN ();
for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i) for(std::list<Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
{ {
UASSERT((*i)->getWords3().empty() || (*i)->getWords().size() == (*i)->getWords3().size()); UASSERT((*i)->getWords3().empty() || (*i)->getWords().size() == (*i)->getWords3().size());
@@ -4200,7 +4210,7 @@ void DBDriverSqlite3::saveQuery(const std::list<Signature *> & signatures)
std::multimap<int, cv::Mat>::const_iterator d=(*i)->getWordsDescriptors().begin(); std::multimap<int, cv::Mat>::const_iterator d=(*i)->getWordsDescriptors().begin();
for(std::multimap<int, cv::KeyPoint>::const_iterator w=(*i)->getWords().begin(); w!=(*i)->getWords().end(); ++w) for(std::multimap<int, cv::KeyPoint>::const_iterator w=(*i)->getWords().begin(); w!=(*i)->getWords().end(); ++w)
{ {
cv::Point3f pt(0,0,0); cv::Point3f pt(nanFloat,nanFloat,nanFloat);
if(p!=(*i)->getWords3().end()) if(p!=(*i)->getWords3().end())
{ {
UASSERT(w->first == p->first); // must be same id! UASSERT(w->first == p->first); // must be same id!

View File

@@ -65,7 +65,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>680</width> <width>680</width>
<height>3157</height> <height>3197</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_16"> <layout class="QVBoxLayout" name="verticalLayout_16">
@@ -95,7 +95,7 @@
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>7</number> <number>5</number>
</property> </property>
<widget class="QWidget" name="page_22"> <widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1"> <layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
@@ -2876,7 +2876,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="10" column="1">
<widget class="QLabel" name="label_244"> <widget class="QLabel" name="label_244">
<property name="text"> <property name="text">
<string>Create a calibration file with known intrinsics (fx, fy, cx, cy). Useful if you already know the intrinsics of the source of images.</string> <string>Create a calibration file with known intrinsics (fx, fy, cx, cy). Useful if you already know the intrinsics of the source of images.</string>
@@ -2889,7 +2889,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="7" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,1"> <layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,1">
<item> <item>
<widget class="QToolButton" name="toolButton_source_path_calibration"> <widget class="QToolButton" name="toolButton_source_path_calibration">
@@ -2989,7 +2989,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</item> </item>
</widget> </widget>
</item> </item>
<item row="10" column="0"> <item row="11" column="0">
<widget class="QPushButton" name="pushButton_test_camera"> <widget class="QPushButton" name="pushButton_test_camera">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@@ -3002,7 +3002,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="9" column="0">
<widget class="QPushButton" name="pushButton_calibrate"> <widget class="QPushButton" name="pushButton_calibrate">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@@ -3015,7 +3015,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="9" column="1">
<widget class="QLabel" name="label_24"> <widget class="QLabel" name="label_24">
<property name="text"> <property name="text">
<string>Calibration files are saved in &quot;camera_info&quot; folder of the working directory.</string> <string>Calibration files are saved in &quot;camera_info&quot; folder of the working directory.</string>
@@ -3035,7 +3035,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item row="10" column="0">
<widget class="QPushButton" name="pushButton_calibrate_simple"> <widget class="QPushButton" name="pushButton_calibrate_simple">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@@ -3048,7 +3048,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="7" column="1">
<widget class="QLabel" name="label_18"> <widget class="QLabel" name="label_18">
<property name="text"> <property name="text">
<string>Calibration file path (*.yaml). If empty, the GUID of the camera is used (for those having one). OpenNI and Freenect drivers use factory calibration by default (so they ignore this parameter). A calibrated camera is required for RGB-D SLAM mode.</string> <string>Calibration file path (*.yaml). If empty, the GUID of the camera is used (for those having one). OpenNI and Freenect drivers use factory calibration by default (so they ignore this parameter). A calibrated camera is required for RGB-D SLAM mode.</string>
@@ -3081,6 +3081,29 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1">
<widget class="QLabel" name="label_229">
<property name="text">
<string>Only RGB images (for RGB-D cameras) or left images (for stereo cameras) are published.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkbox_rgbd_colorOnly">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@@ -3192,29 +3215,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="label_229">
<property name="text">
<string>Only RGB images are published.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkbox_rgbd_colorOnly">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>