The wide application of lenses in the security field has caused more and more attention to the quality of lenses.Due to many problems such as inconsistent implementation standards and high cost of manual quality inspection,and high-precision lens inspection equipment is expensive and the use environment cannot adapt to the changing needs of the factory.Exploring the detection method based on machine vision is of great significance to improve the quality control level of the lens and meet the requirements of automation and informatization.This paper takes security lens as the research object.Based on the principle of light scattering imaging,the detection,location and classification of internal defects are studied by using machine vision detection methods.First of all,based on the principle of light scattering imaging,the machine vision technology is used to design the internal defect detection scheme of the security lens,and the internal defect detection system of the security lens is built.These include the selection of industrial cameras,lenses,light sources and control systems.In order to improve the effect of image processing,the image is preprocessed,and the Gaussian filter algorithm is selected in combination with the mean square error and the maximum peak signal-to-noise ratio.Secondly,in order to solve the defect problem in the optical lens image,an improved connected domain extraction method was adopted,which can effectively detect the defect information area in the image,thereby improving the efficiency and accuracy of image processing.In the study of defect information extraction,defects are extracted by combining frequency domain and space transformation algorithms,and defects are divided into scratches and pits by using the least circumscribed rectangle algorithm.In order to determine the specific spatial position of the internal defects of the lens,a dynamic longitudinal scan is performed on the interior of the security lens according to the step size of 1 mm to obtain all the defect information inside the security lens.By comparing the commonly used sharpness evaluation algorithms,the improved The variance gradient function of the security lens is used to evaluate the clarity of the scanned image sequence,and the specific position of the lens inside the security lens is judged.Combined with the defect fusion algorithm,the detection of the internal defect of the security lens is completed.Finally,according to the detection method proposed in this paper,58 security lenses composed of 5 lenses were selected for experiments and verification was completed.The experimental results show that the internal defects of the security lens are mainly concentrated on the second lens and the third lens inside the security lens.The sharpness evaluation algorithm proposed in this paper combined with the defect detection algorithm can accurately detect the specific location and size of defects inside the security lens.It can guide the quality control in the lens assembly process of enterprises,and has high feasibility and practical application value. |