cloudFromDisparity(): adjusting decimation if not valid with current image size. Standalone: ask user to set other parameters to default if some were set on command line.

This commit is contained in:
matlabbe
2017-04-28 11:43:27 -04:00
parent 1ea94c0356
commit 14baca125d
4 changed files with 58 additions and 6 deletions
+36 -3
View File
@@ -595,10 +595,26 @@ pcl::PointCloud<pcl::PointXYZ>::Ptr cloudFromDisparity(
std::vector<int> * validIndices)
{
UASSERT(imageDisparity.type() == CV_32FC1 || imageDisparity.type()==CV_16SC1);
UASSERT(imageDisparity.rows % decimation == 0);
UASSERT(imageDisparity.cols % decimation == 0);
UASSERT(decimation >= 1);
if(imageDisparity.rows % decimation != 0 || imageDisparity.cols % decimation != 0)
{
int oldDecimation = decimation;
while(decimation >= 1)
{
if(imageDisparity.rows % decimation == 0 && imageDisparity.cols % decimation == 0)
{
break;
}
--decimation;
}
if(imageDisparity.rows % oldDecimation != 0 || imageDisparity.cols % oldDecimation != 0)
{
UWARN("Decimation (%d) is not valid for current image size (depth=%dx%d). Highest compatible decimation used=%d.", oldDecimation, imageDisparity.cols, imageDisparity.rows, decimation);
}
}
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
//cloud.header = cameraInfo.header;
@@ -686,7 +702,24 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudFromDisparityRGB(
(imageDisparity.type() == CV_32FC1 || imageDisparity.type()==CV_16SC1));
UASSERT(imageRgb.channels() == 3 || imageRgb.channels() == 1);
UASSERT(decimation >= 1);
UASSERT(imageDisparity.rows % decimation == 0 && imageDisparity.cols % decimation == 0);
if(imageDisparity.rows % decimation != 0 || imageDisparity.cols % decimation != 0)
{
int oldDecimation = decimation;
while(decimation >= 1)
{
if(imageDisparity.rows % decimation == 0 && imageDisparity.cols % decimation == 0)
{
break;
}
--decimation;
}
if(imageDisparity.rows % oldDecimation != 0 || imageDisparity.cols % oldDecimation != 0)
{
UWARN("Decimation (%d) is not valid for current image size (depth=%dx%d). Highest compatible decimation used=%d.", oldDecimation, imageDisparity.cols, imageDisparity.rows, decimation);
}
}
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
@@ -131,7 +131,7 @@ public:
rtabmap::ParametersMap getAllParameters() const;
std::string getParameter(const std::string & key) const;
void updateParameters(const ParametersMap & parameters);
void updateParameters(const ParametersMap & parameters, bool setOtherParametersToDefault = false);
//General panel
int getGeneralLoggerLevel() const;
+7 -1
View File
@@ -4081,7 +4081,13 @@ void MainWindow::updateParameters(const ParametersMap & parameters)
_ui->widget_console->appendMsg(msg);
UWARN(msg.toStdString().c_str());
}
_preferencesDialog->updateParameters(parameters);
QMessageBox::StandardButton button = QMessageBox::question(this,
tr("Parameters"),
tr("Some parameters have been set on command line, do you "
"want to set all other RTAB-Map's parameters to default?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
_preferencesDialog->updateParameters(parameters, button==QMessageBox::Yes);
}
}
+14 -1
View File
@@ -2889,7 +2889,7 @@ std::string PreferencesDialog::getParameter(const std::string & key) const
return _parameters.at(key);
}
void PreferencesDialog::updateParameters(const ParametersMap & parameters)
void PreferencesDialog::updateParameters(const ParametersMap & parameters, bool setOtherParametersToDefault)
{
if(parameters.size())
{
@@ -2897,6 +2897,19 @@ void PreferencesDialog::updateParameters(const ParametersMap & parameters)
{
this->setParameter(iter->first, iter->second);
}
if(setOtherParametersToDefault)
{
for(ParametersMap::const_iterator iter=Parameters::getDefaultParameters().begin();
iter!=Parameters::getDefaultParameters().end();
++iter)
{
if(parameters.find(iter->first) == parameters.end() &&
iter->first.compare(Parameters::kRtabmapWorkingDirectory())!=0)
{
this->setParameter(iter->first, iter->second);
}
}
}
if(!this->isVisible())
{
this->writeSettings(getTmpIniFilePath());