Skip to content

Commit 8a8add3

Browse files
committed
Improve slides and examples after KRoC 2017 tutorial
1 parent a92319d commit 8a8add3

17 files changed

Lines changed: 201 additions & 134 deletions

3dv_tutorial.pdf

-4.91 MB
Binary file not shown.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## An Invitation to 3D Vision: A Tutorial for Everyone
2+
3+
_An Invitation to 3D Vision_ is a introductory tutorial on 3D vision (a.k.a. visual geometry or geometric vision). It aims to make beginners understand basic theory of 3D vision and implement their own applications using [OpenCV][]. In addition to tutorial slides, we provide a set of example codes. The example codes are written as short as possible (__less than 100 lines__) to improve readability and involve many interesting and practical applications.
4+
5+
* Download tutorial slides [Link][https://github.com/sunglok/3dv_tutorial/releases/download/misc/3dv_slides.pdf]
6+
* Download example codes in a ZIP file [Link][https://github.com/sunglok/3dv_tutorial/archive/master.zip]
7+
* Download binaries and headers for [OpenCV][] and [CLAPACK][] for Windows [Link][https://github.com/sunglok/3dv_tutorial/releases/download/misc/EXTERNAL4Windows.32bit.zip]
8+
9+
### What does its name come from?
10+
* The tutorial title, _An Invitation to 3D Vision_, came from [a legendary book by Yi Ma, Stefano Soatto, Jana Kosecka, and Shankar S. Sastry][http://vision.ucla.edu/MASKS/]. We wish that this tutorial will be the first gentle invitation card for beginners in 3D vision and explorers from other fields.
11+
* The subtitle, _for everyone_, came from [Prof. Kim's online lecture][https://hunkim.github.io/ml/] (in Korean). This tutorial is also intended not only for students and researchers in academia, but also for hobbyists and developers in industries. We tried to describe important and typical problems and their solutions in [OpenCV][]. We hope readers understand it without serious mathematical background.
12+
13+
### Example descriptions
14+
* __Single-view Geometry__
15+
* Camera Projection Model
16+
* Simple Camera Calibration and Object Localization
17+
* Image Formation: [image_formation.cpp][]
18+
* Geometric Distortion Correction: [distortion_correction.cpp][]
19+
* General 2D-3D Geometry
20+
* Camera Calibration: [camera_calibration.cpp][]
21+
* Camera Pose Estimation (Chessboard Version): [pose_estimation_chessboard.cpp][]
22+
* __Two-view Geometry__
23+
* Planar 2D-2D Geometry (Projective Geometry)
24+
* Perspective Distortion Correction: [perspective_correction.cpp][]
25+
* Planar Image Stitching: [image_stitching.cpp][]
26+
* 2D Video Stabilization: [video_stabilization.cpp][]
27+
* General 2D-2D Geometry (Epipolar Geometry)
28+
* Monocular Visual Odometry (Epipolar Version): [visual_odometry_epipolar.cpp][]
29+
* Triangulation (Two-view Reconstruction): [triangulation.cpp][]
30+
* __Multi-view Geometry__
31+
* Bundle Adjustment using cvsba (Multiple-view Reconstruction): [bundle_adjustment.cpp][]
32+
* Sparse and Dense 3D Reconstruction using VisualSFM
33+
* __Correspondence Problem__
34+
* Line Fitting with RANSAC: [ransac_line.cpp][]
35+
36+
### Dependency
37+
* [OpenCV][] (> 3.0.0, 3-clause BSD License)
38+
* _OpenCV_ is a base of all example codes for linear algebra, vision algorithms, image/video manipulation, and GUI.
39+
* [cvsba][] (GPL): An OpenCV wrapper for sba library
40+
* _cvsba_ is used for bundle adjustment and already included in EXTERNAL directory.
41+
* [CLAPACK][] (Public Domain): f2c'ed version of LAPACK
42+
* _CLAPACK_ is necessary for cvsba.
43+
44+
### Contact
45+
* [Sunglok Choi](http://sites.google.com/site/sunglok/) (sunglok AT hanmail DOT net)
46+
47+
[OpenCV][http://opencv.org/]
48+
[cvsba][https://www.uco.es/investiga/grupos/ava/node/39]
49+
[CLAPACK][http://www.netlib.org/clapack/]
50+
[image_formation.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/image_formation.cpp]
51+
[distortion_correction.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/distortion_correction.cpp]
52+
[camera_calibration.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/camera_calibration.cpp]
53+
[pose_estimation_chessboard.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/pose_estimation_chessboard.cpp]
54+
[perspective_correction.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/perspective_correction.cpp]
55+
[image_stitching.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/image_stitching.cpp]
56+
[video_stabilization.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/video_stabilization.cpp]
57+
[visual_odometry_epipolar.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/visual_odometry_epipolar.cpp]
58+
[triangulation.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/triangulation.cpp]
59+
[bundle_adjustment.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/bundle_adjustment.cpp]
60+
[ransac_line.cpp][https://github.com/sunglok/3dv_tutorial/blob/master/src/ransac_line.cpp]

README.mdk

Lines changed: 0 additions & 1 deletion
This file was deleted.

msvs/3dv_tutorial.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "camera_calibration", "camer
1313
EndProject
1414
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "distortion_correction", "distortion_correction\distortion_correction.vcxproj", "{E5444B55-196A-4A71-9BDE-C42E830B87B0}"
1515
EndProject
16-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pose_estimation", "pose_estimation\pose_estimation.vcxproj", "{E28D077A-B8C3-4391-AE2E-757E72C87BF6}"
16+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pose_estimation_chessboard", "pose_estimation_chessboard\pose_estimation_chessboard.vcxproj", "{E28D077A-B8C3-4391-AE2E-757E72C87BF6}"
1717
EndProject
1818
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perspective_correction", "perspective_correction\perspective_correction.vcxproj", "{53A4EA3F-D463-4D4F-A991-77A16129D664}"
1919
EndProject

msvs/pose_estimation/pose_estimation.vcxproj renamed to msvs/pose_estimation_chessboard/pose_estimation_chessboard.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484
</Link>
8585
</ItemDefinitionGroup>
8686
<ItemGroup>
87-
<ClCompile Include="..\..\src\pose_estimation.cpp" />
87+
<ClCompile Include="..\..\src\pose_estimation_chessboard.cpp" />
8888
</ItemGroup>
8989
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
9090
<ImportGroup Label="ExtensionTargets">
9191
</ImportGroup>
92-
</Project>
92+
</Project>

msvs/pose_estimation/pose_estimation.vcxproj.user renamed to msvs/pose_estimation_chessboard/pose_estimation_chessboard.vcxproj.user

File renamed without changes.

src/bundle_adjustment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ int main(void)
88
int n_views = 5;
99

1010
// Load multiple views of 'box.xyz'
11-
// c.f. You need to run 'image_formation%02d.cpp' to generate point observation.
11+
// c.f. You need to run 'image_formation.cpp' to generate point observation.
1212
// You can apply Gaussian noise by change value of 'camera_noise' if necessay.
1313
std::vector<std::vector<cv::Point2d> > xs;
1414
for (int i = 0; i < n_views; i++)
@@ -92,4 +92,4 @@ int main(void)
9292
fprintf(fout, "%f %f %f\n", Xs[i].x, Xs[i].y, Xs[i].z);
9393
fclose(fout);
9494
return 0;
95-
}
95+
}

src/image_formation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ int main(void)
7070
fclose(fout);
7171
}
7272

73-
std::cout << "Press any key to terminate tihs program!" << std::endl;
7473
cv::waitKey(0);
7574
return 0;
76-
}
75+
}

src/image_stitching.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,22 @@ int main(void)
1111
cv::Mat gray1, gray2;
1212
if (image1.channels() > 1)
1313
{
14-
cv::cvtColor(image1, gray1, CV_RGB2GRAY);
15-
cv::cvtColor(image2, gray2, CV_RGB2GRAY);
14+
cv::cvtColor(image1, gray1, cv::COLOR_RGB2GRAY);
15+
cv::cvtColor(image2, gray2, cv::COLOR_RGB2GRAY);
1616
}
1717
else
1818
{
1919
gray1 = image1.clone();
2020
gray2 = image2.clone();
2121
}
22-
cv::Ptr<cv::FeatureDetector> detector = cv::xfeatures2d::SURF::create(); // SURF features
22+
cv::Ptr<cv::FeatureDetector> fdetector = cv::ORB::create();
2323
std::vector<cv::KeyPoint> keypoint1, keypoint2;
24-
detector->detect(gray1, keypoint1);
25-
detector->detect(gray2, keypoint2);
26-
cv::Ptr<cv::FeatureDetector> extractor = cv::xfeatures2d::SURF::create(); // SURF descriptors
2724
cv::Mat descriptor1, descriptor2;
28-
extractor->compute(gray1, keypoint1, descriptor1);
29-
extractor->compute(gray2, keypoint2, descriptor2);
30-
cv::FlannBasedMatcher matcher; // Approximate Nearest Neighbors (ANN) matcher
25+
fdetector->detectAndCompute(gray1, cv::Mat(), keypoint1, descriptor1);
26+
fdetector->detectAndCompute(gray2, cv::Mat(), keypoint2, descriptor2);
27+
cv::Ptr<cv::DescriptorMatcher> fmatcher = cv::DescriptorMatcher::create("BruteForce-Hamming");
3128
std::vector<cv::DMatch> match;
32-
matcher.match(descriptor1, descriptor2, match);
29+
fmatcher->match(descriptor1, descriptor2, match);
3330

3431
// Calculate planar homography and merge them
3532
std::vector<cv::Point2f> points1, points2;
@@ -38,14 +35,20 @@ int main(void)
3835
points1.push_back(keypoint1.at(match.at(i).queryIdx).pt);
3936
points2.push_back(keypoint2.at(match.at(i).trainIdx).pt);
4037
}
41-
cv::Mat H = cv::findHomography(points2, points1, cv::RANSAC);
42-
cv::Mat merge;
43-
cv::warpPerspective(image2, merge, H, cv::Size(image1.cols * 2, image1.rows));
44-
merge.colRange(0, image1.cols) = image1 * 1; // Copy
38+
cv::Mat inlier_mask;
39+
cv::Mat H = cv::findHomography(points2, points1, inlier_mask, cv::RANSAC);
40+
41+
cv::Mat merged;
42+
cv::warpPerspective(image2, merged, H, cv::Size(image1.cols * 2, image1.rows));
43+
merged.colRange(0, image1.cols) = image1 * 1; // Copy
4544

4645
// Show the merged image
47-
cv::imshow("3DV Tutorial: Image Stitching", merge);
48-
printf("Press any key to terminate tihs program!\n");
46+
cv::Mat original, matched;
47+
cv::drawMatches(gray1, keypoint1, gray2, keypoint2, match, matched, cv::Scalar::all(-1), cv::Scalar::all(-1), inlier_mask);
48+
cv::hconcat(image1, image2, original);
49+
cv::vconcat(original, matched, matched);
50+
cv::vconcat(matched, merged, merged);
51+
cv::imshow("3DV Tutorial: Image Stitching", merged);
4952
cv::waitKey(0);
5053
return 0;
51-
}
54+
}

src/opencv_all.hpp

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,32 @@
3232
#include <opencv2/viz.hpp>
3333

3434
// Include extra (contrib) modules
35-
#include <opencv2/opencv.hpp>
36-
#include <opencv2/aruco.hpp>
37-
#include <opencv2/bgsegm.hpp>
38-
#include <opencv2/bioinspired.hpp>
39-
#include <opencv2/ccalib.hpp>
40-
#include <opencv2/dataset.hpp>
41-
#include <opencv2/dpm.hpp>
42-
#include <opencv2/face.hpp>
43-
#include <opencv2/fuzzy.hpp>
44-
#include <opencv2/line_descriptor.hpp>
45-
#include <opencv2/optflow.hpp>
46-
#include <opencv2/phase_unwrapping.hpp>
47-
#include <opencv2/plot.hpp>
48-
#include <opencv2/rgbd.hpp>
49-
#include <opencv2/saliency.hpp>
50-
#include <opencv2/stereo.hpp>
51-
#include <opencv2/structured_light.hpp>
52-
#include <opencv2/surface_matching.hpp>
53-
#include <opencv2/text.hpp>
54-
#include <opencv2/tracking.hpp>
55-
#include <opencv2/xfeatures2d.hpp>
56-
#include <opencv2/ximgproc.hpp>
57-
#include <opencv2/xobjdetect.hpp>
58-
#include <opencv2/xphoto.hpp>
35+
#ifdef USE_OPENCV_CONTRIB
36+
# include <opencv2/opencv.hpp>
37+
# include <opencv2/aruco.hpp>
38+
# include <opencv2/bgsegm.hpp>
39+
# include <opencv2/bioinspired.hpp>
40+
# include <opencv2/ccalib.hpp>
41+
# include <opencv2/dataset.hpp>
42+
# include <opencv2/dpm.hpp>
43+
# include <opencv2/face.hpp>
44+
# include <opencv2/fuzzy.hpp>
45+
# include <opencv2/line_descriptor.hpp>
46+
# include <opencv2/optflow.hpp>
47+
# include <opencv2/phase_unwrapping.hpp>
48+
# include <opencv2/plot.hpp>
49+
# include <opencv2/rgbd.hpp>
50+
# include <opencv2/saliency.hpp>
51+
# include <opencv2/stereo.hpp>
52+
# include <opencv2/structured_light.hpp>
53+
# include <opencv2/surface_matching.hpp>
54+
# include <opencv2/text.hpp>
55+
# include <opencv2/tracking.hpp>
56+
# include <opencv2/xfeatures2d.hpp>
57+
# include <opencv2/ximgproc.hpp>
58+
# include <opencv2/xobjdetect.hpp>
59+
# include <opencv2/xphoto.hpp>
60+
#endif
5961

6062
#ifdef _WIN32
6163
# ifdef _DEBUG

0 commit comments

Comments
 (0)