目的 双目测距对水面无人艇自主避障以及视觉侦察具有重要意义，但视觉传感器成像易受光照环境及运动模糊等因素的影响，基于经典Census变换的立体匹配代价计算方法耗时长，且视差获取精度差，影响测距精度。为了提高测距精度并保证算法运行速度，提出一种用于双目测距的快速立体匹配算法。方法 基于传统Census变换，提出一种新的比特串生成方法，该方法在匹配点的正方形支持窗口的每条边上等间距选取3个像素点，即在该匹配点支持窗口上共选取8个像素点。被选中的8像素点两两之间比较生成一个字节的比特串，用于匹配点之间匹配代价的计算。将左右视场中匹配点与待匹配点的比特串进行异或运算，得到两点的Hamming距离，改变待匹配点的位置并记录匹配点和该待匹配点的Hamming距离。在得到的各Hamming距离结果中找到Hamming距离最小的像素点作为和匹配点匹配的像素点，两点像素的横坐标之差作为两点的视差。为了确保目标视差计算的可靠性和精度，采用区域视差计算的方法，即在左右视场确定同一目标区域后，对该区域进行视差的提取以及滤波，得到该目标的平均视差后计算得到目标到视觉传感器的距离。结果 本文所提算法和基于传统Census变换的立体匹配视差获取方法相比，在运算速度方面优势明显。在实际双目测距实验中，采用本文所提算法在10~20m范围内测距误差在5%以内。结论 本文给出的基于改进Census变换的匹配算法在立体匹配速度上有大幅提高，提取目标视差用于测距，实际测距结果表明所给出的算法能够满足水面无人艇的视觉避障要求。
A fast stereo ranging algorithm based on improved Census transform
Objective The image-based ranging method is more concealment than the traditional ranging methods such as ultrasonic, radar. Ranging based on binocular vision for reconnaissance and obstacle avoiding is one of the important means for USV (Unmanned Surface Vehicle). But visual sensor imaging is easily affected by illumination changing and motion blur, etc. Calculation of stereo matching cost based on classical Census transform is too high and the stereo parallax accuracy is poor, which affects the ranging productiveness and accuracy. In order to improve the ranging accuracy and ensure the speed of the ranging, a fast stereo matching and parallax computation algorithm based on improved Census transform for binocular ranging is proposed. Method Firstly, a new bit string generation method used in the Census transform is proposed. The method selects 3 pixels at equal intervals on each edge of the square supporting window of the matching point. There are total 8 pixels selected on the square supporting window edges around the matching point. An 8 bit string is generated by this 8 pixels pairwise comparison and this 8 bit string is used for the matching cost calculation between the matching points. Then, the Hamming distance between matching points is obtained with the bit OR arithmetic operation between the 8 bit strings of the two matching points from the left and right field of view separately. The two pixel points from different views has the smallest Hamming distance can be regarded as a pair of matched points. After the matched points determined, the parallax between the matched points can be achieved easily. In order to reduce the computational complexity, the average parallax of target area in reference image and target image instead of the parallax of whole area is calculated and adopted to get the target distance. Fortunately, for the stereo ranging used in USV, the target images always occupy a certain area in the two view fields, and the target area has a high similarity in the left and right field of view, such as the contour difference is small, so the target contour feature can be used to identify the same target in the two views. After the same target area in the left and right field of view are determined, the parallaxes of all the pixels in the target area are extracted and the distance of the target is calculated with the average parallax of the target obtained. Result With the increase of matching window, the computation cost of matching based on classical Census transform increases, but the computation cost of matching based on the improved Census transform is stable. It can be seen that the improved algorithm presented in this paper has obvious speed advantage when matching window is large. In the practical binocular ranging for USV, the binocular image are pre-processed firstly, such as de-noising, de-blurring and so on, then the fast stereo matching and parallax calculation based on the improved Census transform are adopted. Finally, the target distance is obtained according to the stereo parallax and binocular imaging model. The ranging error is less than 5% in the range from 10m to 20m based on the algorithm given in this paper. According to binocular imaging ranging principle, the error of fast stereo matching and parallax calculation based on improved Census transform is not greater than 5%. Conclusion The experiment results show that the proposed matching algorithm based on improved Census transform can greatly improve the speed of stereo matching. In the practical binocular ranging for USV, the target area in the left and right field of view are determined firstly and then the average parallax of the target is calculated out to get the target distance. The actual ranging results show distance error is less than 5% and the proposed algorithm can meet the requirements of target ranging, obstacle avoidance for the USV.