diff --git a/CHANGELOG.md b/CHANGELOG.md index bd2b54f7dc..d2804f5691 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 (https://github.com/ami-iit/bipedal-locomotion-framework/pull/589) ## [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)) {