Abstract:Aiming at the problems of low efficiency and accuracy of manual inspection of medical transparent square cups and wear on products, visual inspection technology is introduced, combining image processing and deep learning, a medical transparent square cup posture and defect detection system is designed and developed. For square cup posture detection, firstly, the edge area of the square cup image is accurately segmented based on the improved dynamic threshold. Then, the high and low threshold design of the Canny algorithm is improved to detect more edges with subtle amplitude differences, and the threshold condition for merging collinear edges is set, and then the two edge straight lines are fitted, and the virtual central axis is calculated based on the two edges. Finally, the center is roughly located by the minimum circumscribed rectangle, and the foot of the rough positioning point to the axis is used as the square cup precise positioning coordinate, and the square cup image is corrected to the reference posture according to the affine transformation. In terms of defect detection, the local defects of the image are grayscale spliced to construct an image data set that is balanced between the three defect classes. After training three neural networks, SqueezeNet, Inception-V3 and ResNet-50, through comprehensive evaluation, it was found that the SqueezeNet model had the best performance, with an average accuracy of 98.6% in the test set, and recognition accuracy and recall rates of 99.8% and 98.8% respectively. The experimental verification results show that the detection speeds for the pose and defects of a single image are 770.5ms and 553.1ms respectively. After the improvement, the pose detection accuracy is higher, and the defect detection accuracy rate reaches 94%, which has good real-time performance and stability and can meet the detection requirements. This research can provide technical support for the pose and defect detection of medical transparent square cups.