Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/apps/version/opencv_version.cpp
16337 views
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
static void dumpHWFeatures(bool showAll = false)
18
{
19
std::cout << "OpenCV's HW features list:" << std::endl;
20
int count = 0;
21
for (int i = 0; i < CV_HARDWARE_MAX_FEATURE; i++)
22
{
23
cv::String name = cv::getHardwareFeatureName(i);
24
if (name.empty())
25
continue;
26
bool enabled = cv::checkHardwareSupport(i);
27
if (enabled)
28
count++;
29
if (enabled || showAll)
30
{
31
printf(" ID=%3d (%s) -> %s\n", i, name.c_str(), enabled ? "ON" : "N/A");
32
}
33
}
34
std::cout << "Total available: " << count << std::endl;
35
}
36
37
int main(int argc, const char** argv)
38
{
39
CV_TRACE_FUNCTION();
40
CV_TRACE_ARG(argc);
41
CV_TRACE_ARG_VALUE(argv0, "argv0", argv[0]);
42
CV_TRACE_ARG_VALUE(argv1, "argv1", argv[1]);
43
44
#ifndef OPENCV_WIN32_API
45
cv::CommandLineParser parser(argc, argv,
46
"{ help h usage ? | | show this help message }"
47
"{ verbose v | | show build configuration log }"
48
"{ opencl | | show information about OpenCL (available platforms/devices, default selected device) }"
49
"{ hw | | show detected HW features (see cv::checkHardwareSupport() function). Use --hw=0 to show available features only }"
50
);
51
52
if (parser.has("help"))
53
{
54
parser.printMessage();
55
return 0;
56
}
57
58
if (parser.has("verbose"))
59
{
60
std::cout << cv::getBuildInformation().c_str() << std::endl;
61
}
62
else
63
{
64
std::cout << CV_VERSION << std::endl;
65
}
66
67
if (parser.has("opencl"))
68
{
69
cv::dumpOpenCLInformation();
70
}
71
72
if (parser.has("hw"))
73
{
74
dumpHWFeatures(parser.get<bool>("hw"));
75
}
76
#else
77
std::cout << cv::getBuildInformation().c_str() << std::endl;
78
cv::dumpOpenCLInformation();
79
dumpHWFeatures();
80
MessageBoxA(NULL, "Check console window output", "OpenCV(" CV_VERSION ")", MB_ICONINFORMATION | MB_OK);
81
#endif
82
83
return 0;
84
}
85
86