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
07dc6d2b
Commit
07dc6d2b
authored
Apr 30, 2018
by
Dmitry Kurtaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return a convex hull from rotatedRectangleIntersection
parent
8488f2e2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
22 deletions
+19
-22
nms.cpp
modules/dnn/src/nms.cpp
+2
-3
intersection.cpp
modules/imgproc/src/intersection.cpp
+11
-3
test_intersection.cpp
modules/imgproc/test/test_intersection.cpp
+0
-0
text_detection.cpp
samples/dnn/text_detection.cpp
+6
-16
No files found.
modules/dnn/src/nms.cpp
View file @
07dc6d2b
...
...
@@ -32,14 +32,13 @@ void NMSBoxes(const std::vector<Rect>& bboxes, const std::vector<float>& scores,
static
inline
float
rotatedRectIOU
(
const
RotatedRect
&
a
,
const
RotatedRect
&
b
)
{
std
::
vector
<
Point2f
>
inter
,
hull
;
std
::
vector
<
Point2f
>
inter
;
int
res
=
rotatedRectangleIntersection
(
a
,
b
,
inter
);
if
(
inter
.
empty
()
||
res
==
INTERSECT_NONE
)
return
0.0
f
;
if
(
res
==
INTERSECT_FULL
)
return
1.0
f
;
convexHull
(
inter
,
hull
);
float
interArea
=
contourArea
(
hull
);
float
interArea
=
contourArea
(
inter
);
return
interArea
/
(
a
.
size
.
area
()
+
b
.
size
.
area
()
-
interArea
);
}
...
...
modules/imgproc/src/intersection.cpp
View file @
07dc6d2b
...
...
@@ -219,13 +219,15 @@ int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& r
}
}
// Get rid of dupes
// Get rid of dupes
and order points.
for
(
int
i
=
0
;
i
<
(
int
)
intersection
.
size
()
-
1
;
i
++
)
{
float
dx1
=
intersection
[
i
+
1
].
x
-
intersection
[
i
].
x
;
float
dy1
=
intersection
[
i
+
1
].
y
-
intersection
[
i
].
y
;
for
(
size_t
j
=
i
+
1
;
j
<
intersection
.
size
();
j
++
)
{
float
dx
=
intersection
[
i
].
x
-
intersection
[
j
].
x
;
float
dy
=
intersection
[
i
].
y
-
intersection
[
j
].
y
;
float
dx
=
intersection
[
j
].
x
-
intersection
[
i
].
x
;
float
dy
=
intersection
[
j
].
y
-
intersection
[
i
].
y
;
double
d2
=
dx
*
dx
+
dy
*
dy
;
// can be a really small number, need double here
if
(
d2
<
samePointEps
*
samePointEps
)
...
...
@@ -235,6 +237,12 @@ int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& r
intersection
.
pop_back
();
j
--
;
// restart check
}
else
if
(
dx1
*
dy
-
dy1
*
dx
<
0
)
{
std
::
swap
(
intersection
[
i
+
1
],
intersection
[
j
]);
dx1
=
dx
;
dy1
=
dy
;
}
}
}
...
...
modules/imgproc/test/test_intersection.cpp
View file @
07dc6d2b
This diff is collapsed.
Click to expand it.
samples/dnn/text_detection.cpp
View file @
07dc6d2b
...
...
@@ -124,17 +124,14 @@ void decode(const Mat& scores, const Mat& geometry, float scoreThresh,
const
int
height
=
scores
.
size
[
2
];
const
int
width
=
scores
.
size
[
3
];
const
int
planeSize
=
height
*
width
;
float
*
scoresData
=
(
float
*
)
scores
.
data
;
float
*
geometryData
=
(
float
*
)
geometry
.
data
;
float
*
x0_data
=
geometryData
;
float
*
x1_data
=
geometryData
+
planeSize
;
float
*
x2_data
=
geometryData
+
planeSize
*
2
;
float
*
x3_data
=
geometryData
+
planeSize
*
3
;
float
*
anglesData
=
geometryData
+
planeSize
*
4
;
for
(
int
y
=
0
;
y
<
height
;
++
y
)
{
const
float
*
scoresData
=
scores
.
ptr
<
float
>
(
0
,
0
,
y
);
const
float
*
x0_data
=
geometry
.
ptr
<
float
>
(
0
,
0
,
y
);
const
float
*
x1_data
=
geometry
.
ptr
<
float
>
(
0
,
1
,
y
);
const
float
*
x2_data
=
geometry
.
ptr
<
float
>
(
0
,
2
,
y
);
const
float
*
x3_data
=
geometry
.
ptr
<
float
>
(
0
,
3
,
y
);
const
float
*
anglesData
=
geometry
.
ptr
<
float
>
(
0
,
4
,
y
);
for
(
int
x
=
0
;
x
<
width
;
++
x
)
{
float
score
=
scoresData
[
x
];
...
...
@@ -142,7 +139,6 @@ void decode(const Mat& scores, const Mat& geometry, float scoreThresh,
continue
;
// Decode a prediction.
// Multiple by 4 because feature maps are 4 time less than input image.
float
offsetX
=
x
*
4.0
f
,
offsetY
=
y
*
4.0
f
;
float
angle
=
anglesData
[
x
];
...
...
@@ -159,11 +155,5 @@ void decode(const Mat& scores, const Mat& geometry, float scoreThresh,
detections
.
push_back
(
r
);
confidences
.
push_back
(
score
);
}
scoresData
+=
width
;
x0_data
+=
width
;
x1_data
+=
width
;
x2_data
+=
width
;
x3_data
+=
width
;
anglesData
+=
width
;
}
}
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