Character Defect Detection Method and Related Equipment

By using binarized image comparison technology in character defect detection, the problem of low accuracy of character defect detection is solved, and efficient detection under different lighting conditions is achieved.

CN118366167BActive Publication Date: 2025-07-29GUANGDONG AOPUTE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410459340.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-16
Publication Date
2025-07-29
Estimated Expiration
2044-04-16

AI Technical Summary

Technical Problem

In the prior art, character defect detection has low accuracy, and it is difficult to accurately extract character areas under different lighting conditions, resulting in unstable detection results.

Method used

By obtaining the character segmentation result of the target image, a binarized first character segmentation diagram is generated, and compared with the reference character segmentation diagram of defect-free qualified characters in the template character library to determine the difference pixels to determine character defects.

Benefits of technology

It improves the accuracy of character defect detection, reduces the impact of background images on detection results, and enhances the stability of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118366167B_ABST
    Figure CN118366167B_ABST
Patent Text Reader

Abstract

The present application discloses a character defect detection method and related devices. The method includes: determining, by a target character region segmentation model, a plurality of polygons that form the character contour in the target image from the target image; determining the character region and the character background region in the target image based on the inclusion relationship between the plurality of polygons that form the character contour; setting the pixel values of the character region to a first pixel and setting the pixel values of the character background region to a second pixel to obtain the binary first character segmentation map; after aligning the first character in the first character segmentation map and the second character in the second character segmentation map in the same image coordinate system, performing a difference calculation on the first character and the second character in the same image coordinate system to determine the number of coordinate points of the differential pixels between the first character segmentation map and the second character segmentation map.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular, to a character defect detection method, apparatus, electronic device, storage medium, and computer program product. Background Art

[0002] Currently, during the production process of products, necessary explanatory characters are usually spray-coded or printed on their surfaces. Inspecting whether the characters spray-coded or printed on the product surface are defective is an essential process before the product enters the market.

[0003] Traditional character defect detection methods include: manual visual inspection and detecting by extracting the character region based on traditional image processing technology, etc. Among them, although manual visual inspection can be applied to various complex detection scenarios, it will cause artificial visual fatigue under high-intensity and long-time work, resulting in a high missed detection rate, and thus affecting the accuracy and stability of the detection results. In the process of detecting characters by extracting them based on traditional image processing technology, it is usually necessary to extract the character region in the product image through algorithms such as filtering, threshold segmentation, and cropping for the product image collected by the camera, and then perform defect detection on the extracted character region.

[0004] Although the method of detecting characters by extracting them based on traditional image processing technology has great advantages over manual visual inspection in terms of processing speed and detection stability, due to different lighting conditions and camera positions, the brightness and darkness of the product images collected will be different. For example, in the case of relatively dim light, the color of the characters in the collected product image may be similar to the color of the character background. At this time, it is very difficult to accurately extract the character region through traditional image processing technology and then identify whether there are defects in the characters, thus affecting the accuracy of character defect detection. Summary of the Invention

[0005] Embodiments of this application provide a character defect detection method and related devices to solve the problem of low accuracy in character defect detection in the prior art.

[0006] Embodiments of this application adopt the following technical solutions:

[0007] In a first aspect, this application provides a character defect detection method, including:

[0008] Based on the character segmentation result of the target image, obtain a binary first character segmentation map; in the first character segmentation map, at least one first character is included;

[0009] Compare the first character segmentation map with the binary reference character segmentation map of the defect-free qualified characters pre-stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in terms of character contour as the second character segmentation map; at least one second character is included in the second character segmentation map.

[0010] After aligning the first character in the first character segmentation map and the second character in the second character segmentation map in the same image coordinate system, determine the character defect detection result for the target image based on the difference pixels between the first character and the second character.

[0011] Wherein, the pixel values of the character regions in the second character segmentation map are the same as those of the character regions in the first character segmentation map, and the pixel values of the character background regions in the second character segmentation map are the same as those of the character background regions in the first segmentation map.

[0012] In a second aspect, the present application provides a character defect detection device, including:

[0013] An image segmentation module, configured to obtain a binary first character segmentation map based on the character segmentation result of the target image; at least one first character is included in the first character segmentation map.

[0014] An image matching module, configured to compare the first character segmentation map with the binary reference character segmentation map of the defect-free qualified characters pre-stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in terms of character contour as the second character segmentation map; at least one second character is included in the second character segmentation map.

[0015] A defect determination module, configured to determine the character defect detection result for the target image based on the difference pixels between the first character in the first character segmentation map and the second character in the second character segmentation map after aligning them in the same image coordinate system.

[0016] Wherein, the pixel values of the character regions in the second character segmentation map are the same as those of the character regions in the first character segmentation map, and the pixel values of the character background regions in the second character segmentation map are the same as those of the character background regions in the first segmentation map.

[0017] In a third aspect, the present application provides an electronic device, including: a memory and a processor;

[0018] The memory is used to store a computer program.

[0019] The processor, coupled to the memory, is configured to execute the computer program for:

[0020] Based on the character segmentation result of the target image, obtain a binarized first character segmentation map; the first character segmentation map contains at least one first character.

[0021] Compare the first character segmentation map with the binarized reference character segmentation map of the defect-free qualified characters pre-stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in terms of character contour as the second character segmentation map; the second character segmentation map contains at least one second character.

[0022] In the same image coordinate system, after aligning the first characters in the first character segmentation map and the second characters in the second character segmentation map, determine the character defect detection result for the target image based on the difference pixels between the first characters and the second characters.

[0023] Wherein, the pixel values of the character regions in the second character segmentation map are the same as those of the character regions in the first character segmentation map, and the pixel values of the character background regions in the second character segmentation map are the same as those of the character background regions in the first segmentation map.

[0024] In a fourth aspect, the present application provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps in the character defect detection method described in the first aspect above are implemented.

