Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
b7476335
Commit
b7476335
authored
Jul 18, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6915 from arrybn:bugs_4515_6544_tests
parents
55d09451
2deda0e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
test_fitellipse.cpp
modules/imgproc/test/test_fitellipse.cpp
+70
-0
No files found.
modules/imgproc/test/test_fitellipse.cpp
0 → 100644
View file @
b7476335
// 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.
//
// Copyright (C) 2016, Itseez, Inc, all rights reserved.
#include "test_precomp.hpp"
#include <vector>
#include <cmath>
using
namespace
cv
;
using
namespace
std
;
// return true if point lies inside ellipse
static
bool
check_pt_in_ellipse
(
const
Point2f
&
pt
,
const
RotatedRect
&
el
)
{
Point2f
to_pt
=
pt
-
el
.
center
;
double
pt_angle
=
atan2
(
to_pt
.
y
,
to_pt
.
x
);
double
el_angle
=
el
.
angle
*
CV_PI
/
180
;
double
x_dist
=
0.5
*
el
.
size
.
width
*
cos
(
pt_angle
+
el_angle
);
double
y_dist
=
0.5
*
el
.
size
.
height
*
sin
(
pt_angle
+
el_angle
);
double
el_dist
=
sqrt
(
x_dist
*
x_dist
+
y_dist
*
y_dist
);
return
norm
(
to_pt
)
<
el_dist
;
}
// Return true if mass center of fitted points lies inside ellipse
static
bool
fit_and_check_ellipse
(
const
vector
<
Point2f
>&
pts
)
{
RotatedRect
ellipse
=
fitEllipse
(
pts
);
Point2f
mass_center
;
for
(
size_t
i
=
0
;
i
<
pts
.
size
();
i
++
)
{
mass_center
+=
pts
[
i
];
}
mass_center
/=
(
float
)
pts
.
size
();
return
check_pt_in_ellipse
(
mass_center
,
ellipse
);
}
TEST
(
Imgproc_FitEllipse_Issue_4515
,
DISABLED_accuracy
)
{
vector
<
Point2f
>
pts
;
pts
.
push_back
(
Point2f
(
327
,
317
));
pts
.
push_back
(
Point2f
(
328
,
316
));
pts
.
push_back
(
Point2f
(
329
,
315
));
pts
.
push_back
(
Point2f
(
330
,
314
));
pts
.
push_back
(
Point2f
(
331
,
314
));
pts
.
push_back
(
Point2f
(
332
,
314
));
pts
.
push_back
(
Point2f
(
333
,
315
));
pts
.
push_back
(
Point2f
(
333
,
316
));
pts
.
push_back
(
Point2f
(
333
,
317
));
pts
.
push_back
(
Point2f
(
333
,
318
));
pts
.
push_back
(
Point2f
(
333
,
319
));
pts
.
push_back
(
Point2f
(
333
,
320
));
EXPECT_TRUE
(
fit_and_check_ellipse
(
pts
));
}
TEST
(
Imgproc_FitEllipse_Issue_6544
,
DISABLED_accuracy
)
{
vector
<
Point2f
>
pts
;
pts
.
push_back
(
Point2f
(
924.784
f
,
764.160
f
));
pts
.
push_back
(
Point2f
(
928.388
f
,
615.903
f
));
pts
.
push_back
(
Point2f
(
847.4
f
,
888.014
f
));
pts
.
push_back
(
Point2f
(
929.406
f
,
741.675
f
));
pts
.
push_back
(
Point2f
(
904.564
f
,
825.605
f
));
pts
.
push_back
(
Point2f
(
926.742
f
,
760.746
f
));
pts
.
push_back
(
Point2f
(
863.479
f
,
873.406
f
));
pts
.
push_back
(
Point2f
(
910.987
f
,
808.863
f
));
pts
.
push_back
(
Point2f
(
929.145
f
,
744.976
f
));
pts
.
push_back
(
Point2f
(
917.474
f
,
791.823
f
));
EXPECT_TRUE
(
fit_and_check_ellipse
(
pts
));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment