Fixed SIFT build issue between OpenCV 4.3.0 and OpenCV 4.3.0-dev

This commit is contained in:
matlabbe
2020-05-27 10:35:18 -04:00
parent 798466bb05
commit ae5ce029d6
5 changed files with 22 additions and 14 deletions
+10 -3
View File
@@ -689,6 +689,16 @@ ELSEIF(OpenCV_VERSION VERSION_GREATER "3.4.2")
ENDIF(${matchres} EQUAL -1) ENDIF(${matchres} EQUAL -1)
ENDIF() ENDIF()
# check if version status is "-dev" (SIFT compatibility issue between 4.3.0 vs 4.3.0-dev)
FIND_FILE(OpenCV_VERSION_HPP opencv2/core/version.hpp
PATHS ${OpenCV_INCLUDE_DIRS}
NO_DEFAULT_PATH)
FILE(READ ${OpenCV_VERSION_HPP} TMPTXT)
STRING(FIND "${TMPTXT}" "-dev" matchres)
IF(${matchres} EQUAL -1)
SET(OPENCV_DEV "//")
ENDIF(${matchres} EQUAL -1)
IF(NOT G2O_FOUND) IF(NOT G2O_FOUND)
SET(G2O "//") SET(G2O "//")
ELSE() ELSE()
@@ -856,9 +866,6 @@ IF(NOT WITH_MADGWICK)
SET(MADGWICK "//") SET(MADGWICK "//")
ENDIF() ENDIF()
IF(NOT (OpenCV_FOUND AND NOT (OpenCV_VERSION_MAJOR LESS 3)))
SET(OPENCV3 "//")
ENDIF(NOT (OpenCV_FOUND AND NOT (OpenCV_VERSION_MAJOR LESS 3)))
CONFIGURE_FILE(Version.h.in ${PROJECT_SOURCE_DIR}/corelib/include/${PROJECT_PREFIX}/core/Version.h) CONFIGURE_FILE(Version.h.in ${PROJECT_SOURCE_DIR}/corelib/include/${PROJECT_PREFIX}/core/Version.h)
ADD_SUBDIRECTORY( utilite ) ADD_SUBDIRECTORY( utilite )
+1
View File
@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define RTABMAP_VERSION_COMPARE(major, minor, patch) (major>=@PROJECT_VERSION_MAJOR@ || (major==@PROJECT_VERSION_MAJOR@ && minor>=@PROJECT_VERSION_MINOR@) || (major==@PROJECT_VERSION_MAJOR@ && minor==@PROJECT_VERSION_MINOR@ && patch >=@PROJECT_VERSION_PATCH@)) #define RTABMAP_VERSION_COMPARE(major, minor, patch) (major>=@PROJECT_VERSION_MAJOR@ || (major==@PROJECT_VERSION_MAJOR@ && minor>=@PROJECT_VERSION_MINOR@) || (major==@PROJECT_VERSION_MAJOR@ && minor==@PROJECT_VERSION_MINOR@ && patch >=@PROJECT_VERSION_PATCH@))
@NONFREE@#define RTABMAP_NONFREE @NONFREE@#define RTABMAP_NONFREE
@OPENCV_DEV@#define RTABMAP_OPENCV_DEV
@TORO@#define RTABMAP_TORO @TORO@#define RTABMAP_TORO
@G2O@#define RTABMAP_G2O @G2O@#define RTABMAP_G2O
@G2O_CPP_CONF@#define RTABMAP_G2O_CPP11 @G2O_CPP_CONF@#define RTABMAP_G2O_CPP11
+3 -3
View File
@@ -62,7 +62,7 @@ namespace cv{
namespace xfeatures2d { namespace xfeatures2d {
class FREAK; class FREAK;
class BriefDescriptorExtractor; class BriefDescriptorExtractor;
#if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 and CV_MINOR_VERSION < 3) #if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && (CV_MINOR_VERSION < 3 || (CV_MINOR_VERSION==3 && !defined(RTABMAP_OPENCV_DEV))))
class SIFT; class SIFT;
#endif #endif
class SURF; class SURF;
@@ -73,10 +73,10 @@ class ORB;
class SURF_CUDA; class SURF_CUDA;
} }
} }
#if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 and CV_MINOR_VERSION < 3) #if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && (CV_MINOR_VERSION < 3 || (CV_MINOR_VERSION==3 && !defined(RTABMAP_OPENCV_DEV))))
typedef cv::xfeatures2d::SIFT CV_SIFT; typedef cv::xfeatures2d::SIFT CV_SIFT;
#else #else
typedef cv::SIFT CV_SIFT; // SIFT is back in features2d since 4.3.0 typedef cv::SIFT CV_SIFT; // SIFT is back in features2d since 4.3.0-dev
#endif #endif
typedef cv::xfeatures2d::SURF CV_SURF; typedef cv::xfeatures2d::SURF CV_SURF;
typedef cv::FastFeatureDetector CV_FAST; typedef cv::FastFeatureDetector CV_FAST;
+4 -4
View File
@@ -473,7 +473,7 @@ Feature2D * Feature2D::create(const ParametersMap & parameters)
Feature2D * Feature2D::create(Feature2D::Type type, const ParametersMap & parameters) Feature2D * Feature2D::create(Feature2D::Type type, const ParametersMap & parameters)
{ {
#if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION < 3) #if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && (CV_MINOR_VERSION < 3 || (CV_MINOR_VERSION==3 && !defined(RTABMAP_OPENCV_DEV))))
#ifndef RTABMAP_NONFREE #ifndef RTABMAP_NONFREE
if(type == Feature2D::kFeatureSurf || type == Feature2D::kFeatureSift) if(type == Feature2D::kFeatureSurf || type == Feature2D::kFeatureSift)
{ {
@@ -496,7 +496,7 @@ Feature2D * Feature2D::create(Feature2D::Type type, const ParametersMap & parame
#endif #endif
#endif #endif
#else // >= 4.3.0 #else // >= 4.3.0-dev
#ifndef RTABMAP_NONFREE #ifndef RTABMAP_NONFREE
if(type == Feature2D::kFeatureSurf) if(type == Feature2D::kFeatureSurf)
@@ -506,7 +506,7 @@ Feature2D * Feature2D::create(Feature2D::Type type, const ParametersMap & parame
} }
#endif #endif
#endif // 4.3.0 #endif // 4.3.0-dev
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
if(type == Feature2D::kFeatureKaze) if(type == Feature2D::kFeatureKaze)
@@ -925,7 +925,7 @@ void SIFT::parseParameters(const ParametersMap & parameters)
Parameters::parse(parameters, Parameters::kSIFTSigma(), sigma_); Parameters::parse(parameters, Parameters::kSIFTSigma(), sigma_);
Parameters::parse(parameters, Parameters::kSIFTRootSIFT(), rootSIFT_); Parameters::parse(parameters, Parameters::kSIFTRootSIFT(), rootSIFT_);
#if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION < 3) #if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && (CV_MINOR_VERSION < 3 || (CV_MINOR_VERSION==3 && !defined(RTABMAP_OPENCV_DEV))))
#ifdef RTABMAP_NONFREE #ifdef RTABMAP_NONFREE
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
_sift = cv::Ptr<CV_SIFT>(new CV_SIFT(this->getMaxFeatures(), nOctaveLayers_, contrastThreshold_, edgeThreshold_, sigma_)); _sift = cv::Ptr<CV_SIFT>(new CV_SIFT(this->getMaxFeatures(), nOctaveLayers_, contrastThreshold_, edgeThreshold_, sigma_));
+4 -4
View File
@@ -198,7 +198,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
#endif #endif
// SIFT // SIFT
#if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION < 3) #if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && (CV_MINOR_VERSION < 3 || (CV_MINOR_VERSION==3 && !defined(RTABMAP_OPENCV_DEV))))
#ifndef RTABMAP_NONFREE #ifndef RTABMAP_NONFREE
_ui->comboBox_detector_strategy->setItemData(1, 0, Qt::UserRole - 1); _ui->comboBox_detector_strategy->setItemData(1, 0, Qt::UserRole - 1);
_ui->vis_feature_detector->setItemData(1, 0, Qt::UserRole - 1); _ui->vis_feature_detector->setItemData(1, 0, Qt::UserRole - 1);
@@ -2921,7 +2921,7 @@ void PreferencesDialog::writeCoreSettings(const QString & filePath) const
bool PreferencesDialog::validateForm() bool PreferencesDialog::validateForm()
{ {
#if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION < 3) #if CV_MAJOR_VERSION < 4 || (CV_MAJOR_VERSION == 4 && (CV_MINOR_VERSION < 3 || (CV_MINOR_VERSION==3 && !defined(RTABMAP_OPENCV_DEV))))
#ifndef RTABMAP_NONFREE #ifndef RTABMAP_NONFREE
// verify that SURF/SIFT cannot be selected if not built with OpenCV nonfree module // verify that SURF/SIFT cannot be selected if not built with OpenCV nonfree module
// BOW dictionary type // BOW dictionary type
@@ -2942,7 +2942,7 @@ bool PreferencesDialog::validateForm()
_ui->vis_feature_detector->setCurrentIndex(Feature2D::kFeatureFastBrief); _ui->vis_feature_detector->setCurrentIndex(Feature2D::kFeatureFastBrief);
} }
#endif #endif
#else //>= 4.3.0 #else //>= 4.3.0-dev
#ifndef RTABMAP_NONFREE #ifndef RTABMAP_NONFREE
// verify that SURF cannot be selected if not built with OpenCV nonfree module // verify that SURF cannot be selected if not built with OpenCV nonfree module
// BOW dictionary type // BOW dictionary type
@@ -4141,7 +4141,7 @@ void PreferencesDialog::setParameter(const std::string & key, const std::string
(combo->objectName().toStdString().compare(Parameters::kKpDetectorStrategy()) == 0 || (combo->objectName().toStdString().compare(Parameters::kKpDetectorStrategy()) == 0 ||
combo->objectName().toStdString().compare(Parameters::kVisFeatureType()) == 0)) combo->objectName().toStdString().compare(Parameters::kVisFeatureType()) == 0))
{ {
UWARN("Trying to set \"%s\" to SIFT/SURF but RTAB-Map isn't built " UWARN("Trying to set \"%s\" to SURF but RTAB-Map isn't built "
"with the nonfree module from OpenCV. Keeping default combo value: %s.", "with the nonfree module from OpenCV. Keeping default combo value: %s.",
combo->objectName().toStdString().c_str(), combo->objectName().toStdString().c_str(),
combo->currentText().toStdString().c_str()); combo->currentText().toStdString().c_str());