Skip to content

Commit

Permalink
Merge pull request #1555 from fspindle/fix_removed_sift_opencv_4.5.0
Browse files Browse the repository at this point in the history
Fix sift not enabled with opencv 4.5.0
  • Loading branch information
fspindle authored Jan 23, 2025
2 parents d77e4a3 + 26db0d9 commit 40cf96b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 28 deletions.
1 change: 1 addition & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ ViSP 3.x.x (Version in development)
. [#1521] Build issues with OpenCV 5.0.0
. [#1546] OIS 3rdparty not detected during CMake configuration
. [#1547] Build issue with Ogre 1.12.0 or more recent versions
. [#1552] Unabled to use SIFT feature with opencv 4.5.4
----------------------------------------------
ViSP 3.6.0 (released September 22, 2023)
- Contributors:
Expand Down
32 changes: 17 additions & 15 deletions modules/vision/include/visp3/vision/vpKeyPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,23 +325,25 @@ class VISP_EXPORT vpKeyPoint : public vpBasicKeyPoint
# endif
#else // OpenCV < 5.0.0
# if defined(HAVE_OPENCV_FEATURES2D)
#if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
DETECTOR_AGAST, //!< AGAST detector
DETECTOR_AKAZE, //!< AKAZE detector
#endif
DETECTOR_BRISK, //!< BRISK detector
DETECTOR_FAST, //!< FAST detector
DETECTOR_GFTT, //!< GFTT detector
#if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
DETECTOR_KAZE, //!< KAZE detector
#endif
DETECTOR_MSER, //!< MSER detector
DETECTOR_ORB, //!< ORB detector
DETECTOR_SimpleBlob, //!< SimpleBlob detector
# if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
DETECTOR_AGAST, //!< AGAST detector
DETECTOR_AKAZE, //!< AKAZE detector
DETECTOR_KAZE, //!< KAZE detector
# endif
# endif
# if defined(HAVE_OPENCV_XFEATURES2D)
# if (VISP_HAVE_OPENCV_VERSION >= 0x030100) && defined(VISP_HAVE_OPENCV_XFEATURES2D)
DETECTOR_MSD, //!< MSD detector
# endif
# if ((VISP_HAVE_OPENCV_VERSION >= 0x030411 && CV_MAJOR_VERSION < 4) || (VISP_HAVE_OPENCV_VERSION >= 0x040400)) && defined(HAVE_OPENCV_FEATURES2D)
DETECTOR_SIFT, //!< SIFT detector
# endif
#if (VISP_HAVE_OPENCV_VERSION < 0x030000) || (defined(VISP_HAVE_OPENCV_XFEATURES2D))
DETECTOR_STAR, //!< STAR detector
# endif
# if defined(OPENCV_ENABLE_NONFREE) && defined(HAVE_OPENCV_XFEATURES2D)
Expand Down Expand Up @@ -376,26 +378,26 @@ class VISP_EXPORT vpKeyPoint : public vpBasicKeyPoint
# endif
#else // opencv < 5.0.0
# if defined(HAVE_OPENCV_FEATURES2D)
#if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
DESCRIPTOR_AKAZE, //!< AKAZE descriptor
#endif
DESCRIPTOR_BRISK, //!< BRISK descriptor
#if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
DESCRIPTOR_KAZE, //!< KAZE descriptor
#endif
DESCRIPTOR_ORB, //!< ORB descriptor
# if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
DESCRIPTOR_AKAZE, //!< AKAZE descriptor
DESCRIPTOR_KAZE, //!< KAZE descriptor
# endif
# endif
# if defined(HAVE_OPENCV_XFEATURES2D)
DESCRIPTOR_BRIEF, //!< BRIEF descriptor
DESCRIPTOR_DAISY, //!< DAISY descriptor
DESCRIPTOR_FREAK, //!< FREAK descriptor
DESCRIPTOR_LATCH, //!< LATCH descriptor
# endif
# if ((VISP_HAVE_OPENCV_VERSION >= 0x030411 && CV_MAJOR_VERSION < 4) || (VISP_HAVE_OPENCV_VERSION >= 0x040400)) && defined(HAVE_OPENCV_FEATURES2D)
DESCRIPTOR_SIFT, //!< SIFT descriptor
# endif
# if defined(OPENCV_ENABLE_NONFREE) && defined(HAVE_OPENCV_XFEATURES2D)
DESCRIPTOR_SURF, //!< SURF descriptor
# endif
# if defined(HAVE_OPENCV_XFEATURES2D) && (VISP_HAVE_OPENCV_VERSION >= 0x030200)
#if (VISP_HAVE_OPENCV_VERSION >= 0x030200) && defined(VISP_HAVE_OPENCV_XFEATURES2D)
DESCRIPTOR_BoostDesc, //!< BoostDesc descriptor, only with OpenCV >= 3.2.0
DESCRIPTOR_VGG, //!< VGG descriptor, only with OpenCV >= 3.2.0
# endif
Expand Down
28 changes: 16 additions & 12 deletions modules/vision/src/key-point/vpKeyPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,8 @@ void vpKeyPoint::initDetector(const std::string &detectorName)
}

if (detectorNameTmp == "SIFT") {
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_XFEATURES2D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && ((VISP_HAVE_OPENCV_VERSION >= 0x030411 && CV_MAJOR_VERSION < 4) || (VISP_HAVE_OPENCV_VERSION >= 0x040400)) && defined(HAVE_OPENCV_FEATURES2D)) \
|| ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
# if (VISP_HAVE_OPENCV_VERSION >= 0x040500) // OpenCV >= 4.5.0
cv::Ptr<cv::FeatureDetector> siftDetector = cv::SiftFeatureDetector::create();
if (!usePyramid) {
Expand Down Expand Up @@ -1976,7 +1977,8 @@ void vpKeyPoint::initDetector(const std::string &detectorName)
#endif
}
else if (detectorNameTmp == "STAR") {
#if defined(HAVE_OPENCV_XFEATURES2D)
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && (VISP_HAVE_OPENCV_VERSION < 0x030000) || (defined(VISP_HAVE_OPENCV_XFEATURES2D))) \
|| ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_XFEATURES2D))
cv::Ptr<cv::FeatureDetector> starDetector = cv::xfeatures2d::StarDetector::create();
if (!usePyramid) {
m_detectors[detectorNameTmp] = starDetector;
Expand Down Expand Up @@ -2010,7 +2012,7 @@ void vpKeyPoint::initDetector(const std::string &detectorName)
#endif
}
else if (detectorNameTmp == "MSD") {
#if defined(HAVE_OPENCV_XFEATURES2D)
#if (VISP_HAVE_OPENCV_VERSION >= 0x030100) && defined(VISP_HAVE_OPENCV_XFEATURES2D)
cv::Ptr<cv::FeatureDetector> msdDetector = cv::xfeatures2d::MSDDetector::create();
if (!usePyramid) {
m_detectors[detectorNameTmp] = msdDetector;
Expand Down Expand Up @@ -2061,7 +2063,7 @@ void vpKeyPoint::initExtractor(const std::string &extractorName)
m_extractors[extractorName] = cv::DescriptorExtractor::create(extractorName);
#else
if (extractorName == "SIFT") {
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_XFEATURES2D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && ((VISP_HAVE_OPENCV_VERSION >= 0x030411 && CV_MAJOR_VERSION < 4) || (VISP_HAVE_OPENCV_VERSION >= 0x040400)) && defined(HAVE_OPENCV_FEATURES2D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
// SIFT is no more patented since 09/03/2020
# if (VISP_HAVE_OPENCV_VERSION >= 0x030411)
m_extractors[extractorName] = cv::SIFT::create();
Expand Down Expand Up @@ -2246,31 +2248,33 @@ void vpKeyPoint::initFeatureNames()
m_mapOfDetectorNames[DETECTOR_AGAST] = "AGAST";
#endif
#endif
#if defined(HAVE_OPENCV_XFEATURES2D)
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && (VISP_HAVE_OPENCV_VERSION < 0x030000) || (defined(VISP_HAVE_OPENCV_XFEATURES2D))) \
|| ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_XFEATURES2D))
m_mapOfDetectorNames[DETECTOR_STAR] = "STAR";
#endif
#if (VISP_HAVE_OPENCV_VERSION >= 0x030100) && defined(VISP_HAVE_OPENCV_XFEATURES2D)
m_mapOfDetectorNames[DETECTOR_MSD] = "MSD";
#endif
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_XFEATURES2D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && ((VISP_HAVE_OPENCV_VERSION >= 0x030411 && CV_MAJOR_VERSION < 4) || (VISP_HAVE_OPENCV_VERSION >= 0x040400)) && defined(HAVE_OPENCV_FEATURES2D)) \
|| ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
m_mapOfDetectorNames[DETECTOR_SIFT] = "SIFT";
#endif
#if defined(OPENCV_ENABLE_NONFREE) && defined(HAVE_OPENCV_XFEATURES2D)
m_mapOfDetectorNames[DETECTOR_SURF] = "SURF";
#endif
#if defined(HAVE_OPENCV_XFEATURES2D)
m_mapOfDetectorNames[DETECTOR_MSD] = "MSD";
#endif

#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_FEATURES2D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
m_mapOfDescriptorNames[DESCRIPTOR_ORB] = "ORB";
#endif
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_FEATURES2D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_XFEATURES2D))
m_mapOfDescriptorNames[DESCRIPTOR_BRISK] = "BRISK";
#endif
#if defined(HAVE_OPENCV_XFEATURES2D)
m_mapOfDescriptorNames[DESCRIPTOR_FREAK] = "FREAK";
#if defined(VISP_HAVE_OPENCV_XFEATURES2D)
m_mapOfDescriptorNames[DESCRIPTOR_BRIEF] = "BRIEF";
m_mapOfDescriptorNames[DESCRIPTOR_FREAK] = "FREAK";
#endif
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_XFEATURES2D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && ((VISP_HAVE_OPENCV_VERSION >= 0x030411 && CV_MAJOR_VERSION < 4) || (VISP_HAVE_OPENCV_VERSION >= 0x040400)) && defined(HAVE_OPENCV_FEATURES2D)) \
|| ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
m_mapOfDescriptorNames[DESCRIPTOR_SIFT] = "SIFT";
#endif
#if defined(OPENCV_ENABLE_NONFREE) && defined(HAVE_OPENCV_XFEATURES2D)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis

std::map<vpKeyPoint::vpFeatureDetectorType, std::string> mapOfDetectorNames = keyPoints.getDetectorNames();
for (int i = 0; i < vpKeyPoint::DETECTOR_TYPE_SIZE; i++) {
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_XFEATURES2D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
#if ((VISP_HAVE_OPENCV_VERSION < 0x050000) && ((VISP_HAVE_OPENCV_VERSION >= 0x030411 && CV_MAJOR_VERSION < 4) || (VISP_HAVE_OPENCV_VERSION >= 0x040400)) && defined(HAVE_OPENCV_FEATURES2D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_FEATURES))
#if ((VISP_HAVE_OPENCV_VERSION == 0x040504) || (VISP_HAVE_OPENCV_VERSION == 0x040505) || \
(VISP_HAVE_OPENCV_VERSION == 0x040600) || (VISP_HAVE_OPENCV_VERSION == 0x040700) || \
(VISP_HAVE_OPENCV_VERSION == 0x040900) || (VISP_HAVE_OPENCV_VERSION == 0x040A00)) && \
Expand Down

0 comments on commit 40cf96b

Please sign in to comment.