32 #include <QDoubleSpinBox>    37 #include <QVBoxLayout>    38 #include <QMessageBox>    41 #include <opencv2/opencv_modules.hpp>    56         return this->findChild<QWidget*>(key);
    61         QStringList paramChanged;
    62         const QObjectList & children = this->widget(index)->children();
    63         for(
int j=0; j<children.size();++j)
    65                 QString key = children.at(j)->objectName();
    67                 if(key.compare(Settings::kGeneral_nextObjID()) != 0)
    74                                 if(qobject_cast<QComboBox*>(children.at(j)))
    76                                         if(((QComboBox*)children.at(j))->currentIndex() != value.toString().split(
':').first().toInt())
    78                                                 ((QComboBox*)children.at(j))->setCurrentIndex(value.toString().split(
':').first().toInt());
    79                                                 paramChanged.append(key);
    82                                 else if(qobject_cast<QSpinBox*>(children.at(j)))
    84                                         if(((QSpinBox*)children.at(j))->value() != value.toInt())
    86                                                 ((QSpinBox*)children.at(j))->setValue(value.toInt());
    87                                                 paramChanged.append(key);
    90                                 else if(qobject_cast<QDoubleSpinBox*>(children.at(j)))
    92                                         if(((QDoubleSpinBox*)children.at(j))->value() != value.toDouble())
    94                                                 ((QDoubleSpinBox*)children.at(j))->setValue(value.toDouble());
    95                                                 paramChanged.append(key);
    98                                 else if(qobject_cast<QCheckBox*>(children.at(j)))
   100                                         if(((QCheckBox*)children.at(j))->isChecked() != value.toBool())
   102                                                 ((QCheckBox*)children.at(j))->setChecked(value.toBool());
   103                                                 paramChanged.append(key);
   106                                 else if(qobject_cast<QLineEdit*>(children.at(j)))
   108                                         if(((QLineEdit*)children.at(j))->text().compare(value.toString()) != 0)
   110                                                 ((QLineEdit*)children.at(j))->setText(value.toString());
   111                                                 paramChanged.append(key);
   122         this->blockSignals(
true);
   123         QStringList paramChanged = this->
