The invention discloses a distance measuring method based on a binocular camera. The method comprises the steps that a left camera and a right camera are calibrated, and the calibration of the binocular camera is achieved by calculating the rotation and translation matrix between the left camera and the right camera; distortion correction and three-dimensional correction are conducted on the radial distortion and the tangential distortion of the image; cost calculation, cost aggregation, parallax calculation and parallax optimization are carried out on images formed by the binocular camera insequence; depth calculation is carried out. According to the three-dimensional matching algorithm of a self-adaptive region, the self-adaptive region is constructed to carry out cost polymerization, so that the error and the time are reduced, and the error is reduced by means of the method for optimizing the scanning lines in the four directions (up and down, left and right) by means of binocularimage correction, the parallax precision is improved. A voting method and other methods are adopted in the parallax optimization process, the shielding points and the mismatching points which are matched with the parallax are eliminated, and the parallax matching precision is further improved, the depth of the to-be-measured point is finally calculated, the precision is high, and the operation time is short.