完成 双目视差匹配disparity matching, 生成当前相机坐标系下的点云point clouds camera's local reference frame.
a. <stereo>/left/<image> (sensor_msgs/Image) 左图矫正后的图像 Left rectified stereo image.
b. <stereo>/right/<image> (sensor_msgs/Image) 右图矫正后的图像 Right rectified stereo image.
c. <stereo>/left/camera_info (sensor_msgs/CameraInfo) 左相机参数 Camera info for left camera.
4. <stereo>/right/camera_info (sensor_msgs/CameraInfo) 右相机参数 Camera info for right camera.
a. disparity (sensor_msgs/Image) 视差 话题
Image representing the calculated disparity at each point.
Note that the values are scaled to be in the range [0, 255]
b. point_cloud (sensor_msgs/PointCloud2) 左相机当前坐标系下 的点云地图
The point cloud assosciated with the calculated disparity in the left camera's local reference frame.
c. frame_data (elas_ros/ElasFrameData) 结构数据 用于三维重建
Frame data used for the point cloud concatenation process. See node pc_construction.
a. ~queue_size (int, default: 5) 队列大小
Length of the input queues for left and right camera synchronization.
b. ~approximate_sync (bool, default: false) 同步
Whether the node should use approximate synchronization of incoming messages.
Set to true if cameras do not have synchronised timestamps.
This node concatenates the point clouds generated by the elas_ros node.
<frame_data> (elas_ros/ElasFrameData) 结构数据 用于三维重建
The frame data generated by the elas_ros node.
<pose> (geometry_msgs/PoseStamped) 相机姿态数据 来自视觉里程计
The pose transformation from base frame to pose frame.
This accounts for motion of the camera. This can typically be determined by appropriate visual odometry.
See usage notes below.
point_cloud (sensor_msgs/PointCloud2) 世界坐标系下的点云地图
The concatenated point cloud.
~queue_size (int, default: 5) 队列大小
Length of the input queues for frame data and pose synchronization.
~approximate_sync (bool, default: false) 同步 Whether the node should use approximate synchronization of incoming messages. Set to true if frame data and pose do not have synchronised timestamps.
base_frame_id (string) 基坐标系
The name of the base frame that the concatenated point cloud should be cast into.
pose_frame_id (string) 相机位姿坐标系
The name of the frame that the given pose transforms into.
Tables | Are | Cool |
---|---|---|
col 3 is | right-aligned | $1600 |
col 2 is | centered | $12 |
zebra stripes | are neat | $1 |
![][1] [1]: http://latex.codecogs.com/gif.latex?\prod%20(n_{i})+1
1. 基于局部的块匹配 Block Matching(BM) StereoBM
2. 半全局块匹配 Semi-Global Block Matching(SGBM) StereoSGBM
>第一步对每一个Pixel使用块匹配BM进行匹配,得到了全部Pixel的disparity map。
>第二步对Disparity map建立图,用Graph Cut对其进行全局优化。
>利用Rectification将二维转化为一维
3. 基于全局的图割 Graph Cut(GC)cvStereoGCState()
4. 基于全局的 动态规划 Dynamic Programming(DP)cvFindStereoCorrespondence()
* 用法 ./Stereo_Calibr -w=6 -h=8 -s=24.3 stereo_calib.xml
我的 ./Stereo_Calibr -w=8 -h=10 -s=200 stereo_calib.xml
* ./stereo_calib -w=9 -h=6 stereo_calib.xml 标准图像
* 实际的正方格尺寸在程序中指定 const float squareSize = 2.43f;
2.43cm mm为单位的话为 24.3 0.1mm为精度的话为 243 注意 标定结果单位(纲量)和此一致
Xp=Xd(1 + k1*r^2 + k2*r^4 + k3*r^6)
Yp=Yd(1 + k1*r^2 + k2*r^4 + k3*r^6)
Xp= Xd + ( 2*p1*y + p2*(r^2 + 2*x^2) )
Yp= Yd + ( p1 * (r^2 + 2*y^2) + 2*p2*x )
r^2 = x^2+y^2
| Xw|
* | u| |fx 0 ux 0| | R T | | Yw|
* | v| = |0 fy uy 0| * | | * | Zw| = M*W
* | 1| |0 0 1 0| | 0 0 0 1| | 1 |
* 像素坐标齐次表示(3*1) = 内参数矩阵 齐次表示(3*4) × 外参数矩阵齐次表示(4*4) × 物体世界坐标 齐次表示(4*1)
* 内参数齐次 × 外参数齐次 整合 得到 投影矩阵 3*4 左右两个相机 投影矩阵 P1 = K1*T1 P2 = k2*T2
* 世界坐标 W ----> 左相机投影矩阵 P1 ------> 左相机像素点 (u1,v1,1)
* ----> 右相机投影矩阵 P2 ------> 右相机像素点 (u2,v2,1)
* Z = f*B/d = f /(d/B)
* X = Z*(x-c_x)/f = (x-c_x)/(d/B)
* X = Z*(y-c_y)/f = (y-y_x)/(d/B)
* Q= | 1 0 0 -c_x | Q03
* | 0 1 0 -c_y | Q13
* | 0 0 0 f | Q23
* | 0 0 -1/B (c_x-c_x')/B | c_x和c_x' 为左右相机 平面坐标中心的差值(内参数)
* Q32 Q33
* 以左相机光心为世界坐标系原点 左手坐标系Z 垂直向后指向 相机平面
* |x| | x-c_x | |X|
* |y| | y-c_y | |Y|
* Q * |d| = | f | = |Z|======> Z' = Z/W = f/((-d+c_x-c_x')/B)
* |1| |(-d+c_x-c_x')/B | |W| X' = X/W = ( x-c_x)/((-d+c_x-c_x')/B)
Y' = Y/W = ( y-c_y)/((-d+c_x-c_x')/B)
与实际值相差一个负号
Z = f * T / D
f 焦距 量纲为像素点
T 左右相机基线长度
量纲和标定时 所给标定板尺寸 相同
D视差 量纲也为 像素点 分子分母约去,
Z的量纲同 T
* CCD的尺寸是8mm X 6mm,帧画面的分辨率设置为640X480,那么毫米与像素点之间的转换关系就是80pixel/mm
* CCD传感器每个像素点的物理大小为dx*dy,相应地,就有 dx=dy=1/80
* 假设像素点的大小为k x l,其中 fx = f / k, fy = f / (l * sinA),
A一般假设为 90°,是指摄像头坐标系的偏斜度(就是镜头坐标和CCD是否垂直)。
* 摄像头矩阵(内参)的目的是把图像的点从图像坐标转换成实际物理的三维坐标。因此其中的fx,y, cx, cy 都是使用类似上面的纲量。
* 同样,Q 中的变量 f,cx, cy 也应该是一样的。
参考代码
https://github.com/yuhuazou/StereoVision/blob/master/StereoVision/StereoMatch.cpp
https://blog.csdn.net/hujingshuang/article/details/47759579
http://blog.sina.com.cn/s/blog_c3db2f830101fp2l.html
【1】对应像素差的绝对值和(SAD, Sum of Absolute Differences)
【2】对应像素差的平方和(SSD, Sum of Squared Differences)
【3】图像的相关性(NCC, Normalized Cross Correlation) 归一化积相关算法
【4】ADCensus 代价