resetPage(this->currentIndex());
   124         this->blockSignals(
false);
   130         QStringList paramChanged;
   131         this->blockSignals(
true);
   132         for(
int i=0; i< this->count(); ++i)
   136         this->blockSignals(
false);
   143         QComboBox * descriptorBox = this->findChild<QComboBox*>(Settings::kFeature2D_2Descriptor());
   144         QComboBox * detectorBox = this->findChild<QComboBox*>(Settings::kFeature2D_1Detector());
   145         if(descriptorBox && detectorBox)
   147                 QString group = Settings::kFeature2D_2Descriptor().split(
'/').first();
   149                 for(
int i=0; i<this->count(); ++i)
   151                         if(this->widget(i)->objectName().compare(group) == 0)
   153                                 panel = this->widget(i);
   159                         const QObjectList & objects = panel->children();
   160                         QString descriptorName = descriptorBox->currentText();
   161                         QString detectorName = detectorBox->currentText();
   163                         for(
int i=0; i<objects.size(); ++i)
   165                                 if(!objects[i]->objectName().isEmpty())
   167                                         if(objects[i]->objectName().contains(descriptorName) || objects[i]->objectName().contains(detectorName))
   169                                                 ((QWidget*)objects[i])->setVisible(
true);
   171                                         else if(objects[i]->objectName().contains(
"Fast") && detectorName == QString(
"ORB"))
   173                                                 ((QWidget*)objects[i])->setVisible(
true);       
   175                                         else if(!objects[i]->objectName().split(
'/').at(1).at(0).isDigit())
   177                                                 ((QWidget*)objects[i])->setVisible(
false);
   184         QComboBox * nnBox = this->findChild<QComboBox*>(Settings::kNearestNeighbor_1Strategy());
   187                 QString group = Settings::kNearestNeighbor_1Strategy().split(
'/').first();
   189                 for(
int i=0; i<this->count(); ++i)
   191                         if(this->widget(i)->objectName().compare(group) == 0)
   193                                 panel = this->widget(i);
   199                         const QObjectList & objects = panel->children();
   200                         QString nnName = nnBox->currentText();
   202                         for(
int i=0; i<objects.size(); ++i)
   204                                 if(!objects[i]->objectName().isEmpty())
   206                                         if(objects[i]->objectName().contains(nnName))
   208                                                 ((QWidget*)objects[i])->setVisible(
true);
   210                                         else if(!objects[i]->objectName().split(
'/').at(1).at(0).isDigit())
   212                                                 ((QWidget*)objects[i])->setVisible(
false);
   213                                                 if(nnBox->currentIndex() < 6 && objects[i]->objectName().split(
'/').at(1).contains(
"search"))
   216                                                         ((QWidget*)objects[i])->setVisible(
true);
   219                                         else if(objects[i]->objectName().split(
'/').at(1).contains(
"Distance_type"))
   222                                                 ((QWidget*)objects[i])->setVisible(nnBox->currentIndex() != 6);
   233         QWidget * currentItem = 0;
   235         for(ParametersMap::const_iterator iter=parameters.constBegin();
   236                         iter!=parameters.constEnd();
   239                 QStringList splitted = iter.key().split(
'/');
   240                 QString group = splitted.first();
   241                 QString name = splitted.last();
   242                 if(currentItem == 0 || currentItem->objectName().compare(group) != 0)
   244                         currentItem = 
new QWidget(
this);
   245                         this->addItem(currentItem, group);
   246                         currentItem->setObjectName(group);
   247                         QVBoxLayout * layout = 
new QVBoxLayout(currentItem);
   248                         currentItem->setLayout(layout);
   249                         layout->setContentsMargins(0,0,0,0);
   250                         layout->setSpacing(0);
   251                         layout->addSpacerItem(
new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding));
   257                         addParameter((QVBoxLayout*)currentItem->layout(), iter.key(), iter.value());
   266         QWidget * widget = this->findChild<QWidget*>(key);
   268         if(type.compare(
"QString") == 0)
   271                 if(value.contains(
';'))
   274                         QStringList splitted = value.split(
':');
   275                         ((QComboBox*)widget)->setCurrentIndex(splitted.first().toInt());
   279                         ((QLineEdit*)widget)->setText(value);
   282         else if(type.compare(
"int") == 0)
   286         else if(type.compare(
"uint") == 0)
   290         else if(type.compare(
"double") == 0)
   294         else if(type.compare(
"float") == 0)
   298         else if(type.compare(
"bool") == 0)
   306                 const QVariant & value)
   309         if(type.compare(
"QString") == 0)
   313         else if(type.compare(
"int") == 0)
   317         else if(type.compare(
"uint") == 0)
   321         else if(type.compare(
"double") == 0)
   325         else if(type.compare(
"float") == 0)
   329         else if(type.compare(
"bool") == 0)
   337                 const QString & value)
   339         if(value.contains(
';'))
   341                 QComboBox * widget = 
