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 widget->setItemData(5, 0, Qt::UserRole - 1);
350 widget->setItemData(7, 0, Qt::UserRole - 1);
352 #if CV_MAJOR_VERSION < 3 353 widget->setItemData(9, 0, Qt::UserRole - 1);
354 widget->setItemData(10, 0, Qt::UserRole - 1);
355 widget->setItemData(11, 0, Qt::UserRole - 1);
357 widget->setItemData(0, 0, Qt::UserRole - 1);
358 #ifndef HAVE_OPENCV_XFEATURES2D 359 widget->setItemData(6, 0, Qt::UserRole - 1);
363 if(key.compare(Settings::kFeature2D_2Descriptor()) == 0)
365 #if FINDOBJECT_NONFREE == 0 366 widget->setItemData(2, 0, Qt::UserRole - 1);
367 widget->setItemData(3, 0, Qt::UserRole - 1);
369 #if CV_MAJOR_VERSION < 3 370 widget->setItemData(6, 0, Qt::UserRole - 1);
371 widget->setItemData(7, 0, Qt::UserRole - 1);
372 widget->setItemData(8, 0, Qt::UserRole - 1);
373 widget->setItemData(9, 0, Qt::UserRole - 1);
374 widget->setItemData(10, 0, Qt::UserRole - 1);
377 #ifndef HAVE_OPENCV_XFEATURES2D 378 widget->setItemData(0, 0, Qt::UserRole - 1);
379 widget->setItemData(5, 0, Qt::UserRole - 1);
380 widget->setItemData(8, 0, Qt::UserRole - 1);
381 widget->setItemData(9, 0, Qt::UserRole - 1);
382 widget->setItemData(10, 0, Qt::UserRole - 1);
386 if(key.compare(Settings::kNearestNeighbor_1Strategy()) == 0)
388 #if FINDOBJECT_NONFREE == 0 && CV_MAJOR_VERSION < 3 390 widget->setItemData(0, 0, Qt::UserRole - 1);
391 widget->setItemData(1, 0, Qt::UserRole - 1);
392 widget->setItemData(2, 0, Qt::UserRole - 1);
393 widget->setItemData(3, 0, Qt::UserRole - 1);
394 widget->setItemData(4, 0, Qt::UserRole - 1);
397 if(key.compare(Settings::kHomography_method()) == 0)
399 #if CV_MAJOR_VERSION < 3 401 widget->setItemData(2, 0, Qt::UserRole - 1);
405 widget->setCurrentIndex(splitted.first().toInt());
406 connect(widget, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
changeParameter(
int)));
411 QLineEdit * widget =
new QLineEdit(value,
this);
412 widget->setObjectName(key);
413 connect(widget, SIGNAL(editingFinished()),
this, SLOT(
changeParameter()));
420 const double & value)
422 QDoubleSpinBox * widget =
new QDoubleSpinBox(
this);
424 int decimalValue = 0;
427 str.remove( QRegExp(
"0+$") );
431 str.replace(
',',
'.');
432 QStringList items = str.split(
'.');
433 if(items.size() == 2)
435 decimals = items.back().length();
436 decimalValue = items.back().toInt();
441 if(def<0.001 || (decimals >= 4 && decimalValue>0))
443 widget->setDecimals(5);
444 widget->setSingleStep(0.0001);
446 else if(def<0.01 || (decimals >= 3 && decimalValue>0))
448 widget->setDecimals(4);
449 widget->setSingleStep(0.001);
451 else if(def<0.1 || (decimals >= 2 && decimalValue>0))
453 widget->setDecimals(3);
454 widget->setSingleStep(0.01);
456 else if(def<1.0 || (decimals >= 1 && decimalValue>0))
458 widget->setDecimals(2);
459 widget->setSingleStep(0.1);
463 widget->setDecimals(1);
468 widget->setMaximum(def*1000000.0);
472 widget->setMaximum(1000000.0);
476 widget->setMinimum(def*1000000.0);
477 widget->setMaximum(0.0);
479 widget->setValue(value);
480 widget->setObjectName(key);
481 connect(widget, SIGNAL(editingFinished()),
this, SLOT(
changeParameter()));
489 QSpinBox * widget =
new QSpinBox(
this);
494 widget->setMaximum(def*1000000);
498 widget->setMaximum(1000000);
502 widget->setMinimum(def*1000000);
503 widget->setMaximum(0);
505 widget->setValue(value);
506 widget->setObjectName(key);
507 connect(widget, SIGNAL(editingFinished()),
this, SLOT(
changeParameter()));
515 QCheckBox * widget =
new QCheckBox(
this);
516 widget->setChecked(value);
517 widget->setObjectName(key);
518 connect(widget, SIGNAL(toggled(
bool)),
this, SLOT(
changeParameter(
bool)));
524 QHBoxLayout * hLayout =
new QHBoxLayout();
525 layout->insertLayout(layout->count()-1, hLayout);
526 QString tmp = key.split(
'/').last();
527 if(tmp.at(0).isDigit())
531 QLabel * label =
new QLabel(tmp,
this);
532 label->setObjectName(key+
"/label");
534 label->setTextInteractionFlags(Qt::TextSelectableByMouse);
535 hLayout->addWidget(label);
536 hLayout->addWidget(widget);
544 QStringList paramChanged;
545 paramChanged.append(sender()->objectName());
553 QDoubleSpinBox * doubleSpinBox = qobject_cast<QDoubleSpinBox*>(sender());
554 QSpinBox * spinBox = qobject_cast<QSpinBox*>(sender());
555 QLineEdit * lineEdit = qobject_cast<QLineEdit*>(sender());
562 if(spinBox->objectName().compare(Settings::kHomography_minimumInliers()) == 0 &&
563 spinBox->value() < 4)
565 Settings::setHomography_minimumInliers(4);
566 spinBox->blockSignals(
true);
568 spinBox->blockSignals(
false);
579 QStringList paramChanged;
580 paramChanged.append(sender()->objectName());
606 QStringList paramChanged;
607 QComboBox * comboBox = qobject_cast<QComboBox*>(sender);
608 QCheckBox * checkBox = qobject_cast<QCheckBox*>(sender);
610 bool descriptorChanged =
false;
611 if(comboBox && comboBox->objectName().compare(Settings::kFeature2D_1Detector()) == 0)
613 QComboBox * descriptorBox = (QComboBox*)this->
getParameterWidget(Settings::kFeature2D_2Descriptor());
614 if(comboBox->objectName().compare(Settings::kFeature2D_1Detector()) == 0 &&
615 comboBox->currentText() != descriptorBox->currentText() &&
616 Settings::getFeature2D_2Descriptor().contains(comboBox->currentText()))
618 QMessageBox::StandardButton b = QMessageBox::question(
this,
619 tr(
"Use corresponding descriptor type?"),
620 tr(
"Current selected detector type (\"%1\") has its own corresponding descriptor type.\n" 621 "Do you want to use its corresponding descriptor?")
622 .arg(comboBox->currentText()),
623 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
624 if(b == QMessageBox::Yes)
626 int index = descriptorBox->findText(comboBox->currentText());
629 QStringList tmp = Settings::getFeature2D_2Descriptor().split(
':');
631 QString newTmp = QString(
'0'+index)+
":"+tmp.back();
632 Settings::setFeature2D_2Descriptor(newTmp);
633 descriptorBox->blockSignals(
true);
635 descriptorBox->blockSignals(
false);
636 paramChanged.append(Settings::kFeature2D_2Descriptor());
637 descriptorChanged =
true;
641 UERROR(
"Combo box detector type not found \"%s\"?!", comboBox->currentText().toStdString().c_str());
647 bool nnStrategyChanged =
false;
649 if((comboBox && (comboBox->objectName().compare(Settings::kFeature2D_2Descriptor()) == 0 ||
650 comboBox->objectName().compare(Settings::kNearestNeighbor_1Strategy()) == 0)) ||
652 (checkBox && checkBox->objectName().compare(Settings::kNearestNeighbor_7ConvertBinToFloat()) == 0))
654 QComboBox * descriptorBox = (QComboBox*)this->
getParameterWidget(Settings::kFeature2D_2Descriptor());
655 QComboBox * nnBox = (QComboBox*)this->
getParameterWidget(Settings::kNearestNeighbor_1Strategy());
656 QComboBox * distBox = (QComboBox*)this->
getParameterWidget(Settings::kNearestNeighbor_2Distance_type());
657 QCheckBox * binToFloatCheckbox = (QCheckBox*)this->
getParameterWidget(Settings::kNearestNeighbor_7ConvertBinToFloat());
658 bool isBinaryDescriptor = descriptorBox->currentText().compare(
"ORB") == 0 ||
659 descriptorBox->currentText().compare(
"Brief") == 0 ||
660 descriptorBox->currentText().compare(
"BRISK") == 0 ||
661 descriptorBox->currentText().compare(
"FREAK") == 0 ||
662 descriptorBox->currentText().compare(
"AKAZE") == 0 ||
663 descriptorBox->currentText().compare(
"LATCH") == 0 ||
664 descriptorBox->currentText().compare(
"LUCID") == 0;
665 bool binToFloat = binToFloatCheckbox->isChecked();
666 if(isBinaryDescriptor && !binToFloat && nnBox->currentText().compare(
"Lsh") != 0 && nnBox->currentText().compare(
"BruteForce") != 0)
668 QMessageBox::warning(
this,
670 tr(
"Current selected descriptor type (\"%1\") is binary while nearest neighbor strategy is not (\"%2\").\n" 671 "Falling back to \"BruteForce\" nearest neighbor strategy with Hamming distance (by default).")
672 .arg(descriptorBox->currentText())
673 .arg(nnBox->currentText()));
674 QString tmp = Settings::getNearestNeighbor_1Strategy();
676 Settings::setNearestNeighbor_1Strategy(tmp);
677 tmp = Settings::getNearestNeighbor_2Distance_type();
679 Settings::setNearestNeighbor_2Distance_type(tmp);
680 nnBox->blockSignals(
true);
681 distBox->blockSignals(
true);
684 nnBox->blockSignals(
false);
685 distBox->blockSignals(
false);
691 nnStrategyChanged =
true;
692 paramChanged.append(Settings::kNearestNeighbor_1Strategy());
693 paramChanged.append(Settings::kNearestNeighbor_2Distance_type());
695 else if((!isBinaryDescriptor || binToFloat) && nnBox->currentText().compare(
"Lsh") == 0)
699 QMessageBox::warning(
this,
701 tr(
"Current selected descriptor type (\"%1\") is binary, but binary to float descriptors conversion is activated while nearest neighbor strategy is (\"%2\").\n" 702 "Disabling binary to float descriptors conversion and use Hamming distance (by default).")
703 .arg(descriptorBox->currentText())
704 .arg(nnBox->currentText()));
706 binToFloatCheckbox->blockSignals(
true);
707 if(checkBox && checkBox->objectName().compare(Settings::kNearestNeighbor_7ConvertBinToFloat()) == 0)
714 paramChanged.append(Settings::kNearestNeighbor_7ConvertBinToFloat());
716 this->
updateParameter(Settings::kNearestNeighbor_7ConvertBinToFloat());
717 binToFloatCheckbox->blockSignals(
false);
719 QString tmp = Settings::getNearestNeighbor_2Distance_type();
721 Settings::setNearestNeighbor_2Distance_type(tmp);
722 distBox->blockSignals(
true);
724 distBox->blockSignals(
false);
725 paramChanged.append(Settings::kNearestNeighbor_2Distance_type());
729 QMessageBox::warning(
this,
731 tr(
"Current selected descriptor type (\"%1\") is not binary while nearest neighbor strategy is (\"%2\").\n" 732 "Falling back to \"KDTree\" nearest neighbor strategy with Euclidean_L2 distance (by default).")
733 .arg(descriptorBox->currentText())
734 .arg(nnBox->currentText()));
736 QString tmp = Settings::getNearestNeighbor_1Strategy();
738 Settings::setNearestNeighbor_1Strategy(tmp);
739 tmp = Settings::getNearestNeighbor_2Distance_type();
741 Settings::setNearestNeighbor_2Distance_type(tmp);
742 nnBox->blockSignals(
true);
743 distBox->blockSignals(
true);
746 nnBox->blockSignals(
false);
747 distBox->blockSignals(
false);
753 nnStrategyChanged =
true;
754 paramChanged.append(Settings::kNearestNeighbor_1Strategy());
755 paramChanged.append(Settings::kNearestNeighbor_2Distance_type());
761 if(nnStrategyChanged ||
762 (comboBox && (comboBox->objectName().compare(Settings::kNearestNeighbor_1Strategy()) == 0 ||
763 comboBox->objectName().compare(Settings::kNearestNeighbor_2Distance_type()) == 0)))
765 QComboBox * nnBox = (QComboBox*)this->
getParameterWidget(Settings::kNearestNeighbor_1Strategy());
766 QComboBox * distBox = (QComboBox*)this->
getParameterWidget(Settings::kNearestNeighbor_2Distance_type());
767 if(nnBox->currentText().compare(
"BruteForce") != 0 && nnBox->currentText().compare(
"Lsh") != 0 && distBox->currentIndex() > 1)
769 QMessageBox::warning(
this,
771 tr(
"Current selected nearest neighbor strategy type (\"%1\") cannot handle distance strategy (\"%2\").\n" 772 "Falling back to \"EUCLIDEAN_L2\" distance strategy (by default).")
773 .arg(nnBox->currentText())
774 .arg(distBox->currentText()));
775 QString tmp = Settings::getNearestNeighbor_2Distance_type();
777 Settings::setNearestNeighbor_2Distance_type(tmp);
778 distBox->blockSignals(
true);
780 distBox->blockSignals(
false);
781 if(sender == distBox)
786 paramChanged.append(Settings::kNearestNeighbor_2Distance_type());
793 for(
int i=0; i<comboBox->count(); ++i)
795 items.append(comboBox->itemText(i));
797 QString merged = QString::number(value) + QString(
":") + items.join(
";");
808 paramChanged.append(sender->objectName());
static QVariant getParameter(const QString &key)
TFSIMD_FORCE_INLINE void setValue(const tfScalar &x, const tfScalar &y, const tfScalar &z)
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()