双目测距-初识
双目测距流程
1 相机标定(获取内外参数)
2 双目矫正(矫正镜头变形图像)
3 双目立体匹配(视差图)
4 计算深度信息(深度图)
5 计算距离
其中立体匹配是整个流程中比较重要的一环,往往在这里做研究和优化
流程
标定
参考 标定+矫正 MATLAB
矫正
匹配(传统算法或深度学习算法)
双目测距原理
其中_Xr_是负数,解释如下:
xr
** represents a negative value.**
Here’s a step-by-step explanation of why:
1. The Coordinate System
To make the math work, we need to establish a consistent coordinate system for each camera’s image sensor. The standard convention is:
- The origin (0) is at the center of the image (the principal point, where the optical axis intersects the sensor).
- The x-axis increases to the right.
- Therefore, any point to the right of the center has a positive x-coordinate, and any point to the left has a negative x-coordinate.
2. Analyzing the Diagram
Let’s apply this coordinate system to the diagram:
- For the Left Camera (Ol): The point P is to the right of the camera’s central axis. Its projection on the image sensor,
xl
, is therefore also to the right of the center. So,xl
** is a positive number**. - For the Right Camera (Or): The point P is to the left of this camera’s central axis. Its projection on the image sensor,
xr
, is therefore to the left of the center. So,xr
** is a negative number**.
3. Why This is Crucial for the Formula
Now, let’s look at the formula for disparity (d
):
d = xl - xr
If we substitute the signs we just determined:
d = (a positive number) - (a negative number)
d = (a positive number) + (another positive number)
This means the disparity d
will be a positive value, which makes perfect sense. Disparity represents a distance (in pixels) and should be positive.
The Final Calculation
The final formula for calculating the distance Z is:
Z = f * T / d
Since the focal length f
, the baseline T
, and the disparity d
are all positive values, the calculated distance Z
will also be positive, which is correct.
In summary: Although the diagram draws xr
as a length, the formula d = xl - xr
treats it as a coordinate. For this formula to be correct in this geometric setup, xr
must be a negative value.
双目测距的优势和劣势
- 成本比单目高,但是比激光雷达低
- 没有识别率的限制,无需维护样本库
- 双目的匹配效果,直接影响测距的准确性
- 对环境光照非常敏感
- 不适用于单调缺乏纹理的场景(天空、沙漠、白墙)
- 相机基线限制了测量范围