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
0154b18a
Commit
0154b18a
authored
Jun 30, 2010
by
Ilya Lysenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speeded up BruteForceMatcher using matrix multiplication
parent
2f4d3965
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
features2d.hpp
modules/features2d/include/opencv2/features2d/features2d.hpp
+3
-0
descriptors.cpp
modules/features2d/src/descriptors.cpp
+45
-0
No files found.
modules/features2d/include/opencv2/features2d/features2d.hpp
View file @
0154b18a
...
...
@@ -1872,6 +1872,9 @@ void BruteForceMatcher<Distance>::matchImpl( const Mat& descriptors_1, const Mat
}
}
template
<>
void
BruteForceMatcher
<
L2
<
float
>
>::
matchImpl
(
const
Mat
&
descriptors_1
,
const
Mat
&
descriptors_2
,
const
Mat
&
mask
,
vector
<
int
>&
matches
)
const
;
CV_EXPORTS
DescriptorMatcher
*
createDescriptorMatcher
(
const
string
&
descriptorMatcherType
);
...
...
modules/features2d/src/descriptors.cpp
View file @
0154b18a
...
...
@@ -41,6 +41,10 @@
#include "precomp.hpp"
#ifdef HAVE_EIGEN2
#include <Eigen/Array>
#endif
//#define _KDTREE
using
namespace
std
;
...
...
@@ -267,6 +271,47 @@ DescriptorMatcher* createDescriptorMatcher( const string& descriptorMatcherType
}
template
<>
void
BruteForceMatcher
<
L2
<
float
>
>::
matchImpl
(
const
Mat
&
descriptors_1
,
const
Mat
&
descriptors_2
,
const
Mat
&
mask
,
vector
<
int
>&
matches
)
const
{
matches
.
clear
();
matches
.
reserve
(
descriptors_1
.
rows
);
#if (defined _DEBUG || !defined HAVE_EIGEN2)
Mat
norms
;
cv
::
reduce
(
descriptors_2
.
mul
(
descriptors_2
),
norms
,
1
,
0
);
norms
=
norms
.
t
();
Mat
desc_2t
=
descriptors_2
.
t
();
for
(
int
i
=
0
;
i
<
descriptors_1
.
rows
;
i
++
)
{
Mat
distances
=
(
-
2
)
*
descriptors_1
.
row
(
i
)
*
desc_2t
;
distances
+=
norms
;
Point
minLoc
;
minMaxLoc
(
distances
,
0
,
0
,
&
minLoc
);
matches
.
push_back
(
minLoc
.
x
);
}
#else
Eigen
::
Matrix
<
float
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
desc1
;
Eigen
::
Matrix
<
float
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
desc2
;
cv2eigen
(
descriptors_1
,
desc1
);
cv2eigen
(
descriptors_2
,
desc2
);
Eigen
::
Matrix
<
float
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
norms
=
desc2
.
rowwise
().
squaredNorm
().
transpose
();
for
(
int
i
=
0
;
i
<
descriptors_1
.
rows
;
i
++
)
{
//TODO: it doesn't work in Debug due to assert in lazyAssign
Eigen
::
Matrix
<
float
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
distances
=
(
-
2
)
*
desc1
.
row
(
i
)
*
desc2
.
transpose
();
distances
+=
norms
;
int
idx
;
distances
.
minCoeff
(
&
idx
);
matches
.
push_back
(
idx
);
}
#endif
}
/****************************************************************************************\
* GenericDescriptorMatch *
\****************************************************************************************/
...
...
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