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
5f9c881f
Commit
5f9c881f
authored
Jun 21, 2018
by
Davis King
Browse files
Made remove_duplicates() take any type rather than just being limited to
rectangle.
parent
64fb2312
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
dlib/image_transforms/segment_image.h
dlib/image_transforms/segment_image.h
+8
-8
dlib/image_transforms/segment_image_abstract.h
dlib/image_transforms/segment_image_abstract.h
+8
-4
No files found.
dlib/image_transforms/segment_image.h
View file @
5f9c881f
...
...
@@ -595,22 +595,22 @@ namespace dlib
// ----------------------------------------------------------------------------------------
template
<
typename
alloc
>
template
<
typename
T
,
typename
alloc
>
void
remove_duplicates
(
std
::
vector
<
rectangle
,
alloc
>&
rect
s
std
::
vector
<
T
,
alloc
>&
item
s
)
{
std
::
sort
(
rect
s
.
begin
(),
rect
s
.
end
(),
std
::
less
<
rectangle
>
());
std
::
sort
(
item
s
.
begin
(),
item
s
.
end
(),
std
::
less
<
T
>
());
unsigned
long
num_unique
=
1
;
for
(
unsigned
long
i
=
1
;
i
<
rect
s
.
size
();
++
i
)
for
(
unsigned
long
i
=
1
;
i
<
item
s
.
size
();
++
i
)
{
if
(
rect
s
[
i
]
!=
rect
s
[
i
-
1
])
if
(
item
s
[
i
]
!=
item
s
[
i
-
1
])
{
rect
s
[
num_unique
++
]
=
rect
s
[
i
];
item
s
[
num_unique
++
]
=
item
s
[
i
];
}
}
if
(
rect
s
.
size
()
!=
0
)
rect
s
.
resize
(
num_unique
);
if
(
item
s
.
size
()
!=
0
)
item
s
.
resize
(
num_unique
);
}
// ----------------------------------------------------------------------------------------
...
...
dlib/image_transforms/segment_image_abstract.h
View file @
5f9c881f
...
...
@@ -105,16 +105,20 @@ namespace dlib
// ----------------------------------------------------------------------------------------
template
<
template
T
,
typename
alloc
>
void
remove_duplicates
(
std
::
vector
<
rectangle
,
alloc
>&
rects
std
::
vector
<
T
,
alloc
>
&
items
);
/*!
requires
- T is comparable via operator != and std::less.
ensures
- This function finds any duplicate rectangles in rects and removes the extra
instances. This way, the result is that rects contains only unique rectangle
instances.
- This function finds any duplicate objects in items and removes the extra
instances. This way, the result is that items contains only unique
instances. It does this by sorting items and removing neighboring elements
unless they compare != according to operator !=.
!*/
// ----------------------------------------------------------------------------------------
...
...
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