Method for detecting code spraying character defects of high-frequency transformer
Through Hough linear detection and filtering conditions, character areas are located, and combined with glue, position and skew detection algorithms, the problems of low efficiency and poor stability of ink-coded characters in high-frequency transformers in the prior art are solved, and efficient and accurate defect detection is achieved.
Patent Information
- Application Number
- CN202311791029.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-25
- Publication Date
- 2025-06-27
AI Technical Summary
The existing high-frequency transformer ink-coded character defect detection methods are inefficient and have poor stability, making it difficult to effectively detect defects such as glue, position errors and skews of characters.
The specified straight lines are filtered using Hough line detection and filtering conditions, positioning character areas and extracting character area images. Through glue detection, position detection and skew detection algorithms, we can determine whether the character area is glued, whether the position is wrong and whether it is skewed, so as to determine the good and bad state of the product.
It improves the efficiency and stability of character defect detection of high-frequency transformers, and can accurately detect defects such as glue, position errors and skews of characters, ensuring the accuracy of product quality and functional specifications.
Smart Images

Figure FT_1 
Figure QLYQS_1 
Figure QLYQS_2
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of defect detection, and particularly to a method for detecting defects in the inkjet characters of high-frequency transformers. Background Art
[0002] The printed characters on high-frequency transformers indicate the specifications and batch numbers, which are important bases for product use. However, defects such as character smudging, character missing printing, and character overlapping are likely to occur in the printed characters. These defects not only directly affect the appearance of the product, but also cause the loss of product function specification information due to unclear and incomplete characters, resulting in its inability to be used normally. Therefore, detecting defects in the printed characters of high-frequency transformers is of great significance for ensuring the production quality and normal use of high-frequency transformers.
[0003] Currently, the main defect detection methods are manual detection and machine vision detection. Manual detection has low efficiency, and the detection accuracy is easily affected by factors such as the experience, mood, and visual fatigue of inspectors. Machine vision is widely used in product detection, especially in the aspect of online product defect detection. Machine vision detection has become an effective detection means with its advantages of objectivity, high efficiency, accuracy, reliability, etc., and has great value and significance for ensuring product quality and improving the intelligent manufacturing level of high-frequency transformers. Summary of the Invention
[0004] The purpose of the present invention is to provide a method for detecting defects in the inkjet characters of high-frequency transformers to solve the problems of low efficiency and poor stability of manual detection. The present invention is implemented by the following steps:
[0005] A method for detecting defects in the inkjet characters of high-frequency transformers:
[0006] S1: Collect the image image of the character surface of the high-frequency transformer;
[0007] S2: Screen the specified straight lines through Hough line detection and screening conditions, locate the character area through the specified straight lines, and extract the character area image ROI;
[0008] S3: Use the glue adhesion detection algorithm to detect the image ROI, determine whether the character area is glued. If it is glued, it is a defective product, and the detection of this workpiece ends. If it is not glued, perform position detection;
[0009] S4: Use the position detection algorithm to detect the image ROI, determine whether the character position is incorrect. If the position is incorrect, it is a defective product, and the detection of this workpiece ends. If the position is correct, perform skew detection;
[0010] S5: Use the skew detection algorithm to detect the image ROI, determine whether the character is skewed. If the character is skewed, it is a defective product, and the detection of this workpiece ends. If the character is not skewed, it is a good product, and the detection of this workpiece ends.
[0011] Further, the step S2 specifically includes:
[0012] S21: Perform bilateral filtering on the character surface image image and then convert it into a binary image. Use the Hough line detection algorithm to detect all the lines and only retain the line with the longest length in the vertical direction. After calculating the inclination angle of the line, perform inclination correction on the original image image;
[0013] S22: Convert the inclination-corrected image into a binary image. Use the Hough line detection algorithm to detect all the lines and only retain the lines in the vertical direction. Select two lines that are located at the leftmost end and have the longest length and at the rightmost end and have the longest length in the retained lines. Crop the area between the two lines to obtain the character region image ROI.
[0014] Further, the step S3 specifically includes:
[0015] S31: Convert the image ROI into a grayscale image gray and calculate its grayscale histogram. Set the grayscale threshold range [gray_min, gray_max]. The number of pixels corresponding to the grayscale values within the range [gray_min, gray_max] constitutes a list gray_count, and there are N elements in the list gray_count. Make the following judgment on each element gray_count[i] (0 < i < N) in the list: gray_count[i - 1] > gray_count[i] < gray_count[i + 1];
[0016] S32: Add the grayscale values corresponding to the gray_count[i] that meet the judgment conditions to an empty list. After the above operations, obtain the list value, compare the sizes of each element in value, and obtain the maximum value value_max among them;
[0017] S33: Perform a binarization operation on the grayscale image gray, and the binarization threshold is value_max, to obtain the binarized image dst;
[0018] S34: Perform contour detection on the binarized image dst to obtain a contour list cons. Calculate the contour area of each element in the list, compare the sizes of their contour areas, obtain the maximum contour area area_max, and compare the size of area_max with the preset area threshold area_ths;
[0019] S35: If area_max ≥ area_ths, the character of the workpiece is glued, and it is a defective product. The detection of this workpiece ends. If area_max < area_ths, perform position detection.
[0020] Further, the step S4 specifically includes:
[0021] S41: Statistically count the number of white pixels in each row of the binarized image dst in step S3 from top to bottom, record the line number frist_go corresponding to the first time the number of white pixels exceeds the preset threshold white_ths, and compare whether frist_go is within the preset line number range [min_go, max_go];
[0022] S42: If frist_go is outside [min_go, max_go], the character position of the workpiece is incorrect and it is a defective product, and the detection of this workpiece ends; if frist_go is within [min_go, max_go], skew detection is performed.
[0023] Further, the step S5 specifically includes:
[0024] S51: Perform dilation processing on the binarized image dst obtained in step S3 using a 10×50 dilation kernel;
[0025] S52: Perform contour detection on the dilated binarized image to obtain all contours, calculate the area of each contour, and select the contour with the largest area;
[0026] S53: Calculate the minimum bounding rectangle corresponding to the contour with the largest area to obtain the tilt angle δ of the minimum bounding rectangle, and compare the size of δ with the preset angle threshold angle_ths;
[0027] S54: If δ≥angle_ths, the characters of the workpiece are skewed and it is a defective product, and the detection of this workpiece ends; if δ<angle_ths, the workpiece is a good product, and the detection of this workpiece ends. Description of the Drawings
[0028] Figure 1 is a flowchart of the method for detecting defects in the inkjet characters of the high-frequency transformer of the present invention. Detailed Embodiments
[0029] The following further describes the present invention in conjunction with the drawings in the specification and embodiments.
[0030] Please refer to Figure 1 as shown, the method for detecting defects in the inkjet characters of the high-frequency transformer of the present invention includes the following steps:
[0031] S1: Collect the image image of the character surface of the high-frequency transformer.
[0032] S2: Screen the specified straight lines through Hough line detection and screening conditions, locate the character area through the specified straight lines, and extract the character area image ROI.
[0033] Further, step S2 specifically includes:
[0034] S21: Perform bilateral filtering on the character surface image image and then convert it into a binary image. Use the Hough line detection algorithm to detect all straight lines and only retain the straight line with the longest length in the vertical direction. After calculating the inclination angle of the straight line, perform inclination correction on the original image image.
[0035] S22: Convert the inclination-corrected image into a binary image. Use the Hough line detection algorithm to detect all straight lines and only retain the straight lines in the vertical direction. Select the two straight lines with the longest length at the leftmost end and the rightmost end of the image from the retained straight lines, and crop the area between the two straight lines to obtain the character area image ROI.
[0036] S3: Use the glue detection algorithm to detect the image ROI, and determine whether the character area is glued. If it is glued, it is a defective product, and the detection of this workpiece ends. If it is not glued, perform position detection.
[0037] Further, step S3 specifically includes:
[0038] S31: Convert the image ROI into a grayscale image gray and calculate its grayscale histogram. Set the grayscale threshold range [gray_min, gray_max]. The number of pixels corresponding to the grayscale values within the range [gray_min, gray_max] constitutes a list gray_count, and there are N elements in the list gray_count. Perform the following judgment on each element gray_count[i] (0 < i < N) in the list: gray_count[i - 1] > gray_count[i] < gray_count[i + 1];
[0039] S32: Add the grayscale values corresponding to the gray_count[i] that meet the judgment conditions to an empty list. After the above operations, obtain the list value, compare the sizes of each element in the value, and obtain the maximum value value_max among them;
[0040] S33: Perform a binarization operation on the grayscale image gray, and the binarization threshold is value_max, to obtain the binarized image dst;
[0041] S34: Perform contour detection on the binary image dst to obtain a contour list cons, calculate the contour area of each element in the list, compare the contour area sizes, obtain the maximum contour area area_max, and compare the size of area_max with the preset area threshold area_ths;
[0042] S35: If area_max ≥ area_ths, the characters of the workpiece are glued, and it is a defective product. The detection of this workpiece ends. If area_max < area_ths, perform position detection.
[0043] S4: The position detection algorithm detects the image ROI, determines whether the character position is incorrect. If the position is incorrect, it is a defective product, and the detection of this workpiece ends. If the position is correct, perform skew detection.
[0044] Further, step S4 specifically includes:
[0045] S41: Statistically count the number of white pixels in each row of the binary image dst in step S3 from top to bottom, record the row number frist_go corresponding to the first time the number of white pixels exceeds the preset threshold white_ths, and compare whether frist_go is within the preset row number range [min_go, max_go];
[0046] S42: If frist_go is outside [min_go, max_go], the character position of the workpiece is incorrect, and it is a defective product. The detection of this workpiece ends. If frist_go is within [min_go, max_go], perform skew detection.
[0047] S5: The skew detection algorithm detects the image ROI, determines whether the character is skewed. If the character is skewed, it is a defective product, and the detection of this product ends. If the character is not skewed, it is a good product, and the detection of this product ends.
[0048] Further, step S5 specifically includes:
[0049] S51: Use a 10×50 dilation kernel to perform dilation processing on the binary image dst obtained in step S3;
[0050] S52: Perform contour detection on the dilated binary image to obtain all contours, calculate the area of each contour, and screen out the contour with the largest area;
[0051] S53: Calculate the minimum bounding rectangle corresponding to the contour with the largest area, obtain the tilt angle δ of the minimum bounding rectangle, and compare the size of δ with the preset angle threshold angle_ths;
[0052] S54: If δ ≥ angle_ths, the characters of the workpiece are skewed and it is a defective product, and the inspection of this workpiece ends. If δ < angle_ths, the workpiece is a good product and the inspection of this workpiece ends.
[0053] As described above, it is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art in this technical field modifies the technical solution recorded in the present invention, or makes equivalent replacements for some of the technical features, and these should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claimed rights.
Claims
1. A method for detecting defects in the inkjet printing characters of a high-frequency transformer, characterized in that, It includes the following steps: S1: Collect the character surface image image of the high-frequency transformer; S2: Screen the specified lines through the Hough line detection and screening conditions, locate the character area through the specified lines, and extract the character area image ROI; S3: Use the glue detection algorithm to detect the image ROI, judge whether the character area is glued. If it is glued, it is a defective product and the detection of this workpiece ends. If it is not glued, perform position detection; S4: Use the position detection algorithm to detect the image ROI, judge whether the character position is incorrect. If the position is incorrect, it is a defective product and the detection of this workpiece ends. If the position is correct, perform skew detection; S5: Use the skew detection algorithm to detect the image ROI, judge whether the character is skewed. If the character is skewed, it is a defective product and the detection of this workpiece ends. If the character is not skewed, it is a good product and the detection of this workpiece ends.
2. The method for detecting the character defect of the ink jet printing on the high-frequency transformer according to claim 1, wherein The specific steps of step S2 include: S21: Perform bilateral filtering on the character surface image image and then convert it into a binary image. Use the Hough line detection algorithm to detect all lines and only retain the line with the longest length in the vertical direction. Calculate the inclination angle of the line and then perform inclination correction on the original image image; S22: Convert the inclination-corrected image into a binary image. Use the Hough line detection algorithm to detect all lines and only retain the lines in the vertical direction. Select the two lines with the longest length at the leftmost end of the image and the two lines with the longest length at the rightmost end of the image from the retained lines. Crop the area between the two lines to obtain the character area image ROI.
3. A method for detecting defects in the inkjet printing characters of a high-frequency transformer according to claim 1, characterized in that The specific steps of step S3 include: S31: Convert the image ROI to a grayscale image gray and calculate its grayscale histogram. Set the grayscale threshold range , within , the number of pixels corresponding to the grayscale values within the range forms a list . For each element in the list , perform the following judgment: ; S32: Add the grayscale values that meet the judgment conditions to an empty list. After the above operations, the list is obtained. Compare the sizes of each element in to obtain the maximum value among them ; S33: Perform a binarization operation on the grayscale image gray with a binarization threshold of to obtain a binary image dst; S34: Perform contour detection on the binary image dst to obtain a contour list , calculate the contour area of each element in the list, compare the sizes of their contour areas, and obtain the maximum contour area , compare with the preset area threshold ; S35: If , the characters of the workpiece are glued, and it is a defective product. The inspection of this workpiece is completed. If , position detection is performed.
4. A method for detecting defects in the inkjet printing characters of a high-frequency transformer according to claim 1, characterized in that, The specific steps of step S4 include: S41: Statistically count the number of white pixels in each row of the binarized image dst from top to bottom in step S3, and record the row number corresponding to the first time the number of white pixels exceeds a preset threshold, and compare whether it is within the preset row number range; corresponding row number , compare whether it is within the preset row number range ; S42: If is located outside , the character position of the workpiece is incorrect, and it is a defective product. The inspection of this workpiece ends. If is located inside , skew detection is performed.
5. A method for detecting defects in the inkjet printing characters of a high-frequency transformer according to claim 1, characterized in that, The specific steps of step S5 include: S51: Use to perform dilation processing on the binary image dst obtained in step S3 with a dilation kernel; S52: Perform contour detection on the dilated binary image to obtain all contours, calculate the area of each contour, and select the contour with the largest area; S53: Calculate the minimum bounding rectangle corresponding to the contour with the largest area, and obtain the inclination angle of the minimum bounding rectangle , compare with the preset angle threshold for their magnitudes; S54: If , the characters of the workpiece are skewed, and it is a defective product. The inspection of this workpiece ends. If , the workpiece is a good product, and the inspection of this workpiece ends.