Abstract:In order to obtain the information of the distance between the camera and the target object, based on the principle of binocular measurement, a stereo vision system for binocular ranging was designed by combining OpenCV and Matlab. This system first calibrated the internal and external parameters of the binocular camera, got the corner point information from the calibration board composed of black and white grids, and used the sub-pixel corner detection method to detect the corner point coordinate information more accurately. The board was respectively 300mm, 400mm, 500mm, 600mm, and 700mm away from the binocular camera to obtain calibration images at different positions. By using Zhang Zhengyou's calibration method, the internal and external parameters required by the binocular camera were finally obtained. Secondly, through the BM(Block Matching) stereo matching algorithm in the VS2017 environment and the opencv3.4.7 library, the stereo correction and stereo matching of the camera were completed to obtain the disparity map. Finally, a binocular camera was used in the experiment, and a code was written to obtain the corresponding world coordinates through the disparity map obtained by clicking the mouse to realize the measurement of the object distance. The experimental results show that when the measured object is in the range of 500 mm to 700 mm from the optical center of the camera, the relative error percentage between the measured distance and the actual distance is between 0.171% and 0.192%, and the accuracy is high and when the measured distance is within 2 950 mm and the experimental error is less than 5%, which meets the requirements of experimental accuracy.