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
44eaeee8
Commit
44eaeee8
authored
Apr 24, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored gpu BruteForceMather (made it similar to BFMatcher)
parent
c2935a65
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
55 deletions
+27
-55
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+3
-29
perf_features2d.cpp
modules/gpu/perf/perf_features2d.cpp
+3
-3
brute_force_matcher.cpp
modules/gpu/src/brute_force_matcher.cpp
+0
-0
test_features2d.cpp
modules/gpu/test/test_features2d.cpp
+17
-19
matchers.cpp
modules/stitching/src/matchers.cpp
+1
-1
tests.cpp
samples/gpu/performance/tests.cpp
+1
-1
surf_keypoint_matcher.cpp
samples/gpu/surf_keypoint_matcher.cpp
+2
-2
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
44eaeee8
...
...
@@ -1220,12 +1220,10 @@ protected:
////////////////////////////////// BruteForceMatcher //////////////////////////////////
class
CV_EXPORTS
B
ruteForceMatcher_GPU_base
class
CV_EXPORTS
B
FMatcher_GPU
{
public
:
enum
DistType
{
L1Dist
=
0
,
L2Dist
,
HammingDist
};
explicit
BruteForceMatcher_GPU_base
(
DistType
distType
=
L2Dist
);
explicit
BFMatcher_GPU
(
int
norm
=
cv
::
NORM_L2
);
// Add descriptors to train descriptor collection
void
add
(
const
std
::
vector
<
GpuMat
>&
descCollection
);
...
...
@@ -1367,36 +1365,12 @@ public:
void
radiusMatch
(
const
GpuMat
&
query
,
std
::
vector
<
std
::
vector
<
DMatch
>
>&
matches
,
float
maxDistance
,
const
std
::
vector
<
GpuMat
>&
masks
=
std
::
vector
<
GpuMat
>
(),
bool
compactResult
=
false
);
DistType
distType
;
int
norm
;
private
:
std
::
vector
<
GpuMat
>
trainDescCollection
;
};
template
<
class
Distance
>
class
CV_EXPORTS
BruteForceMatcher_GPU
;
template
<
typename
T
>
class
CV_EXPORTS
BruteForceMatcher_GPU
<
L1
<
T
>
>
:
public
BruteForceMatcher_GPU_base
{
public
:
explicit
BruteForceMatcher_GPU
()
:
BruteForceMatcher_GPU_base
(
L1Dist
)
{}
explicit
BruteForceMatcher_GPU
(
L1
<
T
>
/*d*/
)
:
BruteForceMatcher_GPU_base
(
L1Dist
)
{}
};
template
<
typename
T
>
class
CV_EXPORTS
BruteForceMatcher_GPU
<
L2
<
T
>
>
:
public
BruteForceMatcher_GPU_base
{
public
:
explicit
BruteForceMatcher_GPU
()
:
BruteForceMatcher_GPU_base
(
L2Dist
)
{}
explicit
BruteForceMatcher_GPU
(
L2
<
T
>
/*d*/
)
:
BruteForceMatcher_GPU_base
(
L2Dist
)
{}
};
template
<>
class
CV_EXPORTS
BruteForceMatcher_GPU
<
Hamming
>
:
public
BruteForceMatcher_GPU_base
{
public
:
explicit
BruteForceMatcher_GPU
()
:
BruteForceMatcher_GPU_base
(
HammingDist
)
{}
explicit
BruteForceMatcher_GPU
(
Hamming
/*d*/
)
:
BruteForceMatcher_GPU_base
(
HammingDist
)
{}
};
////////////////////////////////// CascadeClassifier_GPU //////////////////////////////////////////
// The cascade classifier class for object detection.
class
CV_EXPORTS
CascadeClassifier_GPU
...
...
modules/gpu/perf/perf_features2d.cpp
View file @
44eaeee8
...
...
@@ -21,7 +21,7 @@ GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, int)
cv
::
gpu
::
GpuMat
train
(
train_host
);
cv
::
gpu
::
GpuMat
trainIdx
,
distance
;
cv
::
gpu
::
B
ruteForceMatcher_GPU
<
cv
::
L2
<
float
>
>
matcher
;
cv
::
gpu
::
B
FMatcher_GPU
matcher
(
cv
::
NORM_L2
)
;
declare
.
time
(
3.0
);
...
...
@@ -55,7 +55,7 @@ GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, int, int)
cv
::
gpu
::
GpuMat
train
(
train_host
);
cv
::
gpu
::
GpuMat
trainIdx
,
distance
,
allDist
;
cv
::
gpu
::
B
ruteForceMatcher_GPU
<
cv
::
L2
<
float
>
>
matcher
;
cv
::
gpu
::
B
FMatcher_GPU
matcher
(
cv
::
NORM_L2
)
;
declare
.
time
(
3.0
);
...
...
@@ -90,7 +90,7 @@ GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, int)
cv
::
gpu
::
GpuMat
train
(
train_host
);
cv
::
gpu
::
GpuMat
trainIdx
,
nMatches
,
distance
;
cv
::
gpu
::
B
ruteForceMatcher_GPU
<
cv
::
L2
<
float
>
>
matcher
;
cv
::
gpu
::
B
FMatcher_GPU
matcher
(
cv
::
NORM_L2
)
;
declare
.
time
(
3.0
);
...
...
modules/gpu/src/brute_force_matcher.cpp
View file @
44eaeee8
This diff is collapsed.
Click to expand it.
modules/gpu/test/test_features2d.cpp
View file @
44eaeee8
...
...
@@ -503,13 +503,12 @@ INSTANTIATE_TEST_CASE_P(GPU_Features2D, ORB, testing::Combine(
/////////////////////////////////////////////////////////////////////////////////////////////////
// BruteForceMatcher
CV_ENUM
(
DistType
,
cv
::
gpu
::
BruteForceMatcher_GPU_base
::
L1Dist
,
cv
::
gpu
::
BruteForceMatcher_GPU_base
::
L2Dist
,
cv
::
gpu
::
BruteForceMatcher_GPU_base
::
HammingDist
)
IMPLEMENT_PARAM_CLASS
(
DescriptorSize
,
int
)
PARAM_TEST_CASE
(
BruteForceMatcher
,
cv
::
gpu
::
DeviceInfo
,
DistTyp
e
,
DescriptorSize
)
PARAM_TEST_CASE
(
BruteForceMatcher
,
cv
::
gpu
::
DeviceInfo
,
NormCod
e
,
DescriptorSize
)
{
cv
::
gpu
::
DeviceInfo
devInfo
;
cv
::
gpu
::
BruteForceMatcher_GPU_base
::
DistType
distTyp
e
;
int
normCod
e
;
int
dim
;
int
queryDescCount
;
...
...
@@ -520,7 +519,7 @@ PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, DistType, DescriptorSize
virtual
void
SetUp
()
{
devInfo
=
GET_PARAM
(
0
);
distType
=
(
cv
::
gpu
::
BruteForceMatcher_GPU_base
::
DistType
)(
int
)
GET_PARAM
(
1
);
normCode
=
GET_PARAM
(
1
);
dim
=
GET_PARAM
(
2
);
cv
::
gpu
::
setDevice
(
devInfo
.
deviceID
());
...
...
@@ -566,7 +565,7 @@ PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, DistType, DescriptorSize
TEST_P
(
BruteForceMatcher
,
Match
)
{
cv
::
gpu
::
B
ruteForceMatcher_GPU_base
matcher
(
distTyp
e
);
cv
::
gpu
::
B
FMatcher_GPU
matcher
(
normCod
e
);
std
::
vector
<
cv
::
DMatch
>
matches
;
matcher
.
match
(
loadMat
(
query
),
loadMat
(
train
),
matches
);
...
...
@@ -584,10 +583,9 @@ TEST_P(BruteForceMatcher, Match)
ASSERT_EQ
(
0
,
badCount
);
}
TEST_P
(
BruteForceMatcher
,
MatchAdd
)
{
cv
::
gpu
::
B
ruteForceMatcher_GPU_base
matcher
(
distTyp
e
);
cv
::
gpu
::
B
FMatcher_GPU
matcher
(
normCod
e
);
cv
::
gpu
::
GpuMat
d_train
(
train
);
...
...
@@ -638,9 +636,9 @@ TEST_P(BruteForceMatcher, MatchAdd)
TEST_P
(
BruteForceMatcher
,
KnnMatch2
)
{
c
onst
int
knn
=
2
;
c
v
::
gpu
::
BFMatcher_GPU
matcher
(
normCode
)
;
c
v
::
gpu
::
BruteForceMatcher_GPU_base
matcher
(
distType
)
;
c
onst
int
knn
=
2
;
std
::
vector
<
std
::
vector
<
cv
::
DMatch
>
>
matches
;
matcher
.
knnMatch
(
loadMat
(
query
),
loadMat
(
train
),
matches
,
knn
);
...
...
@@ -670,7 +668,7 @@ TEST_P(BruteForceMatcher, KnnMatch2)
TEST_P
(
BruteForceMatcher
,
KnnMatch3
)
{
cv
::
gpu
::
B
ruteForceMatcher_GPU_base
matcher
(
distTyp
e
);
cv
::
gpu
::
B
FMatcher_GPU
matcher
(
normCod
e
);
const
int
knn
=
3
;
...
...
@@ -702,9 +700,9 @@ TEST_P(BruteForceMatcher, KnnMatch3)
TEST_P
(
BruteForceMatcher
,
KnnMatchAdd2
)
{
c
onst
int
knn
=
2
;
c
v
::
gpu
::
BFMatcher_GPU
matcher
(
normCode
)
;
c
v
::
gpu
::
BruteForceMatcher_GPU_base
matcher
(
distType
)
;
c
onst
int
knn
=
2
;
cv
::
gpu
::
GpuMat
d_train
(
train
);
...
...
@@ -761,9 +759,9 @@ TEST_P(BruteForceMatcher, KnnMatchAdd2)
TEST_P
(
BruteForceMatcher
,
KnnMatchAdd3
)
{
c
onst
int
knn
=
3
;
c
v
::
gpu
::
BFMatcher_GPU
matcher
(
normCode
)
;
c
v
::
gpu
::
BruteForceMatcher_GPU_base
matcher
(
distType
)
;
c
onst
int
knn
=
3
;
cv
::
gpu
::
GpuMat
d_train
(
train
);
...
...
@@ -819,9 +817,9 @@ TEST_P(BruteForceMatcher, KnnMatchAdd3)
TEST_P
(
BruteForceMatcher
,
RadiusMatch
)
{
c
onst
float
radius
=
1.
f
/
countFactor
;
c
v
::
gpu
::
BFMatcher_GPU
matcher
(
normCode
)
;
c
v
::
gpu
::
BruteForceMatcher_GPU_base
matcher
(
distType
)
;
c
onst
float
radius
=
1.
f
/
countFactor
;
if
(
!
supportFeature
(
devInfo
,
cv
::
gpu
::
GLOBAL_ATOMICS
))
{
...
...
@@ -861,11 +859,11 @@ TEST_P(BruteForceMatcher, RadiusMatch)
TEST_P
(
BruteForceMatcher
,
RadiusMatchAdd
)
{
cv
::
gpu
::
BFMatcher_GPU
matcher
(
normCode
);
const
int
n
=
3
;
const
float
radius
=
1.
f
/
countFactor
*
n
;
cv
::
gpu
::
BruteForceMatcher_GPU_base
matcher
(
distType
);
cv
::
gpu
::
GpuMat
d_train
(
train
);
// make add() twice to test such case
...
...
@@ -936,7 +934,7 @@ TEST_P(BruteForceMatcher, RadiusMatchAdd)
INSTANTIATE_TEST_CASE_P
(
GPU_Features2D
,
BruteForceMatcher
,
testing
::
Combine
(
ALL_DEVICES
,
testing
::
Values
(
DistType
(
cv
::
gpu
::
BruteForceMatcher_GPU_base
::
L1Dist
),
DistType
(
cv
::
gpu
::
BruteForceMatcher_GPU_base
::
L2Dist
)),
testing
::
Values
(
NormCode
(
cv
::
NORM_L1
),
NormCode
(
cv
::
NORM_L2
)),
testing
::
Values
(
DescriptorSize
(
57
),
DescriptorSize
(
64
),
DescriptorSize
(
83
),
DescriptorSize
(
128
),
DescriptorSize
(
179
),
DescriptorSize
(
256
),
DescriptorSize
(
304
))));
}
// namespace
modules/stitching/src/matchers.cpp
View file @
44eaeee8
...
...
@@ -219,7 +219,7 @@ void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat
descriptors1_
.
upload
(
features1
.
descriptors
);
descriptors2_
.
upload
(
features2
.
descriptors
);
B
ruteForceMatcher_GPU
<
L2
<
float
>
>
matcher
;
B
FMatcher_GPU
matcher
(
NORM_L2
)
;
MatchesSet
matches
;
// Find 1->2 matches
...
...
samples/gpu/performance/tests.cpp
View file @
44eaeee8
...
...
@@ -363,7 +363,7 @@ TEST(BruteForceMatcher)
// Init GPU matcher
gpu
::
B
ruteForceMatcher_GPU
<
L2
<
float
>
>
d_matcher
;
gpu
::
B
FMatcher_GPU
d_matcher
(
NORM_L2
)
;
gpu
::
GpuMat
d_query
(
query
);
gpu
::
GpuMat
d_train
(
train
);
...
...
samples/gpu/surf_keypoint_matcher.cpp
View file @
44eaeee8
...
...
@@ -57,7 +57,7 @@ int main(int argc, char* argv[])
cout
<<
"FOUND "
<<
keypoints2GPU
.
cols
<<
" keypoints on second image"
<<
endl
;
// matching descriptors
B
ruteForceMatcher_GPU
<
L2
<
float
>
>
matcher
;
B
FMatcher_GPU
matcher
(
NORM_L2
)
;
GpuMat
trainIdx
,
distance
;
matcher
.
matchSingle
(
descriptors1GPU
,
descriptors2GPU
,
trainIdx
,
distance
);
...
...
@@ -69,7 +69,7 @@ int main(int argc, char* argv[])
surf
.
downloadKeypoints
(
keypoints2GPU
,
keypoints2
);
surf
.
downloadDescriptors
(
descriptors1GPU
,
descriptors1
);
surf
.
downloadDescriptors
(
descriptors2GPU
,
descriptors2
);
B
ruteForceMatcher_GPU
<
L2
<
float
>
>
::
matchDownload
(
trainIdx
,
distance
,
matches
);
B
FMatcher_GPU
::
matchDownload
(
trainIdx
,
distance
,
matches
);
// drawing the results
Mat
img_matches
;
...
...
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