梳理一下方法,准备开始写代码了。
参考文章:https://blog.csdn.net/u013832707/article/details/53781810
1. 概念梳理
1.1 Stereo:
1.2 Depth from Stereo
1.3 Point correspondence: 所谓 Xleft和Xright 是在 左和右的图像平面下讨论的,它们的坐标系是各自图像平面坐标系下的坐标。两个图像平面的坐标原点分别为各自光轴与像平面的交点。
* 1.3的前置补充知识:
- 世界坐标,相机坐标(3D,坐标原点O为相机的光心,x和y是世界位置,z是相机光轴),图像平面坐标(2D,坐标原点O1为光轴z和像平面的交点),像素坐标(2D,坐标原点为像平面坐标的左顶点)。
- 焦距f: OO1的距离

1.4 原理


f:焦距
B:两个光心的距离
两台相机在同一平面上(光心在同一世界高度吧),投影中心的Y坐标相等。”同一时刻空间点p(x,y,z)在两相机上成像点(像素平面吧)分别为Pleft和Pright。
Xleft和Xright分别在左右相机的图像平面下讨论,它们的坐标系是在各自的图像平面坐标系的坐标。视差D是Xleft-Xright。视差越小,意味着在所提供的照片中对应点成像的位置越相似。也就说明物体越远。

2. 实现梳理
2.1 准备图片:Horizontal Movement 与 distance from the camera成反比。
一组图片有两张相片。
这两张图片相机光心改变,光心的相机y坐标不变(所以两张图像的y坐标系也没有变),x坐标改变。
2.2 实现所基于的原理概述:
disparity = x - x'
x-x' / O-O' = f / z i.e. disparity/B = f/z
disparity = B*f/z (disparity和z成反比)
目的:用disparity求解z
所需原材料:x, x'
主要目标:求x'
需要解决的问题:Calibration(recover the relation of the cameras), Correspondence
2.3 Correspondence Problem - Match a point in the first image to a point in the second
2.3.1 Epipolar Constraint
- Corresponding line
- Calibrated case/ uncalibrated case 标定是为了测相机的内外参数
Essential Matrix (parameters of two cameras)
1) Get normalized image coordinates with calibration matrix
2) Set global coordinates system to 1st camera and gain projection matrices of 2 cameras
=> Fuse calibrated binocular stereo pair to produce a depth image
Fundamental Matrix (8 point algorithms) - TBC
2.3.2 Basic Stereo Matching Algorithm
- (Can) Rectify two stereo images to transform epipolar lines into scanlines - gain parallel images 双目校正是为了得到两个平行的摄像头
- For each pixel x in the first image
1) Find the corresponding epipolar scanline in the right image
2) Search (Side a window along )the scanline and pick the best match x'
Matching cost e.g. : SSD, SAD, normalized correlation
Effect of parameters: window size
3) Compute disparity x-x' and set depth(x) = fB/(x-x') 怎么算啊?
reprojectImageTo3D(disp, xyz, Q, true); //该函数将视差图,通过投影矩阵Q,得到一副映射
saveXYZ(point_cloud_filename, xyz); //Z就是深度
2.3.3 Shortcoming of correspondence Search: TBC
2.3.4 Improve Window Based Search with Energy Minimization View
- Uniqueness
- Ordering
- Smoothness
2.3.5 Error from:
• Camera calibration errors
• Poor image resolution
• Occlusions
• Violations of brightness constancy (specular reflections)
• Large motions
• Low-contrast image regions
3. Application
Multi-view stereo, 用多张2D图片建模成3D模型。
浙公网安备 33010602011771号