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
d8ad4e22
Commit
d8ad4e22
authored
Aug 05, 2010
by
Maria Dimashova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added detector and descriptor evaluation to sample descriptor_extractor_matcher
parent
4395bad9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
descriptor_extractor_matcher.cpp
samples/cpp/descriptor_extractor_matcher.cpp
+28
-6
No files found.
samples/cpp/descriptor_extractor_matcher.cpp
View file @
d8ad4e22
...
@@ -30,7 +30,7 @@ void warpPerspectiveRand( const Mat& src, Mat& dst, Mat& H, RNG& rng )
...
@@ -30,7 +30,7 @@ void warpPerspectiveRand( const Mat& src, Mat& dst, Mat& H, RNG& rng )
const
string
winName
=
"correspondences"
;
const
string
winName
=
"correspondences"
;
void
doIteration
(
const
Mat
&
img1
,
Mat
&
img2
,
bool
isWarpPerspective
,
void
doIteration
(
const
Mat
&
img1
,
Mat
&
img2
,
bool
isWarpPerspective
,
const
vector
<
KeyPoint
>&
keypoints1
,
const
Mat
&
descriptors1
,
vector
<
KeyPoint
>&
keypoints1
,
const
Mat
&
descriptors1
,
Ptr
<
FeatureDetector
>&
detector
,
Ptr
<
DescriptorExtractor
>&
descriptorExtractor
,
Ptr
<
FeatureDetector
>&
detector
,
Ptr
<
DescriptorExtractor
>&
descriptorExtractor
,
Ptr
<
DescriptorMatcher
>&
descriptorMatcher
,
Ptr
<
DescriptorMatcher
>&
descriptorMatcher
,
double
ransacReprojThreshold
,
RNG
&
rng
)
double
ransacReprojThreshold
,
RNG
&
rng
)
...
@@ -45,12 +45,23 @@ void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective,
...
@@ -45,12 +45,23 @@ void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective,
cout
<<
endl
<<
"< Extracting keypoints from second image..."
<<
endl
;
cout
<<
endl
<<
"< Extracting keypoints from second image..."
<<
endl
;
vector
<
KeyPoint
>
keypoints2
;
vector
<
KeyPoint
>
keypoints2
;
detector
->
detect
(
img2
,
keypoints2
);
detector
->
detect
(
img2
,
keypoints2
);
cout
<<
keypoints2
.
size
()
<<
" >"
<<
endl
;
cout
<<
keypoints2
.
size
()
<<
" points"
<<
endl
<<
">"
<<
endl
;
if
(
!
H12
.
empty
()
)
{
cout
<<
"< Evaluate feature detector..."
<<
endl
;
float
repeatability
;
int
correspCount
;
evaluateFeatureDetector
(
img1
,
img2
,
H12
,
&
keypoints1
,
&
keypoints2
,
repeatability
,
correspCount
);
cout
<<
"repeatability = "
<<
repeatability
<<
endl
;
cout
<<
"correspCount = "
<<
correspCount
<<
endl
;
cout
<<
">"
<<
endl
;
}
cout
<<
"< Computing descriptors for keypoints from second image..."
<<
endl
;
cout
<<
"< Computing descriptors for keypoints from second image..."
<<
endl
;
Mat
descriptors2
;
Mat
descriptors2
;
descriptorExtractor
->
compute
(
img2
,
keypoints2
,
descriptors2
);
descriptorExtractor
->
compute
(
img2
,
keypoints2
,
descriptors2
);
cout
<<
"
>"
<<
endl
;
cout
<<
">"
<<
endl
;
cout
<<
"< Matching descriptors..."
<<
endl
;
cout
<<
"< Matching descriptors..."
<<
endl
;
vector
<
int
>
matches
;
vector
<
int
>
matches
;
...
@@ -59,6 +70,17 @@ void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective,
...
@@ -59,6 +70,17 @@ void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective,
descriptorMatcher
->
match
(
descriptors1
,
matches
);
descriptorMatcher
->
match
(
descriptors1
,
matches
);
cout
<<
">"
<<
endl
;
cout
<<
">"
<<
endl
;
if
(
!
H12
.
empty
()
)
{
cout
<<
"< Evaluate descriptor match..."
<<
endl
;
vector
<
Point2f
>
curve
;
Ptr
<
GenericDescriptorMatch
>
gdm
=
new
VectorDescriptorMatch
(
descriptorExtractor
,
descriptorMatcher
);
evaluateDescriptorMatch
(
img1
,
img2
,
H12
,
keypoints1
,
keypoints2
,
0
,
0
,
curve
,
gdm
);
for
(
float
l_p
=
0
;
l_p
<
1
-
FLT_EPSILON
;
l_p
+=
0.1
)
cout
<<
"1-precision = "
<<
l_p
<<
"; recall = "
<<
getRecall
(
curve
,
l_p
)
<<
endl
;
cout
<<
">"
<<
endl
;
}
if
(
!
isWarpPerspective
&&
ransacReprojThreshold
>=
0
)
if
(
!
isWarpPerspective
&&
ransacReprojThreshold
>=
0
)
{
{
cout
<<
"< Computing homography (RANSAC)..."
<<
endl
;
cout
<<
"< Computing homography (RANSAC)..."
<<
endl
;
...
@@ -144,15 +166,15 @@ int main(int argc, char** argv)
...
@@ -144,15 +166,15 @@ int main(int argc, char** argv)
cout
<<
endl
<<
"< Extracting keypoints from first image..."
<<
endl
;
cout
<<
endl
<<
"< Extracting keypoints from first image..."
<<
endl
;
vector
<
KeyPoint
>
keypoints1
;
vector
<
KeyPoint
>
keypoints1
;
detector
->
detect
(
img1
,
keypoints1
);
detector
->
detect
(
img1
,
keypoints1
);
cout
<<
keypoints1
.
size
()
<<
" >"
<<
endl
;
cout
<<
keypoints1
.
size
()
<<
"
points"
<<
endl
<<
"
>"
<<
endl
;
cout
<<
"< Computing descriptors for keypoints from first image..."
<<
endl
;
cout
<<
"< Computing descriptors for keypoints from first image..."
<<
endl
;
Mat
descriptors1
;
Mat
descriptors1
;
descriptorExtractor
->
compute
(
img1
,
keypoints1
,
descriptors1
);
descriptorExtractor
->
compute
(
img1
,
keypoints1
,
descriptors1
);
cout
<<
"
>"
<<
endl
;
cout
<<
">"
<<
endl
;
namedWindow
(
winName
,
1
);
namedWindow
(
winName
,
1
);
RNG
rng
;
RNG
rng
=
theRNG
()
;
doIteration
(
img1
,
img2
,
isWarpPerspective
,
keypoints1
,
descriptors1
,
doIteration
(
img1
,
img2
,
isWarpPerspective
,
keypoints1
,
descriptors1
,
detector
,
descriptorExtractor
,
descriptorMatcher
,
detector
,
descriptorExtractor
,
descriptorMatcher
,
ransacReprojThreshold
,
rng
);
ransacReprojThreshold
,
rng
);
...
...
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