In order to solve the time-consuming and laborious problem of manual inspection of bearing cages, and to improve the level of industrial production automation, a method of measuring the diameter of cages based on Zernike moments is presented. Taking the 32007E cylindrical roller cage as an example, a vision-based diameter measurement method is proposed to analyze the image of the bearing cage size captured by the CCD camera. After image preprocessing, the threshold of the Sobel operator is changed and is used to detect the possible edge point set, after the effective circle detection, remove part of the interference point, and then using Zernike moment operator on the edge of these re-positioning to detect the image sub-pixel edge and calculate the exact location. Finally, these exact positions are fitted by using the least squares method to obtain the specific dimensions of the diameter of the cage. The actual operation shows that this method can achieve the expected accuracy, with good results and practical value.