forked from opencv/opencv_contrib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperf_mser.cpp
71 lines (60 loc) · 2.26 KB
/
perf_mser.cpp
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
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include "perf_precomp.hpp"
namespace opencv_test {
// we use such nested structure to combine test values
typedef std::tuple< std::tuple<bool /* useBboxes */, bool /* useContourData */>,
int /* numNeighbors */, std::string /*file path*/> MSERPerfParams;
typedef perf::TestBaseWithParam<MSERPerfParams> MSERPerfTest;
PERF_TEST_P(MSERPerfTest, run,
::testing::Combine(::testing::Values(std::tuple<bool, bool> { true, false},
std::tuple<bool, bool> {false, false},
std::tuple<bool, bool> { true, true}
), // useBboxes, useContourData
::testing::Values(4, 8), // numNeighbors
::testing::Values("cv/shared/baboon.png", "cv/mser/puzzle.png")
)
)
{
auto p = GetParam();
bool useBboxes = std::get<0>(std::get<0>(p));
bool useContourData = std::get<1>(std::get<0>(p));
int numNeighbors = std::get<1>(p); // 4 or 8
std::string imgPath = std::get<2>(p);
cv::Mat src = imread(cvtest::findDataFile(imgPath), cv::IMREAD_GRAYSCALE);
uint32_t delta = 2;
uint32_t minArea = 256;
uint32_t maxArea = (int)src.total()/4;
float maxVariation = 0.15f;
float minDiversity = 0.2f;
cv::Ptr<cv::fastcv::FCVMSER> mser;
mser = cv::fastcv::FCVMSER::create(src.size(), numNeighbors, delta, minArea, maxArea,
maxVariation, minDiversity);
while(next())
{
std::vector<std::vector<Point>> contours;
std::vector<cv::Rect> bboxes;
std::vector<cv::fastcv::FCVMSER::ContourData> contourData;
startTimer();
if (useBboxes)
{
if (useContourData)
{
mser->detect(src, contours, bboxes, contourData);
}
else
{
mser->detect(src, contours, bboxes);
}
}
else
{
mser->detect(src, contours);
}
stopTimer();
}
SANITY_CHECK_NOTHING();
}
} // namespace