From c8930cc27964680b0df97aaed2250347c449ad07 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sat, 27 Jan 2018 13:37:38 +0000 Subject: [PATCH] opencv_version: dump detected HW features --- apps/version/opencv_version.cpp | 22 +++++++++++++++++++ modules/core/include/opencv2/core/utility.hpp | 6 +++++ modules/core/src/system.cpp | 5 +++++ 3 files changed, 33 insertions(+) diff --git a/apps/version/opencv_version.cpp b/apps/version/opencv_version.cpp index ecb602c171..04aa25917f 100644 --- a/apps/version/opencv_version.cpp +++ b/apps/version/opencv_version.cpp @@ -20,6 +20,7 @@ int main(int argc, const char** argv) "{ help h usage ? | | show this help message }" "{ verbose v | | show build configuration log }" "{ opencl | | show information about OpenCL (available platforms/devices, default selected device) }" + "{ hw | | show detected HW features (see cv::checkHardwareSupport() function). Use --hw=0 to show available features only }" ); if (parser.has("help")) @@ -42,5 +43,26 @@ int main(int argc, const char** argv) cv::dumpOpenCLInformation(); } + if (parser.has("hw")) + { + bool showAll = parser.get("hw"); + std::cout << "OpenCV's HW features list:" << std::endl; + int count = 0; + for (int i = 0; i < CV_HARDWARE_MAX_FEATURE; i++) + { + cv::String name = cv::getHardwareFeatureName(i); + if (name.empty()) + continue; + bool enabled = cv::checkHardwareSupport(i); + if (enabled) + count++; + if (enabled || showAll) + { + printf(" ID=%3d (%s) -> %s\n", i, name.c_str(), enabled ? "ON" : "N/A"); + } + } + std::cout << "Total available: " << count << std::endl; + } + return 0; } diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp index 69d114e156..863012710c 100644 --- a/modules/core/include/opencv2/core/utility.hpp +++ b/modules/core/include/opencv2/core/utility.hpp @@ -427,6 +427,12 @@ in OpenCV. */ CV_EXPORTS_W bool checkHardwareSupport(int feature); +/** @brief Returns feature name by ID + +Returns empty string if feature is not defined +*/ +CV_EXPORTS_W String getHardwareFeatureName(int feature); + /** @brief Returns the number of logical CPUs available for the process. */ CV_EXPORTS_W int getNumberOfCPUs(); diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index ccf2ca0e28..ceca01f82e 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -663,6 +663,11 @@ bool checkHardwareSupport(int feature) return currentFeatures->have[feature]; } +String getHardwareFeatureName(int feature) +{ + const char* name = getHWFeatureName(feature); + return name ? String(name) : String(); +} volatile bool useOptimizedFlag = true;