1 | // This file is part of OpenCV project. |
2 | // It is subject to the license terms in the LICENSE file found in the top-level directory |
3 | // of this distribution and at http://opencv.org/license.html. |
4 | |
5 | #include <iostream> |
6 | |
7 | #include <opencv2/core.hpp> |
8 | #include <opencv2/core/utils/trace.hpp> |
9 | |
10 | #include <opencv2/core/opencl/opencl_info.hpp> |
11 | |
12 | #ifdef OPENCV_WIN32_API |
13 | #define WIN32_LEAN_AND_MEAN |
14 | #include <windows.h> |
15 | #endif |
16 | |
17 | // defined in core/private.hpp |
18 | namespace cv { |
19 | CV_EXPORTS const char* currentParallelFramework(); |
20 | } |
21 | |
22 | static void dumpHWFeatures(bool showAll = false) |
23 | { |
24 | std::cout << "OpenCV's HW features list:" << std::endl; |
25 | int count = 0; |
26 | for (int i = 0; i < CV_HARDWARE_MAX_FEATURE; i++) |
27 | { |
28 | cv::String name = cv::getHardwareFeatureName(feature: i); |
29 | if (name.empty()) |
30 | continue; |
31 | bool enabled = cv::checkHardwareSupport(feature: i); |
32 | if (enabled) |
33 | count++; |
34 | if (enabled || showAll) |
35 | { |
36 | printf(format: " ID=%3d (%s) -> %s\n" , i, name.c_str(), enabled ? "ON" : "N/A" ); |
37 | } |
38 | } |
39 | std::cout << "Total available: " << count << std::endl; |
40 | } |
41 | |
42 | static void dumpParallelFramework() |
43 | { |
44 | const char* parallelFramework = cv::currentParallelFramework(); |
45 | if (parallelFramework) |
46 | { |
47 | int threads = cv::getNumThreads(); |
48 | std::cout << "Parallel framework: " << parallelFramework << " (nthreads=" << threads << ")" << std::endl; |
49 | } |
50 | } |
51 | |
52 | int main(int argc, const char** argv) |
53 | { |
54 | CV_TRACE_FUNCTION(); |
55 | CV_TRACE_ARG(argc); |
56 | CV_TRACE_ARG_VALUE(argv0, "argv0" , argv[0]); |
57 | CV_TRACE_ARG_VALUE(argv1, "argv1" , argv[1]); |
58 | |
59 | #ifndef OPENCV_WIN32_API |
60 | cv::CommandLineParser parser(argc, argv, |
61 | "{ help h usage ? | | show this help message }" |
62 | "{ verbose v | | show build configuration log }" |
63 | "{ opencl | | show information about OpenCL (available platforms/devices, default selected device) }" |
64 | "{ hw | | show detected HW features (see cv::checkHardwareSupport() function). Use --hw=0 to show available features only }" |
65 | "{ threads | | show configured parallel framework and number of active threads }" |
66 | ); |
67 | |
68 | if (parser.has(name: "help" )) |
69 | { |
70 | parser.printMessage(); |
71 | return 0; |
72 | } |
73 | |
74 | if (parser.has(name: "verbose" )) |
75 | { |
76 | std::cout << cv::getBuildInformation().c_str() << std::endl; |
77 | } |
78 | else |
79 | { |
80 | std::cout << CV_VERSION << std::endl; |
81 | } |
82 | |
83 | if (parser.has(name: "opencl" )) |
84 | { |
85 | cv::dumpOpenCLInformation(); |
86 | } |
87 | |
88 | if (parser.has(name: "hw" )) |
89 | { |
90 | dumpHWFeatures(showAll: parser.get<bool>(name: "hw" )); |
91 | } |
92 | |
93 | if (parser.has(name: "threads" )) |
94 | { |
95 | dumpParallelFramework(); |
96 | } |
97 | |
98 | #else |
99 | std::cout << cv::getBuildInformation().c_str() << std::endl; |
100 | cv::dumpOpenCLInformation(); |
101 | dumpHWFeatures(); |
102 | dumpParallelFramework(); |
103 | MessageBoxA(NULL, "Check console window output" , "OpenCV(" CV_VERSION ")" , MB_ICONINFORMATION | MB_OK); |
104 | #endif |
105 | |
106 | return 0; |
107 | } |
108 | |