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
966d5076
Commit
966d5076
authored
May 07, 2015
by
laurentBerger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to include comment from @eduardo and @berak
Akaze descriptor with DESCRIPTOR_KAZE_UPRIGHT added
parent
cfcef3ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
36 deletions
+53
-36
matchmethod_orb_akaze_brisk.cpp
samples/cpp/matchmethod_orb_akaze_brisk.cpp
+53
-36
No files found.
samples/cpp/matchmethod_orb_akaze_brisk.cpp
View file @
966d5076
...
@@ -21,8 +21,8 @@ int main(int argc, char *argv[])
...
@@ -21,8 +21,8 @@ int main(int argc, char *argv[])
vector
<
String
>
typeAlgoMatch
;
vector
<
String
>
typeAlgoMatch
;
vector
<
String
>
fileName
;
vector
<
String
>
fileName
;
help
();
help
();
system
(
"cd"
);
// This descriptor are going to be detect and compute
// This descriptor are going to be detect and compute
typeDesc
.
push_back
(
"AKAZE-DESCRIPTOR_KAZE_UPRIGHT"
);
// see http://docs.opencv.org/trunk/d8/d30/classcv_1_1AKAZE.html
typeDesc
.
push_back
(
"AKAZE"
);
// see http://docs.opencv.org/trunk/d8/d30/classcv_1_1AKAZE.html
typeDesc
.
push_back
(
"AKAZE"
);
// see http://docs.opencv.org/trunk/d8/d30/classcv_1_1AKAZE.html
typeDesc
.
push_back
(
"ORB"
);
// see http://docs.opencv.org/trunk/de/dbf/classcv_1_1BRISK.html
typeDesc
.
push_back
(
"ORB"
);
// see http://docs.opencv.org/trunk/de/dbf/classcv_1_1BRISK.html
typeDesc
.
push_back
(
"BRISK"
);
// see http://docs.opencv.org/trunk/db/d95/classcv_1_1ORB.html
typeDesc
.
push_back
(
"BRISK"
);
// see http://docs.opencv.org/trunk/db/d95/classcv_1_1ORB.html
...
@@ -74,9 +74,12 @@ int main(int argc, char *argv[])
...
@@ -74,9 +74,12 @@ int main(int argc, char *argv[])
// Descriptor for img1 and img2
// Descriptor for img1 and img2
Mat
descImg1
,
descImg2
;
Mat
descImg1
,
descImg2
;
vector
<
String
>::
iterator
itMatcher
=
typeAlgoMatch
.
end
();
vector
<
String
>::
iterator
itMatcher
=
typeAlgoMatch
.
end
();
if
(
*
itDesc
==
"AKAZE-DESCRIPTOR_KAZE_UPRIGHT"
){
b
=
AKAZE
::
create
(
AKAZE
::
DESCRIPTOR_KAZE_UPRIGHT
);
}
if
(
*
itDesc
==
"AKAZE"
){
if
(
*
itDesc
==
"AKAZE"
){
b
=
AKAZE
::
create
();
b
=
AKAZE
::
create
();
}
}
if
(
*
itDesc
==
"ORB"
){
if
(
*
itDesc
==
"ORB"
){
b
=
ORB
::
create
();
b
=
ORB
::
create
();
}
}
...
@@ -93,44 +96,57 @@ int main(int argc, char *argv[])
...
@@ -93,44 +96,57 @@ int main(int argc, char *argv[])
// Match method loop
// Match method loop
for
(
itMatcher
=
typeAlgoMatch
.
begin
();
itMatcher
!=
typeAlgoMatch
.
end
();
itMatcher
++
){
for
(
itMatcher
=
typeAlgoMatch
.
begin
();
itMatcher
!=
typeAlgoMatch
.
end
();
itMatcher
++
){
descriptorMatcher
=
DescriptorMatcher
::
create
(
*
itMatcher
);
descriptorMatcher
=
DescriptorMatcher
::
create
(
*
itMatcher
);
descriptorMatcher
->
match
(
descImg1
,
descImg2
,
matches
,
Mat
());
if
((
*
itMatcher
==
"BruteForce-Hamming"
||
*
itMatcher
==
"BruteForce-Hamming(2)"
)
&&
(
b
->
descriptorType
()
==
CV_32F
||
b
->
defaultNorm
()
<=
NORM_L2SQR
)
)
// Keep best matches only to have a nice drawing.
// We sort distance between descriptor matches
Mat
index
;
int
nbMatch
=
int
(
matches
.
size
());
Mat
tab
(
nbMatch
,
1
,
CV_32F
);
for
(
int
i
=
0
;
i
<
nbMatch
;
i
++
)
{
{
tab
.
at
<
float
>
(
i
,
0
)
=
matches
[
i
].
distance
;
cout
<<
"**************************************************************************
\n
"
;
cout
<<
"It's strange. You should use Hamming distance only for a binary descriptor
\n
"
;
cout
<<
"**************************************************************************
\n
"
;
}
}
sortIdx
(
tab
,
index
,
SORT_EVERY_COLUMN
+
SORT_ASCENDING
);
try
vector
<
DMatch
>
bestMatches
;
for
(
int
i
=
0
;
i
<
30
;
i
++
)
{
{
bestMatches
.
push_back
(
matches
[
index
.
at
<
int
>
(
i
,
0
)]);
descriptorMatcher
->
match
(
descImg1
,
descImg2
,
matches
,
Mat
());
// Keep best matches only to have a nice drawing.
// We sort distance between descriptor matches
Mat
index
;
int
nbMatch
=
int
(
matches
.
size
());
Mat
tab
(
nbMatch
,
1
,
CV_32F
);
for
(
int
i
=
0
;
i
<
nbMatch
;
i
++
)
{
tab
.
at
<
float
>
(
i
,
0
)
=
matches
[
i
].
distance
;
}
sortIdx
(
tab
,
index
,
SORT_EVERY_COLUMN
+
SORT_ASCENDING
);
vector
<
DMatch
>
bestMatches
;
for
(
int
i
=
0
;
i
<
30
;
i
++
)
{
bestMatches
.
push_back
(
matches
[
index
.
at
<
int
>
(
i
,
0
)]);
}
Mat
result
;
drawMatches
(
img1
,
keyImg1
,
img2
,
keyImg2
,
bestMatches
,
result
);
namedWindow
(
*
itDesc
+
": "
+*
itMatcher
,
WINDOW_AUTOSIZE
);
imshow
(
*
itDesc
+
": "
+
*
itMatcher
,
result
);
// Saved result could be wrong due to bug 4308
FileStorage
fs
(
*
itDesc
+
"_"
+
*
itMatcher
+
".yml"
,
FileStorage
::
WRITE
);
fs
<<
"Matches"
<<
matches
;
vector
<
DMatch
>::
iterator
it
;
cout
<<
"**********Match results**********
\n
"
;
cout
<<
"Index
\t
Index
\t
distance
\n
"
;
cout
<<
"in img1
\t
in img2
\n
"
;
// Use to compute distance between keyPoint matches and to evaluate match algorithm
double
cumSumDist2
=
0
;
for
(
it
=
bestMatches
.
begin
();
it
!=
bestMatches
.
end
();
it
++
)
{
cout
<<
it
->
queryIdx
<<
"
\t
"
<<
it
->
trainIdx
<<
"
\t
"
<<
it
->
distance
<<
"
\n
"
;
Point2d
p
=
keyImg1
[
it
->
queryIdx
].
pt
-
keyImg2
[
it
->
trainIdx
].
pt
;
cumSumDist2
=
p
.
x
*
p
.
x
+
p
.
y
*
p
.
y
;
}
desMethCmp
.
push_back
(
cumSumDist2
);
waitKey
();
}
}
Mat
result
;
catch
(
Exception
&
e
)
drawMatches
(
img1
,
keyImg1
,
img2
,
keyImg2
,
bestMatches
,
result
);
{
namedWindow
(
*
itDesc
+
": "
+*
itMatcher
,
WINDOW_AUTOSIZE
);
desMethCmp
.
push_back
(
-
1
);
imshow
(
*
itDesc
+
": "
+
*
itMatcher
,
result
);
}
// Saved result could be wrong due to bug 4308
FileStorage
fs
(
*
itDesc
+
"_"
+
*
itMatcher
+
".yml"
,
FileStorage
::
WRITE
);
fs
<<
"Matches"
<<
matches
;
vector
<
DMatch
>::
iterator
it
;
cout
<<
"**********Match results**********
\n
"
;
cout
<<
"Index
\t
Index
\t
distance
\n
"
;
cout
<<
"in img1
\t
in img2
\n
"
;
// Use to compute distance between keyPoint matches and to evaluate match algorithm
double
cumSumDist2
=
0
;
for
(
it
=
bestMatches
.
begin
();
it
!=
bestMatches
.
end
();
it
++
)
{
cout
<<
it
->
queryIdx
<<
"
\t
"
<<
it
->
trainIdx
<<
"
\t
"
<<
it
->
distance
<<
"
\n
"
;
Point2d
p
=
keyImg1
[
it
->
queryIdx
].
pt
-
keyImg2
[
it
->
trainIdx
].
pt
;
cumSumDist2
=
p
.
x
*
p
.
x
+
p
.
y
*
p
.
y
;
}
}
desMethCmp
.
push_back
(
cumSumDist2
);
waitKey
();
}
}
}
catch
(
Exception
&
e
)
catch
(
Exception
&
e
)
{
{
...
@@ -139,11 +155,12 @@ int main(int argc, char *argv[])
...
@@ -139,11 +155,12 @@ int main(int argc, char *argv[])
{
{
cout
<<
"Matcher : "
<<
*
itMatcher
<<
"
\n
"
;
cout
<<
"Matcher : "
<<
*
itMatcher
<<
"
\n
"
;
}
}
cout
<<
e
.
msg
<<
endl
;
cout
<<
e
.
msg
<<
endl
;
}
}
}
}
int
i
=
0
;
int
i
=
0
;
cout
<<
"Cumulative distance between keypoint match for different algorithm and feature detector
\n\t
"
;
cout
<<
"Cumulative distance between keypoint match for different algorithm and feature detector
\n\t
"
;
cout
<<
"We cannot say which is the best but we can say results are differents!
\n\t
"
;
for
(
vector
<
String
>::
iterator
itMatcher
=
typeAlgoMatch
.
begin
();
itMatcher
!=
typeAlgoMatch
.
end
();
itMatcher
++
)
for
(
vector
<
String
>::
iterator
itMatcher
=
typeAlgoMatch
.
begin
();
itMatcher
!=
typeAlgoMatch
.
end
();
itMatcher
++
)
{
{
cout
<<*
itMatcher
<<
"
\t
"
;
cout
<<*
itMatcher
<<
"
\t
"
;
...
...
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