Method, device and electronic equipment for detecting defects in printed characters
Patent Information
- Application Number
- CN202611174781.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-04
- Publication Date
- 2026-10-30
AI Technical Summary
为此,本申请提出一种印刷字符缺陷检测方法、装置和电子设备,以解决无法精准确定印刷缺陷的缺陷信息的问题
第二确定模块,用于基于第一缺陷信息,确定第二缺陷信息;第二缺陷信息包括缺陷等级。
Smart Images

Figure CN123015445A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of printed character detection technology, and in particular relates to a method, apparatus and electronic device for detecting defects in printed characters. Background Technology
[0002] During the character printing process, due to malfunctions such as inkjet device blockage or dripping, defects such as multiple printings, missing printings, and black and white lines are inevitable, which seriously affect the usability of the printed products.
[0003] Generally, character inspection tools can be used to perform defect detection on characters. However, these tools can usually only determine whether a character has a defect, but cannot accurately determine the location, area, or extent of the adverse effects of the defect, making it difficult to assist in subsequent defect processing. Summary of the Invention
[0004] This application aims to address at least one of the technical problems existing in the prior art. To this end, this application proposes a method, apparatus, and electronic device for detecting printing character defects, to solve the problem of the inability to accurately determine defect information of printing defects.
[0005] Firstly, this application provides a method for detecting defects in printed characters, including: For the character image to be detected, determine the target defect detection method for the character image to be detected; Based on the target defect detection method, defect detection is performed on the character image to be detected to generate first defect information; the first defect information includes at least defect type, defect region location, defect contour information and defect region structure information; Based on the first defect information, the second defect information is determined; the second defect information includes the defect level.
[0006] According to the printed character defect detection method of this application, a target defect detection method is determined for the character image to be detected; based on the target defect detection method, defect detection is performed on the character image to be detected, generating first defect information such as defect type, defect region location, defect contour information, and defect region structure information; and Based on the first defect information, the second defect information, such as the defect level of the character image to be detected, is determined to solve the problem of not being able to accurately determine the defect information of printing defects, and to provide more processing basis for subsequent defect processing.
[0007] According to one embodiment of this application, based on a target defect detection method, defect detection is performed on the character image to be detected to generate first defect information, including: When the target defect detection method is template comparison detection, grayscale comparison detection, contour distance detection, projection detection and external region detection are performed on the character image to be detected based on the character template image, and the first defect information is generated statistically.
[0008] According to one embodiment of this application, grayscale comparison detection, contour distance detection, projection detection, and external region detection are performed on the character image to be detected based on the character template image, including: Obtain a first set of contour points from the character image to be detected and a second set of contour points from the character template image; the first set of contour points includes multiple first contour points and the second set of contour points includes multiple second contour points. For each first contour point, obtain the first target distance between the first contour point and each second contour point, obtain the first average of all first target distances, and for each second contour point, obtain the second target distance between the second contour point and each first contour point, obtain the second average of all second target distances. Based on the first and second means, contour distance detection is performed on the character image to be detected.
[0009] According to one embodiment of this application, grayscale comparison detection, contour distance detection, projection detection, and external region detection are performed on the character image to be detected based on the character template image, including: Perform horizontal projection on the character image to be detected to generate a first set of horizontal projection values; perform vertical projection on the character image to be detected to generate a first set of vertical projection values; perform horizontal projection on the character template image to generate a second set of horizontal projection values; and perform vertical projection on the character template image to generate a second set of vertical projection values. The first horizontal projection value set is compared with the second horizontal projection value set, and the first vertical projection value set is compared with the second vertical projection value set to perform projection detection on the character image to be detected.
[0010] According to one embodiment of this application, grayscale comparison detection, contour distance detection, projection detection, and external region detection are performed on the character image to be detected based on the character template image, including: A difference image is generated based on the character template image and the image of the character to be detected; Binarization masking is performed on the image of the character to be detected to generate a character region mask, and the character region mask is inverted to generate a mask for the region outside the character. Based on the difference image and the character outer region mask, external region detection is performed on the character image to be detected.
[0011] According to one embodiment of this application, based on a target defect detection method, defect detection is performed on the character image to be detected to generate first defect information, including: When the target defect detection method is deep learning detection, the character image to be detected is input into the target defect detection model to obtain the first defect information of the character image to be detected.
[0012] According to one embodiment of this application, determining second defect information based on first defect information includes: Based on the first defect information, the defect area score, geometric overlap score, grayscale similarity score and structural integrity score of the character image to be detected are obtained; The defect level of the character image to be detected is obtained based on the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score.
[0013] According to one embodiment of this application, for a character image to be detected, determining the target defect detection method for the character image to be detected includes: Obtain the detection accuracy parameters of the character image to be detected, and determine whether there is a character template image for the character image to be detected; In the absence of a character template image or when the detection accuracy parameter is less than the accuracy threshold, deep learning detection is determined as the target defect detection method for the character image to be detected; or, in the presence of a character template image and when the detection accuracy parameter is greater than or equal to the accuracy threshold, template comparison detection is determined as the target defect detection method for the character image to be detected.
[0014] Secondly, this application provides a printing character defect detection device, comprising: The first determining module is used to determine the target defect detection method for the character image to be detected. The detection module is used to perform defect detection on the character image to be detected based on the target defect detection method and generate first defect information; the first defect information includes at least defect type, defect region location, defect contour information and defect region structure information; The second determining module is used to determine the second defect information based on the first defect information; the second defect information includes the defect level.
[0015] According to the printed character defect detection device of this application, the target defect detection method of the character image to be detected is determined; based on the target defect detection method, defect detection is performed on the character image to be detected, generating first defect information such as defect type, defect area location, defect contour information, and defect area structure information, and... Based on the first defect information, the second defect information, such as the defect level of the character image to be detected, is determined to solve the problem of not being able to accurately determine the defect information of printing defects, and to provide more processing basis for subsequent defect processing.
[0016] Thirdly, this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the printing character defect detection method described in the first aspect.
[0017] Fourthly, this application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the printing character defect detection method of the first aspect described above.
[0018] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the printing character defect detection method described in the first aspect.
[0019] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0020] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is one of the flowcharts illustrating the printing character defect detection method provided in the embodiments of this application; Figure 2 This is a second schematic flowchart of the printing character defect detection method provided in the embodiments of this application; Figure 3 This is a schematic diagram of the printed character defect detection device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0021] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0022] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0023] The following description, in conjunction with the accompanying drawings, details the printing character defect detection method, apparatus, and electronic device provided in this application through specific embodiments and application scenarios.
[0024] Among them, the method for detecting defects in printed characters can be applied to a terminal, specifically executed by the hardware or software in the terminal.
[0025] The terminal includes, but is not limited to, portable communication devices such as mobile phones or tablets with touch-sensitive surfaces (e.g., touchscreen displays and / or touchpads). It should also be understood that, in some embodiments, the terminal may not be a portable communication device, but rather a desktop computer with touch-sensitive surfaces (e.g., touchscreen displays and / or touchpads).
[0026] The following embodiments describe a terminal including a display and a touch-sensitive surface. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse, and joystick.
[0027] The printing character defect detection method provided in this application embodiment can be executed by an electronic device or a functional module or entity in an electronic device that can implement the printing character defect detection method. The electronic devices mentioned in this application embodiment include, but are not limited to, mobile phones, tablets, computers, cameras and wearable devices. The printing character defect detection method provided in this application embodiment is described below using an electronic device as the execution subject.
[0028] like Figure 1 As shown, the printed character defect detection method includes steps 110, 120 and 130.
[0029] Step 110: For the character image to be detected, determine the target defect detection method for the character image to be detected.
[0030] In actual execution, the image of the character to be detected can be an image of a printed product.
[0031] In some embodiments, an image of the character to be detected can be acquired using an image acquisition device. The image acquisition device can be deployed at the finished product exit of the printing equipment, or any theoretically feasible location; this application does not impose specific limitations on this.
[0032] In some embodiments, the character image to be detected may include at least one printed character. For each printed character in the character image to be detected, a target defect detection method for that printed character can be determined.
[0033] In some embodiments, the defect detection method may include template comparison detection and deep learning detection. For the character image to be detected, the target defect detection method suitable for the character image to be detected can be determined from the two defect detection methods of template comparison detection and deep learning detection.
[0034] Step 120: Based on the target defect detection method, perform defect detection on the character image to be detected and generate first defect information; the first defect information includes at least the defect type, defect region location, defect contour information and defect region structure information.
[0035] In some embodiments, after determining the target defect detection method for the character image to be detected, defect detection can be performed on the character image to be detected based on the target defect detection method. If the character image to be detected has defects, first defect information such as defect type, defect region location, defect contour information, and defect region structure information of the character image to be detected can be obtained.
[0036] In some embodiments, when the target defect detection method is template comparison detection, defect detection can be performed on the character image to be detected based on the character template image corresponding to the character image to be detected, and first defect information can be generated.
[0037] In some embodiments, when the target defect detection method is deep learning detection, defect detection can be performed on the character image to be detected based on a pre-trained target defect detection model to generate first defect information.
[0038] Step 130: Based on the first defect information, determine the second defect information; the second defect information includes the defect level.
[0039] In some embodiments, after acquiring first defect information such as defect type, defect region location, defect contour information, and defect region structure information of the character image to be detected, the first defect information such as defect type, defect region location, defect contour information, and defect region structure information can be summarized to determine the defect level of the character image to be detected.
[0040] According to the printing character defect detection method of this application embodiment, for the character image to be detected, a target defect detection method for the character image to be detected is determined; based on the target defect detection method, defect detection is performed on the character image to be detected to generate first defect information such as defect type, defect area location, defect contour information and defect area structure information, and based on the first defect information, second defect information such as defect level of the character image to be detected is determined, so as to solve the problem of not being able to accurately determine the defect information of printing defects and provide more processing basis for subsequent defect processing.
[0041] In some embodiments, when the target defect detection method is template comparison detection, grayscale comparison detection, contour distance detection, projection detection and external region detection are performed on the character image to be detected based on the character template image, and first defect information is generated statistically.
[0042] In some embodiments, when the target defect detection method is template comparison detection, an affine transformation positioning operation can be performed on the character template image to obtain the deformation relationship between the character template image and the character image to be detected. Based on the deformation relationship, a deformation operation is performed on the character template image to eliminate the position and orientation deviation between the character template image and the character image to be detected. Based on the character template image after the deformation operation, grayscale comparison detection, contour distance detection, projection detection, and external region detection are performed on the character image to be detected.
[0043] In some embodiments, affine transformation positioning operations may include contour positioning, grayscale positioning, and any theoretically feasible positioning operations.
[0044] In some embodiments, before performing grayscale comparison detection, contour distance detection, projection detection, and external region detection on the character image to be detected, a brightness deviation correction operation can be performed on the character image to be detected and the character template image. For example, at least one of the brightness distribution histogram, brightness mean, and brightness variance of the character image to be detected and the character template image can be obtained respectively, and a brightness deviation correction operation can be performed on the character image to be detected and the character template image based on at least one of the brightness distribution histogram, brightness mean, and brightness variance.
[0045] In some embodiments, the grayscale of each first pixel image in the character image to be detected can be obtained, and the grayscale of each second pixel image in the character template image can be obtained. For each first pixel image, the grayscale of the first pixel image is compared with the grayscale of the corresponding second pixel image to perform grayscale comparison detection. For example, if the grayscale of the first pixel image is less than the grayscale of the second pixel image, it is determined that there is a printing defect at the location of the first pixel image in the character image to be detected.
[0046] In some embodiments, after performing grayscale comparison detection, contour distance detection, projection detection, and external region detection sequentially on the character image to be detected, the detection results of each detection can be summarized to generate first defect information of the character image to be detected. For example, after performing grayscale comparison detection, contour distance detection, projection detection, and external region detection sequentially on the character image to be detected, the defect type, defect region location, defect contour information, and defect region structure information obtained from each detection are summarized to generate first defect information.
[0047] According to the printing character defect detection method of this application embodiment, for the character image to be detected, the target defect detection method of the character image to be detected is determined; when the target defect detection method is template comparison detection, grayscale comparison detection, contour distance detection, projection detection and external region detection are performed on the character image to be detected based on the character template image to generate first defect information such as defect type, defect region location, defect contour information and defect region structure information, and based on the first defect information, second defect information such as defect level of the character image to be detected is determined to solve the problem of not being able to accurately determine the defect information of printing defects, and to provide more processing basis for subsequent defect processing.
[0048] In some embodiments, a first set of contour points of the character image to be detected and a second set of contour points of the character template image are obtained; the first set of contour points includes a plurality of first contour points and the second set of contour points includes a plurality of second contour points. For each first contour point, obtain the first target distance between the first contour point and each second contour point, obtain the first mean of all first target distances, and for each second contour point, obtain the second target distance between the second contour point and each first contour point, obtain the second mean of all second target distances; based on the first mean and the second mean, perform contour distance detection on the character image to be detected.
[0049] In some embodiments, a first contour point set P = {P_i = (x_i,y_i) | i ∈ (0, M]} of the character image to be detected can be obtained, and the first contour point set includes M first contour points P_i. A second contour point set Q = {Q_j = (x_j, y_j) | j ∈ (0, N]} of the character template image can be obtained, and the second contour point set includes N second contour points Q_j. M can be equal to N.
[0050] In actual execution, both the distance to the first target and the distance to the second target can be the shortest straight-line distance.
[0051] In some embodiments, for each first contour point P_i, a first target distance is obtained between the first contour point P_i and each of the second contour points Q_1, Q_2...Q_N in the set of second contour points, and a first mean of all first target distances is obtained. For each second contour point Q_j, a second target distance is obtained between the second contour point Q_j and each of the first contour points P_1, P_2...P_M, and a second mean of all second target distances is obtained.
[0052] In some embodiments, for a first contour point P_i, if the first mean of the first contour point is not equal to the second mean of the second contour point Q_j (i=j) corresponding to the first contour point, the detection result of the contour distance detection of the character image to be detected is determined to be defective.
[0053] In some embodiments, for a first contour point P_i, if the first mean of the first contour point is greater than the second mean of the second contour point Q_j (i=j) corresponding to the first contour point, it is determined that there is a multi-print defect at the location of the first contour point; if the first mean of the first contour point is less than the second mean of the second contour point Q_j (i=j) corresponding to the first contour point, it is determined that there is a missing print defect at the location of the first contour point.
[0054] According to the printing character defect detection method of this application embodiment, for the character image to be detected, the target defect detection method of the character image to be detected is determined; when the target defect detection method is template comparison detection, grayscale comparison detection, contour distance detection, projection detection and external region detection are performed on the character image to be detected based on the character template image to generate first defect information such as defect type, defect region location, defect contour information and defect region structure information, and based on the first defect information, second defect information such as defect level of the character image to be detected is determined to solve the problem of not being able to accurately determine the defect information of printing defects, and to provide more processing basis for subsequent defect processing.
[0055] In some embodiments, a horizontal projection is performed on the character image to be detected to generate a first set of horizontal projection values, a vertical projection is performed on the character image to be detected to generate a first set of vertical projection values, a horizontal projection is performed on the character template image to generate a second set of horizontal projection values, and a vertical projection is performed on the character template image to generate a second set of vertical projection values; the first set of horizontal projection values and the second set of horizontal projection values are compared, and the first set of vertical projection values and the second set of vertical projection values are compared, so as to perform projection detection on the character image to be detected.
[0056] In some embodiments, the first horizontal projection value set includes multiple first projection values. For each row of first pixel images in the character image to be detected, the pixel grayscale value of each first pixel image in the row is integrated and projected along the horizontal direction to obtain the first projection value of that row.
[0057] In some embodiments, the first vertical projection value set includes a plurality of second projection values. For each column of first pixel images in the character image to be detected, the pixel grayscale value of each first pixel image in the column is integrated and projected along the vertical direction to obtain the second projection value of the column.
[0058] In some embodiments, the second horizontal projection value set includes multiple third projection values. For each row of second pixel images in the character template image, the pixel grayscale value of each second pixel image in that row is integrated and projected along the horizontal direction to obtain the third projection value of that row.
[0059] In some embodiments, the second vertical projection value set includes a plurality of fourth projection values. For each column of second pixel images in the character template image, the pixel grayscale value of each second pixel image in that column is integrated and projected along the vertical direction to obtain the fourth projection value of that column.
[0060] In some embodiments, for each row of first pixel images in the character image to be detected, a first projection value of the row of first pixel images is compared with a corresponding third projection value to perform projection detection. If the first projection value is less than the corresponding third projection value, it is determined that the row of first pixel images has a printing defect (e.g., a white line penetrating a character); if the first projection value is greater than the corresponding third projection value, it is determined that the row of first pixel images has a printing defect (e.g., a black line attached near a character).
[0061] In some embodiments, for each column of first pixel images in the character image to be detected, a second projection value of the first pixel image in that column is compared with a corresponding fourth projection value to perform projection detection. If the second projection value is less than the corresponding fourth projection value, it is determined that the first pixel image in that column has a printing defect (e.g., a white line penetrating the character); if the second projection value is greater than the corresponding fourth projection value, it is determined that the first pixel image in that column has a printing defect (e.g., a black line attached near the character).
[0062] According to the printing character defect detection method of this application embodiment, for the character image to be detected, the target defect detection method of the character image to be detected is determined; when the target defect detection method is template comparison detection, grayscale comparison detection, contour distance detection, projection detection and external region detection are performed on the character image to be detected based on the character template image to generate first defect information such as defect type, defect region location, defect contour information and defect region structure information, and based on the first defect information, second defect information such as defect level of the character image to be detected is determined to solve the problem of not being able to accurately determine the defect information of printing defects, and to provide more processing basis for subsequent defect processing.
[0063] In some embodiments, a difference image is generated based on the character template image and the character image to be detected; a binarization mask is performed on the character image to be detected to generate a character region mask, and the character region mask is inverted to generate an outer region mask; based on the difference image and the outer region mask, outer region detection is performed on the character image to be detected.
[0064] In some embodiments, a subtraction operation can be performed on the character image to be detected and the character template image after brightness deviation correction to generate a difference image.
[0065] In some embodiments, a pixel multiplication operation can be performed on the mask and the difference image outside the character to obtain the difference image outside the character. A binarization operation can be performed on the difference image outside the character, and a connected component analysis can be performed on the binarized difference image outside the character to obtain defect information.
[0066] According to the printing character defect detection method of this application embodiment, for the character image to be detected, the target defect detection method of the character image to be detected is determined; when the target defect detection method is template comparison detection, grayscale comparison detection, contour distance detection, projection detection and external region detection are performed on the character image to be detected based on the character template image to generate first defect information such as defect type, defect region location, defect contour information and defect region structure information, and based on the first defect information, second defect information such as defect level of the character image to be detected is determined to solve the problem of not being able to accurately determine the defect information of printing defects, and to provide more processing basis for subsequent defect processing.
[0067] In some embodiments, when the target defect detection method is deep learning detection, the character image to be detected is input into the target defect detection model to obtain the first defect information of the character image to be detected.
[0068] In some embodiments, the target defect detection model may be a model that executes the U-Net algorithm or a model based on the Transformer architecture; this application does not specifically limit this.
[0069] In some embodiments, the target defect detection model may deploy several detection channels, each corresponding to a defect type. After the character image to be detected is input into the target defect detection model, each detection channel performs defect detection on the character image to be detected, generates defect detection results and detection confidence, determines the defect detection result with the highest detection confidence among multiple defect detection results as the defect detection result of the character image to be detected, and generates first defect information based on the defect detection result.
[0070] In some embodiments, several defect detection models can be pre-trained and stored, such as models trained on defective character images in printing scenarios, models trained on defective character images in laser engraving scenarios, etc. Based on the character image to be detected and detection accuracy parameters, a target defect detection model for the character image to be detected can be determined from among several defect detection models. For example, the target defect detection model for the character image to be detected can be determined based on the absolute pixel count of the characters in the character image to be detected.
[0071] In some embodiments, the target defect detection model can be trained and fine-tuned based on an online incremental learning mechanism to improve detection accuracy.
[0072] According to the printing character defect detection method of this application embodiment, for the character image to be detected, the target defect detection method of the character image to be detected is determined; when the target defect detection method is deep learning detection, the character image to be detected is input into the target defect detection model to obtain first defect information such as defect type, defect region location, defect contour information and defect region structure information of the character image to be detected, and based on the first defect information, the second defect information such as defect level of the character image to be detected is determined, so as to solve the problem of not being able to accurately determine the defect information of printing defects and provide more processing basis for subsequent defect processing.
[0073] In some embodiments, based on the first defect information, the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score of the character image to be detected are obtained; based on the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score, the defect level of the character image to be detected is obtained.
[0074] In some embodiments, a defect area score for the character image to be detected can be obtained based on the defect area and the character area. The area ratio between the defect area and the character area can be obtained, and the defect area score is determined based on the relationship between the area ratio and multiple area percentage thresholds. For example, if the area ratio is less than a first area percentage threshold (e.g., 0.5%), the defect area score is determined to be 1; if the area ratio is greater than or equal to the first area percentage threshold and less than a second area percentage threshold (e.g., 2%), the defect area score is determined to be 2; if the area ratio is greater than or equal to the second area percentage threshold and less than a third area percentage threshold (e.g., 5%), the defect area score is determined to be 3; and if the area ratio is greater than or equal to the third area percentage threshold, the defect area score is determined to be 4; wherein the second area percentage threshold is greater than the first area percentage threshold, and the third area percentage threshold is greater than the second area percentage threshold.
[0075] In some embodiments, a target mean of the first mean of all first contour points can be obtained, and the mean character width of the character image to be detected can be obtained. The ratio of the target mean to the mean character width is determined as the geometric deviation degree. Based on the relationship between the geometric deviation degree and multiple geometric deviation thresholds, a geometric overlap score is determined. For example, if the geometric deviation degree is less than a first geometric deviation threshold (e.g., 0.1), the geometric overlap score is determined to be 1; if the geometric deviation degree is greater than or equal to the first geometric deviation threshold and less than a second geometric deviation threshold (e.g., 0.3), the geometric overlap score is determined to be 2; if the geometric deviation degree is greater than or equal to the second geometric deviation threshold and less than a third geometric deviation threshold (e.g., 0.5), the geometric overlap score is determined to be 3; if the geometric deviation degree is greater than or equal to the third geometric deviation threshold, the geometric overlap score is determined to be 4; wherein the second geometric deviation threshold is greater than the first geometric deviation threshold, and the third geometric deviation threshold is greater than the second geometric deviation threshold.
[0076] In some embodiments, based on the first defect information, the ratio between the sum of the gray levels of the first pixel images with defects in the character image to be detected and the number of first pixel images with defects can be determined as the defect gray level mean, and the ratio between the sum of the gray levels of the character image to be detected and the number of first pixel images can be determined as the character gray level mean, and the absolute value of the difference between the defect gray level mean and the character gray level mean can be determined as the gray level difference value, and a gray level similarity score can be determined based on the relationship between the gray level difference value and multiple gray level difference thresholds. For example, if the grayscale difference value is less than the first grayscale difference threshold (e.g., 0.05), the defect area score is determined to be 1; if the grayscale difference value is greater than or equal to the first grayscale difference threshold and less than the second grayscale difference threshold (e.g., 0.15), the grayscale similarity score is determined to be 2; if the grayscale difference value is greater than or equal to the second grayscale difference threshold and less than the third grayscale difference threshold (e.g., 0.3), the grayscale similarity score is determined to be 3; if the grayscale difference value is greater than or equal to the third grayscale difference threshold, the grayscale similarity score is determined to be 4; wherein, the second grayscale difference threshold is greater than the first grayscale difference threshold, and the third grayscale difference threshold is greater than the second grayscale difference threshold.
[0077] In some embodiments, the defect width of the character image to be detected can be determined based on the first defect information, and the ratio of the defect width to the average character width can be determined as the breakage ratio. A structural integrity score can be determined based on the relationship between the breakage ratio and multiple breakage thresholds. For example, if the breakage ratio is less than a first breakage threshold (e.g., 0.3), the defect area score is determined to be 1; if the breakage ratio is greater than or equal to the first breakage threshold and less than a second breakage threshold (e.g., 0.3), the structural integrity score is determined to be 2; if the breakage ratio is greater than or equal to the second breakage threshold and less than a third breakage threshold (e.g., 0.6), the structural integrity score is determined to be 3; if the breakage ratio is greater than or equal to the third breakage threshold, the structural integrity score is determined to be 4; wherein the second breakage threshold is greater than the first breakage threshold, and the third breakage threshold is greater than the second breakage threshold.
[0078] In some embodiments, normalization operations can be performed on the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score, respectively, and the defect level of the character image to be detected can be obtained based on the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score after normalization operations.
[0079] In some embodiments, the defect level of the character image to be detected can be obtained based on the following formula: S = w1·Score_area + w2·Score_geo + w3·Score_gray + w4·Score_struct; Where S represents the defect level, Score_area represents the defect area score, Score_geo represents the geometric overlap score, Score_gray represents the gray-scale similarity score, Score_struct represents the structural integrity score, w1 represents the first weight, w2 represents the second weight, w3 represents the third weight, w4 represents the fourth weight, and w1 + w2 + w3 + w4.
[0080] In some embodiments, a processing strategy for the character image to be detected can be determined based on the defect level and multiple level thresholds. For example, if the defect level is less than a first level threshold, the character image to be detected is determined to be qualified; if the defect level is greater than or equal to the first level threshold but less than a second level threshold, it is determined that the character image to be detected will be reworked; if the defect level is greater than or equal to the second level threshold, it is determined that the character image to be detected will be scrapped; wherein the second level threshold is greater than the first level threshold.
[0081] According to the printing character defect detection method of this application embodiment, for the character image to be detected, a target defect detection method is determined for the character image to be detected; based on the target defect detection method, defect detection is performed on the character image to be detected to generate first defect information such as defect type, defect area location, defect contour information, and defect area structure information; and based on the first defect information, the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score of the character image to be detected are obtained; based on the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score, the defect level of the character image to be detected is obtained, so as to solve the problem of not being able to accurately determine the defect information of printing defects and provide more processing basis for subsequent defect processing.
[0082] In some embodiments, the detection accuracy parameters of the character image to be detected are obtained, and it is determined whether there is a character template image for the character image to be detected; if there is no character template image or the detection accuracy parameters are less than the accuracy threshold, deep learning detection is determined as the target defect detection method for the character image to be detected; or, if there is a character template image and the detection accuracy parameters are greater than or equal to the accuracy threshold, template comparison detection is determined as the target defect detection method for the character image to be detected.
[0083] In actual implementation, the detection accuracy parameter is used to characterize the user's detection accuracy requirements for the character image to be detected.
[0084] In some embodiments, character localization operations can be performed on the character image to be detected to obtain printed characters, recognition operations can be performed on the printed characters to obtain character information, and character template images of the character image to be detected can be found based on the character information.
[0085] In some embodiments, the image of the character to be detected can be grayscaled, binarized based on an adaptive threshold algorithm to eliminate the effects of uneven illumination, morphological operations can be performed on the image of the character to be detected to remove noise, and character localization can be performed on the image of the character to be detected through connected component analysis to obtain the printed characters.
[0086] In some embodiments, printed characters can be identified using an Optical Character Recognition (OCR) algorithm to obtain character information.
[0087] In some embodiments, character template images of printed characters can be generated in advance and stored.
[0088] To better understand the printing character defect detection method provided in the embodiments of this application, further explanation is provided below. It should be understood that the following discussion is merely exemplary.
[0089] This application provides a method for detecting defects in printed characters, the specific steps of which are as follows: Figure 2 As shown: Step 210: Obtain the detection accuracy parameters of the character image to be detected, and determine whether there is a character template image for the character image to be detected; if there is no character template image or the detection accuracy parameters are less than the accuracy threshold, determine deep learning detection as the target defect detection method for the character image to be detected; or, if there is a character template image and the detection accuracy parameters are greater than or equal to the accuracy threshold, determine template comparison detection as the target defect detection method for the character image to be detected.
[0090] In actual implementation, the detection accuracy parameter is used to characterize the user's detection accuracy requirements for the character image to be detected.
[0091] In some embodiments, character localization operations can be performed on the character image to be detected to obtain printed characters, recognition operations can be performed on the printed characters to obtain character information, and character template images of the character image to be detected can be found based on the character information.
[0092] In some embodiments, the image of the character to be detected can be grayscaled, binarized based on an adaptive threshold algorithm to eliminate the effects of uneven illumination, morphological operations can be performed on the image of the character to be detected to remove noise, and character localization can be performed on the image of the character to be detected through connected component analysis to obtain the printed characters.
[0093] In some embodiments, printed characters can be identified using an Optical Character Recognition (OCR) algorithm to obtain character information.
[0094] In some embodiments, character template images of printed characters can be generated in advance and stored.
[0095] Step 220: When the target defect detection method is template comparison detection, perform grayscale comparison detection, contour distance detection, projection detection and external region detection on the character image to be detected based on the character template image, and generate the first defect information.
[0096] In some embodiments, when the target defect detection method is template comparison detection, an affine transformation positioning operation can be performed on the character template image to obtain the deformation relationship between the character template image and the character image to be detected. Based on the deformation relationship, a deformation operation is performed on the character template image to eliminate the position and orientation deviation between the character template image and the character image to be detected. Based on the character template image after the deformation operation, grayscale comparison detection, contour distance detection, projection detection, and external region detection are performed on the character image to be detected.
[0097] In some embodiments, affine transformation positioning operations may include contour positioning, grayscale positioning, and any theoretically feasible positioning operations.
[0098] In some embodiments, before performing grayscale comparison detection, contour distance detection, projection detection, and external region detection on the character image to be detected, a brightness deviation correction operation can be performed on the character image to be detected and the character template image. For example, at least one of the brightness distribution histogram, brightness mean, and brightness variance of the character image to be detected and the character template image can be obtained respectively, and a brightness deviation correction operation can be performed on the character image to be detected and the character template image based on at least one of the brightness distribution histogram, brightness mean, and brightness variance.
[0099] In some embodiments, the grayscale of each first pixel image in the character image to be detected can be obtained, and the grayscale of each second pixel image in the character template image can be obtained. For each first pixel image, the grayscale of the first pixel image is compared with the grayscale of the corresponding second pixel image to perform grayscale comparison detection. For example, if the grayscale of the first pixel image is less than the grayscale of the second pixel image, it is determined that there is a printing defect at the location of the first pixel image in the character image to be detected.
[0100] In some embodiments, after performing grayscale comparison detection, contour distance detection, projection detection, and external region detection sequentially on the character image to be detected, the detection results of each detection can be summarized to generate first defect information of the character image to be detected. For example, after performing grayscale comparison detection, contour distance detection, projection detection, and external region detection sequentially on the character image to be detected, the defect type, defect region location, defect contour information, and defect region structure information obtained from each detection are summarized to generate first defect information.
[0101] In some embodiments, a first set of contour points of the character image to be detected and a second set of contour points of the character template image are obtained; the first set of contour points includes a plurality of first contour points and the second set of contour points includes a plurality of second contour points. For each first contour point, obtain the first target distance between the first contour point and each second contour point, obtain the first mean of all first target distances, and for each second contour point, obtain the second target distance between the second contour point and each first contour point, obtain the second mean of all second target distances; based on the first mean and the second mean, perform contour distance detection on the character image to be detected.
[0102] In some embodiments, a first contour point set P = {P_i = (x_i,y_i) | i ∈ (0, M]} of the character image to be detected can be obtained, and the first contour point set includes M first contour points P_i. A second contour point set Q = {Q_j = (x_j, y_j) | j ∈ (0, N]} of the character template image can be obtained, and the second contour point set includes N second contour points Q_j. M can be equal to N.
[0103] In actual execution, both the distance to the first target and the distance to the second target can be the shortest straight-line distance.
[0104] In some embodiments, for each first contour point P_i, a first target distance is obtained between the first contour point P_i and each of the second contour points Q_1, Q_2...Q_N in the set of second contour points, and a first mean of all first target distances is obtained. For each second contour point Q_j, a second target distance is obtained between the second contour point Q_j and each of the first contour points P_1, P_2...P_M, and a second mean of all second target distances is obtained.
[0105] In some embodiments, for a first contour point P_i, if the first mean of the first contour point is not equal to the second mean of the second contour point Q_j (i=j) corresponding to the first contour point, the detection result of the contour distance detection of the character image to be detected is determined to be defective.
[0106] In some embodiments, for a first contour point P_i, if the first mean of the first contour point is greater than the second mean of the second contour point Q_j (i=j) corresponding to the first contour point, it is determined that there is a multi-print defect at the location of the first contour point; if the first mean of the first contour point is less than the second mean of the second contour point Q_j (i=j) corresponding to the first contour point, it is determined that there is a missing print defect at the location of the first contour point.
[0107] In some embodiments, a horizontal projection is performed on the character image to be detected to generate a first set of horizontal projection values, a vertical projection is performed on the character image to be detected to generate a first set of vertical projection values, a horizontal projection is performed on the character template image to generate a second set of horizontal projection values, and a vertical projection is performed on the character template image to generate a second set of vertical projection values; the first set of horizontal projection values and the second set of horizontal projection values are compared, and the first set of vertical projection values and the second set of vertical projection values are compared, so as to perform projection detection on the character image to be detected.
[0108] In some embodiments, the first horizontal projection value set includes multiple first projection values. For each row of first pixel images in the character image to be detected, the pixel grayscale value of each first pixel image in the row is integrated and projected along the horizontal direction to obtain the first projection value of that row.
[0109] In some embodiments, the first vertical projection value set includes a plurality of second projection values. For each column of first pixel images in the character image to be detected, the pixel grayscale value of each first pixel image in the column is integrated and projected along the vertical direction to obtain the second projection value of the column.
[0110] In some embodiments, the second horizontal projection value set includes multiple third projection values. For each row of second pixel images in the character template image, the pixel grayscale value of each second pixel image in that row is integrated and projected along the horizontal direction to obtain the third projection value of that row.
[0111] In some embodiments, the second vertical projection value set includes a plurality of fourth projection values. For each column of second pixel images in the character template image, the pixel grayscale value of each second pixel image in that column is integrated and projected along the vertical direction to obtain the fourth projection value of that column.
[0112] In some embodiments, for each row of first pixel images in the character image to be detected, a first projection value of the row of first pixel images is compared with a corresponding third projection value to perform projection detection. If the first projection value is less than the corresponding third projection value, it is determined that the row of first pixel images has a printing defect (e.g., a white line penetrating a character); if the first projection value is greater than the corresponding third projection value, it is determined that the row of first pixel images has a printing defect (e.g., a black line attached near a character).
[0113] In some embodiments, for each column of first pixel images in the character image to be detected, a second projection value of the first pixel image in that column is compared with a corresponding fourth projection value to perform projection detection. If the second projection value is less than the corresponding fourth projection value, it is determined that the first pixel image in that column has a printing defect (e.g., a white line penetrating the character); if the second projection value is greater than the corresponding fourth projection value, it is determined that the first pixel image in that column has a printing defect (e.g., a black line attached near the character).
[0114] In some embodiments, a difference image is generated based on the character template image and the character image to be detected; a binarization mask is performed on the character image to be detected to generate a character region mask, and the character region mask is inverted to generate an outer region mask; based on the difference image and the outer region mask, outer region detection is performed on the character image to be detected.
[0115] In some embodiments, a subtraction operation can be performed on the character image to be detected and the character template image after brightness deviation correction to generate a difference image.
[0116] In some embodiments, a pixel multiplication operation can be performed on the mask and the difference image outside the character to obtain the difference image outside the character. A binarization operation can be performed on the difference image outside the character, and a connected component analysis can be performed on the binarized difference image outside the character to obtain defect information.
[0117] Step 230: When the target defect detection method is deep learning detection, input the character image to be detected into the target defect detection model to obtain the first defect information of the character image to be detected.
[0118] In some embodiments, the target defect detection model may be a model that executes the U-Net algorithm or a model based on the Transformer architecture; this application does not specifically limit this.
[0119] In some embodiments, the target defect detection model may deploy several detection channels, each corresponding to a defect type. After the character image to be detected is input into the target defect detection model, each detection channel performs defect detection on the character image to be detected, generates defect detection results and detection confidence, determines the defect detection result with the highest detection confidence among multiple defect detection results as the defect detection result of the character image to be detected, and generates first defect information based on the defect detection result.
[0120] In some embodiments, several defect detection models can be pre-trained and stored, such as models trained on defective character images in printing scenarios, models trained on defective character images in laser engraving scenarios, etc. Based on the character image to be detected and detection accuracy parameters, a target defect detection model for the character image to be detected can be determined from among several defect detection models. For example, the target defect detection model for the character image to be detected can be determined based on the absolute pixel count of the characters in the character image to be detected.
[0121] In some embodiments, the target defect detection model can be trained and fine-tuned based on an online incremental learning mechanism to improve detection accuracy.
[0122] Step 240: Based on the first defect information, obtain the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score of the character image to be detected; based on the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score, obtain the defect level of the character image to be detected.
[0123] In some embodiments, a defect area score for the character image to be detected can be obtained based on the defect area and the character area. The area ratio between the defect area and the character area can be obtained, and the defect area score is determined based on the relationship between the area ratio and multiple area percentage thresholds. For example, if the area ratio is less than a first area percentage threshold (e.g., 0.5%), the defect area score is determined to be 1; if the area ratio is greater than or equal to the first area percentage threshold and less than a second area percentage threshold (e.g., 2%), the defect area score is determined to be 2; if the area ratio is greater than or equal to the second area percentage threshold and less than a third area percentage threshold (e.g., 5%), the defect area score is determined to be 3; and if the area ratio is greater than or equal to the third area percentage threshold, the defect area score is determined to be 4; wherein the second area percentage threshold is greater than the first area percentage threshold, and the third area percentage threshold is greater than the second area percentage threshold.
[0124] In some embodiments, a target mean of the first mean of all first contour points can be obtained, and the mean character width of the character image to be detected can be obtained. The ratio of the target mean to the mean character width is determined as the geometric deviation degree. Based on the relationship between the geometric deviation degree and multiple geometric deviation thresholds, a geometric overlap score is determined. For example, if the geometric deviation degree is less than a first geometric deviation threshold (e.g., 0.1), the geometric overlap score is determined to be 1; if the geometric deviation degree is greater than or equal to the first geometric deviation threshold and less than a second geometric deviation threshold (e.g., 0.3), the geometric overlap score is determined to be 2; if the geometric deviation degree is greater than or equal to the second geometric deviation threshold and less than a third geometric deviation threshold (e.g., 0.5), the geometric overlap score is determined to be 3; if the geometric deviation degree is greater than or equal to the third geometric deviation threshold, the geometric overlap score is determined to be 4; wherein the second geometric deviation threshold is greater than the first geometric deviation threshold, and the third geometric deviation threshold is greater than the second geometric deviation threshold.
[0125] In some embodiments, based on the first defect information, the ratio between the sum of the gray levels of the first pixel images with defects in the character image to be detected and the number of first pixel images with defects can be determined as the defect gray level mean, and the ratio between the sum of the gray levels of the character image to be detected and the number of first pixel images can be determined as the character gray level mean, and the absolute value of the difference between the defect gray level mean and the character gray level mean can be determined as the gray level difference value, and a gray level similarity score can be determined based on the relationship between the gray level difference value and multiple gray level difference thresholds. For example, if the grayscale difference value is less than the first grayscale difference threshold (e.g., 0.05), the defect area score is determined to be 1; if the grayscale difference value is greater than or equal to the first grayscale difference threshold and less than the second grayscale difference threshold (e.g., 0.15), the grayscale similarity score is determined to be 2; if the grayscale difference value is greater than or equal to the second grayscale difference threshold and less than the third grayscale difference threshold (e.g., 0.3), the grayscale similarity score is determined to be 3; if the grayscale difference value is greater than or equal to the third grayscale difference threshold, the grayscale similarity score is determined to be 4; wherein, the second grayscale difference threshold is greater than the first grayscale difference threshold, and the third grayscale difference threshold is greater than the second grayscale difference threshold.
[0126] In some embodiments, the defect width of the character image to be detected can be determined based on the first defect information, and the ratio of the defect width to the average character width can be determined as the breakage ratio. A structural integrity score can be determined based on the relationship between the breakage ratio and multiple breakage thresholds. For example, if the breakage ratio is less than a first breakage threshold (e.g., 0.3), the defect area score is determined to be 1; if the breakage ratio is greater than or equal to the first breakage threshold and less than a second breakage threshold (e.g., 0.3), the structural integrity score is determined to be 2; if the breakage ratio is greater than or equal to the second breakage threshold and less than a third breakage threshold (e.g., 0.6), the structural integrity score is determined to be 3; if the breakage ratio is greater than or equal to the third breakage threshold, the structural integrity score is determined to be 4; wherein the second breakage threshold is greater than the first breakage threshold, and the third breakage threshold is greater than the second breakage threshold.
[0127] In some embodiments, normalization operations can be performed on the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score, respectively, and the defect level of the character image to be detected can be obtained based on the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score after normalization operations.
[0128] In some embodiments, the defect level of the character image to be detected can be obtained based on the following formula: S = w1·Score_area + w2·Score_geo + w3·Score_gray + w4·Score_struct; Where S represents the defect level, Score_area represents the defect area score, Score_geo represents the geometric overlap score, Score_gray represents the gray-scale similarity score, Score_struct represents the structural integrity score, w1 represents the first weight, w2 represents the second weight, w3 represents the third weight, w4 represents the fourth weight, and w1 + w2 + w3 + w4.
[0129] In some embodiments, a processing strategy for the character image to be detected can be determined based on the defect level and multiple level thresholds. For example, if the defect level is less than a first level threshold, the character image to be detected is determined to be qualified; if the defect level is greater than or equal to the first level threshold but less than a second level threshold, it is determined that the character image to be detected will be reworked; if the defect level is greater than or equal to the second level threshold, it is determined that the character image to be detected will be scrapped; wherein the second level threshold is greater than the first level threshold.
[0130] This application also provides a printing character defect detection device.
[0131] like Figure 3As shown, the printed character defect detection device 300 includes: a first determining module 310, a detection module 320, and a second determining module 330.
[0132] The first determining module 310 is used to determine the target defect detection method for the character image to be detected. The detection module 320 is used to perform defect detection on the character image to be detected based on the target defect detection method and generate first defect information; the first defect information includes at least the defect type, defect region location, defect contour information and defect region structure information; The second determining module 330 is used to determine the second defect information based on the first defect information; the second defect information includes the defect level.
[0133] According to the printed character defect detection device of this application, for a character image to be detected, a target defect detection method for the character image to be detected is determined; based on the target defect detection method, defect detection is performed on the character image to be detected, generating first defect information such as defect type, defect region location, defect contour information, and defect region structure information, and... Based on the first defect information, the second defect information, such as the defect level of the character image to be detected, is determined to solve the problem of not being able to accurately determine the defect information of printing defects, and to provide more processing basis for subsequent defect processing.
[0134] In some embodiments, the detection module 320 includes: The first detection unit is used to perform grayscale comparison detection, contour distance detection, projection detection, and external region detection on the character image to be detected based on the character template image when the target defect detection method is template comparison detection, and to generate the first defect information.
[0135] In some embodiments, the first detection unit is used for: Obtain a first set of contour points from the character image to be detected and a second set of contour points from the character template image; the first set of contour points includes multiple first contour points and the second set of contour points includes multiple second contour points. For each first contour point, obtain the first target distance between the first contour point and each second contour point, obtain the first average of all first target distances, and for each second contour point, obtain the second target distance between the second contour point and each first contour point, obtain the second average of all second target distances. Based on the first and second means, contour distance detection is performed on the character image to be detected.
[0136] In some embodiments, the first detection unit is used for: Perform horizontal projection on the character image to be detected to generate a first set of horizontal projection values; perform vertical projection on the character image to be detected to generate a first set of vertical projection values; perform horizontal projection on the character template image to generate a second set of horizontal projection values; and perform vertical projection on the character template image to generate a second set of vertical projection values. The first horizontal projection value set is compared with the second horizontal projection value set, and the first vertical projection value set is compared with the second vertical projection value set to perform projection detection on the character image to be detected.
[0137] In some embodiments, the first detection unit is used for: A difference image is generated based on the character template image and the image of the character to be detected; Binarization masking is performed on the image of the character to be detected to generate a character region mask, and the character region mask is inverted to generate a mask for the region outside the character. Based on the difference image and the character outer region mask, external region detection is performed on the character image to be detected.
[0138] In some embodiments, the detection module 320 further includes: The second detection unit is used to input the character image to be detected into the target defect detection model when the target defect detection method is deep learning detection, and to obtain the first defect information of the character image to be detected.
[0139] In some embodiments, the second determining module 330 includes: The first acquisition unit is used to acquire, based on the first defect information, the defect area score, geometric overlap score, grayscale similarity score and structural integrity score of the character image to be detected. The second acquisition unit is used to obtain the defect level of the character image to be detected based on the defect area score, geometric overlap score, grayscale similarity score and structural integrity score.
[0140] In some embodiments, the first determining module 310 includes: The first determining unit is used to obtain the detection accuracy parameters of the character image to be detected and to determine whether there is a character template image of the character image to be detected. The second determining unit is used to determine deep learning detection as the target defect detection method for the character image to be detected when there is no character template image or the detection accuracy parameter is less than the accuracy threshold; or, when there is a character template image and the detection accuracy parameter is greater than or equal to the accuracy threshold, to determine template comparison detection as the target defect detection method for the character image to be detected.
[0141] The printed character defect detection device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.
[0142] The printed character defect detection device in this application embodiment can be a device with an operating system. This operating system can be a Microsoft (Windows) operating system, an Android operating system, an iOS operating system, or other possible operating systems; this application embodiment does not specifically limit it.
[0143] The printed character defect detection device 300 provided in this application embodiment can achieve... Figures 1 to 2 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0144] In some embodiments, such as Figure 4 As shown, this application embodiment also provides an electronic device 400, including a processor 401, a memory 402, and a computer program stored in the memory 402 and executable on the processor 401. When the program is executed by the processor 401, it implements the various processes of the above-described printing character defect detection method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0145] It should be noted that the computer equipment in this application embodiment includes the mobile electronic equipment and non-mobile electronic equipment described above.
[0146] This application also provides a non-transitory computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described printing character defect detection method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0147] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0148] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method for detecting defects in printed characters.
[0149] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0150] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described printing character defect detection method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0151] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0152] It should be noted that, in this document, 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 limitations, 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 that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0153] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0154] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0155] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0156] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
Claims
1. A method for detecting defects in printed characters, characterized in that, include: For the character image to be detected, determine the target defect detection method for the character image to be detected; Based on the target defect detection method, defect detection is performed on the character image to be detected to generate first defect information; The first defect information includes at least the defect type, defect region location, defect outline information, and defect region structure information; Based on the first defect information, second defect information is determined; the second defect information includes the defect level.
2. The method for detecting defects in printed characters according to claim 1, characterized in that, The step of performing defect detection on the character image to be detected based on the target defect detection method to generate first defect information includes: When the target defect detection method is template comparison detection, grayscale comparison detection, contour distance detection, projection detection and external region detection are performed on the character image to be detected based on the character template image, and first defect information is generated statistically.
3. The method for detecting defects in printed characters according to claim 2, characterized in that, Based on the character template image, perform grayscale comparison detection, contour distance detection, projection detection, and external region detection on the character image to be detected, including: Obtain a first set of contour points of the character image to be detected and a second set of contour points of the character template image; the first set of contour points includes a plurality of first contour points and the second set of contour points includes a plurality of second contour points; For each first contour point, obtain the first target distance between the first contour point and each second contour point, obtain the first average of all first target distances, and for each second contour point, obtain the second target distance between the second contour point and each first contour point, obtain the second average of all second target distances. Based on the first mean and the second mean, contour distance detection is performed on the character image to be detected.
4. The method for detecting defects in printed characters according to claim 2, characterized in that, Based on the character template image, perform grayscale comparison detection, contour distance detection, projection detection, and external region detection on the character image to be detected, including: Perform horizontal projection on the character image to be detected to generate a first set of horizontal projection values; perform vertical projection on the character image to be detected to generate a first set of vertical projection values; perform horizontal projection on the character template image to generate a second set of horizontal projection values; and perform vertical projection on the character template image to generate a second set of vertical projection values. The first set of horizontal projection values is compared with the second set of horizontal projection values, and the first set of vertical projection values is compared with the second set of vertical projection values to perform projection detection on the character image to be detected.
5. The method for detecting defects in printed characters according to claim 2, characterized in that, Based on the character template image, perform grayscale comparison detection, contour distance detection, projection detection, and external region detection on the character image to be detected, including: A difference image is generated based on the character template image and the character image to be detected; Binarization masking is performed on the image of the character to be detected to generate a character region mask, and the character region mask is inverted to generate an outer region mask. Based on the difference image and the character outer region mask, external region detection is performed on the character image to be detected.
6. The method for detecting defects in printed characters according to claim 1, characterized in that, Based on the aforementioned target defect detection method, defect detection is performed on the character image to be detected to generate first defect information, including: When the target defect detection method is deep learning detection, the character image to be detected is input into the target defect detection model to obtain the first defect information of the character image to be detected.
7. The method for detecting defects in printed characters according to claim 1, characterized in that, The step of determining the second defect information based on the first defect information includes: Based on the first defect information, the defect area score, geometric overlap score, grayscale similarity score, and structural integrity score of the character image to be detected are obtained. Based on the defect area score, the geometric overlap score, the grayscale similarity score, and the structural integrity score, the defect level of the character image to be detected is obtained.
8. The method for detecting defects in printed characters according to any one of claims 1-7, characterized in that, The step of determining the target defect detection method for the character image to be detected includes: Obtain the detection accuracy parameters of the character image to be detected, and determine whether a character template image for the character image to be detected exists; If the character template image is not available or the detection accuracy parameter is less than the accuracy threshold, deep learning detection is determined as the target defect detection method for the character image to be detected; or, if the character template image exists and the detection accuracy parameter is greater than or equal to the accuracy threshold, template comparison detection is determined as the target defect detection method for the character image to be detected.
9. A printing character defect detection device, characterized in that, include: The first determining module is used to determine the target defect detection method for the character image to be detected; The detection module is used to perform defect detection on the character image to be detected based on the target defect detection method, and generate first defect information; The first defect information includes at least the defect type, defect region location, defect outline information, and defect region structure information; The second determining module is used to determine second defect information based on the first defect information; the second defect information includes a defect level.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the printed character defect detection method according to any one of claims 1-8.
