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
378a596b
Commit
378a596b
authored
7 years ago
by
Angel Santamaria-Navarro
Browse files
Options
Downloads
Patches
Plain Diff
Fix test_opencv.cpp
parent
bdf32ae7
No related branches found
No related tags found
1 merge request
!128
Updates for OpenCV 3 api (keeping OpenCV 2 back compatibility)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/examples/CMakeLists.txt
+4
-6
4 additions, 6 deletions
src/examples/CMakeLists.txt
src/examples/test_opencv.cpp
+11
-17
11 additions, 17 deletions
src/examples/test_opencv.cpp
with
15 additions
and
23 deletions
src/examples/CMakeLists.txt
+
4
−
6
View file @
378a596b
...
...
@@ -113,14 +113,12 @@ IF(OpenCV_FOUND)
ENDIF
(
Ceres_FOUND
)
# Testing opencv matching and fundamental matrix with ransac
#
ADD_EXECUTABLE(test_opencv test_opencv.cpp)
#
TARGET_LINK_LIBRARIES(test_opencv ${PROJECT_NAME})
ADD_EXECUTABLE
(
test_opencv test_opencv.cpp
)
TARGET_LINK_LIBRARIES
(
test_opencv
${
PROJECT_NAME
}
)
# Testing OpenCV functions for projection of points
# ADD_EXECUTABLE(test_projection_points test_projection_points.cpp)
# TARGET_LINK_LIBRARIES(test_projection_points ${PROJECT_NAME})
ADD_EXECUTABLE
(
test_projection_points test_projection_points.cpp
)
TARGET_LINK_LIBRARIES
(
test_projection_points
${
PROJECT_NAME
}
)
# Constraint test
ADD_EXECUTABLE
(
test_constraint_AHP test_constraint_AHP.cpp
)
...
...
This diff is collapsed.
Click to expand it.
src/examples/test_opencv.cpp
+
11
−
17
View file @
378a596b
...
...
@@ -30,6 +30,7 @@ int main(int argc, char** argv)
// parsing input params
const
char
*
filename
;
cv
::
VideoCapture
capture
;
if
(
argc
<
2
)
{
std
::
cout
<<
"Please use
\n\t
./test_opencv <arg> "
...
...
@@ -41,16 +42,17 @@ int main(int argc, char** argv)
else
if
(
std
::
string
(
argv
[
1
])
==
"0"
)
{
filename
=
"0"
;
// camera
capture
.
open
(
0
);
std
::
cout
<<
"Input stream from camera "
<<
std
::
endl
;
}
else
{
filename
=
argv
[
1
];
// provided through argument
capture
.
open
(
filename
);
std
::
cout
<<
"Input video file: "
<<
filename
<<
std
::
endl
;
}
// Open input stream
cv
::
VideoCapture
capture
(
filename
);
if
(
!
capture
.
isOpened
())
// check if we succeeded
std
::
cout
<<
"failed"
<<
std
::
endl
;
else
...
...
@@ -71,12 +73,8 @@ int main(int argc, char** argv)
cv
::
moveWindow
(
"Feature tracker"
,
0
,
0
);
// set image processors
// cv::BRISK detector(30, 0, 1.0);
// cv::BRISK descriptor(30, 0, 1.0);
cv
::
BFMatcher
matcher
(
cv
::
NORM_HAMMING2
);
cv
::
ORB
detector
(
1000
,
1.2
,
8
,
16
,
0
,
3
,
0
,
31
);
cv
::
ORB
descriptor
(
1000
,
1.2
,
8
,
16
,
0
,
3
,
0
,
31
);
// cv::FlannBasedMatcher matcher;
cv
::
Ptr
<
cv
::
FeatureDetector
>
detector_descriptor_ptr
=
cv
::
ORB
::
create
(
1000
,
2
,
8
,
16
,
0
,
3
,
0
,
31
);
cv
::
Ptr
<
cv
::
DescriptorMatcher
>
matcher_ptr
=
cv
::
DescriptorMatcher
::
create
(
"BruteForce-Hamming(2)"
);
// declare all variables
std
::
vector
<
cv
::
KeyPoint
>
keypoints_1
,
keypoints_2
;
...
...
@@ -88,7 +86,6 @@ int main(int argc, char** argv)
std
::
vector
<
cv
::
Point2f
>
inliers_1
,
inliers_2
;
cv
::
Mat
img_matches
;
cv
::
Mat
img_scaled
;
// double scale = 1;//0.875;
unsigned
int
f
=
0
;
capture
>>
image_buffer
[
f
%
buffer_size
];
...
...
@@ -116,10 +113,10 @@ int main(int argc, char** argv)
img_2
=
image_buffer
[(
f
-
buffer_size
+
1
)
%
buffer_size
];
// detect and describe in both images
detector
.
detect
(
img_1
,
keypoints_1
);
detector
.
detect
(
img_2
,
keypoints_2
);
descriptor
.
compute
(
img_1
,
keypoints_1
,
descriptors_1
);
descriptor
.
compute
(
img_2
,
keypoints_2
,
descriptors_2
);
detector
_descriptor_ptr
->
detect
(
img_1
,
keypoints_1
);
detector
_descriptor_ptr
->
detect
(
img_2
,
keypoints_2
);
detector_
descriptor
_ptr
->
compute
(
img_1
,
keypoints_1
,
descriptors_1
);
detector_
descriptor
_ptr
->
compute
(
img_2
,
keypoints_2
,
descriptors_2
);
unsigned
int
max_dist
=
0
;
unsigned
int
min_dist
=
512
;
...
...
@@ -128,7 +125,7 @@ int main(int argc, char** argv)
{
// match (try flann later)
//-- Step 3: Matching descriptor vectors using FLANN matcher
matcher
.
match
(
descriptors_1
,
descriptors_2
,
matches
);
matcher
_ptr
->
match
(
descriptors_1
,
descriptors_2
,
matches
);
//-- Quick calculation of max and min distances between keypoints
for
(
int
i
=
0
;
i
<
descriptors_1
.
rows
;
i
++
)
...
...
@@ -180,10 +177,7 @@ int main(int argc, char** argv)
// Draw RANSAC inliers
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_1);
// imshow("Feature tracker", img_2);
// Show detected matches
imshow
(
"Feature tracker"
,
img_matches
);
// pause every X images and wait for key
...
...
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