Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
ae00161f
Commit
ae00161f
authored
Mar 20, 2012
by
Davis King
Browse files
Made determine_object_boxes() a little more robust. Previously, it
would sometimes select an invalid set of object boxes.
parent
75e6baf9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
dlib/image_processing/scan_image_pyramid_tools.h
dlib/image_processing/scan_image_pyramid_tools.h
+14
-2
No files found.
dlib/image_processing/scan_image_pyramid_tools.h
View file @
ae00161f
...
@@ -128,12 +128,21 @@ namespace dlib
...
@@ -128,12 +128,21 @@ namespace dlib
typedef
std
::
list
<
std
::
pair
<
unsigned
long
,
rectangle
>
>
list_type
;
typedef
std
::
list
<
std
::
pair
<
unsigned
long
,
rectangle
>
>
list_type
;
unsigned
long
max_area
=
0
;
// copy rects into sorted_rects and sort them in order of increasing area
// copy rects into sorted_rects and sort them in order of increasing area
list_type
sorted_rects
;
list_type
sorted_rects
;
for
(
unsigned
long
i
=
0
;
i
<
rects
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
rects
.
size
();
++
i
)
{
max_area
=
std
::
max
(
rects
[
i
].
area
(),
max_area
);
sorted_rects
.
push_back
(
std
::
make_pair
(
rects
[
i
].
area
(),
rects
[
i
]));
sorted_rects
.
push_back
(
std
::
make_pair
(
rects
[
i
].
area
(),
rects
[
i
]));
}
sorted_rects
.
sort
(
dlib
::
impl
::
compare_first
);
sorted_rects
.
sort
(
dlib
::
impl
::
compare_first
);
// Make sure this area value is comfortably larger than all the
// rectangles' areas.
max_area
=
3
*
max_area
+
100
;
std
::
vector
<
rectangle
>
object_boxes
;
std
::
vector
<
rectangle
>
object_boxes
;
while
(
sorted_rects
.
size
()
!=
0
)
while
(
sorted_rects
.
size
()
!=
0
)
...
@@ -142,8 +151,11 @@ namespace dlib
...
@@ -142,8 +151,11 @@ namespace dlib
sorted_rects
.
pop_front
();
sorted_rects
.
pop_front
();
object_boxes
.
push_back
(
centered_rect
(
point
(
0
,
0
),
cur
.
width
(),
cur
.
height
()));
object_boxes
.
push_back
(
centered_rect
(
point
(
0
,
0
),
cur
.
width
(),
cur
.
height
()));
// remove all the rectangles which match cur
// Scale cur up the image pyramid and remove any rectangles which match.
for
(
unsigned
long
itr
=
0
;
itr
<
scanner
.
get_max_pyramid_levels
();
++
itr
)
// But also stop when cur gets large enough to not match anything.
for
(
unsigned
long
itr
=
0
;
itr
<
scanner
.
get_max_pyramid_levels
()
&&
cur
.
area
()
<
max_area
;
++
itr
)
{
{
list_type
::
iterator
i
=
sorted_rects
.
begin
();
list_type
::
iterator
i
=
sorted_rects
.
begin
();
while
(
i
!=
sorted_rects
.
end
())
while
(
i
!=
sorted_rects
.
end
())
...
...
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