Skip to content

Commit c8930cc

Browse files
committed
opencv_version: dump detected HW features
1 parent 01f4a17 commit c8930cc

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

apps/version/opencv_version.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ int main(int argc, const char** argv)
2020
"{ help h usage ? | | show this help message }"
2121
"{ verbose v | | show build configuration log }"
2222
"{ opencl | | show information about OpenCL (available platforms/devices, default selected device) }"
23+
"{ hw | | show detected HW features (see cv::checkHardwareSupport() function). Use --hw=0 to show available features only }"
2324
);
2425

2526
if (parser.has("help"))
@@ -42,5 +43,26 @@ int main(int argc, const char** argv)
4243
cv::dumpOpenCLInformation();
4344
}
4445

46+
if (parser.has("hw"))
47+
{
48+
bool showAll = parser.get<bool>("hw");
49+
std::cout << "OpenCV's HW features list:" << std::endl;
50+
int count = 0;
51+
for (int i = 0; i < CV_HARDWARE_MAX_FEATURE; i++)
52+
{
53+
cv::String name = cv::getHardwareFeatureName(i);
54+
if (name.empty())
55+
continue;
56+
bool enabled = cv::checkHardwareSupport(i);
57+
if (enabled)
58+
count++;
59+
if (enabled || showAll)
60+
{
61+
printf(" ID=%3d (%s) -> %s\n", i, name.c_str(), enabled ? "ON" : "N/A");
62+
}
63+
}
64+
std::cout << "Total available: " << count << std::endl;
65+
}
66+
4567
return 0;
4668
}

modules/core/include/opencv2/core/utility.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,12 @@ in OpenCV.
427427
*/
428428
CV_EXPORTS_W bool checkHardwareSupport(int feature);
429429

430+
/** @brief Returns feature name by ID
431+
432+
Returns empty string if feature is not defined
433+
*/
434+
CV_EXPORTS_W String getHardwareFeatureName(int feature);
435+
430436
/** @brief Returns the number of logical CPUs available for the process.
431437
*/
432438
CV_EXPORTS_W int getNumberOfCPUs();

modules/core/src/system.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,11 @@ bool checkHardwareSupport(int feature)
663663
return currentFeatures->have[feature];
664664
}
665665

666+
String getHardwareFeatureName(int feature)
667+
{
668+
const char* name = getHWFeatureName(feature);
669+
return name ? String(name) : String();
670+
}
666671

667672
volatile bool useOptimizedFlag = true;
668673

0 commit comments

Comments
 (0)