Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/video/perf/perf_ecc.cpp
16354 views
1
#include "perf_precomp.hpp"
2
3
namespace opencv_test
4
{
5
using namespace perf;
6
7
CV_ENUM(MotionType, MOTION_TRANSLATION, MOTION_EUCLIDEAN, MOTION_AFFINE, MOTION_HOMOGRAPHY)
8
9
typedef tuple<MotionType> MotionType_t;
10
typedef perf::TestBaseWithParam<MotionType_t> TransformationType;
11
12
13
PERF_TEST_P(TransformationType, findTransformECC, /*testing::ValuesIn(MotionType::all())*/
14
testing::Values((int) MOTION_TRANSLATION, (int) MOTION_EUCLIDEAN,
15
(int) MOTION_AFFINE, (int) MOTION_HOMOGRAPHY)
16
)
17
{
18
Mat img = imread(getDataPath("cv/shared/fruits_ecc.png"),0);
19
Mat templateImage;
20
21
int transform_type = get<0>(GetParam());
22
23
Mat warpMat;
24
Mat warpGround;
25
26
double angle;
27
switch (transform_type) {
28
case MOTION_TRANSLATION:
29
warpGround = (Mat_<float>(2,3) << 1.f, 0.f, 7.234f,
30
0.f, 1.f, 11.839f);
31
32
warpAffine(img, templateImage, warpGround,
33
Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP);
34
break;
35
case MOTION_EUCLIDEAN:
36
angle = CV_PI/30;
37
38
warpGround = (Mat_<float>(2,3) << (float)cos(angle), (float)-sin(angle), 12.123f,
39
(float)sin(angle), (float)cos(angle), 14.789f);
40
warpAffine(img, templateImage, warpGround,
41
Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP);
42
break;
43
case MOTION_AFFINE:
44
warpGround = (Mat_<float>(2,3) << 0.98f, 0.03f, 15.523f,
45
-0.02f, 0.95f, 10.456f);
46
warpAffine(img, templateImage, warpGround,
47
Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP);
48
break;
49
case MOTION_HOMOGRAPHY:
50
warpGround = (Mat_<float>(3,3) << 0.98f, 0.03f, 15.523f,
51
-0.02f, 0.95f, 10.456f,
52
0.0002f, 0.0003f, 1.f);
53
warpPerspective(img, templateImage, warpGround,
54
Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP);
55
break;
56
}
57
58
TEST_CYCLE()
59
{
60
if (transform_type<3)
61
warpMat = Mat::eye(2,3, CV_32F);
62
else
63
warpMat = Mat::eye(3,3, CV_32F);
64
65
findTransformECC(templateImage, img, warpMat, transform_type,
66
TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 5, -1));
67
}
68
SANITY_CHECK(warpMat, 3e-3);
69
}
70
71
} // namespace
72
73