Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
5f9c881f
Commit
5f9c881f
authored
Jun 22, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made remove_duplicates() take any type rather than just being limited to
rectangle.
parent
64fb2312
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
segment_image.h
dlib/image_transforms/segment_image.h
+8
-8
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
(
rects
.
begin
(),
rects
.
end
(),
std
::
less
<
rectangle
>
());
std
::
sort
(
items
.
begin
(),
items
.
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
(
rects
[
i
]
!=
rect
s
[
i
-
1
])
if
(
items
[
i
]
!=
item
s
[
i
-
1
])
{
rects
[
num_unique
++
]
=
rect
s
[
i
];
items
[
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