From 39ee5c5a461760b528e157960d36c567eba236f6 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 8 Oct 2021 20:34:07 +0000 Subject: [PATCH] plugins: reverse candidates order to fetch higher versions first --- modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp | 3 +++ modules/highgui/src/plugin_wrapper.impl.hpp | 3 +++ modules/videoio/src/backend_plugin.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp b/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp index a5649b60c083..b9b3105d20e0 100644 --- a/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp +++ b/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp @@ -223,6 +223,9 @@ std::vector getPluginCandidates(const std::string& baseName) continue; std::vector candidates; cv::glob(utils::fs::join(path, plugin_expr), candidates); + // Prefer candisates with higher versions + // TODO: implemented accurate versions-based comparator + std::sort(candidates.begin(), candidates.end(), std::greater()); CV_LOG_DEBUG(NULL, " - " << path << ": " << candidates.size()); copy(candidates.begin(), candidates.end(), back_inserter(results)); } diff --git a/modules/highgui/src/plugin_wrapper.impl.hpp b/modules/highgui/src/plugin_wrapper.impl.hpp index 97aea69098cb..23f0ecf6bf84 100644 --- a/modules/highgui/src/plugin_wrapper.impl.hpp +++ b/modules/highgui/src/plugin_wrapper.impl.hpp @@ -224,6 +224,9 @@ std::vector getPluginCandidates(const std::string& baseName) continue; std::vector candidates; cv::glob(utils::fs::join(path, plugin_expr), candidates); + // Prefer candisates with higher versions + // TODO: implemented accurate versions-based comparator + std::sort(candidates.begin(), candidates.end(), std::greater()); CV_LOG_DEBUG(NULL, " - " << path << ": " << candidates.size()); copy(candidates.begin(), candidates.end(), back_inserter(results)); } diff --git a/modules/videoio/src/backend_plugin.cpp b/modules/videoio/src/backend_plugin.cpp index e42c98649cfc..039083c6ad47 100644 --- a/modules/videoio/src/backend_plugin.cpp +++ b/modules/videoio/src/backend_plugin.cpp @@ -373,6 +373,9 @@ std::vector getPluginCandidates(const std::string& baseName) continue; std::vector candidates; cv::glob(utils::fs::join(path, plugin_expr), candidates); + // Prefer candisates with higher versions + // TODO: implemented accurate versions-based comparator + std::sort(candidates.begin(), candidates.end(), std::greater()); CV_LOG_INFO(NULL, " - " << path << ": " << candidates.size()); copy(candidates.begin(), candidates.end(), back_inserter(results)); }