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
06c138bd
Commit
06c138bd
authored
Mar 07, 2014
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make the correctness test pass
parent
8e1918e8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
fast.cpp
modules/features2d/src/fast.cpp
+27
-12
fast.cl
modules/features2d/src/opencl/fast.cl
+0
-0
No files found.
modules/features2d/src/fast.cpp
View file @
06c138bd
...
...
@@ -250,6 +250,11 @@ void FAST_t(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bo
}
}
template
<
typename
pt
>
struct
cmp_pt
{
bool
operator
()(
const
pt
&
a
,
const
pt
&
b
)
const
{
return
a
.
y
<
b
.
y
||
(
a
.
y
==
b
.
y
&&
a
.
x
<
b
.
x
);
}
};
static
bool
ocl_FAST
(
InputArray
_img
,
std
::
vector
<
KeyPoint
>&
keypoints
,
int
threshold
,
bool
nonmax_suppression
,
int
maxKeypoints
)
...
...
@@ -265,8 +270,8 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
UMat
kp1
(
1
,
maxKeypoints
*
2
+
1
,
CV_32S
),
score
;
UMat
u
temp
(
kp1
,
Rect
(
0
,
0
,
1
,
1
));
u
temp
.
setTo
(
Scalar
::
all
(
0
));
UMat
u
counter1
(
kp1
,
Rect
(
0
,
0
,
1
,
1
));
u
counter1
.
setTo
(
Scalar
::
all
(
0
));
if
(
nonmax_suppression
)
{
...
...
@@ -284,10 +289,15 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
return
false
;
Mat
mcounter
;
u
temp
.
copyTo
(
mcounter
);
u
counter1
.
copyTo
(
mcounter
);
int
i
,
counter
=
mcounter
.
at
<
int
>
(
0
);
counter
=
std
::
min
(
counter
,
maxKeypoints
);
keypoints
.
clear
();
if
(
counter
==
0
)
return
true
;
if
(
!
nonmax_suppression
)
{
Mat
m
;
...
...
@@ -299,24 +309,29 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
else
{
UMat
kp2
(
1
,
maxKeypoints
*
3
+
1
,
CV_32S
);
utemp
=
kp2
(
Rect
(
0
,
0
,
1
,
1
));
u
temp
.
setTo
(
Scalar
::
all
(
0
));
UMat
ucounter2
=
kp2
(
Rect
(
0
,
0
,
1
,
1
));
u
counter2
.
setTo
(
Scalar
::
all
(
0
));
ocl
::
Kernel
fastNMSKernel
(
"FAST_nonmaxSupression"
,
ocl
::
features2d
::
fast_oclsrc
);
if
(
fastNMSKernel
.
empty
())
return
false
;
size_t
globalsize_nms
[]
=
{
counter
};
if
(
!
fastNMSKernel
.
args
(
ocl
::
KernelArg
::
PtrReadOnly
(
kp1
),
ocl
::
KernelArg
::
PtrReadWrite
(
kp2
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
score
),
counter
,
maxKeypoints
).
run
(
2
,
globalsize
,
0
,
true
))
counter
,
counter
).
run
(
1
,
globalsize_nms
,
0
,
true
))
return
false
;
Mat
m
;
kp2
(
Rect
(
0
,
0
,
counter
*
3
+
1
,
1
)).
copyTo
(
m
);
const
Point3i
*
pt
=
(
const
Point3i
*
)(
m
.
ptr
<
int
>
()
+
1
);
for
(
i
=
0
;
i
<
counter
;
i
++
)
keypoints
.
push_back
(
KeyPoint
((
float
)
pt
[
i
].
x
,
(
float
)
pt
[
i
].
y
,
7.
f
,
-
1
,
(
float
)
pt
[
i
].
z
));
Mat
m2
;
kp2
(
Rect
(
0
,
0
,
counter
*
3
+
1
,
1
)).
copyTo
(
m2
);
Point3i
*
pt2
=
(
Point3i
*
)(
m2
.
ptr
<
int
>
()
+
1
);
int
newcounter
=
std
::
min
(
m2
.
at
<
int
>
(
0
),
counter
);
std
::
sort
(
pt2
,
pt2
+
newcounter
,
cmp_pt
<
Point3i
>
());
for
(
i
=
0
;
i
<
newcounter
;
i
++
)
keypoints
.
push_back
(
KeyPoint
((
float
)
pt2
[
i
].
x
,
(
float
)
pt2
[
i
].
y
,
7.
f
,
-
1
,
(
float
)
pt2
[
i
].
z
));
}
return
true
;
...
...
@@ -325,7 +340,7 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
void
FAST
(
InputArray
_img
,
std
::
vector
<
KeyPoint
>&
keypoints
,
int
threshold
,
bool
nonmax_suppression
,
int
type
)
{
if
(
ocl
::
useOpenCL
()
&&
/*_img.isUMat() &&*/
type
==
FastFeatureDetector
::
TYPE_9_16
&&
if
(
ocl
::
useOpenCL
()
&&
_img
.
isUMat
()
&&
type
==
FastFeatureDetector
::
TYPE_9_16
&&
ocl_FAST
(
_img
,
keypoints
,
threshold
,
nonmax_suppression
,
10000
))
return
;
...
...
modules/features2d/src/opencl/fast.cl
View file @
06c138bd
This diff is collapsed.
Click to expand it.
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