new QComboBox(
this);
   342                 widget->setObjectName(key);
   343                 QStringList splitted = value.split(
':');
   344                 widget->addItems(splitted.last().split(
';'));
   346                 if(key.compare(Settings::kFeature2D_1Detector()) == 0)
   348 #if FINDOBJECT_NONFREE == 0   349 #if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && (CV_MINOR_VERSION < 3 || (CV_MINOR_VERSION==3 && !defined(OPENCV_DEV))))   350                         widget->setItemData(5, 0, Qt::UserRole - 1); 
   352                         widget->setItemData(7, 0, Qt::UserRole - 1); 
   354 #if CV_MAJOR_VERSION < 3   355                         widget->setItemData(9, 0, Qt::UserRole - 1); 
   356                         widget->setItemData(10, 0, Qt::UserRole - 1); 
   357                         widget->setItemData(11, 0, Qt::UserRole - 1); 
   359                         widget->setItemData(0, 0, Qt::UserRole - 1); 
   360 #ifndef HAVE_OPENCV_XFEATURES2D   361                         widget->setItemData(6, 0, Qt::UserRole - 1); 
   364 #if FINDOBJECT_TORCH == 0   365                         widget->setItemData(12, 0, Qt::UserRole - 1); 
   368                 if(key.compare(Settings::kFeature2D_2Descriptor()) == 0)
   370 #if FINDOBJECT_NONFREE == 0   371 #if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && (CV_MINOR_VERSION < 3 || (CV_MINOR_VERSION==3 && !defined(OPENCV_DEV))))   372                         widget->setItemData(2, 0, Qt::UserRole - 1); 
   374                         widget->setItemData(3, 0, Qt::UserRole - 1); 
   376 #if CV_MAJOR_VERSION < 3   377                         widget->setItemData(6, 0, Qt::UserRole - 1); 
   378                         widget->setItemData(7, 0, Qt::UserRole - 1); 
   379                         widget->setItemData(8, 0, Qt::UserRole - 1); 
   380                         widget->setItemData(9, 0, Qt::UserRole - 1); 
   381                         widget->setItemData(10, 0, Qt::UserRole - 1); 
   384 #ifndef HAVE_OPENCV_XFEATURES2D   385                         widget->setItemData(0, 0, Qt::UserRole - 1); 
   386                         widget->setItemData(5, 0, Qt::UserRole - 1); 
   387                         widget->setItemData(8, 0, Qt::UserRole - 1); 
   388                         widget->setItemData(9, 0, Qt::UserRole - 1); 
   389                         widget->setItemData(10, 0, Qt::UserRole - 1); 
   392 #if FINDOBJECT_TORCH == 0   393                         widget->setItemData(11, 0, Qt::UserRole - 1); 
   396                 if(key.compare(Settings::kNearestNeighbor_1Strategy()) == 0)
   398 #if FINDOBJECT_NONFREE == 0 && CV_MAJOR_VERSION < 3   400                         widget->setItemData(0, 0, Qt::UserRole - 1);
   401                         widget->setItemData(1, 0, Qt::UserRole - 1);
   402                         widget->setItemData(2, 0, Qt::UserRole - 1);
   403                         widget->setItemData(3, 0, Qt::UserRole - 1);
   404                         widget->setItemData(4, 0, Qt::UserRole - 1);
   407                 if(key.compare(Settings::kHomography_method()) == 0)
   409 #if CV_MAJOR_VERSION < 3   411                         widget->setItemData(2, 0, Qt::UserRole - 1);
   415                 widget->setCurrentIndex(splitted.first().toInt());
   416                 connect(widget, SIGNAL(currentIndexChanged(
int)), 
this, SLOT(
changeParameter(
int)));
   421                 QLineEdit * widget = 
new QLineEdit(value, 
this);
   422                 widget->setObjectName(key);
   423                 connect(widget, SIGNAL(editingFinished()), 
this, SLOT(
changeParameter()));
   430                 const double & value)
   432         QDoubleSpinBox * widget = 
new QDoubleSpinBox(
this);
   434         int decimalValue = 0;
   437         str.remove( QRegExp(
"0+$") );
   441                 str.replace(
',', 
'.');
   442                 QStringList items = str.split(
'.');
   443                 if(items.size() == 2)
   445                         decimals = items.back().length();
   446                         decimalValue = items.back().toInt();
   451         if(def<0.001 || (decimals >= 4 && decimalValue>0))
   453                 widget->setDecimals(5);
   454                 widget->setSingleStep(0.0001);
   456         else if(def<0.01 || (decimals >= 3 && decimalValue>0))
   458                 widget->setDecimals(4);
   459                 widget->setSingleStep(0.001);
   461         else if(def<0.1 || (decimals >= 2 && decimalValue>0))
   463                 widget->setDecimals(3);
   464                 widget->setSingleStep(0.01);
   466         else if(def<1.0 || (decimals >= 1 && decimalValue>0))
   468                 widget->setDecimals(2);
   469                 widget->setSingleStep(0.1);
   473                 widget->setDecimals(1);
   478                 widget->setMaximum(def*1000000.0);
   482                 widget->setMaximum(1000000.0);
   486                 widget->setMinimum(def*1000000.0);
   487                 widget->setMaximum(0.0);
   489         widget->setValue(value);
   490         widget->setObjectName(key);
   491         connect(widget, SIGNAL(editingFinished()), 
this, SLOT(
changeParameter()));
   499         QSpinBox * widget = 
