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
fdbed4a4
Commit
fdbed4a4
authored
Sep 26, 2015
by
Balint Cristian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speedup AGAST nonmax-suppression.
parent
3a3f4038
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
agast.cpp
modules/features2d/src/agast.cpp
+25
-25
No files found.
modules/features2d/src/agast.cpp
View file @
fdbed4a4
...
...
@@ -7511,19 +7511,22 @@ Ptr<AgastFeatureDetector> AgastFeatureDetector::create( int threshold, bool nonm
void
AGAST
(
InputArray
_img
,
std
::
vector
<
KeyPoint
>&
keypoints
,
int
threshold
,
bool
nonmax_suppression
,
int
type
)
{
std
::
vector
<
KeyPoint
>
kpts
;
// detect
switch
(
type
)
{
case
AgastFeatureDetector
:
:
AGAST_5_8
:
AGAST_5_8
(
_img
,
k
eypoin
ts
,
threshold
);
AGAST_5_8
(
_img
,
k
p
ts
,
threshold
);
break
;
case
AgastFeatureDetector
:
:
AGAST_7_12d
:
AGAST_7_12d
(
_img
,
k
eypoin
ts
,
threshold
);
AGAST_7_12d
(
_img
,
k
p
ts
,
threshold
);
break
;
case
AgastFeatureDetector
:
:
AGAST_7_12s
:
AGAST_7_12s
(
_img
,
k
eypoin
ts
,
threshold
);
AGAST_7_12s
(
_img
,
k
p
ts
,
threshold
);
break
;
case
AgastFeatureDetector
:
:
OAST_9_16
:
OAST_9_16
(
_img
,
k
eypoin
ts
,
threshold
);
OAST_9_16
(
_img
,
k
p
ts
,
threshold
);
break
;
}
...
...
@@ -7534,7 +7537,7 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
makeAgastOffsets
(
pixel_
,
(
int
)
img
.
step
,
type
);
std
::
vector
<
KeyPoint
>::
iterator
kpt
;
for
(
kpt
=
k
eypoints
.
begin
();
kpt
!=
keypoin
ts
.
end
();
kpt
++
)
for
(
kpt
=
k
pts
.
begin
();
kpt
!=
kp
ts
.
end
();
kpt
++
)
{
switch
(
type
)
{
case
AgastFeatureDetector
:
:
AGAST_5_8
:
...
...
@@ -7555,20 +7558,21 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
break
;
}
}
// suppression
if
(
nonmax_suppression
)
{
size_t
j
;
size_t
curr_idx
;
size_t
lastRow
=
0
,
next_lastRow
=
0
;
size_t
num_Corners
=
k
eypoin
ts
.
size
();
size_t
num_Corners
=
k
p
ts
.
size
();
size_t
lastRowCorner_ind
=
0
,
next_lastRowCorner_ind
=
0
;
std
::
vector
<
int
>
nmsFlags
;
std
::
vector
<
KeyPoint
>::
iterator
currCorner_nms
;
std
::
vector
<
KeyPoint
>::
const_iterator
currCorner
;
currCorner
=
k
eypoin
ts
.
begin
();
currCorner
=
k
p
ts
.
begin
();
nmsFlags
.
resize
((
int
)
num_Corners
);
...
...
@@ -7593,11 +7597,11 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
if
(
lastRow
+
1
==
currCorner
->
pt
.
y
)
{
// find the corner above the current one
while
(
(
k
eypoin
ts
[
lastRowCorner_ind
].
pt
.
x
<
currCorner
->
pt
.
x
)
&&
(
k
eypoin
ts
[
lastRowCorner_ind
].
pt
.
y
==
lastRow
)
)
while
(
(
k
p
ts
[
lastRowCorner_ind
].
pt
.
x
<
currCorner
->
pt
.
x
)
&&
(
k
p
ts
[
lastRowCorner_ind
].
pt
.
y
==
lastRow
)
)
lastRowCorner_ind
++
;
if
(
(
k
eypoin
ts
[
lastRowCorner_ind
].
pt
.
x
==
currCorner
->
pt
.
x
)
if
(
(
k
p
ts
[
lastRowCorner_ind
].
pt
.
x
==
currCorner
->
pt
.
x
)
&&
(
lastRowCorner_ind
!=
curr_idx
)
)
{
size_t
w
=
lastRowCorner_ind
;
...
...
@@ -7605,7 +7609,7 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
while
(
nmsFlags
[
w
]
!=
-
1
)
w
=
nmsFlags
[
w
];
if
(
k
eypoints
[
curr_idx
].
response
<
keypoin
ts
[
w
].
response
)
if
(
k
pts
[
curr_idx
].
response
<
kp
ts
[
w
].
response
)
nmsFlags
[
curr_idx
]
=
(
int
)
w
;
else
nmsFlags
[
w
]
=
(
int
)
curr_idx
;
...
...
@@ -7614,8 +7618,8 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
// check left
t
=
(
int
)
curr_idx
-
1
;
if
(
(
curr_idx
!=
0
)
&&
(
k
eypoin
ts
[
t
].
pt
.
y
==
currCorner
->
pt
.
y
)
&&
(
k
eypoin
ts
[
t
].
pt
.
x
+
1
==
currCorner
->
pt
.
x
)
)
if
(
(
curr_idx
!=
0
)
&&
(
k
p
ts
[
t
].
pt
.
y
==
currCorner
->
pt
.
y
)
&&
(
k
p
ts
[
t
].
pt
.
x
+
1
==
currCorner
->
pt
.
x
)
)
{
int
currCornerMaxAbove_ind
=
nmsFlags
[
curr_idx
];
// find the maximum in that area
...
...
@@ -7626,7 +7630,7 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
{
if
((
size_t
)
t
!=
curr_idx
)
{
if
(
k
eypoints
[
curr_idx
].
response
<
keypoin
ts
[
t
].
response
)
if
(
k
pts
[
curr_idx
].
response
<
kp
ts
[
t
].
response
)
nmsFlags
[
curr_idx
]
=
t
;
else
nmsFlags
[
t
]
=
(
int
)
curr_idx
;
...
...
@@ -7636,7 +7640,7 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
{
if
(
t
!=
currCornerMaxAbove_ind
)
{
if
(
k
eypoints
[
currCornerMaxAbove_ind
].
response
<
keypoin
ts
[
t
].
response
)
if
(
k
pts
[
currCornerMaxAbove_ind
].
response
<
kp
ts
[
t
].
response
)
{
nmsFlags
[
currCornerMaxAbove_ind
]
=
t
;
nmsFlags
[
curr_idx
]
=
t
;
...
...
@@ -7652,19 +7656,15 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
currCorner
++
;
}
//
marks non-
maximum corners
//
collecting
maximum corners
for
(
curr_idx
=
0
;
curr_idx
<
num_Corners
;
curr_idx
++
)
{
if
(
nmsFlags
[
curr_idx
]
!=
-
1
)
keypoints
[
curr_idx
].
response
=
-
1
;
}
// erase non-maximum corners
for
(
j
=
keypoints
.
size
();
j
>
0
;
j
--
)
{
if
(
keypoints
[
j
-
1
].
response
==
-
1
)
keypoints
.
erase
(
keypoints
.
begin
()
+
j
-
1
);
if
(
nmsFlags
[
curr_idx
]
==
-
1
)
keypoints
.
push_back
(
kpts
[
curr_idx
]);
}
}
else
{
keypoints
=
kpts
;
}
}
...
...
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