Skip to content

Commit 8a16997

Browse files
committed
Merge pull request opencv#8580 from terfendail:ovx_newperftest
2 parents 374c5ce + 2492c29 commit 8a16997

File tree

7 files changed

+313
-0
lines changed

7 files changed

+313
-0
lines changed

modules/core/perf/perf_lut.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "perf_precomp.hpp"
2+
3+
using namespace std;
4+
using namespace cv;
5+
using namespace perf;
6+
7+
typedef perf::TestBaseWithParam<Size> SizePrm;
8+
9+
PERF_TEST_P( SizePrm, LUT,
10+
testing::Values(szQVGA, szVGA, sz1080p)
11+
)
12+
{
13+
Size sz = GetParam();
14+
15+
int maxValue = 255;
16+
17+
Mat src(sz, CV_8UC1);
18+
randu(src, 0, maxValue);
19+
Mat lut(1, 256, CV_8UC1);
20+
randu(lut, 0, maxValue);
21+
Mat dst(sz, CV_8UC1);
22+
23+
TEST_CYCLE() LUT(src, lut, dst);
24+
25+
SANITY_CHECK(dst, 0.1);
26+
}

modules/features2d/perf/perf_fast.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,26 @@ PERF_TEST_P(fast, detect, testing::Combine(
3838

3939
SANITY_CHECK_KEYPOINTS(points);
4040
}
41+
42+
PERF_TEST_P(fast, detect_ovx, testing::Combine(
43+
testing::Values(FAST_IMAGES),
44+
FastType::all()
45+
))
46+
{
47+
string filename = getDataPath(get<0>(GetParam()));
48+
int type = get<1>(GetParam());
49+
Mat frame = imread(filename, IMREAD_GRAYSCALE);
50+
51+
if (frame.empty())
52+
FAIL() << "Unable to load source image " << filename;
53+
54+
declare.in(frame);
55+
56+
Ptr<FeatureDetector> fd = FastFeatureDetector::create(20, false, type);
57+
ASSERT_FALSE(fd.empty());
58+
vector<KeyPoint> points;
59+
60+
TEST_CYCLE() fd->detect(frame, points);
61+
62+
SANITY_CHECK_KEYPOINTS(points);
63+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#include "perf_precomp.hpp"
2+
3+
using namespace std;
4+
using namespace cv;
5+
using namespace perf;
6+
using std::tr1::get;
7+
8+
#ifdef HAVE_OPENVX
9+
PERF_TEST_P(Size_MatType, Accumulate,
10+
testing::Combine(
11+
testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
12+
testing::Values(CV_16SC1, CV_32FC1)
13+
)
14+
)
15+
#else
16+
PERF_TEST_P( Size_MatType, Accumulate,
17+
testing::Combine(
18+
testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
19+
testing::Values(CV_32FC1)
20+
)
21+
)
22+
#endif
23+
{
24+
Size sz = get<0>(GetParam());
25+
int dstType = get<1>(GetParam());
26+
27+
Mat src(sz, CV_8UC1);
28+
Mat dst(sz, dstType);
29+
30+
declare.time(100);
31+
declare.in(src, WARMUP_RNG).out(dst);
32+
33+
TEST_CYCLE() accumulate(src, dst);
34+
35+
SANITY_CHECK(dst);
36+
}
37+
38+
#ifdef HAVE_OPENVX
39+
PERF_TEST_P(Size_MatType, AccumulateSquare,
40+
testing::Combine(
41+
testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
42+
testing::Values(CV_16SC1, CV_32FC1)
43+
)
44+
)
45+
#else
46+
PERF_TEST_P( Size_MatType, AccumulateSquare,
47+
testing::Combine(
48+
testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
49+
testing::Values(CV_32FC1)
50+
)
51+
)
52+
#endif
53+
{
54+
Size sz = get<0>(GetParam());
55+
int dstType = get<1>(GetParam());
56+
57+
Mat src(sz, CV_8UC1);
58+
Mat dst(sz, dstType);
59+
60+
declare.time(100);
61+
declare.in(src, WARMUP_RNG).out(dst);
62+
63+
TEST_CYCLE() accumulateSquare(src, dst);
64+
65+
SANITY_CHECK(dst);
66+
}
67+
68+
#ifdef HAVE_OPENVX
69+
PERF_TEST_P(Size_MatType, AccumulateWeighted,
70+
testing::Combine(
71+
testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
72+
testing::Values(CV_8UC1, CV_32FC1)
73+
)
74+
)
75+
#else
76+
PERF_TEST_P( Size_MatType, AccumulateWeighted,
77+
testing::Combine(
78+
testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
79+
testing::Values(CV_32FC1)
80+
)
81+
)
82+
#endif
83+
{
84+
Size sz = get<0>(GetParam());
85+
int dstType = get<1>(GetParam());
86+
87+
Mat src(sz, CV_8UC1);
88+
Mat dst(sz, dstType);
89+
90+
declare.time(100);
91+
declare.in(src, WARMUP_RNG).out(dst);
92+
93+
TEST_CYCLE() accumulateWeighted(src, dst, 0.314);
94+
95+
SANITY_CHECK(dst);
96+
}

modules/imgproc/perf/perf_filter2d.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,33 @@ PERF_TEST_P( TestFilter2d, Filter2d,
4242
SANITY_CHECK(dst, 1);
4343
}
4444

45+
PERF_TEST_P(TestFilter2d, Filter2d_ovx,
46+
Combine(
47+
Values(Size(320, 240), sz1080p),
48+
Values(3, 5),
49+
Values(BORDER_CONSTANT, BORDER_REPLICATE)
50+
)
51+
)
52+
{
53+
Size sz;
54+
int borderMode, kSize;
55+
sz = get<0>(GetParam());
56+
kSize = get<1>(GetParam());
57+
borderMode = get<2>(GetParam());
58+
59+
Mat src(sz, CV_8UC1);
60+
Mat dst(sz, CV_16SC1);
61+
62+
Mat kernel(kSize, kSize, CV_16SC1);
63+
randu(kernel, -3, 10);
64+
65+
declare.in(src, WARMUP_RNG).out(dst).time(20);
66+
67+
TEST_CYCLE() filter2D(src, dst, CV_16SC1, kernel, Point(kSize / 2, kSize / 2), 0., borderMode);
68+
69+
SANITY_CHECK(dst, 1);
70+
}
71+
4572
PERF_TEST_P( Image_KernelSize, GaborFilter2d,
4673
Combine(
4774
Values("stitching/a1.png", "cv/shared/pic5.png"),

modules/imgproc/perf/perf_pyramids.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ PERF_TEST_P(Size_MatType, pyrDown, testing::Combine(
2727
SANITY_CHECK(dst, eps, error_type);
2828
}
2929

30+
PERF_TEST_P(Size_MatType, pyrDown_ovx, testing::Combine(
31+
testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
32+
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
33+
)
34+
)
35+
{
36+
Size sz = get<0>(GetParam());
37+
int matType = get<1>(GetParam());
38+
const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
39+
perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
40+
41+
Mat src(sz, matType);
42+
Mat dst((sz.height + 1) / 2, (sz.width + 1) / 2, matType);
43+
44+
declare.in(src, WARMUP_RNG).out(dst);
45+
46+
TEST_CYCLE() pyrDown(src, dst, cv::Size(), BORDER_REPLICATE);
47+
48+
SANITY_CHECK(dst, eps, error_type);
49+
}
50+
3051
PERF_TEST_P(Size_MatType, pyrUp, testing::Combine(
3152
testing::Values(sz720p, szVGA, szQVGA, szODD),
3253
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)

modules/imgproc/perf/perf_warp.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,36 @@ PERF_TEST_P( TestWarpAffine, WarpAffine,
5050
#endif
5151
}
5252

53+
PERF_TEST_P(TestWarpAffine, WarpAffine_ovx,
54+
Combine(
55+
Values(szVGA, sz720p, sz1080p),
56+
InterType::all(),
57+
BorderMode::all()
58+
)
59+
)
60+
{
61+
Size sz, szSrc(512, 512);
62+
int borderMode, interType;
63+
sz = get<0>(GetParam());
64+
interType = get<1>(GetParam());
65+
borderMode = get<2>(GetParam());
66+
Scalar borderColor = Scalar::all(150);
67+
68+
Mat src(szSrc, CV_8UC1), dst(sz, CV_8UC1);
69+
cvtest::fillGradient(src);
70+
if (borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
71+
Mat warpMat = getRotationMatrix2D(Point2f(src.cols / 2.f, src.rows / 2.f), 30., 2.2);
72+
declare.in(src).out(dst);
73+
74+
TEST_CYCLE() warpAffine(src, dst, warpMat, sz, interType, borderMode, borderColor);
75+
76+
#ifdef ANDROID
77+
SANITY_CHECK(dst, interType == INTER_LINEAR ? 5 : 10);
78+
#else
79+
SANITY_CHECK(dst, 1);
80+
#endif
81+
}
82+
5383
PERF_TEST_P( TestWarpPerspective, WarpPerspective,
5484
Combine(
5585
Values( szVGA, sz720p, sz1080p ),
@@ -88,6 +118,44 @@ PERF_TEST_P( TestWarpPerspective, WarpPerspective,
88118
#endif
89119
}
90120

121+
PERF_TEST_P(TestWarpPerspective, WarpPerspective_ovx,
122+
Combine(
123+
Values(szVGA, sz720p, sz1080p),
124+
InterType::all(),
125+
BorderMode::all()
126+
)
127+
)
128+
{
129+
Size sz, szSrc(512, 512);
130+
int borderMode, interType;
131+
sz = get<0>(GetParam());
132+
interType = get<1>(GetParam());
133+
borderMode = get<2>(GetParam());
134+
Scalar borderColor = Scalar::all(150);
135+
136+
Mat src(szSrc, CV_8UC1), dst(sz, CV_8UC1);
137+
cvtest::fillGradient(src);
138+
if (borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
139+
Mat rotMat = getRotationMatrix2D(Point2f(src.cols / 2.f, src.rows / 2.f), 30., 2.2);
140+
Mat warpMat(3, 3, CV_64FC1);
141+
for (int r = 0; r<2; r++)
142+
for (int c = 0; c<3; c++)
143+
warpMat.at<double>(r, c) = rotMat.at<double>(r, c);
144+
warpMat.at<double>(2, 0) = .3 / sz.width;
145+
warpMat.at<double>(2, 1) = .3 / sz.height;
146+
warpMat.at<double>(2, 2) = 1;
147+
148+
declare.in(src).out(dst);
149+
150+
TEST_CYCLE() warpPerspective(src, dst, warpMat, sz, interType, borderMode, borderColor);
151+
152+
#ifdef ANDROID
153+
SANITY_CHECK(dst, interType == INTER_LINEAR ? 5 : 10);
154+
#else
155+
SANITY_CHECK(dst, 1);
156+
#endif
157+
}
158+
91159
PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear,
92160
Combine(
93161
Values( Size(640,480), Size(1920,1080), Size(2592,1944) ),

modules/video/perf/perf_optflowpyrlk.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,58 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine(
9797
SANITY_CHECK(err, 2);
9898
}
9999

100+
typedef tr1::tuple<std::string, int, tr1::tuple<int, int>, int> Path_Idx_NPoints_WSize_t;
101+
typedef TestBaseWithParam<Path_Idx_NPoints_WSize_t> Path_Idx_NPoints_WSize;
102+
103+
PERF_TEST_P(Path_Idx_NPoints_WSize, OpticalFlowPyrLK_ovx, testing::Combine(
104+
testing::Values<std::string>("cv/optflow/frames/VGA_%02d.png", "cv/optflow/frames/720p_%02d.png"),
105+
testing::Range(1, 3),
106+
testing::Values(make_tuple(9, 9), make_tuple(15, 15)),
107+
testing::Values(7, 11)
108+
)
109+
)
110+
{
111+
string filename1 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam())));
112+
string filename2 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam()) + 1));
113+
Mat img1 = imread(filename1);
114+
Mat img2 = imread(filename2);
115+
if (img1.empty()) FAIL() << "Unable to load source image " << filename1;
116+
if (img2.empty()) FAIL() << "Unable to load source image " << filename2;
117+
118+
int nPointsX = min(get<0>(get<2>(GetParam())), img1.cols);
119+
int nPointsY = min(get<1>(get<2>(GetParam())), img1.rows);
120+
int winSize = get<3>(GetParam());
121+
122+
int maxLevel = 2;
123+
TermCriteria criteria(TermCriteria::COUNT|TermCriteria::EPS, 7, 0.001);
124+
int flags = 0;
125+
double minEigThreshold = 1e-4;
126+
127+
Mat frame1, frame2;
128+
cvtColor(img1, frame1, COLOR_BGR2GRAY, 1);
129+
cvtColor(img2, frame2, COLOR_BGR2GRAY, 1);
130+
131+
vector<Point2f> inPoints;
132+
vector<Point2f> outPoints;
133+
vector<uchar> status;
134+
135+
FormTrackingPointsArray(inPoints, frame1.cols, frame1.rows, nPointsX, nPointsY);
136+
outPoints.resize(inPoints.size());
137+
status.resize(inPoints.size());
138+
139+
declare.in(frame1, frame2, inPoints).out(outPoints);
140+
141+
TEST_CYCLE_N(30)
142+
{
143+
calcOpticalFlowPyrLK(frame1, frame2, inPoints, outPoints, status, cv::noArray(),
144+
Size(winSize, winSize), maxLevel, criteria,
145+
flags, minEigThreshold);
146+
}
147+
148+
SANITY_CHECK(outPoints, 0.3);
149+
SANITY_CHECK(status);
150+
}
151+
100152
typedef tr1::tuple<std::string, int, int, tr1::tuple<int,int>, int, bool> Path_Idx_Cn_NPoints_WSize_Deriv_t;
101153
typedef TestBaseWithParam<Path_Idx_Cn_NPoints_WSize_Deriv_t> Path_Idx_Cn_NPoints_WSize_Deriv;
102154

0 commit comments

Comments
 (0)