Vision-based ultrasonic radar part surface printing character defect detection method
By adopting vision-based defect detection methods on the surface of ultrasonic radar parts, combined with OCR, deep learning and GAN technology, the problem of character defect detection in real-time changes in printing content is solved, and efficient and accurate defect recognition and positioning is achieved, which is suitable for complex environments.
Patent Information
- Application Number
- CN202510165743.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-14
- Publication Date
- 2025-05-02
AI Technical Summary
Existing machine vision technology has limitations in character detection of changing print content in real-time, and cannot be effectively applied to scenarios such as ultrasonic radar parts, because it cannot ensure the accuracy and consistency of templates and real-time print content.
Vision-based ultrasonic radar parts surface printing character defect detection method is adopted, and defect recognition and positioning of real-time changing print content is achieved through camera images, OCR text recognition technology, deep learning object detection technology and GAN image generation model, without presetting templates.
The defect identification and positioning in environments such as different printing contents, light differences, font deformation on the surface of ultrasonic radar parts is realized, which improves the accuracy and adaptability of defect identification, shortens the defect detection time, and reduces production costs.
Smart Images

Figure CN119915824A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine vision technology, and in particular to a vision-based method for detecting printed character defects on the surface of ultrasonic radar parts, which is particularly suitable for scenarios such as ultrasonic radar parts where the printed content is not fixed and templates cannot be set in advance for matching. Background Art
[0002] As an interdisciplinary subject, machine vision integrates knowledge and technology from multiple fields such as artificial intelligence, neurobiology, psychophysics, computer science, image processing, and pattern recognition. It uses computers to simulate or reproduce certain intelligent behaviors related to human vision, extracts information from the images of objective things for processing and understanding, and finally applies it to actual detection and control. Machine vision technology plays an important role in industrial production, quality inspection, precision measurement and control, automated production lines, postal automation, grain selection, microscopic medical operations, and robots working in dangerous places.
[0003] In terms of character defect detection, existing machine vision technology usually relies on pre-set templates for matching. For example, the patent "AOI character defect detection method and device based on industrial machine vision" (application number 202010306399.1) obtains the image to be detected by image preprocessing and setting the region of interest, and then performs template matching on the character area image of the image to be detected with the pre-created reference image template, and judges whether the character has defects based on the matching results. Another patent "A vision-based image defect detection method" (application number 202010683186.0) uses a color high-definition industrial camera and lens to take pictures of printed materials. First, a standard template of qualified products is made and feature information is extracted. Then, the printed samples placed in random postures are photographed and high-precision multi-scale registration and correction are performed with the template to finally identify image printing defects.
[0004] However, the above method has limitations when applied to character detection of real-time changing print content. In particular, in certain specific fields, such as the production process of ultrasonic radar parts, the print content may change in real time with changes in production batches, product models or customer needs, and it is impossible to set a fixed template content in advance for matching. In this case, the traditional character defect detection method based on template matching will not be effectively applied because it cannot ensure the accuracy and consistency of the template with the real-time print content.
[0005] Therefore, there is an urgent need for a character defect detection method that can adapt to real-time changes in printed content. This method should be able to accurately and efficiently detect defects in real-time printed characters without pre-setting templates to meet the actual needs of industrial production. Summary of the invention
[0006] In view of the shortcomings of the prior art, the present invention provides a vision-based method for detecting printed character defects on the surface of ultrasonic radar parts. The method realizes the identification and positioning of defects on the surface of ultrasonic radar parts under environments such as different printed contents, light differences, and font deformation, and can output the threshold of the defect for subsequent filtering.
[0007] The present invention achieves the above-mentioned purpose through the following technical solutions:
[0008] A method for detecting printed character defects on the surface of ultrasonic radar parts based on vision comprises the following steps:
[0009] Camera image acquisition step: taking a picture of the printed characters on the surface of the ultrasonic radar part to obtain an image containing the printed characters;
[0010] Content recognition step: Use OCR text recognition technology to recognize the acquired image and determine whether the recognized printed content is consistent with the specified printed content; if not, it is determined that there is a printing error; if consistent, it is further determined whether there is a defect in the printing of a single character;
[0011] Single character target recognition and positioning step: split the recognized printed content into single characters, use deep learning target detection technology to recognize and locate single characters, and extract the region of interest ROI as the input image;
[0012] Single character template generation step: for each single character ROI obtained by positioning, the image generation neural network algorithm is trained respectively to generate the corresponding GAN image generation model; the ROI of each single character is used as the input image of the corresponding GAN image generation model, the corresponding single character image is generated through the model, and the generated image is used as the template;
[0013] Defect location steps: Use image difference to obtain the difference between the original image of a single character and the generated single character image, filter out pixels with large differences through a set threshold, and thus locate the specific pixel position of the defect; count the number of defective pixels to obtain the area ratio of the defect, and then obtain the size score of the defect.
[0014] According to a method for detecting printed character defects on the surface of ultrasonic radar parts based on vision provided by the present invention, the steps of judging the consistency of printed content identified by OCR text recognition technology specifically include:
[0015] Character matching: compare the recognized print content with the specified print content character by character to check whether each character is exactly the same;
[0016] String matching algorithm: If the matching efficiency is low in the character matching step due to the length of the printed content or slight format differences, the string matching algorithm is used to calculate the similarity between the recognized printed content and the specified printed content, and a similarity threshold is set. When the calculated similarity is higher than the threshold, the two contents are determined to be consistent;
[0017] Result output: Based on the results of the character matching or string matching algorithm, the judgment result of whether the recognized print content is consistent with the specified print content is output.
[0018] According to a method for detecting printed character defects on the surface of an ultrasonic radar part based on vision provided by the present invention, the step of splitting the recognized printed content into individual characters specifically includes:
[0019] Character region segmentation: In the recognized printed content image, the edges and contours of characters are detected using image processing technology, and the continuous character region is segmented into multiple independent character regions according to the spacing and layout between characters;
[0020] Character extraction and normalization: extracting character images from each independent character region and normalizing the extracted character images, including at least adjusting the size, rotation angle and position of the characters to ensure the consistency of the character images;
[0021] Character feature extraction and recognition: Extract features from the normalized character image, extract feature vectors that can represent character information, compare the extracted feature vectors with the pre-trained character library, and identify the specific content of each character;
[0022] Character splitting result output: Arrange the recognized single characters in the order of the original printed content and output the split single character sequence.
[0023] According to a vision-based ultrasonic radar part surface printed character defect detection method provided by the present invention, a single character is identified and located using deep learning target detection technology, specifically comprising:
[0024] Character candidate region generation: Extract features from the input image through a deep neural network model, and generate candidate boxes containing possible character regions based on the extracted features. The candidate boxes are generated by a region proposal network (RPN) or other region generation algorithms.
[0025] Character feature extraction: For each candidate box, a convolutional neural network or other feature extractor is used to extract the feature map of the character area. These feature maps are used for subsequent character classification and bounding box regression.
[0026] Character classification and bounding box regression: The extracted character feature map is input into the fully connected layer or other classifier to determine whether the candidate box contains characters, and bounding box regression is performed on the candidate box containing characters;
[0027] Region of interest (ROI) extraction: Based on the results of character classification and bounding box regression, a region of interest (ROI) containing a single character is extracted from the original input image as the input image for subsequent processing.
[0028] According to a method for detecting printed character defects on the surface of an ultrasonic radar part based on vision provided by the present invention, the GAN image generation model specifically includes the following steps:
[0029] Data preparation: For each single character, collect and organize its corresponding ROI image data to form a training data set;
[0030] GAN model design: Design a GAN model suitable for character ROI image generation, including a generator network and a discriminator network. The generator network is used to generate realistic character ROI images, while the discriminator network is used to distinguish the generated images from the real images.
[0031] Model training: The GAN model is trained using the training data set. During the training process, the generator network continuously tries to generate more realistic character ROI images to deceive the discriminator network. The discriminator network continuously improves its ability to distinguish between generated images and real images.
[0032] Model evaluation and optimization: After training is complete, the GAN model is evaluated to verify the quality and diversity of the images it generates;
[0033] Obtaining generative models: Obtaining GAN image generation models for each single character, which are used to generate high-quality images similar to real character ROI images.
[0034] According to a vision-based ultrasonic radar part surface printing character defect detection method provided by the present invention, the preprocessed ROI image is used as the input of the corresponding GAN image generation model, and the input image is fed into the generator network of the GAN model. The generator network generates a new character image similar to the input ROI image based on the learned character image distribution;
[0035] Generate a single character image corresponding to the input ROI image through the generator network of the GAN model, where the generated character image should be visually similar to the real character ROI image, with similar shape, texture, and detail features;
[0036] The generated character image is post-processed, and the post-processed generated character image is saved as a template.
[0037] According to a method for detecting printed character defects on the surface of ultrasonic radar parts based on vision provided by the present invention, when the GAN generative model is tested, it is observed that when the input is an ROI image of character 0 or an image similar thereto, that is, the input can be regarded as a specific pattern or feature representing 0, the output image of the model is not much different from the input image, and the shape and features of character 0 can be maintained, and the defective position in the input image can be filled, thereby generating a higher quality character 0 image;
[0038] When the input is an ROI image of a digit other than character 0, the model output image tends to generate an image similar to character 0, showing the model's preference for generating a specific character 0.
[0039] According to a method for detecting printed character defects on the surface of an ultrasonic radar part based on vision provided by the present invention, the difference between an original image of a single character and a generated single character image is obtained by using image difference, including:
[0040] Compare each pixel of the original image and the generated image one by one, calculate the absolute difference between them, and obtain a differential image; wherein each pixel value in the differential image represents the degree of difference between the original image and the generated image at that position;
[0041] A difference threshold is set, each pixel in the differential image is traversed, and pixels with difference values greater than the threshold are marked as pixels with large differences. The specific pixel positions of the defects are located on the original image or the generated image based on the marked pixels with large differences. A defect marking image is generated, in which pixels with large differences are highlighted so that the location and distribution of the defects can be viewed intuitively.
[0042] According to a method for detecting printed character defects on the surface of an ultrasonic radar part based on vision provided by the present invention, the method of obtaining the area ratio of the defects by counting the number of defective pixels and then obtaining the size score of the defects includes:
[0043] Mark each pixel in the defect area, and count the total number of pixels in the defect area, recorded as N_defect;
[0044] At the same time, the total number of pixels in the entire image area is calculated, recorded as N_total;
[0045] According to the number of defective pixels and the total number of pixels, the defect area ratio t is calculated using the formula:
[0046]
[0047] A series of defect area ratio thresholds and corresponding size score levels are preset, and the calculated defect area ratio t is compared with the preset threshold to determine the size score level to which the defect belongs;
[0048] Outputs the size score of the defect, which is used to reflect the relative size and severity of the defect in the image.
[0049] It can be seen that compared with the prior art, the present invention proposes a method for detecting printed character defects on the surface of ultrasonic radar parts based on vision, which provides a complete and efficient solution to the defects such as missing, wrong, and misaligned printed characters caused by performance and power attenuation of existing laser printing equipment. The following are the beneficial effects of the present invention:
[0050] 1. The present invention uses a camera to collect images and combines content recognition technology to capture and analyze the printed content on the surface of ultrasonic radar parts in real time. Through single character target recognition and positioning, and single character templates generated by deep learning algorithms, the present invention can accurately identify defects in printed characters, such as missing, wrong, misaligned, etc., significantly improving the accuracy of defect recognition.
[0051] 2. The solution designed by the present invention can adapt to the situation where the printed content changes in real time, and can accurately identify defects regardless of how the printed content changes. At the same time, the present invention can also cope with complex environments such as different light differences and font deformation, ensuring the stability and reliability of defect identification.
[0052] 3. Through the automated and intelligent defect detection method, the present invention greatly shortens the defect detection time and improves production efficiency. Timely identification and location of defects helps to find problems and repair them in time, reducing production waste and rework costs caused by defects.
[0053] 4. The present invention can not only identify and locate defects, but also output the threshold of defects, which provides convenience for subsequent filtering and processing. By setting a reasonable defect threshold, accurate control and management of defects can be achieved, further improving product quality and production efficiency.
[0054] 5. The implementation of the present invention will help promote the intelligent upgrade of the ultrasonic radar parts production process and improve the automation level of the production line. By introducing visual inspection and deep learning technology, it will inject new vitality into the traditional manufacturing industry and promote technological progress and innovative development in the industry.
[0055] In summary, the vision-based ultrasonic radar parts surface printed character defect detection method proposed in the present invention has the beneficial effects of improving defect recognition accuracy, strong adaptability, improving production efficiency, providing defect threshold output, and promoting intelligent upgrading. The implementation of this method will bring significant improvements and enhancements to the production process of ultrasonic radar parts, and has broad application prospects and market value.
[0056] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 It is a flow chart of an embodiment of a method for detecting printed character defects on the surface of an ultrasonic radar part based on vision of the present invention.
[0058] Figure 2 It is a schematic diagram of printed characters on the surface of an ultrasonic radar part in an embodiment of a method for detecting printed characters on the surface of an ultrasonic radar part based on vision of the present invention.
[0059] Figure 3 It is a schematic diagram of single character target recognition and positioning in an embodiment of a method for detecting character defects printed on a part surface by a vision-based ultrasonic radar of the present invention.
[0060] Figure 4 It is a schematic diagram of generating a single character template in an embodiment of a method for detecting character defects printed on a surface of an ultrasonic radar part based on vision of the present invention. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0062] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0063] See also Figures 1 to 4 This embodiment provides a method for detecting printed character defects on the surface of an ultrasonic radar part based on vision, and the method comprises the following steps:
[0064] Camera image acquisition step-S1: taking a picture of the printed characters on the surface of the ultrasonic radar part to obtain an image containing the printed characters;
[0065] Content recognition step-S2: using OCR text recognition technology to recognize the acquired image, and judging whether the recognized printed content is consistent with the specified printed content; if not, determining that there is a printing error; if consistent, further judging whether there is a defect in the printing of a single character;
[0066] Single character target recognition and positioning step - S3: split the recognized printed content into single characters, use deep learning target detection technology to recognize and locate the single characters, and extract the region of interest ROI as the input image;
[0067] Single character template generation step - S4: for each single character ROI obtained by positioning, respectively train the image generation neural network algorithm to generate a corresponding GAN image generation model; use the ROI of each single character as the input image of the corresponding GAN image generation model, generate the corresponding single character image through the model, and use the generated image as a template;
[0068] Defect location step - S5: Use image difference to obtain the difference between the original image of a single character and the generated single character image, filter out pixels with large differences through a set threshold, perform morphological operations such as binarization, dilation, and corrosion on the filtered pixels to remove noise, thereby locating the specific pixel position of the defect; count the number of defective pixels to obtain the area ratio of the defect, and then obtain the size score of the defect.
[0069] In the above-mentioned camera image acquisition step, an industrial camera is used in conjunction with a lighting device to take a picture of the characters printed on the part to obtain an image. Figure 2 As shown in the figure, the difficulties of this type of part character defects include:
[0070] 1. Even for the same part, the printed content is different, such as date, part number, etc. It can be said that the character content of each part is unique, and there is no template to compare, so template matching cannot solve the problem; 2. You can see that the fonts also change; 3. The surface of some parts is cylindrical, and the characters on both sides will be deformed when photographed.
[0071] The above difficulties cannot be solved by using traditional image processing methods. Therefore, this embodiment designs a complete solution including image acquisition, content recognition, single character target recognition and positioning, deep learning algorithm to generate single character templates, and defect positioning, which successfully realizes the defect recognition and positioning of ultrasonic radar parts under different printing content, light differences, font deformation and other environments, and can output the threshold of defects for subsequent filtering.
[0072] In the above content recognition step, the step of performing consistency judgment on the printed content recognized by using the OCR text recognition technology specifically includes:
[0073] Character matching: compare the recognized print content with the specified print content character by character to check whether each character is exactly the same;
[0074] String matching algorithm: If the matching efficiency is low in the character matching step due to the length of the printed content or slight format differences, the string matching algorithm is used to calculate the similarity between the recognized printed content and the specified printed content, and a similarity threshold is set. When the calculated similarity is higher than the threshold, the two contents are determined to be consistent;
[0075] Result output: Based on the results of the character matching or string matching algorithm, the judgment result of whether the recognized print content is consistent with the specified print content is output.
[0076] In this embodiment, the step of splitting the recognized printed content into individual characters specifically includes:
[0077] Character region segmentation: In the recognized printed content image, the edges and contours of the characters are detected using image processing technology, and the continuous character region is segmented into multiple independent character regions according to the spacing and layout between the characters. The character region segmentation can be achieved by using methods such as adaptive threshold, projection method, connected domain analysis or character region segmentation algorithm based on deep learning.
[0078] Character extraction and normalization: Extract character images from each independent character area and normalize the extracted character images, including at least adjusting the size, rotation angle and position of the characters to ensure the consistency of the character images. The normalization process can be implemented by bilinear interpolation, affine transformation or deep learning-based character normalization algorithms.
[0079] Character feature extraction and recognition: Extract features from the normalized character image, extract feature vectors that can represent character information, compare the extracted feature vectors with the pre-trained character library, and identify the specific content of each character. Character recognition can be achieved using methods such as template matching, machine learning algorithms, or deep learning algorithms.
[0080] Character splitting result output: Arrange the recognized single characters in the order of the original printed content and output the split single character sequence.
[0081] The above steps together realize the function of splitting the recognized printed content into individual characters, thereby improving the accuracy and practicality of OCR text recognition technology.
[0082] In the above single character target recognition and positioning step, deep learning target detection technology is used to recognize and locate single characters, specifically including:
[0083] Character candidate region generation: Extract features from the input image through a deep neural network model, and generate candidate boxes containing possible character regions based on the extracted features. The candidate boxes are generated through a region proposal network (RPN) or other region generation algorithms. Among them, deep neural network models include but are not limited to convolutional neural networks (CNN) and their variants, and the candidate boxes are generated through a region proposal network (RPN) or other region generation algorithms.
[0084] Character feature extraction: For each candidate box, a convolutional neural network or other feature extractor is used to extract feature maps of the character area. These feature maps are used for subsequent character classification and bounding box regression.
[0085] Character classification and bounding box regression: The extracted character feature map is input into the fully connected layer or other classifier to determine whether the candidate box contains the character, and the bounding box regression is performed on the candidate box containing the character to locate the character more accurately.
[0086] Region of Interest (ROI) extraction: Based on the results of character classification and bounding box regression, the region of interest (ROI) containing a single character is extracted from the original input image as the input image for subsequent processing. The ROI extraction process ensures the integrity and accuracy of the characters for subsequent character recognition tasks.
[0087] Among them, the above-mentioned target detection algorithm regards each character as a category, such as 0, 1, 2, 3, 4...9A, B,.....X, Y, Z, and punctuation marks, so that the printed content can be disassembled and defects can be analyzed in units of single characters.
[0088] Among them, the training data of the deep neural network model includes a large number of images marked with character positions and categories. Through supervised learning, the model learns how to accurately generate candidate boxes, extract character features, perform character classification and bounding box regression.
[0089] Specifically, the GAN image generation model includes the following steps:
[0090] Data preparation: For each single character, the corresponding ROI image data is collected and sorted to form a training dataset. The training dataset contains a sufficient number of diverse character ROI images to ensure the generalization ability of the generated model.
[0091] GAN model design: Design a GAN model suitable for character ROI image generation, including a generator network and a discriminator network, where the generator network is used to generate realistic character ROI images, while the discriminator network is used to distinguish the generated images from the real images.
[0092] Model training: The GAN model is trained using the training data set. During the training process, the generator network continuously tries to generate more realistic character ROI images to deceive the discriminator network. The discriminator network continuously improves its ability to distinguish between generated images and real images. Through this adversarial training, the generator network gradually learns to generate high-quality character ROI images.
[0093] Model evaluation and optimization: After training is completed, the GAN model is evaluated to verify the quality and diversity of its generated images. Based on the evaluation results, the model is optimized and adjusted to further improve the quality of the generated images.
[0094] Obtaining generative models: Obtaining GAN image generation models for each single character, which are used to generate high-quality images similar to real character ROI images.
[0095] Among them, the training process of the GAN model can adopt various optimization algorithms and loss functions, such as gradient descent algorithm, cross entropy loss function, etc., to ensure the training effect and stability of the model. In addition, the structure and parameters of the GAN model can be adjusted and optimized according to actual needs to meet the generation requirements of different character ROI images.
[0096] In this embodiment, the preprocessed ROI image is used as the input of the corresponding GAN image generation model, and the input image is fed into the generator network of the GAN model. The generator network generates a new character image similar to the input ROI image based on the learned character image distribution.
[0097] Through the generator network of the GAN model, a single character image corresponding to the input ROI image is generated, where the generated character image should be visually similar to the real character ROI image, with similar shape, texture, and detail features.
[0098] The generated character image is post-processed, such as removing artifacts, enhancing contrast, adjusting brightness, etc., and the post-processed generated character image is saved as a template.
[0099] When testing the GAN generative model, it was observed that when the input was an ROI image of the character 0 or an image similar to it, that is, the input could be regarded as a specific pattern or feature representing 0, the output image of the model was not much different from the input image, and was able to maintain the shape and features of the character 0, and could fill in the defective positions in the input image to generate a higher quality character 0 image; when the input was an ROI image of other digits other than the character 0, the model output image tended to generate an image similar to the character 0, showing the model's preference for generating the specific character 0.
[0100] Specifically, Figure 4 As shown, when the model takes 0 as input, the input and output are not much different (the defect position will be filled); when a non-zero number is used as input, it will also become a number similar to 0, so it is necessary to identify a single character and use the corresponding model. This embodiment will make a corresponding model for each character. For example, the character "4" is used to collect its images on various parts, lighting, and material surfaces by using the recognition and positioning of the previous single character for training the GAN model. The size and location of the defect can be analyzed by making a difference in the input and output images.
[0101] In the above defect location step, the difference between the original image of a single character and the generated single character image is obtained by image difference, including:
[0102] Each pixel of the original image and the generated image is compared one by one, and the absolute difference between them is calculated to obtain a differential image; wherein each pixel value in the differential image represents the degree of difference between the original image and the generated image at that position.
[0103] A difference threshold is set, each pixel in the differential image is traversed, and pixels with difference values greater than the threshold are marked as pixels with large differences. The specific pixel positions of the defects are located on the original image or the generated image based on the marked pixels with large differences. A defect marking image is generated, in which pixels with large differences are highlighted so that the location and distribution of the defects can be viewed intuitively.
[0104] Specifically, the number of defective pixels is counted to obtain the area ratio of the defects, and then the size score of the defects is obtained, including:
[0105] Each pixel in the defect area is marked, and the total number of pixels in the defect area is counted, recorded as N_defect.
[0106] At the same time, the total number of pixels in the entire image area is calculated and recorded as N_total.
[0107] According to the number of defective pixels and the total number of pixels, the defect area ratio t is calculated using the formula:
[0108]
[0109] A series of defect area ratio thresholds and corresponding size score levels are preset, and the calculated defect area ratio t is compared with the preset threshold to determine the size score level to which the defect belongs.
[0110] Outputs the size score of the defect, which is used to reflect the relative size and severity of the defect in the image.
[0111] The image processing algorithm includes but is not limited to edge detection, region segmentation, shape matching, etc., to ensure that the defect area can be accurately extracted. In addition, the method for determining the size score can be adjusted according to actual needs to adapt to the defect detection needs in different application scenarios.
[0112] In this embodiment, the process of performing morphological operations such as binarization, dilation, and corrosion on the filtered pixel points to remove noise can be specifically described as follows:
[0113] Binarization is the process of converting an image into only two colors (such as black and white) to simplify image information for subsequent processing. To binarize the filtered pixels, follow these steps:
[0114] Set threshold: Select a suitable threshold and set the pixels with values greater than the threshold as foreground (such as white) and the pixels with values less than the threshold as background (such as black). The choice of threshold can be determined according to the actual situation and specific needs of the image.
[0115] Apply binarization: Binarize the filtered pixels according to the set threshold to obtain a binarized image.
[0116] Dilation is a morphological operation used to expand the white area in an image. It is often used to fill small holes, connect broken parts, etc. For a binary image, the dilation operation can remove some small noise points:
[0117] Selecting a structural element: The dilation operation requires a structural element (also called a convolution kernel or filter), whose shape and size determine the effect of the dilation. Common structural elements include rectangles, circles, crosses, etc.
[0118] Apply dilation operation: slide the selected structural element on the binarized image, and if the area covered by the structural element contains foreground pixels, set the pixels at the center of the structural element as foreground. In this way, the white area (foreground) will gradually expand, thus removing some small noise points.
[0119] Erosion is a morphological operation opposite to dilation, which is used to reduce the white area in the image. It is often used to remove small isolated points, disconnected points, etc. For an image that has been dilated, the erosion operation can further remove noise and retain the main image features:
[0120] Choosing a structuring element: The erosion operation also requires a structuring element, which has the same or similar shape and size as the dilation operation.
[0121] Apply the erosion operation: slide the selected structural element on the dilated image. If the area covered by the structural element is all foreground pixels, set the pixels at the center of the structural element as foreground; otherwise, set them as background. In this way, the white area (foreground) will gradually shrink, thereby removing some of the extra noise introduced by the dilation operation.
[0122] In summary, this embodiment can capture and analyze the printed content on the surface of ultrasonic radar parts in real time by collecting images through a camera and combining it with content recognition technology. Through single character target recognition and positioning, as well as a single character template generated by a deep learning algorithm, this embodiment can accurately identify defects in printed characters, such as missing, wrong, misaligned, etc., significantly improving the accuracy of defect recognition. The solution designed in this embodiment can adapt to the situation where the printed content changes in real time, and can accurately identify defects regardless of how the printed content changes. At the same time, the present invention can also cope with complex environments such as different light differences and font deformations to ensure the stability and reliability of defect recognition.
[0123] Furthermore, through the automated and intelligent defect detection method, this embodiment greatly shortens the defect detection time and improves production efficiency. Timely identification and location of defects helps to find problems and repair them in time, reducing production waste and rework costs caused by defects.
[0124] Furthermore, this embodiment can not only identify and locate defects, but also output defect thresholds, which provides convenience for subsequent filtering and processing. By setting reasonable defect thresholds, accurate control and management of defects can be achieved, further improving product quality and production efficiency.
[0125] Furthermore, the implementation of the present invention will help promote the intelligent upgrade of the ultrasonic radar parts production process and improve the automation level of the production line. By introducing visual inspection and deep learning technology, it will inject new vitality into the traditional manufacturing industry and promote technological progress and innovative development in the industry.
[0126] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0127] The above-mentioned embodiments are only preferred embodiments of the present invention and cannot be used to limit the scope of protection of the present invention. Any non-substantial changes and substitutions made by technicians in this field on the basis of the present invention shall fall within the scope of protection required by the present invention.
Claims
1. A method for detecting printed character defects on the surface of ultrasonic radar parts based on vision, characterized in that: The following steps are involved: Camera image acquisition step: taking a picture of the printed characters on the surface of the ultrasonic radar part to obtain an image containing the printed characters; Content recognition step: using OCR text recognition technology to recognize the acquired image and determine whether the recognized print content is consistent with the specified print content; If they are inconsistent, it is determined that there is a printing error; If they are consistent, it is further determined whether there is a defect in the printing of a single character; Single character target recognition and positioning step: split the recognized printed content into single characters, use deep learning target detection technology to recognize and locate single characters, and extract the region of interest ROI as the input image; Single character template generation step: for each single character ROI obtained by positioning, the image generation neural network algorithm is trained respectively to generate the corresponding GAN image generation model; the ROI of each single character is used as the input image of the corresponding GAN image generation model, the corresponding single character image is generated through the model, and the generated image is used as the template; Defect location step: Use image difference to obtain the difference between the original image of a single character and the generated single character image, and filter out pixels with large differences through a set threshold to locate the specific pixel position of the defect; The number of defective pixels is counted to obtain the defect area ratio, and then the defect size score is obtained.
2. The method according to claim 1, characterized in that The steps of judging the consistency of the printed content recognized by the OCR text recognition technology specifically include: Character matching: compare the recognized print content with the specified print content character by character to check whether each character is exactly the same; String matching algorithm: If the matching efficiency is low in the character matching step due to the length of the printed content or slight format differences, the string matching algorithm is used to calculate the similarity between the recognized printed content and the specified printed content, and a similarity threshold is set. When the calculated similarity is higher than the threshold, the two contents are determined to be consistent; Result output: Based on the results of the character matching or string matching algorithm, the judgment result of whether the recognized print content is consistent with the specified print content is output.
3. The method according to claim 1, characterized in that The step of splitting the recognized printed content into individual characters specifically includes: Character region segmentation: In the recognized printed content image, the edges and contours of characters are detected using image processing technology, and the continuous character region is segmented into multiple independent character regions according to the spacing and layout between characters; Character extraction and normalization: extracting character images from each independent character region and normalizing the extracted character images, including at least adjusting the size, rotation angle and position of the characters to ensure the consistency of the character images; Character feature extraction and recognition: Extract features from the normalized character image, extract feature vectors that can represent character information, compare the extracted feature vectors with the pre-trained character library, and identify the specific content of each character; Character splitting result output: Arrange the recognized single characters in the order of the original printed content and output the split single character sequence.
4. The method according to claim 1, characterized in that Use deep learning target detection technology to identify and locate individual characters, including: Character candidate region generation: Extract features from the input image through a deep neural network model, and generate candidate boxes containing possible character regions based on the extracted features. The candidate boxes are generated by a region proposal network (RPN) or other region generation algorithms. Character feature extraction: For each candidate box, a convolutional neural network or other feature extractor is used to extract the feature map of the character area. These feature maps are used for subsequent character classification and bounding box regression. Character classification and bounding box regression: The extracted character feature map is input into the fully connected layer or other classifier to determine whether the candidate box contains characters, and bounding box regression is performed on the candidate box containing characters; Region of interest (ROI) extraction: Based on the results of character classification and bounding box regression, a region of interest (ROI) containing a single character is extracted from the original input image as the input image for subsequent processing.
5. The method according to claim 1, characterized in that: The GAN image generation model specifically includes the following steps: Data preparation: For each single character, collect and organize its corresponding ROI image data to form a training data set; GAN model design: Design a GAN model suitable for character ROI image generation, including a generator network and a discriminator network. The generator network is used to generate realistic character ROI images, while the discriminator network is used to distinguish the generated images from the real images. Model training: The GAN model is trained using the training data set. During the training process, the generator network continuously tries to generate more realistic character ROI images to deceive the discriminator network. The discriminator network continuously improves its ability to distinguish between generated images and real images. Model evaluation and optimization: After training is complete, the GAN model is evaluated to verify the quality and diversity of the images it generates; Obtaining generative models: Obtaining GAN image generation models for each single character, which are used to generate high-quality images similar to real character ROI images.
6. The method according to claim 5, characterized in that: The preprocessed ROI image is used as the input of the corresponding GAN image generation model. The input image is fed into the generator network of the GAN model. The generator network generates a new character image similar to the input ROI image based on the learned character image distribution. Generate a single character image corresponding to the input ROI image through the generator network of the GAN model, where the generated character image should be visually similar to the real character ROI image, with similar shape, texture, and detail features; The generated character image is post-processed, and the post-processed generated character image is saved as a template.
7. The method according to claim 1, characterized in that: When testing the GAN generative model, it was observed that when the input was an ROI image of the character 0 or an image similar to it, that is, the input could be regarded as a specific pattern or feature representing 0, the output image of the model was not much different from the input image, and could maintain the shape and features of the character 0, and could fill in the defective positions in the input image, thereby generating a higher quality character 0 image; When the input is an ROI image of a digit other than character 0, the model output image tends to generate an image similar to character 0, showing the model's preference for generating a specific character 0.
8. The method according to claim 1, characterized in that The method of obtaining the difference between the original image of a single character and the generated single character image by using image difference includes: Compare each pixel of the original image and the generated image one by one, calculate the absolute difference between them, and obtain a differential image; wherein each pixel value in the differential image represents the degree of difference between the original image and the generated image at that position; A difference threshold is set, each pixel in the differential image is traversed, and pixels with difference values greater than the threshold are marked as pixels with large differences. The specific pixel positions of the defects are located on the original image or the generated image based on the marked pixels with large differences. A defect marking image is generated, in which pixels with large differences are highlighted so that the location and distribution of the defects can be viewed intuitively.
9. The method according to any one of claims 1 to 8, characterized in that: The method of counting the number of defective pixels to obtain the area ratio of the defects and then obtaining the size score of the defects includes: Mark each pixel in the defect area, and count the total number of pixels in the defect area, recorded as N_defect; At the same time, the total number of pixels in the entire image area is calculated, recorded as N_total; According to the number of defective pixels and the total number of pixels, the defect area ratio t is calculated using the formula: A series of defect area ratio thresholds and corresponding size score levels are preset, and the calculated defect area ratio t is compared with the preset threshold to determine the size score level to which the defect belongs; Outputs the size score of the defect, which is used to reflect the relative size and severity of the defect in the image.