This study aims to improve the non-contact measurement accuracy of roughness of small samples. Therefore, machine vision and virtual sample generation technology are used to detect the roughness of small sample bearing steel (GCr15) in this study. The surface roughness of different specimens is tested with a contact roughness detector. Image acquisition is carried out on the specimen, histogram equalization image enhancement preprocessing is carried out on the image, and sample capacity expansion is carried out on the basis of data enhancement. On this basis, the gray-level co-occurrence matrix (GLCM) is used to extract the image texture features, and a linear regression model of roughness and Energy, Entropy, Homogeneity, Contrast and Correlation is established. Artificial neural networks (ANNs) is used to classify and predict their surface roughness, train the original samples and virtual samples respectively, and compare their prediction accuracy. The results show that the precision of the virtual samples based on resampling and singular value decomposition(SVD) are 10.13% and 21.21% higher than that of the original samples, respectively, and the average error between the predicted value and the measured value of visual roughness is 3.4%. Therefore, the machine vision and virtual sample generation technology are combined to achieve acceptable surface roughness detection of small samples, which provides a theoretical basis for online detection in gear processing.