Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
a89c4cce
Commit
a89c4cce
authored
9 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Bug fix: image with no keypoints cannot be sent for matching
parent
578aa920
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/examples/test_opencv.cpp
+29
-19
29 additions, 19 deletions
src/examples/test_opencv.cpp
with
29 additions
and
19 deletions
src/examples/test_opencv.cpp
+
29
−
19
View file @
a89c4cce
...
...
@@ -66,7 +66,7 @@ int main(int argc, char** argv)
cv
::
Mat
img_1
,
img_2
;
// user interface
cv
::
namedWindow
(
"Feature tracker"
,
cv
::
WINDOW_AUTOSIZE
);
// Creates a window for display.
cv
::
namedWindow
(
"Feature tracker"
);
// Creates a window for display.
cv
::
moveWindow
(
"Feature tracker"
,
0
,
0
);
// set image processors
...
...
@@ -118,28 +118,36 @@ int main(int argc, char** argv)
descriptor
.
compute
(
img_1
,
keypoints_1
,
descriptors_1
);
descriptor
.
compute
(
img_2
,
keypoints_2
,
descriptors_2
);
// match (try flann later)
//-- Step 3: Matching descriptor vectors using FLANN matcher
matcher
.
match
(
descriptors_1
,
descriptors_2
,
matches
);
unsigned
int
max_dist
=
0
;
unsigned
int
min_dist
=
512
;
double
max_dist
=
0
;
double
min_dist
=
512
;
if
(
keypoints_1
.
size
()
*
keypoints_2
.
size
()
!=
0
)
{
// match (try flann later)
//-- Step 3: Matching descriptor vectors using FLANN matcher
matcher
.
match
(
descriptors_1
,
descriptors_2
,
matches
);
//-- Quick calculation of max and min distances between keypoints
for
(
int
i
=
0
;
i
<
descriptors_1
.
rows
;
i
++
)
//-- Quick calculation of max and min distances between keypoints
for
(
int
i
=
0
;
i
<
descriptors_1
.
rows
;
i
++
)
{
unsigned
int
dist
=
matches
[
i
].
distance
;
if
(
dist
<
min_dist
)
min_dist
=
dist
;
if
(
dist
>
max_dist
)
max_dist
=
dist
;
}
}
else
{
double
dist
=
matches
[
i
].
distance
;
if
(
dist
<
min_dist
)
min_dist
=
dist
;
if
(
dist
>
max_dist
)
max_dist
=
dist
;
min_dist
=
999
;
max_dist
=
999
;
}
printf
(
"-- Max dist : %
f
\n
"
,
max_dist
);
printf
(
"-- Min dist : %
f
\n
"
,
min_dist
);
printf
(
"-- Max dist : %
d
\n
"
,
max_dist
);
printf
(
"-- Min dist : %
d
\n
"
,
min_dist
);
//-- Select only "good" matches (i.e. those at a distance which is small)
for
(
int
i
=
0
;
i
<
matches
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
matches
.
size
();
i
++
)
{
if
(
matches
[
i
].
distance
<=
100
)
//std::max(2*min_dist, 0.02) )
{
...
...
@@ -158,7 +166,7 @@ int main(int argc, char** argv)
std
::
cout
<<
"F = "
<<
F
<<
std
::
endl
;
// Recover the inlier matches
for
(
int
i
=
0
;
i
<
good_matches
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
good_matches
.
size
();
i
++
)
if
(
inliers_bool
.
at
<
char
>
(
i
)
==
1
)
inlier_matches
.
push_back
(
good_matches
[
i
]);
}
...
...
@@ -170,8 +178,10 @@ int main(int argc, char** argv)
cv
::
drawMatches
(
img_1
,
keypoints_1
,
img_2
,
keypoints_2
,
inlier_matches
,
img_matches
,
cv
::
Scalar
::
all
(
-
1
),
cv
::
Scalar
::
all
(
-
1
),
std
::
vector
<
char
>
(),
0
);
//cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
//-- Show detected matches
resize
(
img_matches
,
img_scaled
,
cv
::
Size
(),
scale
,
scale
,
cv
::
INTER_NEAREST
);
imshow
(
"Feature tracker"
,
img_scaled
);
// resize(img_matches, img_scaled, cv::Size(), scale, scale, cv::INTER_NEAREST);
// imshow("Feature tracker", img_1);
// imshow("Feature tracker", img_2);
imshow
(
"Feature tracker"
,
img_matches
);
// pause every X images and wait for key
if
(
f
%
100
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment