Sawtooth defect detection method and device, electronic device, computer storage medium
By acquiring images of printed products and utilizing the relationship between edge lines and convex hulls, as well as the change in tilt angle, accurate detection of jagged defects was achieved. This solved the problems of easy omissions during manual observation and insufficient samples in deep learning, thus improving detection accuracy and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-02
- Publication Date
- 2026-04-14
AI Technical Summary
In existing technologies, the detection of jagged defects in printed products relies on manual observation, which is prone to missed detections, and the deep neural network model has insufficient training samples, resulting in low detection accuracy.
By acquiring an image of the object to be inspected, determining the edge lines and calculating the convex hull, the edge lines with the shortest distance greater than zero are the target edge lines, and the lengths not less than a preset value are determined as concave regions. The serrated defects in the concave regions are judged by the change in tilt angle, thus achieving accurate detection.
Accurate detection can be achieved without a large number of serrated defect samples, improving the accuracy and efficiency of serrated defect detection.
Smart Images

Figure CN115496701B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of defect detection technology, and in particular to a method and apparatus for detecting sawtooth defects, electronic equipment, and computer storage medium. Background Technology
[0002] Printing technology is widely used in industrial production. Besides well-known ink printing and laser engraving, printing technology also includes techniques using various etching methods. However, existing printing technologies, due to limitations in the printing process, may result in localized protrusions or depressions at the edges of the printed image. These localized protrusions or depressions are defined in the printing field as jagged defects.
[0003] Therefore, to ensure the quality of printed products, it is generally necessary to inspect them for serration defects in industrial production. Currently, the inspection of serration defects mainly relies on manual observation. However, some companies have begun to explore deep neural network models for serration defect detection.
[0004] However, small serrated defects are difficult to observe with the naked eye and are easily missed. Furthermore, for detection methods using deep neural network models, the proportion of serrated defects is relatively low due to the relatively mature printing technology, resulting in a smaller sample size and consequently, lower accuracy of the detection results from the trained deep neural network models. Summary of the Invention
[0005] In view of the shortcomings of the prior art, this application provides a method and apparatus for detecting serrated defects, an electronic device, and a computer storage medium to solve the problem of inaccurate detection of serrated defects in printing by the prior art.
[0006] To achieve the above objectives, this application provides the following technical solution:
[0007] The first aspect of this application provides a method for detecting sawtooth defects, including:
[0008] Acquire an image of the item to be inspected; wherein the image to be inspected includes the image to be inspected;
[0009] The edge lines of the graphic to be detected are determined;
[0010] The target edge lines with a length not less than a preset length are defined as concave regions, and the remaining target edge lines are defined as convex regions with jagged defects; wherein, the target edge lines are edge lines where the shortest distance between each point and the convex hull of the edge line is greater than zero;
[0011] For each of the concave regions, a serrated defect in the concave region is determined; wherein, the change in the angle between each point on the serrated defect and the two lines connecting two points that belong to the same concave region and are equidistant from it is greater than a preset change.
[0012] Optionally, in the above method, acquiring the image of the item to be detected includes:
[0013] Acquire images of the item to be inspected;
[0014] The preset detection area in the image of the item to be detected is determined as the image of the item to be detected.
[0015] Optionally, in the above method, determining the edge lines of the graphic to be detected includes:
[0016] Based on a preset binarization threshold, the image to be detected is binarized to convert the image to be detected and the regions that do not belong to the image to be detected into white and black, respectively.
[0017] Boundary tracking is performed on the binarized image to be detected to obtain the edge lines of the image to be detected.
[0018] Optionally, in the above method, defining the target edge line with a length not less than a preset length as a concave region and defining the remaining target edge lines as convex regions with jagged defects includes:
[0019] Calculate the convex hull of the edge line and determine the shortest distance between each point on the edge line and the convex hull of the edge line;
[0020] Identify all points on the edge line whose shortest distance to the convex hull of the edge line is greater than zero;
[0021] Each edge segment, consisting of points whose shortest distance to the convex hull of the edge line is greater than zero, is defined as the target edge line;
[0022] Determine whether the length of the target edge line is less than the preset length; wherein the preset length is greater than the preset maximum length of the sawtooth defect and less than the preset length of the normal concave region;
[0023] If it is determined that the length of the target edge line is less than the preset length, then the target edge line is identified as a convex region sawtooth defect.
[0024] If it is determined that the length of the target edge line is not less than the preset length, then the target edge line is defined as a concave region.
[0025] Optionally, in the above method, determining the concave region serration defect for each of the concave regions includes:
[0026] For each of the concave regions, each point in the concave region is sequentially taken as the target point;
[0027] Based on the coordinates of the target point and the reference point corresponding to the target point, the cosine value of the inclination angle corresponding to the target point is calculated; wherein, the cosine value of the inclination angle corresponding to the target point is the cosine value of the inclination angle of the line connecting the target point and the first reference point corresponding to the target point; the first reference point corresponding to the target point refers to the point on the concave region, located after the target point, and at a distance of a preset interval from the target point;
[0028] Calculate the absolute value of the difference between the cosine value of the inclination angle corresponding to the target point and the cosine value of the inclination angle corresponding to the second reference point corresponding to the target point; wherein, the second reference point corresponding to the target point is a point on the concave region located behind and in front of the target point, and the distance between the target point and the target point is a preset distance.
[0029] Determine whether the absolute value of the difference between the cosine value of the tilt angle corresponding to the target point and the cosine value of the tilt angle corresponding to the second reference point is greater than the preset change amount; wherein, the preset change amount is equal to the ratio of the preset minimum sawtooth height to the preset interval distance; the preset interval distance is greater than 5 times the preset minimum sawtooth height;
[0030] If it is determined that the absolute value of the difference between the cosine value of the tilt angle corresponding to the target point and the cosine value of the tilt angle corresponding to the second reference point is greater than the preset change amount, then the target point is determined as the sawtooth defect point in the concave region.
[0031] Each segment of the edge line, composed of continuous sawtooth defect points, is defined as a sawtooth defect in the concave region.
[0032] A second aspect of this application provides a sawtooth defect detection device, comprising:
[0033] An acquisition unit is used to acquire an image of an item to be detected; wherein the image to be detected includes an image to be detected.
[0034] An edge line determination unit is used to determine the edge lines of the graphic to be detected;
[0035] The first detection unit is used to identify target edge lines with a length not less than a preset length as concave regions and the remaining target edge lines as convex region sawtooth defects; wherein, the target edge lines are edge lines where the shortest distance between each point and the convex hull of the edge line is greater than zero;
[0036] The second detection unit is used to determine the serration defect in each of the concave regions; wherein the change in the angle between each point on the serration defect and the two lines connecting two points that belong to the same concave region and are equidistant from it is greater than a preset change.
[0037] Optionally, in the above-described apparatus, the acquiring unit includes:
[0038] The acquisition unit is used to acquire images of the item to be inspected.
[0039] The cropping unit is used to determine the preset detection area in the image of the object to be detected as the image of the object to be detected.
[0040] Optionally, in the above-described apparatus, the edge line determination unit includes:
[0041] The processing unit is used to perform binarization processing on the image to be detected based on a preset binarization threshold, so as to convert the image to be detected and the regions that do not belong to the image to be detected into white and black, respectively.
[0042] The edge line determination subunit performs boundary tracking on the binarized image to be detected to obtain the edge lines of the image to be detected.
[0043] Optionally, in the above-described apparatus, the first detection unit includes:
[0044] The first calculation unit is used to calculate the convex hull of the edge line and determine the shortest distance between each point on the edge line and the convex hull of the edge line;
[0045] The first determining unit is used to determine each point on the edge line whose shortest distance to the convex hull of the edge line is greater than zero;
[0046] The second determining unit is used to determine each edge line segment composed of points whose shortest distance to the convex hull of the edge line is greater than zero as the target edge line;
[0047] The first judgment unit is used to determine whether the length of the target edge line is less than the preset length; wherein the preset length is greater than the preset maximum length of the sawtooth defect and less than the preset length of the normal concave area;
[0048] A convex region sawtooth defect determination unit is used to determine the target edge line as a convex region sawtooth defect when the first determination unit determines that the length of the target edge line is less than the preset length.
[0049] The concave region determination unit is used to determine the target edge line as a concave region when the first determination unit determines that the length of the target edge line is not less than the preset length.
[0050] Optionally, in the above-described apparatus, the second detection unit includes:
[0051] A selection unit is used to sequentially select each point in each of the concave regions as a target point for each concave region.
[0052] The second calculation unit is used to calculate the cosine value of the inclination angle corresponding to the target point based on the coordinates of the target point and the reference point corresponding to the target point; wherein, the cosine value of the inclination angle corresponding to the target point is the cosine value of the inclination angle of the line connecting the target point and the first reference point corresponding to the target point; the first reference point corresponding to the target point refers to a point on the concave region that is located after the target point and is spaced at a preset distance from the target point;
[0053] The third calculation unit is used to calculate the absolute value of the difference between the inclination cosine value corresponding to the target point and the inclination cosine value corresponding to the second reference point corresponding to the target point; wherein, the second reference point corresponding to the target point is a point on the concave region located behind and in front of the target point, and the distance between the target point and the target point is a preset distance.
[0054] The second judgment unit is used to determine whether the absolute value of the difference between the inclination cosine value corresponding to the target point and the inclination cosine value corresponding to the second reference point is greater than the preset change amount; wherein, the preset change amount is equal to the ratio of the preset minimum sawtooth height to the preset interval distance; the preset interval distance is greater than 5 times the preset minimum sawtooth height;
[0055] A sawtooth defect point determination unit is used to determine the target point as a sawtooth defect point in the concave region when the second judgment unit determines that the absolute value of the difference between the inclination cosine value corresponding to the target point and the inclination cosine value corresponding to the second reference point of the target point is greater than the preset change amount.
[0056] The third determining unit is used to determine each segment of the edge line, which is composed of continuous sawtooth defect points, as a concave region sawtooth defect.
[0057] A third aspect of this application provides an electronic device, comprising:
[0058] Memory and processor;
[0059] The memory is used to store programs;
[0060] The processor is used to execute the program, which, when executed, is specifically used to implement the sawtooth defect detection method as described in any of the above.
[0061] The fourth aspect of this application provides a computer storage medium for storing a computer program, which, when executed, is used to implement the sawtooth defect detection method as described in any of the preceding claims.
[0062] This application provides a method for detecting jagged defects. It acquires an image of the object to be inspected, including the image itself, and determines the edge lines of the graphic. Then, edge lines where the shortest distance between each point and the convex hull of the edge line is greater than zero are designated as target edge lines. Since the length of a concave region is greater than the length of a jagged defect in a convex region, target edge lines with a length not less than a preset length are designated as concave regions, and the remaining target edge lines are designated as jagged defects in convex regions. Thus, by analyzing the positional relationship between the edge lines and the convex hull, concave regions and jagged defects in convex regions are determined. Finally, because jagged defects in concave regions are not smooth, for each concave region, the edge lines formed by the points whose angle of inclination changes more than a preset amount when connecting two equidistant points belonging to the same concave region are defined as jagged defects in the concave region. This method accurately detects jagged defects in the entire image without requiring the collection of a large number of jagged defect samples. Attached Figure Description
[0063] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0064] Figure 1 A flowchart of a sawtooth defect detection method provided in an embodiment of this application;
[0065] Figure 2 A flowchart illustrating a method for acquiring an image to be detected, provided in an embodiment of this application;
[0066] Figure 3 An image of the object to be detected and a schematic diagram of the image to be detected in an example provided for an embodiment of this application;
[0067] Figure 4 A schematic diagram of the edge lines of the graphic to be detected in an example provided for an embodiment of this application;
[0068] Figure 5 A schematic diagram of the convex and concave regions in a pattern to be detected in an example provided in an embodiment of this application;
[0069] Figure 6 A schematic diagram illustrating the relationship between edge lines and jagged defects in an example provided for an embodiment of this application;
[0070] Figure 7 A flowchart illustrating a method for determining convex serration defects and concave regions, provided in an embodiment of this application;
[0071] Figure 8 A flowchart illustrating a method for determining serrated defect points in a concave region, provided as an embodiment of this application;
[0072] Figure 9 A schematic diagram of the cosine value of the inclination angle of a point in an example provided in an embodiment of this application;
[0073] Figure 10 This is a schematic diagram of a sawtooth defect detection device provided in another embodiment of this application;
[0074] Figure 11 This is a schematic diagram of the structure of an electronic device provided in another embodiment of this application. Detailed Implementation
[0075] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0076] In this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0077] This application provides a method for detecting sawtooth defects, such as... Figure 1 As shown, the specific steps include:
[0078] S101. Obtain the image of the item to be detected; the image to be detected includes the image to be detected.
[0079] It should be noted that the graphic to be detected in the image is the area printed on the item to be detected.
[0080] Optionally, in another embodiment of this application, a specific implementation of step S101 is as follows: Figure 2 As shown, it includes:
[0081] S201. Acquire images of the items to be inspected.
[0082] First, image acquisition of the item to be inspected is required. Image acquisition must clearly show the printed area on the workpiece and, as far as possible, allow the human eye to identify areas with jagged defects. Image acquisition can be achieved using an industrial camera for capturing images or scanning. Taking a mobile phone back panel as an example, an industrial line scan camera can be used to scan the back panel. A schematic diagram of the scanned image is shown below. Figure 3 As shown in the left image, the pattern on the back of the phone is the printed area. In this image, two obvious jagged defects can be observed in the printed area, located at the upper left corner and the right recess of the printed area, respectively.
[0083] S202. The preset detection area in the image of the item to be detected is determined as the image of the item to be detected.
[0084] Since the image of the entire item to be inspected is relatively large, and the main area to be inspected is the printing area, it is not necessary to process the entire image of the item to be inspected. Therefore, in order to reduce the workload, a partial image of the item to be inspected containing the printing area can be extracted from the image of the item to be inspected.
[0085] Optionally, when inspecting items generated on the production line, since the printed areas on each item are roughly in the same position in the captured image, the printed areas requiring serration detection can be located by pre-setting the inspection area. Again, using a mobile phone back panel as an example, as shown in the figure... Figure 3 As shown in the left image, the region to be detected is located in the center of the acquired image. Therefore, the central region of the image is set as the preset region to be detected. The acquired image is then cropped according to the preset region to be detected. The cropped image is as follows: Figure 3 As shown in the right figure.
[0086] S102. Determine the edge lines of the graphic to be detected.
[0087] Specifically, the edge lines of the image to be detected can be obtained by tracing the edge lines of the graphic to be detected in the image to be detected.
[0088] Optionally, this application provides a specific implementation of step S102:
[0089] Based on a preset binarization threshold, the image to be detected is binarized to convert the target graphic and the regions that do not belong to the target graphic into white and black, respectively. Then, boundary tracking is performed on the binarized image to obtain the edge lines of the target graphic.
[0090] The graphic to be detected is a graphic printed on the item to be detected using printing technology.
[0091] It should be noted that image binarization is the process of setting the grayscale value of pixels in an image to 0 or 255, thereby presenting the entire image with a clear black and white effect. This makes it easier to determine the edge lines of the graphic to be detected, but will not determine the edge lines of other graphics in the image to be detected.
[0092] In this application, a binarization threshold can be set based on the color of the image to be detected and the color of the area not belonging to the image to be detected, i.e., the background color. Then, based on the preset binarization threshold, the image to be detected is binarized, thereby turning the image to be detected into white (i.e., setting the grayscale value of the image to 255) and turning the background area into black (i.e., setting the grayscale value of the background area to 0).
[0093] Optionally, a digital binary image topology analysis algorithm based on boundary tracking can be used to process the binarized image to be detected, thereby determining the edge lines of the target graphic in the image. For example, for the image to be detected in the above example, its edge lines can be determined as follows: Figure 4 As shown.
[0094] S103. Define the target edge line with a length not less than the preset length as a concave region, and define the remaining target edge lines as convex region sawtooth defects; the target edge line is the edge line where the shortest distance between each point and the convex hull of the edge line is greater than zero.
[0095] Among them, the serrated defect in the convex area refers to the serrated defect on the convex area of the edge line.
[0096] It should be noted that, in this embodiment, the edge lines of the image to be detected are divided into convex and concave regions, both defined on the edge lines of a smooth graphic. A convex region is defined as a portion of the edge line that is prominent or straight relative to the entire closed pattern. A concave region is defined as the edge line that is recessed relative to the entire closed pattern. For example, as... Figure 5 As shown in the figure, the areas marked by white ellipses are concave areas, while the unmarked areas are convex areas.
[0097] The convex hull is a concept in computational geometry. Its rigorous mathematical definition is: In a vector space V, for a given set X, the intersection S of all convex sets containing X is called the convex hull of X.
[0098] Alternatively, the Graham Scan algorithm can be used to calculate the convex hull of the edge lines.
[0099] Since the convex region of an edge line does not have jagged edges, the convex hull corresponding to the edge line coincides with a point on the edge line. Therefore, by finding the shortest distance between each point on the edge line and its convex hull, we can determine whether the convex region of the edge line coincides with the convex hull, and thus determine whether jagged edges exist in the convex region of the edge line. For example, as... Figure 6 As shown, the solid lines represent the edge lines of the graphic to be inspected, and the dashed lines represent the convex hull of the edge lines. Therefore, it is clear that when jagged defects exist, the shortest distance between the points on the edge lines of the jagged defects and the points on the convex hull is not zero.
[0100] It should be noted that the region where the shortest distance between a point on the edge line and a point on the convex hull is not zero, i.e., the target edge line in this embodiment, is not necessarily a jagged defect. Since the concave region and the convex hull do not coincide, the target edge line may also be a concave region on the graphic to be detected.
[0101] Since jagged defects are relatively small compared to concave areas, a preset length can be used to determine whether the target edge line belongs to a concave area. If the target edge line is not shorter than the preset length, it is determined to belong to a concave area. If the target edge line is shorter than the preset length, it means it does not belong to a concave area. In a convex area, the region where the shortest distance between a point on the edge line and a point on the convex hull is not zero is a jagged defect. Therefore, if the target edge line is shorter than the preset length, it is determined to be a convex area jagged defect.
[0102] Optionally, in another embodiment of this application, a specific implementation of step S105 is as follows: Figure 7 As shown, it includes:
[0103] S701. Calculate the convex hull of the edge line and determine the shortest distance between each point on the edge line and the convex hull of the edge line.
[0104] S702. Identify all points on the edge line whose shortest distance to the convex hull of the edge line is greater than zero.
[0105] S703. Determine each edge line segment formed by points whose shortest distance to the convex hull of the edge line is greater than zero as the target edge line.
[0106] S704. Determine whether the length of the target edge line is less than the preset length.
[0107] The preset length is greater than the preset maximum length of the sawtooth defect, but less than the preset length of the normal concave area. The preset maximum length of the sawtooth defect can be set according to the inspection standard, while the length of the normal concave area can be obtained by manually tracing the length of the line connecting all the normal concave areas.
[0108] It should be noted that if the length of the target edge line is determined to be less than the preset length, step S705 is executed. If the length of the target edge line is determined to be not less than the preset length, step S706 is executed.
[0109] S705. Define the target edge line as a convex area sawtooth defect.
[0110] S706. Define the target edge line as a concave region.
[0111] S104. For each concave region, determine the concave region sawtooth defects; the change in the angle between each point on the concave region sawtooth defect and the two lines connecting the two points that belong to the same concave region and are equidistant from it is greater than the preset change.
[0112] For detecting serrated defects in concave regions, this embodiment of the application detects them by calculating the change in the angle of inclination of each point in the concave region relative to the line segment connecting two equidistant points. Since the change in angle is smaller in areas without serrated defects and larger in areas with serrated defects, the serrated defect points in each concave region can be identified. Specifically, points in the concave region where the change in angle of inclination of the two line segments connecting to the two equidistant points before and after the defect is greater than a preset change can be identified. The locations of these points are the serrated defects in the concave region.
[0113] Optionally, in another embodiment of this application, a specific implementation of step S106 is as follows: Figure 8 As shown, it includes the following steps:
[0114] S801. For each concave region, take each point in the concave region as the target point in turn.
[0115] S802. Based on the coordinates of the target point and the reference point corresponding to the target point, calculate the cosine value of the inclination angle corresponding to the target point.
[0116] The cosine of the inclination angle corresponding to the target point is the cosine of the inclination angle of the line connecting the target point and its corresponding first reference point. The first reference point corresponding to the target point refers to a point on the concave region located behind the target point and at a preset interval distance from the target point. The preset interval distance refers to the distance between the two points on the edge line, not the straight-line distance between the two points.
[0117] It should be noted that by calculating the cosine of the inclination angle of the line connecting each point to a point immediately preceding it at a predetermined distance, the cosine of the inclination angle of the line connecting each point to two equidistant points can be obtained. This is because the cosine of the inclination angle of the line connecting a point to a point immediately preceding it at a predetermined distance was already calculated when that point was used as the first reference point. For example, as... Figure 9 As shown, for point P n (x n ,y n The first reference point corresponding to it is: P n+D (x n+D ,y n+D Therefore, P n The corresponding cosine value of the inclination angle is: P n The corresponding second reference point is: P n-D (x n-D ,y n-D ), in calculating P n-D When calculating the cosine of the inclination angle, the corresponding cosine value θ can be obtained using the same method. n-D .
[0118] S803. Calculate the absolute value of the difference between the cosine value of the inclination angle corresponding to the target point and the cosine value of the inclination angle corresponding to the second reference point.
[0119] The second reference point corresponding to the target point is a point on the concave region, located behind and in front of the target point, and at a distance of a preset interval from the target point.
[0120] S804. Determine whether the absolute value of the difference between the cosine value of the inclination angle corresponding to the target point and the cosine value of the inclination angle corresponding to the second reference point is greater than the preset change amount.
[0121] The preset variation is equal to the ratio of the preset minimum sawtooth height to the preset interval distance. The preset interval distance is greater than 5 times the preset minimum sawtooth height. The preset minimum sawtooth height can be set according to the detection standard. The preset interval distance can be set based on experience, provided it is greater than 5 times the preset minimum sawtooth height.
[0122] It should be noted that if the absolute value of the difference between the inclination cosine value corresponding to the target point and the inclination cosine value corresponding to the second reference point is greater than the preset change, then the straight line step S805 is performed for the target point.
[0123] S805. The target point is determined as the sawtooth defect point in the concave region.
[0124] S806. Each segment of the edge line, which consists of continuous sawtooth defect points, is defined as a concave region sawtooth defect.
[0125] After performing step S104, all convex and concave serration defects are integrated into the detection result, and the detection result is fed back.
[0126] This application provides a method for detecting jagged defects. It acquires an image of the object to be inspected, including the image itself, and determines the edge lines of the graphic. Then, edge lines where the shortest distance between each point and the convex hull of the edge line is greater than zero are designated as target edge lines. Since the length of a concave region is greater than the length of a jagged defect in a convex region, target edge lines with a length not less than a preset length are designated as concave regions, and the remaining target edge lines are designated as jagged defects in convex regions. Thus, by analyzing the positional relationship between the edge lines and the convex hull, concave regions and jagged defects in convex regions are determined. Finally, because jagged defects in concave regions are not smooth, for each concave region, the edge lines formed by the points whose angle of inclination changes more than a preset amount when connecting two equidistant points belonging to the same concave region are defined as jagged defects in the concave region. This method accurately detects jagged defects in the entire image without requiring the collection of a large number of jagged defect samples.
[0127] Another embodiment of this application provides a sawtooth defect detection device, such as... Figure 10 As shown, it includes the following units:
[0128] The acquisition unit 1001 is used to acquire the image of the object to be detected.
[0129] The image to be detected includes the image to be detected.
[0130] Edge line determination unit 1002 is used to determine the edge lines of the graphic to be detected.
[0131] The first detection unit 1003 is used to identify target edge lines with a length not less than a preset length as concave areas and the remaining target edge lines as convex areas with sawtooth defects.
[0132] The target edge line is the edge line where the shortest distance between each point and the convex hull of the edge line is greater than zero.
[0133] The second detection unit 1004 is used to determine the serration defects in each concave area.
[0134] Among them, the change in the angle between each point on the sawtooth defect in the concave region and the two lines connecting the two points that belong to the same concave region and are located at equal distances in front of and behind it is greater than the preset change.
[0135] Optionally, in another embodiment of the sawtooth defect detection device provided in this application, the acquisition unit includes:
[0136] The acquisition unit is used to acquire images of the item to be inspected.
[0137] The cropping unit is used to determine the preset detection area in the image of the object to be detected as the image of the object to be detected.
[0138] Optionally, in another embodiment of the sawtooth defect detection device provided in this application, the edge line determination unit includes:
[0139] The processing unit is used to perform binarization processing on the image to be detected based on a preset binarization threshold, so as to convert the image to be detected and the regions that do not belong to the image to be detected into white and black, respectively.
[0140] The edge line determination sub-unit performs boundary tracking on the binarized image to be detected, and obtains the edge lines of the image to be detected.
[0141] Optionally, in another embodiment of the sawtooth defect detection device provided in this application, the first detection unit includes:
[0142] The first calculation unit is used to calculate the convex hull of the edge line and determine the shortest distance between each point on the edge line and the convex hull of the edge line.
[0143] The first determining unit is used to determine each point on the edge line whose shortest distance to the convex hull of the edge line is greater than zero.
[0144] The second determining unit is used to determine each edge line segment, which is composed of points whose shortest distance to the convex hull of the edge line is greater than zero, as the target edge line.
[0145] The first judgment unit is used to determine whether the length of the target edge line is less than the preset length.
[0146] The preset length is greater than the preset maximum length of the sawtooth defect, but less than the preset length of the normal concave area.
[0147] The convex region sawtooth defect determination unit is used to determine the target edge line as a convex region sawtooth defect when the first determination unit determines that the length of the target edge line is less than the preset length.
[0148] The concave region determination unit is used to determine the target edge line as a concave region when the first determination unit determines that the length of the target edge line is not less than a preset length.
[0149] Optionally, in another embodiment of the sawtooth defect detection device provided in this application, the second detection unit includes:
[0150] Select a cell to treat each point in a concave region as a target point in turn.
[0151] The second calculation unit is used to calculate the cosine value of the tilt angle corresponding to the target point based on the coordinates of the target point and the reference point corresponding to the target point.
[0152] The cosine of the inclination angle corresponding to the target point is the cosine of the inclination angle of the line connecting the target point and its corresponding first reference point. The first reference point corresponding to the target point refers to a point on the concave region located behind the target point and at a preset distance from the target point.
[0153] The third calculation unit is used to calculate the absolute value of the difference between the cosine value of the inclination angle corresponding to the target point and the cosine value of the inclination angle corresponding to the second reference point.
[0154] The second reference point corresponding to the target point is a point on the concave region, located behind and in front of the target point, and at a distance of a preset interval from the target point.
[0155] The second judgment unit is used to determine whether the absolute value of the difference between the inclination cosine value corresponding to the target point and the inclination cosine value corresponding to the second reference point is greater than a preset change amount.
[0156] The preset variation is equal to the ratio of the preset minimum sawtooth height to the preset interval distance. The preset interval distance is greater than 5 times the preset minimum sawtooth height.
[0157] The sawtooth defect point determination unit is used to determine the target point as a sawtooth defect point in the concave region when the absolute value of the difference between the inclination cosine value corresponding to the target point and the inclination cosine value corresponding to the second reference point is greater than a preset change value determined by the second judgment unit.
[0158] The third determining unit is used to determine each segment of the edge line, which is composed of continuous sawtooth defect points, as a concave region sawtooth defect.
[0159] It should be noted that the specific working process of each unit provided in the above embodiments of this application can be referred to the implementation process of the corresponding steps in the above method embodiments, and will not be repeated here.
[0160] Another embodiment of this application provides an electronic device, such as... Figure 11 As shown, it includes:
[0161] Memory 1101 and processor 1102.
[0162] The memory 1101 is used to store a program. The processor 1102 is used to execute the program stored in the memory 1101, and when the program is executed, it is specifically used to implement the sawtooth defect detection method provided in any of the above embodiments.
[0163] Another embodiment of this application provides a computer storage medium for storing a computer program, which, when executed, is used to implement the sawtooth defect detection method provided in any of the above embodiments.
[0164] Computer storage media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0165] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0166] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for detecting sawtooth defects, characterized in that, include: Acquire an image of the item to be detected; wherein the image to be detected includes a graphic to be detected; The edge lines of the graphic to be detected are determined; The target edge lines with a length not less than a preset length are defined as concave regions, and the remaining target edge lines are defined as convex regions with jagged defects; wherein, the target edge lines are edge lines where the shortest distance between each point and the convex hull of the edge line is greater than zero; For each of the concave regions, a sawtooth defect in the concave region is determined; wherein, the change in the two angles of the two lines connecting each point on the sawtooth defect in the concave region to two points located at a preset distance before and after it is greater than a preset change; the preset distance refers to the distance between the two points on the edge line; the two angles of the two lines are the angles between the two lines and the horizontal line respectively.
2. The method according to claim 1, characterized in that, The process of acquiring the image of the item to be detected includes: Acquire images of the item to be inspected; The preset detection area in the image of the item to be detected is determined as the image of the item to be detected.
3. The method according to claim 1, characterized in that, Determining the edge lines of the graphic to be detected includes: Based on a preset binarization threshold, the image to be detected is binarized to convert the image to be detected and the regions that do not belong to the image to be detected into white and black, respectively. Boundary tracking is performed on the binarized image to be detected to obtain the edge lines of the image to be detected.
4. The method according to claim 1, characterized in that, The step of defining the target edge lines with a length not less than a preset length as concave regions and defining the remaining target edge lines as convex regions with jagged defects includes: Calculate the convex hull of the edge line and determine the shortest distance between each point on the edge line and the convex hull of the edge line; Identify all points on the edge line whose shortest distance to the convex hull of the edge line is greater than zero; Each edge segment, consisting of points whose shortest distance to the convex hull of the edge line is greater than zero, is defined as the target edge line; Determine whether the length of the target edge line is less than the preset length; wherein the preset length is greater than the preset maximum length of the sawtooth defect and less than the preset length of the normal concave region; If it is determined that the length of the target edge line is less than the preset length, then the target edge line is identified as a convex region sawtooth defect. If it is determined that the length of the target edge line is not less than the preset length, then the target edge line is defined as a concave region.
5. The method according to claim 1, characterized in that, The step of determining the serration defects in each of the concave regions includes: For each of the concave regions, each point in the concave region is sequentially taken as the target point; Based on the coordinates of the target point and the reference point corresponding to the target point, the cosine value of the inclination angle corresponding to the target point is calculated; wherein, the cosine value of the inclination angle corresponding to the target point is the cosine value of the inclination angle of the line connecting the target point and the first reference point corresponding to the target point; the first reference point corresponding to the target point refers to the point on the concave region, located after the target point, and at a distance of a preset interval from the target point; Calculate the absolute value of the difference between the cosine value of the inclination angle corresponding to the target point and the cosine value of the inclination angle corresponding to the second reference point corresponding to the target point; wherein, the second reference point corresponding to the target point is a point on the concave region, located in front of the target point, and at a distance of a preset interval from the target point; Determine whether the absolute value of the difference between the cosine value of the tilt angle corresponding to the target point and the cosine value of the tilt angle corresponding to the second reference point is greater than the preset change amount; wherein, the preset change amount is equal to the ratio of the preset minimum sawtooth height to the preset interval distance; the preset interval distance is greater than 5 times the preset minimum sawtooth height; If it is determined that the absolute value of the difference between the cosine value of the tilt angle corresponding to the target point and the cosine value of the tilt angle corresponding to the second reference point is greater than the preset change amount, then the target point is determined as the sawtooth defect point in the concave region. Each segment of the edge line, composed of continuous sawtooth defect points, is defined as a sawtooth defect in the concave region.
6. A sawtooth defect detection device, characterized in that, include: An acquisition unit is used to acquire an image of an item to be detected; wherein the image to be detected includes a graphic to be detected; An edge line determination unit is used to determine the edge lines of the graphic to be detected; The first detection unit is used to identify target edge lines with a length not less than a preset length as concave regions and the remaining target edge lines as convex region sawtooth defects; wherein, the target edge lines are edge lines where the shortest distance between each point and the convex hull of the edge line is greater than zero; The second detection unit is used to determine the sawtooth defects in each of the concave regions; wherein, the change in the two angles of the two lines connecting each point on the sawtooth defect to two points belonging to the same concave region and located at two preset intervals in front of and behind it is greater than a preset change; the preset interval refers to the distance between the two points on the edge line; the two angles of the two lines are the angles between the two lines and the horizontal line respectively.
7. The apparatus according to claim 6, characterized in that, The first detection unit includes: The first calculation unit is used to calculate the convex hull of the edge line and determine the shortest distance between each point on the edge line and the convex hull of the edge line; The first determining unit is used to determine each point on the edge line whose shortest distance to the convex hull of the edge line is greater than zero; The second determining unit is used to determine each edge line segment composed of points whose shortest distance to the convex hull of the edge line is greater than zero as the target edge line; The first judgment unit is used to determine whether the length of the target edge line is less than the preset length; wherein the preset length is greater than the preset maximum length of the sawtooth defect and less than the preset length of the normal concave area; A convex region sawtooth defect determination unit is used to determine the target edge line as a convex region sawtooth defect when the first determination unit determines that the length of the target edge line is less than the preset length. The concave region determination unit is used to determine the target edge line as a concave region when the first determination unit determines that the length of the target edge line is not less than the preset length.
8. The apparatus according to claim 6, characterized in that, The second detection unit includes: A selection unit is used to sequentially select each point in each of the concave regions as a target point for each concave region. The second calculation unit is used to calculate the cosine value of the inclination angle corresponding to the target point based on the coordinates of the target point and the reference point corresponding to the target point; wherein, the cosine value of the inclination angle corresponding to the target point is the cosine value of the inclination angle of the line connecting the target point and the first reference point corresponding to the target point; the first reference point corresponding to the target point refers to a point on the concave region that is located after the target point and is spaced at a preset distance from the target point; The third calculation unit is used to calculate the absolute value of the difference between the inclination cosine value corresponding to the target point and the inclination cosine value corresponding to the second reference point corresponding to the target point; wherein, the second reference point corresponding to the target point is a point on the concave region, located in front of the target point, and at a distance of a preset interval from the target point; The second judgment unit is used to determine whether the absolute value of the difference between the inclination cosine value corresponding to the target point and the inclination cosine value corresponding to the second reference point is greater than the preset change amount; wherein, the preset change amount is equal to the ratio of the preset minimum sawtooth height to the preset interval distance; the preset interval distance is greater than 5 times the preset minimum sawtooth height; A sawtooth defect point determination unit is used to determine the target point as a sawtooth defect point in the concave region when the second judgment unit determines that the absolute value of the difference between the inclination cosine value corresponding to the target point and the inclination cosine value corresponding to the second reference point of the target point is greater than the preset change amount. The third determining unit is used to determine each segment of the edge line, which is composed of continuous sawtooth defect points, as a concave region sawtooth defect.
9. An electronic device, characterized in that, include: Memory and processor; The memory is used to store programs; The processor is used to execute the program, which, when executed, is specifically used to implement the sawtooth defect detection method as described in any one of claims 1 to 5.
10. A computer storage medium, characterized in that, Used to store a computer program, which, when executed, is used to implement the sawtooth defect detection method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Outline defect detecting method for material having both arc-shaped edge and linear edge
CN107680086A