[0025] In a fifth aspect, the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps in the character defect detection method described in the first aspect above are implemented.

[0026] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:

[0027] When using the method provided in the embodiment of the present application to detect defects in characters on a target image, based on the character segmentation result of the target image, a binarized first character segmentation map can be obtained. Then, the first character segmentation map is compared with the binarized reference character segmentation map of the defect-free qualified characters pre-stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in terms of character contour as the second character segmentation map. After the first character in the first character segmentation map and the second character in the second character segmentation map are aligned in the same image coordinate system, based on the difference pixels between the first character and the second character, the character defect detection result in the target image is determined. Since both the first character segmentation map and the second character segmentation map are processed into binarized maps with different pixel values for the character region and the character background region before comparison, and the pixel values of the character region in the second character segmentation map are the same as those of the character region in the first character segmentation map, and the pixel values of the character background region in the second character segmentation map are the same as those of the character background region in the first segmentation map, when performing defect detection after alignment, only the difference pixels of the characters in the two maps need to be determined to determine whether there are defects in the characters in the target image, so that the accuracy of character defect detection is not affected by the background image of the target image, effectively improving the accuracy of character defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings:

[0029] Figure 1 is a schematic flowchart of the implementation of a character defect detection method provided by an embodiment of the present application;

[0030] Figure 2 is a schematic diagram of the effect of obtaining a character region segmentation map in the character defect detection method provided by an embodiment of the present application;

[0031] Figure 3 is a schematic diagram of the process of obtaining an instance segmentation map in the character defect detection method provided by an embodiment of the present application;

[0032] Figure 4 is a schematic diagram of the comparison effect between a defective character and a template character in the character defect detection method provided by an embodiment of the present application;

[0033] Figure 5 is a schematic flowchart of the process of applying the character defect detection method provided by an embodiment of the present application to an actual scenario;

[0034] Figure 6 is a schematic diagram of the effect of applying the character defect detection method provided by an embodiment of the present application to an actual scenario;

[0035] Figure 7 This is a schematic diagram of the specific structure of a character defect detection device provided by an embodiment of the present application;

[0036] Figure 8 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0037] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the connotation of the present application. Therefore, the present application is not limited by the specific implementations disclosed below.

[0038] The terms used in one or more embodiments of the present application are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of the present application. The singular forms "a", "the", and "said" used in one or more embodiments of the present application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more of the associated listed items.

[0039] It should be understood that although the terms first, second, etc. may be used in one or more embodiments of the present application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining".

[0040] First, the noun terms involved in one or more embodiments of the present application are explained.

[0041] Mask, with the English name "mask", uses a selected image, graphic or object to block a processed image (either in whole or in part) to control the area or process of image processing. The specific image or object used for covering is called a mask or template. A mask is a binary image composed of 0s and 1s. When applying a mask in a certain function, the area with a value of 1 is processed, and the masked area with a value of 0 is not included in the calculation. An image mask is defined by specified data values, data ranges, finite or infinite values, regions of interest, and annotation files. It is also possible to use any combination of the above options as input to create a mask. A mask is a template for an image filter. Remote sensing images are often processed using masks. When extracting roads, rivers, or houses, an N*N matrix is used to filter the pixels of the image, and then the features or landmarks we need are highlighted. This matrix is a type of mask.

[0042] Image segmentation: Image segmentation is the technology and process of dividing an image into several specific regions with unique properties and extracting the objects of interest. It is a key step from image processing to image analysis. The existing image segmentation methods are mainly classified into the following categories: threshold-based segmentation methods, region-based segmentation methods, edge-based segmentation methods, and segmentation methods based on specific theories, etc. From a mathematical perspective, image segmentation is the process of dividing a digital image into non-overlapping regions. The process of image segmentation is also a labeling process, that is, pixels belonging to the same region are assigned the same number.

[0043] Semantic segmentation: Semantic segmentation is classification at the pixel level. Pixels belonging to the same class should be grouped into one class. Therefore, semantic segmentation understands an image from the pixel level. For example, in the following photo, pixels belonging to people should be grouped into one class, pixels belonging to motorcycles should be grouped into one class, and in addition, background pixels are also grouped into one class.

[0044] To solve the above problems existing in the prior art, an embodiment of the present application provides a character defect detection method. Since both the first character segmentation map and the second character segmentation map are processed into binary maps with different pixel values for the character region and the character background region before comparison, and the pixel values of the character region in the second character segmentation map are the same as those of the character region in the first character segmentation map, and the pixel values of the character background region in the second character segmentation map are the same as those of the character background region in the first segmentation map. Therefore, when performing defect detection after alignment, only the different pixels of the characters in the two maps need to be determined to determine whether there are defects in the characters in the target image, so that the accuracy of character defect detection is not affected by the background image of the target image, effectively improving the accuracy of character defect detection. Specifically, in the present application, a character defect detection method is provided. The present application also relates to a character defect detection device, an electronic device, a computer-readable storage medium, and a computer program product, which will be described in detail one by one in the following embodiments.

[0045] The execution subject of this method can be various types of computing devices, or it can be an application program or an application (APP) installed on a computing device, such as a character defect detection application. The computing device can be, for example, a user terminal such as a mobile phone, a tablet computer, a smart wearable device, or a server, etc.

[0046] For ease of description, in the embodiments of the present application, the execution subject of this method is taken as a character defect detection device as an example to introduce this method. Those skilled in the art can understand that taking this character defect detection device as an example to introduce the method in the embodiments of the present application is only an exemplary illustration and does not limit the protection scope of the corresponding claims of this solution.

[0047] Specifically, a schematic implementation flow diagram of a character defect detection method provided by one or more embodiments of the present application is as Figure 1 shown, including:

[0048] Step 110, based on the character segmentation result of the target image, obtain a binary first character segmentation map; the first character segmentation map contains at least one first character.

