Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/core/perf/perf_io_base64.cpp
16354 views
1
#include "perf_precomp.hpp"
2
3
namespace opencv_test
4
{
5
using namespace perf;
6
7
typedef tuple<cv::Size, MatType, String> Size_MatType_Str_t;
8
typedef TestBaseWithParam<Size_MatType_Str_t> Size_Mat_StrType;
9
10
#define MAT_SIZES ::perf::sz1080p/*, ::perf::sz4320p*/
11
#define MAT_TYPES CV_8UC1, CV_32FC1
12
#define FILE_EXTENSION String(".xml"), String(".yml"), String(".json")
13
14
15
PERF_TEST_P(Size_Mat_StrType, fs_text,
16
testing::Combine(testing::Values(MAT_SIZES),
17
testing::Values(MAT_TYPES),
18
testing::Values(FILE_EXTENSION))
19
)
20
{
21
Size size = get<0>(GetParam());
22
int type = get<1>(GetParam());
23
String ext = get<2>(GetParam());
24
25
Mat src(size.height, size.width, type);
26
Mat dst = src.clone();
27
28
declare.in(src, WARMUP_RNG).out(dst);
29
30
cv::String file_name = cv::tempfile(ext.c_str());
31
cv::String key = "test_mat";
32
33
TEST_CYCLE_MULTIRUN(2)
34
{
35
{
36
FileStorage fs(file_name, cv::FileStorage::WRITE);
37
fs << key << src;
38
fs.release();
39
}
40
{
41
FileStorage fs(file_name, cv::FileStorage::READ);
42
fs[key] >> dst;
43
fs.release();
44
}
45
}
46
47
remove(file_name.c_str());
48
SANITY_CHECK_NOTHING();
49
}
50
51
PERF_TEST_P(Size_Mat_StrType, fs_base64,
52
testing::Combine(testing::Values(MAT_SIZES),
53
testing::Values(MAT_TYPES),
54
testing::Values(FILE_EXTENSION))
55
)
56
{
57
Size size = get<0>(GetParam());
58
int type = get<1>(GetParam());
59
String ext = get<2>(GetParam());
60
61
Mat src(size.height, size.width, type);
62
Mat dst = src.clone();
63
64
cv::String file_name = cv::tempfile(ext.c_str());
65
cv::String key = "test_mat";
66
67
declare.in(src, WARMUP_RNG).out(dst);
68
TEST_CYCLE_MULTIRUN(2)
69
{
70
{
71
FileStorage fs(file_name, cv::FileStorage::WRITE_BASE64);
72
fs << key << src;
73
fs.release();
74
}
75
{
76
FileStorage fs(file_name, cv::FileStorage::READ);
77
fs[key] >> dst;
78
fs.release();
79
}
80
}
81
82
remove(file_name.c_str());
83
SANITY_CHECK_NOTHING();
84
}
85
86
} // namespace
87
88