| Machine vision technology has many advantages,such as automation,high accuracy,efficiency,and low cost,and is widely used in industrial manufacturing,vehicle driving,construction engineering,and other fields.In visual inspection,circles and line segments are among the most important features of workpieces.The fitting of incomplete or broken circles and line segments,as well as various interference information in images,can affect the accuracy and precision of inspection.Research on circle and line segment fitting algorithms that are resistant to interference and unaffected by incompleteness can greatly improve industrial production efficiency and reduce inspection costs,which is beneficial to the automation and intelligence of modern manufacturing.To address the problem of poor fitting accuracy for circles with multiple incompleteness and noise,a RANSAC-based circle fitting algorithm is proposed.Firstly,the Canny algorithm based on the Scharr operator is used to obtain a high-quality edge distribution map.Then,the Hough gradient method is used to roughly locate the target arc in the edge distribution map and extract the point set containing the target arc.Next,the RANSAC algorithm is used to remove outlier data from the point set,and obtain the point set consisting of valid sample data for circle fitting.Finally,the LIN algorithm is used to fit the point set for the final circular parameters.The algorithm performs well in anti-interference experiments with salt-andpepper noise and curve noise,and has strong anti-interference ability.It has been successfully applied to the detection of threaded hole circles,and both the accuracy and real-time performance meet practical production requirements.To solve the problems of HTCC board cracking and poor installation of subsequent components caused by the detachment of the HTCC board used in the camera module during mobile phone motherboard production,a HTCC board misalignment detection algorithm based on an improved LSD is proposed.Instead of the Gaussian filter used in the LSD algorithm,bilateral filtering is adopted to achieve better line fitting results.An improved mapping relationship and bilinear interpolation-based scaling algorithm are proposed to eliminate image quantization artifacts and reduce image distortion.A broken line reconnection algorithm is proposed to solve the oversplitting problem of line segments in the LSD algorithm.Finally,the implementation of the improved LSD algorithm-based HTCC board misalignment detection algorithm is achieved,which can accurately detect the number and position of misaligned HTCC boards in the product.The hardware and software structure of the HTCC board misalignment detection platform is designed and implemented.The hardware platform for HTCC board misalignment detection is built,and the selection and calculation of detection camera,lens,and light source are completed.The hardware installation scheme and image acquisition workflow of the visual system are determined.The HTCC board misalignment detection software based on the improved LSD algorithm is designed,with a focus on the design of Modbus TCP protocolbased messages,the implementation of communication between industrial computers and PLCs,and the design of human-machine interaction main interface and interactive parameter intelligent setting functions.This detection system has been applied in a factory to detect each group of products on the production line.The average detection time of this misalignment detection method is within 800 ms,and the detection accuracy is above 97%.Compared with the traditional LSD algorithm,the detection time is reduced by at least 38%,and the accuracy is increased by at least 21%,which can meet the requirements of real-time and accuracy in production. |