[0049] Among them, the pixel values in the binary first character segmentation map include two types. The pixel values of the character region are uniformly set to a value in 0-255, and the pixel values of the character background region are uniformly set to another value in 0-255. It should be noted that the character region in the embodiments of the present application is a pure character region and does not include the character background region covered by the character.

[0050] Optionally, to improve the efficiency of character region segmentation, the character segmentation result of the target image can be obtained by segmenting the target image with a target character region segmentation model. Specifically, based on the character segmentation result of the target image, a binarized first character segmentation map is obtained, including:

[0051] Determine, by means of the target character region segmentation model, multiple polygons that form the character contours in the target image from the target image;

[0052] Based on the inclusion relationship between the multiple polygons that form the character contours, determine the character regions and character background regions in the target image;

[0053] Set the pixel values of the character regions to a first pixel, and set the pixel values of the character background regions to a second pixel, to obtain the binarized first character segmentation map.

[0054] Figure 2 FIG. is a schematic diagram of the effect of obtaining a character region segmentation map in the character defect detection method provided by the embodiments of the present application. Figure 2 The left figure is an instance segmentation map of determining multiple polygons that form the character contours in the target image from the target image by means of the target character region segmentation model. Figure 2 The right figure is the binarized first character segmentation map obtained by setting the pixel values of the character regions to a first pixel and setting the pixel values of the character background regions to a second pixel. As can be seen from Figure 2 this, in the instance segmentation map segmented by the target character region segmentation model, the character regions in the character "8" and the partial character background regions covered by the character regions, that is, the upper and lower "○" regions in the character "8", may present colors relatively similar to the character regions in the character "8" under different image shooting conditions, or the pixels of the character regions in the character "8" and the partial character background regions covered by the character regions are relatively close in the original image. Therefore, when detecting defects in the character "8", there may be a problem of low detection accuracy. Based on this, in the embodiments of the present application, after obtaining the instance segmentation map of determining multiple polygons that form the character contours in the target image from the target image by means of the target character region segmentation model ( Figure 2 left figure), further region screening processing is performed on this instance segmentation map to separately screen out the character regions and character background regions in the target image and set them to different pixels, to obtain the binarized first character segmentation map (i.e., Figure 2 right figure).

[0055] Optionally, to improve the accuracy of character defect detection, after the embodiments of the present application segment a plurality of polygons that make up the character contours in the target image through the target character region segmentation model, two or more polygons with an inclusion relationship can be determined as the character background region. Specifically, based on the inclusion relationship between the plurality of polygons that make up the character contours, determining the character region and the character background region in the target image includes:

[0056] Determine the vertex coordinates of the plurality of polygons in a preset coordinate system;

[0057] When there are at least two polygons with an inclusion relationship among the plurality of polygons, determine the common region of the at least two polygons as the character background region;

[0058] Determine the region other than the character background region in the target image as the character region.

[0059] Among them, the training process of the target character region segmentation model may include:

[0060] Obtain training samples, where the training samples include character images of a plurality of characters under different backgrounds, and annotation information for indicating the character contours in the character images of the plurality of characters;

[0061] Based on the character images of the plurality of characters and the annotation information of the character contours, train a preset instance segmentation model to obtain the target character region segmentation model.

[0062] Among them, obtaining training samples includes:

[0063] Obtain character images of a plurality of characters under different backgrounds;

[0064] Draw the character contours in the plurality of character images through polygons, and generate annotation information for the plurality of character images based on the pixel point coordinates in each character contour;

[0065] Based on the background images in a plurality of industrial scenarios and the annotation information of each character image, generate a plurality of character images including the annotation information of each character image to obtain training samples.

[0066] As an example, obtaining training samples may include:

[0067] S1, collect character images of a plurality of different industrial backgrounds, and determine the contour point coordinates of the character contours obtained by polygon annotation in the plurality of character images in a preset coordinate system.

[0068] S2, perform sample augmentation on the character images of the plurality of different industrial backgrounds to obtain character images of a plurality of characters under different backgrounds.

[0069] First, generate the character contours of each character image according to the contour point coordinates of each character image, then generate multiple different character background images in the industrial scenario, and finally paste the character contours onto the generated character background images to expand the sample quantity and diversity of the character images of multiple different industrial backgrounds obtained in S1, and obtain the character images of multiple characters under different backgrounds. It should be noted that when generating each character image, based on the polygon labels and polygon contour point coordinates that make up the character contour in the character image, an annotation file corresponding to each character image can be generated, and the format of this annotation file is the json format. Among them, this annotation file stores the polygon categories and polygon contour point coordinates that make up the character contour in the form of key-value pairs. This key-value pair includes two categories: one is key = "label", value = "calssName", and the other is key = "points", value = [[p1(x,y)],[p2(x,y)]......].

[0070] S3. Generate a txt label file for training the target character region segmentation model, and the labels in this txt label file are the annotation information for indicating the character contours in the character images of multiple characters.

[0071] As an example, the polygon contour point coordinates and polygon labels of the character contours of each character image can be extracted from the character contours of each character image, and these information are sequentially saved in the txt label file of each character image, and pixel-level semantic annotation of the character image is achieved through the txt label file.

[0072] In an exemplary embodiment, S3 may include:

[0073] S31. For the json annotation file of each character image, respectively determine the value "calssName" of the key = "label" and the value [[p1(x,y)],[p2(x,y)]......] of the key = "points", sequentially extract each coordinate in points in order, perform normalization processing on each coordinate, and then save the normalized points value and label value in the txt label file of each character image.

