test_plugins.cpp
3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
namespace opencv_test { namespace {
enum VideoBackendMode
{
MODE_CAMERA,
MODE_STREAM,
MODE_WRITER,
};
static
void dumpBackendInfo(VideoCaptureAPIs backend, enum VideoBackendMode mode)
{
std::string name;
try
{
name = videoio_registry::getBackendName(backend);
}
catch (const std::exception& e)
{
ADD_FAILURE() << "Can't query name of backend=" << backend << ": " << e.what();
}
catch (...)
{
ADD_FAILURE() << "Can't query name of backend=" << backend << ": unknown C++ exception";
}
bool isBuiltIn = true;
try
{
isBuiltIn = videoio_registry::isBackendBuiltIn(backend);
}
catch (const std::exception& e)
{
ADD_FAILURE() << "Failed isBackendBuiltIn(backend=" << backend << "): " << e.what();
cout << name << " - UNKNOWN TYPE" << endl;
return;
}
if (isBuiltIn)
{
cout << name << " - BUILTIN" << endl;
return;
}
std::string description = "NO_DESCRIPTION";
int version_ABI = 0;
int version_API = 0;
try
{
if (mode == MODE_CAMERA)
description = videoio_registry::getCameraBackendPluginVersion(backend, version_ABI, version_API);
else if (mode == MODE_STREAM)
description = videoio_registry::getStreamBackendPluginVersion(backend, version_ABI, version_API);
else if (mode == MODE_WRITER)
description = videoio_registry::getWriterBackendPluginVersion(backend, version_ABI, version_API);
else
CV_Error(Error::StsInternal, "");
cout << name << " - PLUGIN (" << description << ") ABI=" << version_ABI << " API=" << version_API << endl;
return;
}
catch (const cv::Exception& e)
{
if (e.code == Error::StsNotImplemented)
{
cout << name << " - PLUGIN - NOT LOADED" << endl;
return;
}
ADD_FAILURE() << "Failed getBackendPluginDescription(backend=" << backend << "): " << e.what();
}
catch (const std::exception& e)
{
ADD_FAILURE() << "Failed getBackendPluginDescription(backend=" << backend << "): " << e.what();
}
cout << name << " - PLUGIN (ERROR on quering information)" << endl;
}
TEST(VideoIO_Plugins, query)
{
const std::vector<cv::VideoCaptureAPIs> camera_backends = cv::videoio_registry::getCameraBackends();
cout << "== Camera APIs (" << camera_backends.size() << "):" << endl;
for (auto backend : camera_backends)
{
dumpBackendInfo(backend, MODE_CAMERA);
}
const std::vector<cv::VideoCaptureAPIs> stream_backends = cv::videoio_registry::getStreamBackends();
cout << "== Stream capture APIs (" << stream_backends.size() << "):" << endl;
for (auto backend : stream_backends)
{
dumpBackendInfo(backend, MODE_STREAM);
}
const std::vector<cv::VideoCaptureAPIs> writer_backends = cv::videoio_registry::getWriterBackends();
cout << "== Writer APIs (" << writer_backends.size() << "):" << endl;
for (auto backend : writer_backends)
{
dumpBackendInfo(backend, MODE_WRITER);
}
}
}}