diff --git a/include/find_object/MainWindow.h b/include/find_object/MainWindow.h index 392b4b2f..e2418bae 100644 --- a/include/find_object/MainWindow.h +++ b/include/find_object/MainWindow.h @@ -73,6 +73,7 @@ public: protected: virtual void closeEvent(QCloseEvent * event); + virtual void keyPressEvent(QKeyEvent *event); public Q_SLOTS: void startProcessing(); diff --git a/include/find_object/Settings.h b/include/find_object/Settings.h index dab1f9b5..d90ce1c3 100644 --- a/include/find_object/Settings.h +++ b/include/find_object/Settings.h @@ -288,7 +288,11 @@ class FINDOBJECT_EXP Settings PARAMETER(Homography, homographyComputed, bool, true, "Compute homography? On ROS, this is required to publish objects detected."); PARAMETER(Homography, method, QString, "1:LMEDS;RANSAC;RHO", "Type of the robust estimation algorithm: least-median algorithm or RANSAC algorithm."); - PARAMETER(Homography, ransacReprojThr, double, 5.0, "Maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only). It usually makes sense to set this parameter somewhere in the range of 1 to 10."); + PARAMETER(Homography, ransacReprojThr, double, 3.0, "Maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only). It usually makes sense to set this parameter somewhere in the range of 1 to 10."); +#if CV_MAJOR_VERSION >= 3 + PARAMETER(Homography, maxIterations, int, 2000, "The maximum number of RANSAC iterations, 2000 is the maximum it can be."); + PARAMETER(Homography, confidence, double, 0.995, "Confidence level, between 0 and 1."); +#endif PARAMETER(Homography, minimumInliers, int, 10, "Minimum inliers to accept the homography. Value must be >= 4."); PARAMETER(Homography, ignoreWhenAllInliers, bool, false, "Ignore homography when all features are inliers (sometimes when the homography doesn't converge, it returns the best homography with all features as inliers)."); PARAMETER(Homography, rectBorderWidth, int, 4, "Homography rectangle border width."); diff --git a/src/FindObject.cpp b/src/FindObject.cpp index 862f0df0..03d0706f 100644 --- a/src/FindObject.cpp +++ b/src/FindObject.cpp @@ -1251,11 +1251,21 @@ protected: } UDEBUG("Find homography... begin"); +#if CV_MAJOR_VERSION < 3 h_ = findHomography(mpts_1, mpts_2, Settings::getHomographyMethod(), Settings::getHomography_ransacReprojThr(), outlierMask_); +#else + h_ = findHomography(mpts_1, + mpts_2, + Settings::getHomographyMethod(), + Settings::getHomography_ransacReprojThr(), + outlierMask_, + Settings::getHomography_maxIterations(), + Settings::getHomography_confidence()); +#endif UDEBUG("Find homography... end"); UASSERT(outlierMask_.size() == 0 || outlierMask_.size() == mpts_1.size()); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index f7efc062..f23fe6cc 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -272,6 +272,8 @@ MainWindow::MainWindow(FindObject * findObject, Camera * camera, QWidget * paren //Setup drag and drop images connect(ui_->imageDrop_objects, SIGNAL(imagesReceived(const QStringList &)), this, SLOT(addObjectsFromFiles(const QStringList &))); connect(ui_->imageDrop_scene, SIGNAL(imagesReceived(const QStringList &)), this, SLOT(loadSceneFromFile(const QStringList &))); + + ui_->imageView_source->setFocus(); } MainWindow::~MainWindow() @@ -316,6 +318,22 @@ void MainWindow::closeEvent(QCloseEvent * event) } } +void MainWindow::keyPressEvent(QKeyEvent *event) +{ + //catch ctrl-s to save settings + if(event->key() == Qt::Key_Space) + { + if(ui_->actionStart_camera->isEnabled()) + { + startProcessing(); + } + else if(ui_->actionPause_camera->isEnabled()) + { + pauseProcessing(); + } + } +} + void MainWindow::setupTCPServer() { if(tcpServer_) diff --git a/src/ParametersToolBox.cpp b/src/ParametersToolBox.cpp index e45608ef..71ac78f5 100644 --- a/src/ParametersToolBox.cpp +++ b/src/ParametersToolBox.cpp @@ -420,14 +420,47 @@ void ParametersToolBox::addParameter(QVBoxLayout * layout, const double & value) { QDoubleSpinBox * widget = new QDoubleSpinBox(this); + int decimals = 0; + int decimalValue = 0; + + QString str = QString::number(Settings::getDefaultParameters().value(key).toDouble()); + str.remove( QRegExp("0+$") ); + + if(!str.isEmpty()) + { + str.replace(',', '.'); + QStringList items = str.split('.'); + if(items.size() == 2) + { + decimals = items.back().length(); + decimalValue = items.back().toInt(); + } + } + double def = Settings::getDefaultParameters().value(key).toDouble(); - if(def<0.01) + if(def<0.001 || (decimals >= 4 && decimalValue>0)) + { + widget->setDecimals(5); + widget->setSingleStep(0.0001); + } + else if(def<0.01 || (decimals >= 3 && decimalValue>0)) { widget->setDecimals(4); + widget->setSingleStep(0.001); } - else if(def<0.1) + else if(def<0.1 || (decimals >= 2 && decimalValue>0)) { widget->setDecimals(3); + widget->setSingleStep(0.01); + } + else if(def<1.0 || (decimals >= 1 && decimalValue>0)) + { + widget->setDecimals(2); + widget->setSingleStep(0.1); + } + else + { + widget->setDecimals(1); } if(def>0.0)