[0074] S32. Based on the polygon formed by the points value in the txt label file that makes up the character contour, assign all the pixels inside the polygon the polygon label. Figure 3 This is the effect schematic diagram of obtaining the character region segmentation map in the character defect detection method provided by the embodiment of the present application. Figure 3 The first figure in it is the contour scatter plot of the character "8", and this contour scatter plot is determined based on the points value in the txt label file of the character "8". Figure 3The second figure in [description] is the contour diagram of the character '8', which is obtained by polygon label annotation based on the txt label file of the character '8'. Specifically, the pixels of the contour line of the character '8' in the figure are set as polygon labels. Figure 3 The third figure in [description] is an instance segmentation diagram obtained by semantic annotation based on the second figure.

[0075] Among them, polygon labels are used to indicate the pixel values within the polygon area. For example, for the character '0', the character '0' has two contours, an inner contour line and an outer contour line. The polygon labels of each contour line and the area within the line are the same. Each contour line can be drawn as a polygon, so its label is the pixel value of its internal area.

[0076] As an example, polygon labels can be divided into the following two types:

[0077] (1) The character contour line and the area within the line are defined as the character area: the pixel values of this part of the area can be set to 0, that is, the polygon label of this area is denoted as 0 (it should be understood that 0 is just an example notation, and the embodiments of this application do not make specific limitations on this).

[0078] (2) The non-character contour area is positioned as the character background area: the pixel values of this part of the area can be set to non-0 (any value from 1 to 255), that is, the polygon label of this area is denoted as non-0.

[0079] S4. Based on the character images of multiple characters in different backgrounds, and the annotation information indicating the character contours in the character images of multiple characters, train the YOLOv8 instance segmentation network to obtain a target character area segmentation model.

[0080] S5. Segment the target image through the target character area segmentation model, extract the polygon vertex coordinates of the character contours in the character segmentation result, and remove the non-character areas in the target image through a region screening algorithm, that is, determine the character areas and character background areas in the target image.

[0081] In an exemplary embodiment, the process of removing the non-character areas in the target image through the region screening algorithm in S5 may include:

[0082] S51. Construct a three-dimensional matrix with the same size as the original input image and pixel value of 0, denoted as mask.

[0083] S52. Extract the circumscribed rectangle of the character contour and the contour point coordinate information of the character contour from the character segmentation result of the target image.

[0084] S53. Determine whether there is an inclusion relationship between multiple polygons that make up the outline of each character. If there is an inclusion relationship, it means that the areas formed by the multiple polygons that make up the outline of each character overlap, and the area formed by the character outline needs to be processed for area screening. The polygons with an inclusion relationship can be put into a multi-outline list, while the polygons without an inclusion relationship can be put into a single-outline list.

[0085] In an exemplary embodiment, S53 may include:

[0086] S531. Extract the set of circumscribed rectangle boxes of the character outlines in the target image, RectangleBox = {box i (p lti_x , p lti_y , p rbi_x , p rbi_y ) | i ∈ [0, N - 1]}, and the set of contour point coordinates of the predicted character outlines in the target image, ContourPoint = {contour i (p xi1,yi1 , p xi2,yi2 ...) | i ∈ [0, N - 1]}. Where p lti_x , p lti_y represents the abscissa and ordinate of the upper left vertex of box i , p rbi_x , p rbi_y represents the abscissa and ordinate of the lower right vertex of box i , p xi1,yi1 represents the first contour point of the i-th contour contour i . The number of contour points of each predicted contour is not necessarily the same, and N represents the number of contours.

[0087] S532. In the preset coordinate system, compare the coordinates of the polygon box i with those of RectangleBox_ = {box0, box1... box j | j ∈ [0, N - 1] and j!= i} in turn. If p lti_x > p ltj_x , p lti_y > p ltj_y , p rbi_x < p rbi_x , p rbj_y < p rbj_y Then it means that box i is inside box j , and the area formed by contour j contains the area formed by contour i ; If p lti_x < p ltj_x , plti_y <p ltj_y ,p rbi_x >p rbi_x ,p rbj_y >p rbj_y represents box i Outside the box j , the area formed by contour i contains the area formed by contour j ; otherwise, there is no inclusion relationship between the area formed by contour i and the areas formed by other contours. Then, put the contour point sequences with inclusion relationships into the multi - contour list, and put the contour point sequences without inclusion relationships into the single - contour list.

[0088] S533. Based on the contour point sequences in the multi - contour list and the single - contour list, construct polygons. Use the opencv polygon filling algorithm. When different polygons fill the same coordinate points, the pixel value of this coordinate point is changed to the background pixel value of the mask, and the pixel values of the remaining coordinate points are changed to pixel values that are not the background of the mask (and the pixel values are the same). Finally, the obtained mask is used as the character region segmentation map. Among them, the background pixel value is the pixel value of the character background region, and the pixel value that is not the background of the mask is the pixel value of the character region.

[0089] Step 120. Compare the first character segmentation map with the binary - valued reference character segmentation map of the defect - free qualified characters pre - stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in terms of character contour as the second character segmentation map; the second character segmentation map contains at least one second character.

[0090] Optionally, for constructing the template character library, the method provided by the embodiments of this application further includes:

[0091] Obtain character images of multiple defect - free qualified characters;

[0092] Perform character segmentation on the character images of multiple defect - free qualified characters to obtain multiple character region segmentation maps corresponding to the character images of multiple defect - free qualified characters; or,

[0093] Mark the character contours in the character images of multiple defect - free qualified characters through polygons to obtain multiple character region segmentation maps corresponding to the character images of multiple defect - free qualified characters.

[0094] Optionally, to improve the accuracy of character defect detection, multiple character region segmentation maps in the template character library can also be set as binary images, that is, the pixel values of the character regions are set to the same pixel, and the pixel values of the character background regions are set to the same pixel and are different from the pixel values of the character regions. Specifically, the method provided in the embodiments of the present application further includes:

[0095] Determine the character contour coordinates of multiple character region segmentation maps in a preset coordinate system;

