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
5a4f2b5d
Commit
5a4f2b5d
authored
May 29, 2017
by
Woody Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function to sort keypoints that are calculated in parallel to ensure stable output
parent
89fcd6d8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
features2d.hpp
modules/features2d/include/opencv2/features2d.hpp
+4
-0
keypoint.cpp
modules/features2d/src/keypoint.cpp
+40
-0
No files found.
modules/features2d/include/opencv2/features2d.hpp
View file @
5a4f2b5d
...
...
@@ -117,6 +117,10 @@ public:
* Remove duplicated keypoints.
*/
static
void
removeDuplicated
(
std
::
vector
<
KeyPoint
>&
keypoints
);
/*
* Remove duplicated keypoints and sort the remaining keypoints
*/
static
void
removeDuplicatedSorted
(
std
::
vector
<
KeyPoint
>&
keypoints
);
/*
* Retain the specified number of the best keypoints (according to the response)
...
...
modules/features2d/src/keypoint.cpp
View file @
5a4f2b5d
...
...
@@ -221,4 +221,44 @@ void KeyPointsFilter::removeDuplicated( std::vector<KeyPoint>& keypoints )
keypoints
.
resize
(
j
);
}
struct
KeyPoint12_LessThan
{
bool
operator
()(
const
KeyPoint
&
kp1
,
const
KeyPoint
&
kp2
)
const
{
if
(
kp1
.
pt
.
x
!=
kp2
.
pt
.
x
)
return
kp1
.
pt
.
x
<
kp2
.
pt
.
x
;
if
(
kp1
.
pt
.
y
!=
kp2
.
pt
.
y
)
return
kp1
.
pt
.
y
<
kp2
.
pt
.
y
;
if
(
kp1
.
size
!=
kp2
.
size
)
return
kp1
.
size
>
kp2
.
size
;
if
(
kp1
.
angle
!=
kp2
.
angle
)
return
kp1
.
angle
<
kp2
.
angle
;
if
(
kp1
.
response
!=
kp2
.
response
)
return
kp1
.
response
>
kp2
.
response
;
if
(
kp1
.
octave
!=
kp2
.
octave
)
return
kp1
.
octave
>
kp2
.
octave
;
return
kp1
.
class_id
>
kp2
.
class_id
;
}
};
void
KeyPointsFilter
::
removeDuplicatedSorted
(
std
::
vector
<
KeyPoint
>&
keypoints
)
{
int
i
,
j
,
n
=
(
int
)
keypoints
.
size
();
if
(
n
<
2
)
return
;
std
::
sort
(
keypoints
.
begin
(),
keypoints
.
end
(),
KeyPoint12_LessThan
());
for
(
i
=
0
,
j
=
1
;
j
<
n
;
++
j
)
{
const
KeyPoint
&
kp1
=
keypoints
[
i
];
const
KeyPoint
&
kp2
=
keypoints
[
j
];
if
(
kp1
.
pt
.
x
!=
kp2
.
pt
.
x
||
kp1
.
pt
.
y
!=
kp2
.
pt
.
y
||
kp1
.
size
!=
kp2
.
size
||
kp1
.
angle
!=
kp2
.
angle
)
{
keypoints
[
++
i
]
=
keypoints
[
j
];
}
}
keypoints
.
resize
(
i
+
1
);
}
}
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