From a894712b1d49954ae074714c1d5e4b9a52c55320 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Sat, 28 Jan 2023 16:22:13 +0100 Subject: [PATCH 1/2] Fix compatibility with OpenCV 4.7.0 --- CHANGELOG.md | 1 + src/Perception/src/ArucoDetector.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd2b54f7dc..bef00e0287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project are documented in this file. ### Fix - Return an invalid `PolyDriverDescriptor` if `description` is not found in `constructMultipleAnalogSensorsRemapper()` (https://github.com/ami-iit/bipedal-locomotion-framework/pull/569) +- Fix compatibility with OpenCV 4.7.0 () ## [0.11.1] - 2022-12-19 ### Fix diff --git a/src/Perception/src/ArucoDetector.cpp b/src/Perception/src/ArucoDetector.cpp index 3b05fdcf96..b07d987279 100644 --- a/src/Perception/src/ArucoDetector.cpp +++ b/src/Perception/src/ArucoDetector.cpp @@ -55,6 +55,11 @@ class ArucoDetector::Impl /** * Utility map for choosing Aruco marker dictionary depending on user parameter */ + // TODO(traversaro): when we drop support for OpenCV < 4.7.0, we can cleanup this part + // we can also check if there are other dictionary that should be added here +#if (CV_VERSION_MAJOR >= 5) || (CV_VERSION_MAJOR == 4 && CV_VERSION_MINOR >= 7) +#define PREDEFINED_DICTIONARY_NAME PredefinedDictionaryType +#endif std::unordered_map availableDict{{"4X4_50", cv::aruco::PREDEFINED_DICTIONARY_NAME::DICT_4X4_50}, {"4X4_100", cv::aruco::PREDEFINED_DICTIONARY_NAME::DICT_4X4_100}, @@ -115,7 +120,14 @@ bool ArucoDetector::initialize(std::weak_ptr handler) return false; } +// In OpenCV 4.7.0 getPredefinedDictionary started returning a cv::aruco::Dictionary +// instead of a cv::Ptr +#if (CV_VERSION_MAJOR >= 5) || (CV_VERSION_MAJOR == 4 && CV_VERSION_MINOR >= 7) + m_pimpl->dictionary = cv::makePtr(); + *(m_pimpl->dictionary) = cv::aruco::getPredefinedDictionary(m_pimpl->availableDict.at(dictName)); +#else m_pimpl->dictionary = cv::aruco::getPredefinedDictionary(m_pimpl->availableDict.at(dictName)); +#endif if (!handle->getParameter("marker_length", m_pimpl->markerLength)) { From a80da6b173e4db4ff3ba3a2f8d138c4067c045a6 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 30 Jan 2023 10:59:35 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md Co-authored-by: Stefano Dafarra --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bef00e0287..d2804f5691 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ All notable changes to this project are documented in this file. ### Fix - Return an invalid `PolyDriverDescriptor` if `description` is not found in `constructMultipleAnalogSensorsRemapper()` (https://github.com/ami-iit/bipedal-locomotion-framework/pull/569) -- Fix compatibility with OpenCV 4.7.0 () +- Fix compatibility with OpenCV 4.7.0 (https://github.com/ami-iit/bipedal-locomotion-framework/pull/589) ## [0.11.1] - 2022-12-19 ### Fix