[0096] Based on the character contour coordinates, perform binary processing on multiple character region segmentation maps to obtain binary reference character segmentation maps of multiple defect-free qualified characters; wherein, the pixel values of the character regions in the reference character segmentation maps are different from the pixel values of the character backgrounds;

[0097] Construct a template character library based on the binary reference character segmentation maps of multiple defect-free qualified characters.

[0098] As an example, the process of constructing a template character library may include:

[0099] S121, collect the character images of multiple defect-free qualified characters, label the character contours with polygons and label the polygons, and obtain the json annotation files of the character images of each defect-free qualified character;

[0100] S122, extract the values of label and points in the json annotation files of the character images of each defect-free qualified character, obtain the polygon labels and contour point coordinates of the character contours in each character image, draw a color map mask with the same size as the character images of each defect-free qualified character and a background of 0, and draw polygons in the Mask based on the contour point coordinates of the character contours in each character image;

[0101] S123, use the polygon filling algorithm to fill the pixel points inside each polygon, and change the pixel values of the pixels where the same pixel points are filled in different polygons to 0 (the pixel value of 0 is just an exemplary description), and the remaining areas are filled with pixels with non-0 and the same pixel values. The Mask drawn in this way is the reference character segmentation map.

[0102] Step 130, in the same image coordinate system, after the first character in the first character segmentation map and the second character in the second character segmentation map are aligned, determine the character defect detection result for the target image based on the differential pixels between the first character and the second character.

[0103] Wherein, the pixel values of the character regions in the second character segmentation map are the same as the pixel values of the character regions in the first character segmentation map, and the pixel values of the character background regions in the second character segmentation map are the same as the pixel values of the character background regions in the first segmentation map.

[0104] Optionally, based on the differential pixels between the first character and the second character, determining a character defect detection result for the target image includes:

[0105] In the same image coordinate system, comparing the first character and the second character, and determining the number of coordinate points of differential pixels between the first character segmentation map and the second character segmentation map;

[0106] When the number of coordinate points is greater than or equal to a preset threshold, based on the contour region formed by the coordinate points of the differential pixels, localizing the character defect in the target image.

[0107] As described above, the pixel values of the character regions in the second character segmentation map are the same as those in the first character segmentation map, and the pixel values of the character background regions in the second character segmentation map are the same as those in the first segmentation map. Moreover, both the first character segmentation map and the second character segmentation map are binary images, that is, there are only two pixel values for the pixels in the first character segmentation map and the second character segmentation map. Then, when determining the character defect detection result for the target image, it is only necessary to compare the first character and the second character in the same image coordinate system, determine the coordinate points of the differential pixels between the first character segmentation map and the second character segmentation map, that is, determine the pixel points with different pixel values at the same positions in the first character segmentation map and the second character segmentation map. Finally, based on the number and coordinates of the pixel points with different pixel values at the same positions, localize the character defect in the target image.

[0108] It should be understood that when the number of coordinate points of the differential pixels is greater than or equal to the preset threshold, it indicates that the area of the region with differential pixels is greater than the set threshold. At this time, it can be determined that there is a character defect in the target image, and the preset threshold can be set according to historical experience. Then, based on the contour region formed by the coordinate points of the differential pixels, the character defect in the target image can be accurately located. Since in this process, only the pixel values of the same pixel points between the first character segmentation map and the second character segmentation map need to be compared, without considering the influence of the character background in the original target image, the efficiency and accuracy of character defect detection and localization can be effectively improved. Figure 4 This is a schematic diagram of the comparison effect between the defective character and the template character in the character defect detection method provided by the embodiment of the present application. In Figure 4 In it, after determining the coordinate points of the differential pixels, the character defect of the "Q" character in the target image can be accurately located based on the contour region formed by the coordinate points of the differential pixels.

[0109] As an example, in combination with Figure 5 and Figure 6, determining the character defect detection result for the target image based on the differential pixels between the first character and the second character may include:

[0110] S131, performing template matching on the first character region segmentation map with multiple reference character segmentation maps in the template character library in sequence.

[0111] S132, determining whether the matching degree is greater than or equal to the template matching threshold.

[0112] When the matching degree is greater than the template matching threshold, the reference character segmentation map with a matching degree greater than the template matching threshold belongs to this type of character region segmentation map, and this reference character segmentation map is used as the second character segmentation map.

[0113] As Figure 6 shown, the width of the determined second character segmentation map is 151, the height is 200, the width of the first character segmentation map is 131, and the height is 190.

[0114] S133, determining the dimensions and central coordinates of the minimum bounding rectangles of the character regions in the first character region segmentation map and the second character region segmentation map. Respectively obtain the dimensions and central coordinates of the minimum bounding rectangles of the character regions in the first character region segmentation map, and the dimensions and central coordinates of the minimum bounding rectangles of the character regions in the second character segmentation map, compare the dimensions of the two bounding rectangles and determine whether to move the central coordinates of the character region in the first character region segmentation map.

[0115] As Figure 6 shown, the width of the minimum bounding rectangle of the character region in the second character region segmentation map is 133, the height is 142, the width of the minimum bounding rectangle of the character region in the first character segmentation map is 133, and the height is 142.

[0116] S134, aligning the character region in the first character region segmentation map and the character region in the second character segmentation map. Based on the central coordinates of the minimum bounding rectangles of the character regions in the first character region segmentation map and the second character segmentation map, perform an affine transformation to match the character region in the first character region segmentation map with the character region in the second character segmentation map, so that the character regions in the first character region segmentation map and the second character segmentation map are aligned.

[0117] S135, adjusting the dimensions of the minimum bounding rectangle of the character region in the first character region segmentation map based on the minimum bounding rectangle of the character region in the second character segmentation map, so that the dimensions of the minimum bounding rectangle of the character region in the first character region segmentation map are equal to the dimensions of the minimum bounding rectangle of the character region in the second character segmentation map.

[0118] S136, performing a difference calculation between the first character region and the second character region.

