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
fd4461d5
Commit
fd4461d5
authored
Feb 21, 2014
by
Rohit Girdhar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addressed issues
parent
347a3dc5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
matrix.cpp
modules/core/src/matrix.cpp
+1
-1
test_rotatedrect.cpp
modules/core/test/test_rotatedrect.cpp
+15
-15
No files found.
modules/core/src/matrix.cpp
View file @
fd4461d5
...
...
@@ -5211,7 +5211,7 @@ RotatedRect::RotatedRect(const Point2f& _point1, const Point2f& _point2, const P
vecs
[
0
]
=
Vec2f
(
_point1
-
_point2
);
vecs
[
1
]
=
Vec2f
(
_point2
-
_point3
);
// check that given sides are perpendicular
CV_Assert
(
abs
(
vecs
[
0
].
dot
(
vecs
[
1
]))
<=
FLT_EPSILON
);
CV_Assert
(
abs
(
vecs
[
0
].
dot
(
vecs
[
1
]))
/
(
norm
(
vecs
[
0
])
*
norm
(
vecs
[
1
]))
<=
FLT_EPSILON
);
// wd_i stores which vector (0,1) or (1,2) will make the width
// One of them will definitely have slope within -1 to 1
...
...
modules/core/test/test_rotatedrect.cpp
View file @
fd4461d5
...
...
@@ -52,7 +52,7 @@ protected:
int
prepare_test_case
(
int
);
void
run_func
();
int
validate_test_results
(
int
);
const
static
int
MAX_COORD_VAL
=
1000
;
float
MAX_COORD_VAL
;
Point2f
a
,
b
,
c
;
RotatedRect
rec
;
};
...
...
@@ -60,22 +60,24 @@ protected:
Core_RotatedRectConstructorTest
::
Core_RotatedRectConstructorTest
()
{
test_case_count
=
100
;
MAX_COORD_VAL
=
1000.0
f
;
}
int
Core_RotatedRectConstructorTest
::
prepare_test_case
(
int
test_case_idx
)
{
cvtest
::
BaseTest
::
prepare_test_case
(
test_case_idx
);
RNG
&
rng
=
ts
->
get_rng
();
a
=
Point2f
(
(
float
)
(
cvtest
::
randInt
(
rng
)
%
MAX_COORD_VAL
),
(
float
)
(
cvtest
::
randInt
(
rng
)
%
MAX_COORD_VAL
)
);
b
=
Point2f
(
(
float
)
(
cvtest
::
randInt
(
rng
)
%
MAX_COORD_VAL
)
,
(
float
)
(
cvtest
::
randInt
(
rng
)
%
MAX_COORD_VAL
)
);
// to ensure a != b
while
(
norm
(
a
-
b
)
==
0
)
{
b
=
Point2f
(
(
float
)
(
cvtest
::
randInt
(
rng
)
%
MAX_COORD_VAL
)
,
(
float
)
(
cvtest
::
randInt
(
rng
)
%
MAX_COORD_VAL
)
);
a
=
Point2f
(
rng
.
uniform
(
-
MAX_COORD_VAL
,
MAX_COORD_VAL
),
rng
.
uniform
(
-
MAX_COORD_VAL
,
MAX_COORD_VAL
)
);
do
{
b
=
Point2f
(
rng
.
uniform
(
-
MAX_COORD_VAL
,
MAX_COORD_VAL
),
rng
.
uniform
(
-
MAX_COORD_VAL
,
MAX_COORD_VAL
)
);
}
while
(
norm
(
a
-
b
)
<=
FLT_EPSILON
);
Vec2f
along
(
a
-
b
);
Vec2f
perp
=
Vec2f
(
-
along
[
1
],
along
[
0
]);
float
d
=
(
float
)
(
cvtest
::
randInt
(
rng
)
%
MAX_COORD_VAL
)
+
1.0
f
;
// c can't be same as b, so d must be > 0
c
=
Point2f
(
b
.
x
+
d
*
perp
[
0
],
b
.
y
+
d
*
perp
[
1
]
);
double
d
=
(
double
)
rng
.
uniform
(
1.0
f
,
5.0
f
);
if
(
cvtest
::
randInt
(
rng
)
%
2
==
0
)
d
=
-
d
;
c
=
Point2f
(
(
float
)
((
double
)
b
.
x
+
d
*
perp
[
0
]),
(
float
)
((
double
)
b
.
y
+
d
*
perp
[
1
])
);
return
1
;
}
...
...
@@ -86,22 +88,20 @@ void Core_RotatedRectConstructorTest::run_func()
int
Core_RotatedRectConstructorTest
::
validate_test_results
(
int
)
{
int
code
=
cvtest
::
TS
::
OK
;
Point2f
vertices
[
4
];
rec
.
points
(
vertices
);
int
count_match
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
if
(
norm
(
vertices
[
i
]
-
a
)
<=
0.1
)
count_match
++
;
else
if
(
norm
(
vertices
[
i
]
-
b
)
<=
0.1
)
count_match
++
;
else
if
(
norm
(
vertices
[
i
]
-
c
)
<=
0.1
)
count_match
++
;
if
(
norm
(
vertices
[
i
]
-
a
)
<=
0.
00
1
)
count_match
++
;
else
if
(
norm
(
vertices
[
i
]
-
b
)
<=
0.
00
1
)
count_match
++
;
else
if
(
norm
(
vertices
[
i
]
-
c
)
<=
0.
00
1
)
count_match
++
;
}
if
(
count_match
==
3
)
return
c
ode
;
return
c
vtest
::
TS
::
OK
;
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"RotatedRect end points don't match those supplied in constructor"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_OUTPUT
);
return
c
ode
;
return
c
vtest
::
TS
::
OK
;
}
TEST
(
Core_RotatedRect
,
three_point_constructor
)
{
Core_RotatedRectConstructorTest
test
;
test
.
safe_run
();
}
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