new QSpinBox(
this);
   504                 widget->setMaximum(def*1000000);
   508                 widget->setMaximum(1000000);
   512                 widget->setMinimum(def*1000000);
   513                 widget->setMaximum(0);
   515         widget->setValue(value);
   516         widget->setObjectName(key);
   517         connect(widget, SIGNAL(editingFinished()), 
this, SLOT(
changeParameter()));
   525         QCheckBox * widget = 
new QCheckBox(
this);
   526         widget->setChecked(value);
   527         widget->setObjectName(key);
   528         connect(widget, SIGNAL(toggled(
bool)), 
this, SLOT(
changeParameter(
bool)));
   534         QHBoxLayout * hLayout = 
new QHBoxLayout();
   535         layout->insertLayout(layout->count()-1, hLayout);
   536         QString tmp = key.split(
'/').last();
   537         if(tmp.at(0).isDigit())
   541         QLabel * label = 
new QLabel(tmp, 
this);
   542         label->setObjectName(key+
"/label");
   544         label->setTextInteractionFlags(Qt::TextSelectableByMouse);
   545         hLayout->addWidget(label);
   546         hLayout->addWidget(widget);
   554                 QStringList paramChanged;
   555                 paramChanged.append(sender()->objectName());
   563                 QDoubleSpinBox * doubleSpinBox = qobject_cast<QDoubleSpinBox*>(sender());
   564                 QSpinBox * spinBox = qobject_cast<QSpinBox*>(sender());
   565                 QLineEdit * lineEdit = qobject_cast<QLineEdit*>(sender());
   572                         if(spinBox->objectName().compare(Settings::kHomography_minimumInliers()) == 0 &&
   573                            spinBox->value() < 4)
   575                                 Settings::setHomography_minimumInliers(4);
   576                                 spinBox->blockSignals(
true);
   578                                 spinBox->blockSignals(
false);
   589                 QStringList paramChanged;
   590                 paramChanged.append(sender()->objectName());
   616                 QStringList paramChanged;
   617                 QComboBox * comboBox = qobject_cast<QComboBox*>(sender);
   618                 QCheckBox * checkBox = qobject_cast<QCheckBox*>(sender);
   620                 bool descriptorChanged = 
false;
   621                 if(comboBox && comboBox->objectName().compare(Settings::kFeature2D_1Detector()) == 0)
   623                         QComboBox * descriptorBox = (QComboBox*)this->