[0119] S137 determines the difference between the first character region and the second character region. This difference is the number of coordinate points of the different pixels, i.e., the difference pixels, to complete the character defect detection and positioning. According to the preset threshold set in advance, i.e., the threshold of the number of coordinate points of the difference pixels, when the difference is greater than or equal to the preset threshold, the coordinate points of the difference pixels are output, and then the detection result of the character defect can be obtained. This detection result includes whether the target image contains a character defect and the coordinates of the character defect when the character defect is included.

[0120] As Figure 6 shown, after obtaining the detection result of the character defect, the defect region composed of the coordinates of the character defect can be displayed in the original target image.

[0121] When using the method provided by the embodiment of the present application to perform defect detection on the characters in the target image, based on the character segmentation result of the target image, a binary first character segmentation map can be obtained, and then the first character segmentation map is compared with the binary reference character segmentation map of the defect-free qualified characters pre-stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in the character contour as the second character segmentation map. After the first character in the first character segmentation map and the second character in the second character segmentation map are aligned in the same image coordinate system, based on the difference pixels between the first character and the second character, the detection result of the character defect in the target image is determined. Since both the first character segmentation map and the second character segmentation map are processed as binary maps with different pixel values in the character region and the character background region before comparison, and the pixel values of the character region in the second character segmentation map are the same as those of the character region in the first character segmentation map, and the pixel values of the character background region in the second character segmentation map are the same as those of the character background region in the first segmentation map, therefore, when performing defect detection after alignment, only the difference pixels of the characters in the two maps need to be determined to determine whether there are defects in the characters in the target image, so that the accuracy of character defect detection is not affected by the character background of the target image, effectively improving the accuracy of character defect detection.

[0122] It should be noted that the execution subject of each step of the method provided in the above embodiment can be the same device, or the method can also be executed by different devices. For example, the execution subject of steps 110 to 130 can be device A; for another example, the execution subject of steps 110 to 120 can be device A, and the execution subject of step 130 can be device B; and so on.

[0123] In addition, in some of the processes described in the above embodiments and the accompanying drawings, a number of operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order in which they appear herein or may be executed in parallel. The serial numbers of the operations, such as 110, 120, etc., are only used to distinguish between the different operations, and the serial numbers themselves do not represent any order of execution. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel.

[0124] Figure 7 FIG. is a schematic structural diagram of a character defect detection device 700 provided for an exemplary embodiment of the present application. As Figure 7 shown, the device 700 includes: an image segmentation module 710, an image matching module 720, and a defect determination module 730, where:

[0125] The image segmentation module 710 is configured to obtain a binarized first character segmentation map based on the character segmentation result of the target image; the first character segmentation map includes at least one first character;

[0126] The image matching module 720 is configured to compare the first character segmentation map with a binarized reference character segmentation map of defect-free qualified characters pre-stored in the template character library to determine a reference character segmentation map that matches the first character segmentation map in terms of character contour as a second character segmentation map; the second character segmentation map includes at least one second character;

[0127] The defect determination module 730 is configured to, after aligning the first characters in the first character segmentation map and the second characters in the second character segmentation map in the same image coordinate system, determine a character defect detection result for the target image based on the difference pixels between the first characters and the second characters;

[0128] wherein, the pixel values of the character regions in the second character segmentation map are the same as the pixel values of the character regions in the first character segmentation map, and the pixel values of the character background regions in the second character segmentation map are the same as the pixel values of the character background regions in the first segmentation map.

[0129] When using the device provided by the embodiment of the present application to perform defect detection on the characters in the target image, based on the character segmentation result of the target image, a binary first character segmentation map can be obtained. Then, the first character segmentation map is compared with the binary reference character segmentation map of the defect-free qualified characters pre-stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in terms of character contour as the second character segmentation map. After the first character in the first character segmentation map and the second character in the second character segmentation map are aligned in the same image coordinate system, based on the differential pixels between the first character and the second character, the character defect detection result in the target image is determined. Since both the first character segmentation map and the second character segmentation map are processed into binary maps with different pixel values for the character region and the character background region before comparison, and the pixel values of the character region in the second character segmentation map are consistent with those of the character region in the first character segmentation map, and the pixel values of the character background region in the second character segmentation map are consistent with those of the character background region in the first segmentation map, when performing defect detection after alignment, only the differential pixels of the characters in the two maps need to be determined to determine whether there are defects in the characters in the target image, so that the accuracy of character defect detection is not affected by the character background of the target image, effectively improving the accuracy of character defect detection.

[0130] In some exemplary embodiments, when the defect determination module 730 determines the character defect detection result for the target image based on the differential pixels between the first character and the second character, it is specifically configured to:

[0131] In the same image coordinate system, compare the first character and the second character to determine the number of coordinate points where there are differential pixels between the first character segmentation map and the second character segmentation map;

[0132] When the number of the coordinate points is greater than or equal to a preset threshold, locate the character defect in the target image based on the contour region formed by the coordinate points of the differential pixels.

[0133] In some exemplary embodiments, the device further includes a template construction module, which is used for:

[0134] Obtain the character images of multiple defect-free qualified characters;

[0135] Perform character segmentation on the character images of the multiple defect-free qualified characters to obtain multiple character region segmentation maps corresponding to the character images of the multiple defect-free qualified characters; or,

[0136] Mark the character contours in the character images of the multiple defect-free qualified characters with polygons to obtain multiple character region segmentation maps corresponding to the character images of the multiple defect-free qualified characters.

[0137] In some exemplary embodiments, the template construction module is further configured to:

[0138] Determine the character contour coordinates of the multiple character region segmentation maps in a preset coordinate system;

[0139] Based on the character contour coordinates, perform binarization processing on the multiple character region segmentation maps to obtain multiple binarized reference character segmentation maps of defect-free qualified characters; wherein, the pixel values of the character regions in the reference character segmentation maps are different from the pixel values of the character backgrounds;

