From ccb679e7c2c3342c5768603e93fd4cce37b4a21d Mon Sep 17 00:00:00 2001 From: matlabbe Date: Sun, 17 Jan 2016 12:24:42 -0500 Subject: [PATCH] OpenCV3: added RHO homography type "Homography/method" --- include/find_object/Settings.h | 2 +- src/ParametersToolBox.cpp | 7 +++++++ src/Settings.cpp | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/find_object/Settings.h b/include/find_object/Settings.h index 1a6f3dfc..b9559520 100644 --- a/include/find_object/Settings.h +++ b/include/find_object/Settings.h @@ -282,7 +282,7 @@ class FINDOBJECT_EXP Settings PARAMETER(General, autoPauseOnDetection, bool, false, "Auto pause the camera when an object is detected."); PARAMETER(Homography, homographyComputed, bool, true, "Compute homography? On ROS, this is required to publish objects detected."); - PARAMETER(Homography, method, QString, "1:LMEDS;RANSAC", "Type of the robust estimation algorithm: least-median algorithm or RANSAC algorithm."); + 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, 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)."); diff --git a/src/ParametersToolBox.cpp b/src/ParametersToolBox.cpp index 5b6c181c..871b6da1 100644 --- a/src/ParametersToolBox.cpp +++ b/src/ParametersToolBox.cpp @@ -394,6 +394,13 @@ void ParametersToolBox::addParameter(QVBoxLayout * layout, widget->setItemData(4, 0, Qt::UserRole - 1); #endif } + if(key.compare(Settings::kHomography_method()) == 0) + { +#if CV_MAJOR_VERSION < 3 + // disable RHO approach + widget->setItemData(2, 0, Qt::UserRole - 1); +#endif + } widget->setCurrentIndex(splitted.first().toInt()); connect(widget, SIGNAL(currentIndexChanged(int)), this, SLOT(changeParameter(int))); diff --git a/src/Settings.cpp b/src/Settings.cpp index 6ed7d7cb..682437eb 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -1425,6 +1425,11 @@ int Settings::getHomographyMethod() { switch(method) { +#if CV_MAJOR_VERSION >= 3 + case 2: + method = cv::RHO; + break; +#endif case 0: method = cv::LMEDS; break;