getParameterWidget(Settings::kFeature2D_2Descriptor());
   624                         if(comboBox->objectName().compare(Settings::kFeature2D_1Detector()) == 0 &&
   625                            comboBox->currentText() != descriptorBox->currentText() &&
   626                            Settings::getFeature2D_2Descriptor().contains(comboBox->currentText()))
   628                                 QMessageBox::StandardButton b = QMessageBox::question(
this,
   629                                                 tr(
"Use corresponding descriptor type?"),
   630                                                 tr(
"Current selected detector type (\"%1\") has its own corresponding descriptor type.\n"   631                                                    "Do you want to use its corresponding descriptor?")
   632                                                    .arg(comboBox->currentText()),
   633                                                    QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
   634                                 if(b == QMessageBox::Yes)
   636                                         int index = descriptorBox->findText(comboBox->currentText());
   639                                                 QStringList tmp = Settings::getFeature2D_2Descriptor().split(
':');
   641                                                 QString newTmp = QString::number(index)+
":"+tmp.back();
   642                                                 Settings::setFeature2D_2Descriptor(newTmp);
   643                                                 descriptorBox->blockSignals(
true);
   645                                                 descriptorBox->blockSignals(
false);
   646                                                 paramChanged.append(Settings::kFeature2D_2Descriptor());
   647                                                 descriptorChanged = 
true;
   651                                                 UERROR(
"Combo box detector type not found \"%s\"?!", comboBox->currentText().toStdString().c_str());
   657                 bool nnStrategyChanged = 
false;
   659                 if((comboBox && (comboBox->objectName().compare(Settings::kFeature2D_2Descriptor()) == 0 ||
   660                                                  comboBox->objectName().compare(Settings::kNearestNeighbor_1Strategy()) == 0)) ||
   662                    (checkBox && checkBox->objectName().compare(Settings::kNearestNeighbor_7ConvertBinToFloat()) == 0))
   664                         QComboBox * descriptorBox = (QComboBox*)this->
getParameterWidget(Settings::kFeature2D_2Descriptor());
   665                         QComboBox * nnBox = (QComboBox*)this->
getParameterWidget(Settings::kNearestNeighbor_1Strategy());
   666                         QComboBox * distBox = (QComboBox*)this->
getParameterWidget(Settings::kNearestNeighbor_2Distance_type());
   667                         QCheckBox * binToFloatCheckbox = (QCheckBox*)this->
getParameterWidget(Settings::kNearestNeighbor_7ConvertBinToFloat());
   668                         bool isBinaryDescriptor = descriptorBox->currentText().compare(
"ORB") == 0 ||
   669                                                                           descriptorBox->currentText().compare(
"Brief") == 0 ||
   670                                                                           descriptorBox->currentText().compare(
"BRISK") == 0 ||
   671                                                                           descriptorBox->currentText().compare(
"FREAK") == 0 ||
   672                                                                           descriptorBox->currentText().compare(
"AKAZE") == 0 ||
   673                                                                           descriptorBox->currentText().compare(
"LATCH") == 0 ||
   674                                                                           descriptorBox->currentText().compare(
"LUCID") == 0;
   675                         bool binToFloat = binToFloatCheckbox->isChecked();
   676                         if(isBinaryDescriptor && !binToFloat && nnBox->currentText().compare(
"Lsh") != 0 && nnBox->currentText().compare(
"BruteForce") != 0)
   678                                 QMessageBox::warning(
this,
   680                                                 tr(
"Current selected descriptor type (\"%1\") is binary while nearest neighbor strategy is not (\"%2\").\n"   681                                                    "Falling back to \"BruteForce\" nearest neighbor strategy with Hamming distance (by default).")
   682                                                    .arg(descriptorBox->currentText())
   683                                                    .arg(nnBox->currentText()));
   684                                 QString tmp = Settings::getNearestNeighbor_1Strategy();
   686                                 Settings::setNearestNeighbor_1Strategy(tmp);
   687                                 tmp = Settings::getNearestNeighbor_2Distance_type();
   689                                 Settings::setNearestNeighbor_2Distance_type(tmp);
   690                                 nnBox->blockSignals(
true);
   691                                 distBox->blockSignals(
true);
   694                                 nnBox->blockSignals(
false);
   695                                 distBox->blockSignals(
false);
   701                                 nnStrategyChanged = 
true;
   702                                 paramChanged.append(Settings::kNearestNeighbor_1Strategy());
   703                                 paramChanged.append(Settings::kNearestNeighbor_2Distance_type());
   705                         else if((!isBinaryDescriptor || binToFloat) && nnBox->currentText().compare(
"Lsh") == 0)
   709                                         QMessageBox::warning(
this,
   711                                                         tr(
"Current selected descriptor type (\"%1\") is binary, but binary to float descriptors conversion is activated while nearest neighbor strategy is (\"%2\").\n"   712                                                            "Disabling binary to float descriptors conversion and use Hamming distance (by default).")
   713                                                            .arg(descriptorBox->currentText())
   714                                                            .arg(nnBox->currentText()));
   716                                         binToFloatCheckbox->blockSignals(
true);
   717                                         if(checkBox && checkBox->objectName().compare(Settings::kNearestNeighbor_7ConvertBinToFloat()) == 0)
   724                                                 paramChanged.append(Settings::kNearestNeighbor_7ConvertBinToFloat());
   726                                         this->
updateParameter(Settings::kNearestNeighbor_7ConvertBinToFloat());
   727                                         binToFloatCheckbox->blockSignals(
false);
   729                                         QString tmp = Settings::getNearestNeighbor_2Distance_type();
   731                                         Settings::setNearestNeighbor_2Distance_type(tmp);
   732                                         distBox->blockSignals(
true);
   734                                         distBox->blockSignals(
false);
   735                                         paramChanged.append(Settings::kNearestNeighbor_2Distance_type());
   739                                         QMessageBox::warning(
this,
   741                                                         tr(
"Current selected descriptor type (\"%1\") is not binary while nearest neighbor strategy is (\"%2\").\n"   742                                                            "Falling back to \"KDTree\" nearest neighbor strategy with Euclidean_L2 distance (by default).")
   743                                                            .arg(descriptorBox->currentText())
   744                                                            .arg(nnBox->currentText()));
   746                                         QString tmp = Settings::getNearestNeighbor_1Strategy();
   748                                         Settings::setNearestNeighbor_1Strategy(tmp);
   749                                         tmp = Settings::getNearestNeighbor_2Distance_type();
   751                                         Settings::setNearestNeighbor_2Distance_type(tmp);
   752                                         nnBox->blockSignals(
true);
   753                                         distBox->blockSignals(
true);
   756                                         nnBox->blockSignals(
false);
   757                                         distBox->blockSignals(
false);
   763                                         nnStrategyChanged = 
true;
   764                                         paramChanged.append(Settings::kNearestNeighbor_1Strategy());
   765                                         paramChanged.append(Settings::kNearestNeighbor_2Distance_type());
   771                 if(nnStrategyChanged ||
   772                    (comboBox && (comboBox->objectName().compare(Settings::kNearestNeighbor_1Strategy()) == 0 ||
   773                                                  comboBox->objectName().compare(Settings::kNearestNeighbor_2Distance_type()) == 0)))
   775                         QComboBox * nnBox = (QComboBox*)this->
getParameterWidget(Settings::kNearestNeighbor_1Strategy());
   776                         QComboBox * distBox = (QComboBox*)this->
getParameterWidget(Settings::kNearestNeighbor_2Distance_type());
   777                         if(nnBox->currentText().compare(
"BruteForce") != 0 && nnBox->currentText().compare(
"Lsh") != 0 && distBox->currentIndex() > 1)
   779                                 QMessageBox::warning(
this,
   781                                                                         tr(
"Current selected nearest neighbor strategy type (\"%1\") cannot handle distance strategy (\"%2\").\n"   782                                                                            "Falling back to \"EUCLIDEAN_L2\" distance strategy (by default).")
   783                                                                            .arg(nnBox->currentText())
   784                                                                            .arg(distBox->currentText()));
   785                                 QString tmp = Settings::getNearestNeighbor_2Distance_type();
   787                                 Settings::setNearestNeighbor_2Distance_type(tmp);
   788                                 distBox->blockSignals(
true);
   790                                 distBox->blockSignals(
false);
   791                                 if(sender == distBox)
   796                                 paramChanged.append(Settings::kNearestNeighbor_2Distance_type());
   803                         for(
int i=0; i<comboBox->count(); ++i)
   805                                 items.append(comboBox->itemText(i));
   807                         QString merged = QString::number(value) + QString(
":") + items.join(
";");
   818                 paramChanged.append(sender->objectName());
 
static QVariant getParameter(const QString &key)
static const ParametersType & getParametersType()
#define UASSERT(condition)
static const ParametersMap & getParameters()
static void setParameter(const QString &key, const QVariant &value)
static const DescriptionsMap & getDescriptions()
QMap< QString, QVariant > ParametersMap
ULogger class and convenient macros. 
static const ParametersMap & getDefaultParameters()