[0140] Construct the template character library based on the multiple binarized reference character segmentation maps of defect-free qualified characters.

[0141] In some exemplary embodiments, when the image segmentation module 710 obtains a binarized first character segmentation map based on the character segmentation result of the target image, it is specifically configured to:

[0142] Determine, from the target image, multiple polygons that form the character contour of the target image through a target character region segmentation model;

[0143] Based on the inclusion relationship between the multiple polygons that form the character contour, determine the character region and the character background region in the target image;

[0144] Set the pixel values of the character region to a first pixel and set the pixel values of the character background region to a second pixel to obtain the binarized first character segmentation map.

[0145] In some exemplary embodiments, when the image segmentation module 710 determines the character region and the character background region in the target image based on the inclusion relationship between the multiple polygons that form the character contour, it is specifically configured to:

[0146] Determine the vertex coordinates of the multiple polygons in a preset coordinate system;

[0147] When there is an inclusion relationship between at least two of the multiple polygons, determine the common region of the at least two polygons as the character background region;

[0148] Determine the region other than the character background region in the target image as the character region.

[0149] The character defect detection device 700 can implement Figures 1 to 6 the method of the method embodiment, and specifically refer to Figures 1 to 6 the character defect detection method shown in the embodiment, which will not be elaborated here.

[0150] Figure 8A schematic structural diagram of an electronic device provided for an exemplary embodiment of the present application. As Figure 8 shown, the device includes: a memory 81 and a processor 82.

[0151] The memory 81 is used to store computer programs and can be configured to store various other data to support operations on the computing device. Examples of such data include instructions for any application or method for operating on the computing device, contact data, phone book data, messages, pictures, videos, etc.

[0152] The processor 82 is coupled to the memory 81 and is used to execute the computer program in the memory 81 for:

[0153] Based on the character segmentation result of the target image, obtain a binarized first character segmentation map; in the first character segmentation map, at least one first character is included;

[0154] Compare the first character segmentation map with the binarized reference character segmentation map of the defect-free qualified characters pre-stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in terms of character contour as the second character segmentation map; in the second character segmentation map, at least one second character is included;

[0155] After aligning the first character in the first character segmentation map and the second character in the second character segmentation map in the same image coordinate system, determine the character defect detection result for the target image based on the difference pixels between the first character and the second character;

[0156] Wherein, the pixel values of the character regions in the second character segmentation map are the same as the pixel values of the character regions in the first character segmentation map, and the pixel values of the character background regions in the second character segmentation map are the same as the pixel values of the character background regions in the first segmentation map.

[0157] When using the electronic device provided in the embodiment of the present application to perform defect detection on characters in a target image, based on the character segmentation result of the target image, a binarized first character segmentation map can be obtained. Then, the first character segmentation map is compared with the binarized reference character segmentation map of the defect-free qualified characters pre-stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in terms of character contour as the second character segmentation map. After the first character in the first character segmentation map and the second character in the second character segmentation map are aligned, based on the difference pixels between the first character and the second character, the character defects in the target image are determined. Since both the first character segmentation map and the second character segmentation map are processed into binarized maps with different pixel values for the character region and the character background region before comparison, and the pixel values of the character region in the second character segmentation map are consistent with those of the character region in the first character segmentation map, and the pixel values of the character background region in the second character segmentation map are consistent with those of the character background region in the first segmentation map, therefore, when performing defect detection after alignment, only the difference pixels of the characters in the two maps need to be determined to determine whether there are defects in the characters in the target image, so that the accuracy of character defect detection is not affected by the character background of the target image, effectively improving the accuracy of character defect detection.

[0158] Further, as Figure 8 shown, the electronic device further includes: other components such as a communication component 83, a display 84, a power supply component 85, an audio component 86, etc. Figure 8 Only some components are schematically shown in Figure 8 and it does not mean that the electronic device only includes Figure 8 the components shown. In addition, according to the different implementation forms of the traffic playback device, Figure 8 the components within the dashed box in Figure 8 are optional components, not mandatory components. For example, when the electronic device is implemented as a terminal device such as a smart phone, a tablet computer, or a desktop computer, it may include

[0159] the components within the dashed box in

[0160] Accordingly, the embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the processor is enabled to implement the steps in the above method embodiment.

[0161] The aboveFigure 8 The communication component therein is configured to facilitate communication between the device where the communication component is located and other devices in a wired or wireless manner. The device where the communication component is located can access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component may further include a Near Field Communication (NFC) module, Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, etc.

[0162] The above Figure 8 The memory therein can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.

[0163] The above Figure 8 The display therein includes a screen, and the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation.

[0164] The above Figure 8 The power component therein provides power for various components of the device where the power component is located. The power component may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the device where the power component is located.

[0165] The above Figure 8 The audio component therein can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive external audio signals. The received audio signals can be further stored in the memory or transmitted via the communication component. In some embodiments, the audio component further includes a speaker for outputting audio signals.

[0166] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) that contain computer-usable program code.

[0167] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data that have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.

[0168] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for realizing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 a block or multiple blocks.

[0169] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device realizes the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 a block or multiple blocks.

[0170] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for realizing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 a block or multiple blocks.

[0171] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.

[0172] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0173] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. The 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, compact disc read-only memory (CD-ROM), digital versatile discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0174] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but also other elements not expressly listed, or elements that are inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element.

[0175] The above description is only for the embodiments of the present application and is not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims

