At present, the size measurement of industrial workpieces is mainly manual measurement and CMM measurement, which cannot meet the requirements of high precision, high efficiency and low error rate in industrial production at the same time. In order to solve the above problems, this paper uses monocular vision technology to propose an optimization scheme of workpiece size measurement accuracy based on machine vision, which takes the height and declination Angle between the camera lens and the workpiece as variables. Firstly, the image was captured by camera calibration correction, and morphological methods such as gray-scale, denoising, expansion and corrosion were used for image pre-processing. Secondly, features were extracted using double-threshold canny edge detection algorithm and connected domain algorithm. Finally, the bearing seat size was measured using the minimum external rectangle algorithm. The experiment shows that the higher the distance between the camera lens and the stage, the larger the error is when the image information can be collected completely. The greater the Angle between the center of the camera lens and the center of the workpiece, the greater the error; The device not only meets the precision requirements, but also has the advantages of fast response speed, which can meet the needs of industrial applications.