1. A character defect detection method, characterized in that, Including: Determine, from a target image, a plurality of polygons that form the character contours in the target image through a target character region segmentation model; determine the character region and the character background region in the target image based on the inclusion relationship between the plurality of polygons that form the character contours; set the pixel values of the character region to a first pixel, and set the pixel values of the character background region to a second pixel to obtain a binarized first character segmentation map; wherein, the target character region segmentation model is trained on a preset instance segmentation model based on character images of a plurality of characters under different backgrounds and annotation information for indicating the character contours in the character images of the plurality of characters; in the first character segmentation map, there is at least one first character; Compare the first character segmentation map with a binarized reference character segmentation map of defect-free qualified characters pre-stored in a template character library to determine a reference character segmentation map that matches the first character segmentation map in terms of character contour as a second character segmentation map; in the second character segmentation map, there is at least one second character; After aligning the first characters in the first character segmentation map and the second characters in the second character segmentation map in the same image coordinate system, perform differential calculation on the first characters and the second characters in the same image coordinate system to determine the number of coordinate points of pixels with differences between the first character segmentation map and the second character segmentation map; when the number of the coordinate points is greater than or equal to a preset threshold, locate the character defect in the target image based on the contour region formed by the coordinate points of the differential pixels; Wherein, the pixel values of the character regions in the second character segmentation map are the same as the pixel values of the character regions in the first character segmentation map, and the pixel values of the character background regions in the second character segmentation map are the same as the pixel values of the character background regions in the first character segmentation map, and the character region is a pure character region without including the character background region covered by the character.

2. The method according to claim 1, wherein The method further includes: Obtain character images of a plurality of defect-free qualified characters; Perform character segmentation on the character images of the plurality of defect-free qualified characters to obtain a plurality of character region segmentation maps corresponding to the character images of the plurality of defect-free qualified characters; or, Mark the character contours in the character images of the plurality of defect-free qualified characters with polygons to obtain a plurality of character region segmentation maps corresponding to the character images of the plurality of defect-free qualified characters.

3. The method according to claim 2, wherein The method further includes: Determine the character contour coordinates of the plurality of character region segmentation maps in a preset coordinate system; Based on the character contour coordinates, perform binarization processing on the plurality of character region segmentation maps to obtain binarized reference character segmentation maps of a plurality of defect-free qualified characters; wherein, the pixel values of the character regions in the reference character segmentation map are different from the pixel values of the character background; Construct the template character library based on the binarized reference character segmentation maps of the plurality of defect-free qualified characters.

4. The method according to claim 1, characterized in that, Determining the character region and the character background region in the target image based on the inclusion relationship between multiple polygons that make up the character contour includes: Determining the vertex coordinates of the multiple polygons in a preset coordinate system; When there is an inclusion relationship between at least two of the multiple polygons that make up the multiple polygons, determining the common region of the at least two polygons as the character background region; Determining the region other than the character background region in the target image as the character region.

5. A character defect detection device, characterized in that, Including: An image segmentation module, configured to determine, through a target character region segmentation model, multiple polygons that make up the character contour in the target image; determine the character region and the character background region in the target image based on the inclusion relationship between the multiple polygons that make up the character contour; set the pixel values of the character region to a first pixel, and set the pixel values of the character background region to a second pixel to obtain a binarized first character segmentation map; wherein, the target character region segmentation model is obtained by training a preset instance segmentation model based on character images of multiple characters in different backgrounds and annotation information for indicating the character contours in the character images of the multiple characters; the first character segmentation map contains at least one first character; An image matching module, configured to compare the first character segmentation map with a binarized reference character segmentation map of a defect-free qualified character pre-stored in a template character library to determine a reference character segmentation map that matches the first character segmentation map in character contour as a second character segmentation map; the second character segmentation map contains at least one second character; A defect determination module, configured to, after aligning the first character in the first character segmentation map and the second character in the second character segmentation map in the same image coordinate system, perform a difference calculation on the first character and the second character in the same image coordinate system to determine the number of coordinate points of differential pixels between the first character segmentation map and the second character segmentation map; when the number of the coordinate points is greater than or equal to a preset threshold, locate the character defect in the target image based on the contour region formed by the coordinate points of the differential pixels; Wherein, the pixel values of the character region in the second character segmentation map are the same as the pixel values of the character region in the first character segmentation map, and the pixel values of the character background region in the second character segmentation map are the same as the pixel values of the character background region in the first character segmentation map, and the character region is a pure character region and does not include the character background region covered by the character.

6. An electronic device, characterized in that, Including: A memory and a processor; The memory is configured to store a computer program; The processor, coupled to the memory, is configured to execute the computer program for: Using a target character region segmentation model, determine a plurality of polygons that form the character contours in the target image from the target image; based on the inclusion relationship between the plurality of polygons that form the character contours, determine the character region and the character background region in the target image; set the pixel values of the character region to a first pixel, and set the pixel values of the character background region to a second pixel to obtain a binarized first character segmentation map; wherein, the target character region segmentation model is trained from a preset instance segmentation model based on character images of a plurality of characters under different backgrounds and annotation information indicating the character contours in the character images of the plurality of characters; in the first character segmentation map, there is at least one first character. Compare the first character segmentation map with the binarized reference character segmentation map of the defect-free qualified characters pre-stored in the template character library to determine the reference character segmentation map that matches the first character segmentation map in terms of character contour as the second character segmentation map; in the second character segmentation map, there is at least one second character. After aligning the first character in the first character segmentation map and the second character in the second character segmentation map in the same image coordinate system, perform a difference calculation on the first character and the second character in the same image coordinate system to determine the number of coordinate points of the pixels with differences between the first character segmentation map and the second character segmentation map; when the number of the coordinate points is greater than or equal to a preset threshold, locate the character defect in the target image based on the contour region formed by the coordinate points of the pixels with differences. Wherein, the pixel values of the character region in the second character segmentation map are the same as the pixel values of the character region in the first character segmentation map, and the pixel values of the character background region in the second character segmentation map are the same as the pixel values of the character background region in the first character segmentation map, and the character region is a pure character region without including the character background region covered by the character.

7. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 4 are implemented.

8. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the steps in the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Character defect automatic detection method and system

    CN108416765A