A method and device for detecting missing printed text on a card with a template image

Through the card certificate printing text missing detection method with template images, the target detection and template matching technology are used to solve the problem of automatic detection of card certificate printing text missing, the detection efficiency and accuracy are improved, and automated card certificate quality control is realized.

CN118887672BActive Publication Date: 2024-11-29MICROPATTERN
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411368830.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2024-11-29
Estimated Expiration
2044-09-29

AI Technical Summary

Technical Problem

During the card making process, the printhead failure or the coating is damaged, and the existing methods require manual inspection, which is inefficient and prone to errors, and lacks automated detection methods.

Method used

Using the card certificate printing text missing detection method with template images, the card certificate area is located through the object detection algorithm, perspective transformation and cropping, and zooming to the template image resolution. The text line detection and template matching technology are used to automatically detect the missing text. area.

Benefits of technology

It realizes automatic detection of missing card and certificate printed text, improves detection efficiency and accuracy, and reduces the error rate of manual inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118887672B_ABST
    Figure CN118887672B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for detecting missing printed text on a card with a template image, and relates to the technical field of detecting missing printed text on a card. First, card detection and corner point positioning are performed, and an aligned image is obtained by perspective transformation and cropping and scaling to the same resolution as the template image; then, text line detection is performed on the template image to determine the position of the text block; then, the search range is appropriately expanded with the corresponding position of the aligned image as the center as the candidate area, and a fast template matching is performed in the candidate area with the text block image as the template to obtain the matching result of the text block. Finally, a difference map is calculated based on the template and the matching position, and morphological processing and connected domain analysis are performed to obtain the missing printed text area. The missing printed text of the manufactured card can be automatically detected based on the template image, and the detection efficiency and detection accuracy are high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of card printed text missing detection, and in particular to a card printed text missing detection method and device with a template image. Background Art

[0002] During the card production process, due to a print head failure, the printed text may be missing in a certain area; at the same time, during the card lamination process, the lamination may be damaged. When the damaged position is above the printed text, it may also cause some strokes or areas of the printed text to be missing.

[0003] Both of the above situations will result in unqualified cards. The traditional method to solve this problem often requires manual inspection, which is inefficient and prone to errors.

[0004] Therefore, it is necessary to develop an automated method and device to detect missing printed text in a card. Summary of the invention

[0005] In order to solve the technical problem of automatic detection of missing printed text in cards, the present invention provides a method and device for detecting missing printed text in cards with a template image. The following technical solution is adopted:

[0006] A method for detecting missing printed text on a card with a template image comprises the following steps:

[0007] Step 1: obtain an image to be detected for the prepared card, detect the position of the card in the image to be detected by using a target detection algorithm, and cut out the card area to obtain a card area image;

[0008] Step 2, locating the four corner points of the card in the card area image;

[0009] Step 3, performing perspective transformation on the card area image to correct the tilt and deformation of the card area image;

[0010] Step 4, cutting out a complete card image based on the card area image after perspective transformation;

[0011] Step 5, scaling the cropped card image to the same resolution as the template image to obtain an aligned card image;

[0012] Step 6, determining the position of each text block according to the printing rules or using the text line detection method for the template image;

[0013] Step 7, using the geometric relationship between the template image and the aligned card image, for each text block in step 6, expand the search range centered on the corresponding position in the aligned card image as a candidate area for the text block;

[0014] Step 8, using the text block image in step 6 as a template, performing template matching on the candidate area in step 7, obtaining a matching result of the text block, and obtaining a difference map;

[0015] Step 9, perform morphological opening operation on the difference map to remove interference from small areas;

[0016] Step 10, extracting connected domains from the result of step 9 to obtain the missing area of ​​printed text.

[0017] By adopting the above technical solution, card detection and corner point positioning are first performed, and the aligned image is obtained by perspective transformation and cropping and scaling to the same resolution as the template image; then the template image is detected for text lines to determine the position of the text block; then the search range is appropriately expanded with the corresponding position of the aligned image as the center as the candidate area, and the text block image is used as a template to perform fast template matching in the candidate area to obtain the matching result of the text block. Finally, the difference map is calculated based on the template image and the matching position, and morphological processing and connected domain analysis are performed to obtain the missing area of ​​printed text.

[0018] The missing printed text of the produced card can be automatically detected based on the template image, with high detection efficiency and high detection accuracy.

[0019] Optionally, in step 2, according to the position of the card area image obtained in step 1, the four corner points of the card are located using the CenterNet algorithm.

[0020] By adopting the above technical solution, a high-definition camera is used to take a photo of the prepared card. The card image after the camera takes the photo will have a certain rotation or perspective deformation due to the influence of factors such as shooting angle and position, and needs to be corrected. According to the position of the card in the image obtained in the previous step, the centernet algorithm is used to locate the four corner points of the card.

[0021] Optionally, the method of step 3 is: using a perspective transformation algorithm to perform perspective transformation on the card area image, the perspective transformation eliminates the tilt and deformation of the card image;

[0022] The perspective transformation algorithms are getPerspectiveTransform and warpPerspective in the OpenCV environment.

[0023] By adopting the above technical solution, perspective transformation can eliminate the tilt and deformation of the card image, making the image smoother and convenient for subsequent processing.

[0024] Optionally, the method of step 4 is: determine a cropping area according to the card image after perspective transformation, crop the card image to be detected, and ensure that the cropped area contains the complete card.

[0025] By adopting the above technical solution, a suitable cropping area is determined according to the card image after perspective transformation, and the card image to be detected is cropped out to ensure that the cropped area contains the complete card to avoid missing important content.

[0026] Optionally, the template image in step 6 is an image provided to a printing device, and the specific position of each line of text in the template image is obtained according to printing rules, or the position of each line of text is obtained according to a text line detection algorithm, and each line of text is regarded as a text block.

[0027] By adopting the above technical solution, the template image is prepared in advance and is provided to the printing device. The specific position of each line of text in the template image can be known according to the printing rules, and the position of each line of text can also be obtained according to the text line detection algorithm. Each line of text is regarded as a text block. For example, ID cards generally have corresponding printing standards. The template image is generated by a program according to the corresponding template. According to the printing standards, the position of the text block can be obtained by performing binarization processing and external rectangular frame estimation in the corresponding area.

[0028] Optionally, in step 6, using the geometric relationship between the template image and the aligned card image, for each text block in step 6, the search range is appropriately expanded with the corresponding position in the aligned card image as the center as the candidate area of ​​the text block.

[0029] Due to the positioning problem of the printing device, the actual printing position of the text will be offset from the template card image. Therefore, it is necessary to appropriately expand the search range with the corresponding position as the center. For example, the height of the search area is 3 times the height of the text line, and the width of the search area is 1.3 times the width of the text line.

[0030] Optionally, step 8 includes the following sub-steps:

[0031] Step 81, for black printed fonts, extract the K channel of the CMYK color space from the template and the candidate area image respectively; for color printed fonts, extract the C, M and Y channels;

[0032] Step 82, using a segmentation algorithm to perform binarization processing on the C, M, Y and K channel images respectively;

[0033] Step 83, calculating the matching degree between each sliding window and the template for each channel respectively according to the sliding window method;

[0034] Step 84, selecting the sliding window position with the highest matching degree as the best matching position;

[0035] Step 85, perform pixel AND operation on the template and the sliding window corresponding to the best matching position to obtain the same image, and subtract the same image from the template to obtain the difference image.

[0036] By adopting the above technical solution, for black fonts, the K channel is usually used for printing, and for color fonts, they are synthesized by combining the C, M and Y channels. Therefore, different color channels need to be selected for matching according to fonts of different colors. By processing the printed fonts by channels, it is possible to detect the missing of printed text on a certain color channel. The result of this missing is that the printed text is normal, but the color is abnormal. For example, for red fonts, if there is a missing print on the Y channel, the printed text is normal and intact, but the color of the text is magenta, not red. The above C, M, Y and K channel images are binarized using a segmentation algorithm; binarization mainly reduces the interference of the complex background pattern on the card surface on the printed font, and can also reduce the interference of lighting factors on the results.

[0037] Optionally, in step 8, the template matching adopts a fast matching method based on binary images;

[0038] Define the matching degree: For a binary template and a binary image to be matched, assume that the handwriting is white in the image;

[0039] The matching degree is calculated as follows: the binary template and the sliding window are ANDed pixel by pixel, and the ratio of the number of non-zero pixels in the image after the operation to the total number of pixels is used as the matching degree;

[0040] The matching degree ranges from [0,1]. The higher the matching degree, the more similar the current sliding window is to the template.

[0041] The fast matching process is as follows: calculate the integral image for the binary image to be matched; initialize the best matching degree to 0; for each sliding window, use the integral image to calculate the ratio of the total number of white pixels in the current sliding window to the total number of pixels in the template;

[0042] If the current best matching degree is higher than the ratio, the calculation of the current sliding window is skipped; otherwise, the matching degree of the current sliding window is calculated according to the steps. If the matching degree of the current sliding window is higher than the current best matching degree, the current best matching degree is updated to the matching degree of the current sliding window.

[0043] By adopting the above technical solution, for each sliding window, the total number of white pixels in the current window is calculated using the integral image; the total number of white pixels is the upper limit of the number of pixels that can be matched by the sliding window. The ratio of the total number of white pixels to the total number of pixels in the window is calculated, that is, the upper limit of the matching degree that the sliding window can achieve. If the current best matching degree is higher than this ratio, the calculation of the current window can be safely skipped without affecting the final matching result; otherwise, the matching degree in the current sliding window is calculated according to the matching degree calculation formula, and the best matching degree is updated to the maximum value of the matching degrees of all current sliding windows. According to the current best matching result, the matching degree calculation of some windows can be appropriately skipped to reduce the amount of calculation without affecting the final result. In extreme cases, if the first sliding window is the best match, the matching degree calculation of all subsequent windows can be skipped.

[0044] Optionally, based on the text block matching, the text block is segmented into individual characters, and steps 8 and 9 are performed on the characters to obtain a difference map.

[0045] By adopting the above technical solution, the impact of the detection results on the imaging scale and angle can be further reduced.

[0046] A card and certificate printed text missing detection device with a template image comprises an imaging device, a memory and a processor. The imaging device is used to image a manufactured card and certificate to obtain an image to be detected, and to exchange the image to be detected with the memory. The memory stores a card and certificate printed text missing detection program designed using a card and certificate printed text missing detection method with a template image. The processor is communicatively connected with the memory and runs the card and certificate printed text missing detection program to output a detection result.

[0047] In summary, the present invention includes at least the following beneficial technical effects:

[0048] The present invention can provide a card printed text missing detection method and device with a template image. First, card detection and corner point positioning are performed, and an aligned image is obtained by perspective transformation and cropping and scaling to the same resolution as the template image; then, the template image is subjected to text line detection to determine the text block position; then, the search range is appropriately expanded with the corresponding position of the aligned image as the center as the candidate area, and the text block image is used as a template to perform fast template matching in the candidate area to obtain the matching result of the text block. Finally, a difference map is calculated based on the template image and the matching position, and morphological processing and connected domain analysis are performed to obtain the printed text missing area.

[0049] The missing printed text of the produced card can be automatically detected based on the template image, with high detection efficiency and high detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1It is a flow chart of a method for detecting missing printed text on a card with a template image according to the present invention;

[0051] Figure 2 It is a schematic diagram of the rapid matching process of step 8 of a method for detecting missing printed text on a card with a template image according to the present invention. DETAILED DESCRIPTION

[0052] The present invention is further described in detail below with reference to the accompanying drawings. The embodiment of the present invention discloses a method and device for detecting missing printed text on a card with a template image.

[0053] Reference Figure 1 and Figure 2 , a method for detecting missing printed text on a card with a template image, comprising the following steps:

[0054] Step 1: obtain an image to be detected for the prepared card, detect the position of the card in the image to be detected by using a target detection algorithm, and cut out the card area to obtain a card area image;

[0055] Step 2, locating the four corner points of the card in the card area image;

[0056] Step 3, performing perspective transformation on the card area image to correct the tilt and deformation of the card area image;

[0057] Step 4, cutting out a complete card image based on the card area image after perspective transformation;

[0058] Step 5, scaling the cropped card image to the same resolution as the template image to obtain an aligned card image;

[0059] Step 6, determining the position of each text block according to the printing rules or using the text line detection method for the template image;

[0060] Step 7, using the geometric relationship between the template image and the aligned card image, for each text block in step 6, expand the search range centered on the corresponding position in the aligned card image as a candidate area for the text block;

[0061] Step 8, using the text block image in step 6 as a template, performing template matching on the candidate area in step 7, obtaining a matching result of the text block, and obtaining a difference map;

[0062] Step 9, perform morphological opening operation on the difference map to remove interference from small areas;

[0063] Step 10, extracting connected domains from the result of step 9 to obtain the missing area of ​​printed text.

[0064] First, card detection and corner location are performed, and the aligned image is obtained by perspective transformation and cropping and scaling to the same resolution as the template image; then the template image is detected for text lines to determine the position of the text block; then the search range is appropriately expanded with the corresponding position of the aligned image as the center as the candidate area, and the text block image is used as a template to perform fast template matching in the candidate area to obtain the matching result of the text block. Finally, the difference map is calculated based on the template image and the matching position, and morphological processing and connected domain analysis are performed to obtain the missing area of ​​printed text.

[0065] The missing printed text of the produced card can be automatically detected based on the template image, with high detection efficiency and high detection accuracy.

[0066] In step 2, according to the position of the card area image obtained in step 1, the centernet algorithm is used to locate the four corner points of the card.

[0067] Use a high-definition camera to take a photo of the prepared card. The card image after the camera takes the photo will have a certain rotation or perspective deformation due to the influence of factors such as shooting angle and position, and needs to be corrected. According to the position of the card in the image obtained in the previous step, the centernet algorithm is used to locate the four corner points of the card.

[0068] The method of step 3 is: use a perspective transformation algorithm to perform perspective transformation on the card area image, and the perspective transformation eliminates the tilt and deformation of the card image;

[0069] The perspective transformation algorithms are getPerspectiveTransform and warpPerspective in the OpenCV environment.

[0070] Perspective transformation can eliminate the tilt and deformation of the card image, making the image smoother and easier to process later.

[0071] The method of step 4 is: determine a cropping area according to the card image after perspective transformation, crop the card image to be detected, and ensure that the cropped area contains the complete card.

[0072] According to the card image after perspective transformation, a suitable cropping area is determined, and the card image to be detected is cropped out to ensure that the cropped area contains the complete card to avoid missing important content.

[0073] The template image in step 6 is an image provided to the printing device. The specific position of each line of text in the template image is obtained according to the printing rules, or the position of each line of text is obtained according to the text line detection algorithm. Each line of text is regarded as a text block.

[0074] The template image is prepared in advance and is provided to the printing device. The specific position of each line of text in the template image can be known according to the printing rules, and the position of each line of text can also be obtained according to the text line detection algorithm. Each line of text is regarded as a text block. For example, ID cards generally have corresponding printing standards. The template image is generated by the program according to the corresponding template. According to the printing standards, the position of the text block can be obtained by performing binarization processing and external rectangular frame estimation in the corresponding area.

[0075] In step 6, using the geometric relationship between the template image and the aligned card image, for each text block in step 6, the search range is appropriately expanded with the corresponding position in the aligned card image as the center as the candidate area of ​​the text block.

[0076] Due to the positioning problem of the printing device, the actual printing position of the text will be offset from the template card image. Therefore, it is necessary to appropriately expand the search range with the corresponding position as the center. For example, the height of the search area is 3 times the height of the text line, and the width of the search area is 1.3 times the width of the text line.

[0077] Step 8 includes the following sub-steps:

[0078] Step 81, for black printed fonts, extract the K channel of the CMYK color space from the template and the candidate area image respectively; for color printed fonts, extract the C, M and Y channels;

[0079] Step 82, using a segmentation algorithm to perform binarization processing on the C, M, Y and K channel images respectively;

[0080] Step 83, calculating the matching degree between each sliding window and the template for each channel respectively according to the sliding window method;

[0081] Step 84, selecting the sliding window position with the highest matching degree as the best matching position;

[0082] Step 85, performing pixel AND operation on the template image and the sliding window corresponding to the best matching position to obtain an identical image, and subtracting the identical image from the template image to obtain a difference image.

[0083] For black fonts, the K channel is usually used for printing, while for color fonts, they are synthesized by combining the C, M and Y channels. Therefore, different color channels need to be selected for matching according to fonts of different colors. By processing the printed fonts by channels, it is possible to detect the missing of printed text on a certain color channel. The result of this missing is that the printed text is normal, but the color is abnormal. For example, for red fonts, if there is a missing print on the Y channel, the printed text is normal and intact, but the color of the text is magenta, not red. The above C, M, Y and K channel images are binarized using a segmentation algorithm; binarization mainly reduces the interference of the complex background pattern on the card surface on the printed font, and can also reduce the interference of lighting factors on the results.

[0084] In step 8, template matching adopts a fast matching method based on binary images;

[0085] Define the matching degree: For the binary template image and the binary image to be matched, assume that the handwriting is white in the image;

[0086] The matching degree is calculated as follows: the binary template image and the sliding window are ANDed pixel by pixel, and the ratio of the number of non-zero pixels in the image after the operation to the total number of pixels is used as the matching degree;

[0087] The matching degree ranges from [0,1]. The higher the matching degree, the more similar the current sliding window is to the template image.

[0088] The fast matching process is as follows: calculate the integral image for the binary image to be matched; initialize the best matching degree to 0; for each sliding window, use the integral image to calculate the ratio of the total number of white pixels in the current sliding window to the total number of pixels in the template image;

[0089] If the current best matching degree is higher than the ratio, the calculation of the current sliding window is skipped; otherwise, the matching degree of the current sliding window is calculated according to the steps. If the matching degree of the current sliding window is higher than the current best matching degree, the current best matching degree is updated to the matching degree of the current sliding window.

[0090] For each sliding window, the total number of white pixels in the current window is calculated using the integral image; the total number of white pixels is the upper limit of the number of pixels that can be matched by the sliding window. The ratio of the total number of white pixels to the total number of pixels in the window is calculated, which is the upper limit of the matching degree that the sliding window can achieve. If the current best matching degree is higher than this ratio, the calculation of the current window can be safely skipped without affecting the final matching result; otherwise, the matching degree in the current sliding window is calculated according to the matching degree calculation formula, and the best matching degree is updated to the maximum value of the matching degrees of all current sliding windows. According to the current best matching result, the matching degree calculation of some windows can be appropriately skipped to reduce the amount of calculation without affecting the final result. In extreme cases, if the first sliding window is the best match, the matching degree calculation of all subsequent windows can be skipped.

[0091] Based on the text block matching, the text block is segmented into individual characters, and steps 8 and 9 are performed on the characters to obtain a difference map.

[0092] The impact of the detection results on imaging scale and angle can be further reduced.

[0093] A card and certificate printed text missing detection device with a template image comprises an imaging device, a memory and a processor. The imaging device is used to image a manufactured card and certificate to obtain an image to be detected, and to exchange the image to be detected with the memory. The memory stores a card and certificate printed text missing detection program designed using a card and certificate printed text missing detection method with a template image. The processor is communicatively connected with the memory and runs the card and certificate printed text missing detection program to output a detection result.

[0094] The following uses a specific implementation case to illustrate the implementation principle of a method and device for detecting missing printed text on a card with a template image:

[0095] Take the detection of missing printed text on the second-generation ID card as an example.

[0096] Step 1. Use a high-resolution camera to shoot the prepared second-generation ID card, train a second-generation ID card detection algorithm, perform second-generation ID card detection on the captured image, obtain the location of the second-generation ID card, and cut out the second-generation ID card area image.

[0097] Step 2. Locate the key points of the second-generation ID card area image. Train a centernet model to input the second-generation ID card area image and output the four corner points of the second-generation ID card.

[0098] Step 3. Based on the corner point positions and the width and height of the second-generation ID card template image, use the opencv function warpPerspective to estimate the transformation matrix between the second-generation ID card area image and the second-generation ID card template image. Assuming that the coordinates of the four corner points from the upper left corner to the lower left corner in the clockwise direction are p1, p2, p3 and p4, and the width of the second-generation ID card template image is w and the height is h, then four matching point pairs are obtained (p1, (0, 0)), (p2, (w, 0)) (p3, (w, h)), (p4, (0, h)). Based on these four matching point pairs, an affine transformation matrix can be estimated.

[0099] Step 4. According to the transformation matrix calculated in the previous step, perform an affine transformation on the second-generation ID card area image to eliminate the tilt and deformation caused by the imaging process.

[0100] Step 5: Since the size of the second-generation ID card template image is used when calculating the affine transformation matrix, the transformed card image has the same resolution as the template image. For the transformed image obtained in step 4, the aligned card image can be obtained by cropping the area with a width of w and a height of h;

[0101] Step 6, determining the position of each text block of the template image according to the printing rules, such as the position of the name, gender, ethnicity, date of birth, address and second-generation ID card number on the face of the second-generation ID card.

[0102] Step 7: Using the geometric relationship between the template image and the aligned card image, for each text block in step 6, expand the search range with the corresponding position in the aligned card image as the center as the candidate area of ​​the text block; if the second-generation ID card number text block in the template image is located in the rectangular area of ​​[x0, y0, w0, h0], then the corresponding position in the aligned card image and the four sides are expanded by h0 as the candidate area of ​​the text block, that is, the rectangular area of ​​[x0-h0, y0-h0, w0+2*h0, 3*h0]. Similar operations are performed on other text blocks.

[0103] Step 8, using the text block image in step 6 as a template, perform template matching on the candidate area in step 7, obtain the matching result of the text block, and obtain a difference map; taking the second-generation ID card number text block as an example, take [x0, y0, w0, h0] in the template image as a template, and take [x0-h0, y0-h0, w0+2*h0, 3*h0] of the aligned card image as a candidate image for template matching.

[0104] Step 81. Since the second-generation ID card number text block is in black font, the K channel of the CMYK color space is used for template matching. The K channel images of the CMYK color space are extracted for the template and the candidate image respectively;

[0105] Step 82, using an adaptive binary segmentation algorithm or an OTSU algorithm to perform binarization processing on the K channel image in the above step to obtain a binary template and a binary candidate image.

[0106] Step 83, calculating the matching degree between the binary template and each sliding window of the binary candidate image;

[0107] Step 84, selecting the sliding window position with the highest matching degree as the best matching position;

[0108] Step 85, performing pixel AND operation on the binary template and the sliding window corresponding to the best matching position to obtain the same image, and subtracting the binary template from the same image to obtain a difference image.

[0109] Step 9, perform morphological opening operation on the difference map to remove interference from small areas;

[0110] Step 10, extracting connected domains from the result of step 9 to obtain the missing area of ​​printed text.

[0111] In order to speed up the template matching process, a fast matching algorithm can be used in step 83. The fast matching process is:

[0112] Calculate the integral image for the binary image to be matched;

[0113] Initialize the best matching degree to 0;

[0114] For each sliding window, the integral image is used to calculate the ratio of the total number of white pixels in the current sliding window to the total number of pixels in the template image; according to the definition of matching degree, this ratio is the upper limit of the matching degree that the current sliding window can achieve.

[0115] If the current best match is higher than this ratio, that is, the match of the current window cannot be greater than the best match, then the matching calculation of the current sliding window is skipped, and the update of the best match is skipped; otherwise, the matching of the current sliding window is calculated. If the matching of the current sliding window is higher than the current best match, then the current best match is updated to the matching of the current sliding window.

[0116] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for detecting missing printed text on a card with a template image, characterized in that: The following steps are involved: Step 1: obtain an image to be detected for the prepared card, detect the position of the card in the image to be detected by using a target detection algorithm, and cut out the card area to obtain a card area image; Step 2, locating the four corner points of the card in the card area image; Step 3, performing perspective transformation on the card area image to correct the tilt and deformation of the card area image; Step 4, cutting out a complete card image based on the card area image after perspective transformation; Step 5, scaling the cropped card image to the same resolution as the template image to obtain an aligned card image; Step 6, determining the position of each text block according to the printing rules or using the text line detection method for the template image; Step 7, using the geometric relationship between the template image and the aligned card image, for each text block in step 6, expand the search range centered on the corresponding position in the aligned card image as a candidate area for the text block; Step 8, using the text block image in step 6 as a template, performing template matching on the candidate area in step 7, obtaining a matching result of the text block, and obtaining a difference map; Step 9, perform morphological opening operation on the difference map to remove interference from small areas; Step 10, extracting the connected domain from the result of step 9 to obtain the missing area of ​​printed text; Step 8 includes the following sub-steps: Step 81, for black printed fonts, extract the K channel of the CMYK color space from the template and the candidate area image respectively; for color printed fonts, extract the C, M and Y channels; Step 82, using a segmentation algorithm to perform binarization processing on the C, M, Y and K channel images respectively; Step 83, calculating the matching degree between each sliding window and the template for each channel respectively according to the sliding window method; Step 84, selecting the sliding window position with the highest matching degree as the best matching position; Step 85, performing pixel AND operation on the template and the sliding window corresponding to the best matching position to obtain the same image, and subtracting the same image from the template to obtain the difference image; In step 8, template matching adopts a fast matching method based on binary images; Define the matching degree: For a binary template and a binary image to be matched, assume that the handwriting is white in the image; The matching degree is calculated as follows: the binary template and the sliding window are ANDed pixel by pixel, and the ratio of the number of non-zero pixels in the image after the operation to the total number of pixels is used as the matching degree; The matching degree ranges from [0,1]. The higher the matching degree, the more similar the current sliding window is to the template. The fast matching process is as follows: calculate the integral image for the binary image to be matched; initialize the best matching degree to 0; For each sliding window, the integral image is used to calculate the ratio of the total number of white pixels in the current sliding window to the total number of pixels in the template; If the current best match is higher than this ratio, the calculation of the current sliding window is skipped; Otherwise, the matching degree in the current sliding window is calculated according to the steps. If the matching degree of the current sliding window is higher than the current best matching degree, the current best matching degree is updated as the matching degree of the current sliding window.

2. A method for detecting missing printed text on a card with a template image according to claim 1, characterized in that: In step 2, according to the position of the card area image obtained in step 1, the centernet algorithm is used to locate the four corner points of the card.

3. A method for detecting missing printed text on a card with a template image according to claim 1, characterized in that: The method of step 3 is: use a perspective transformation algorithm to perform perspective transformation on the card area image, and the perspective transformation eliminates the tilt and deformation of the card image; The perspective transformation algorithms are getPerspectiveTransform and warpPerspective in the OpenCV environment.

4. A method for detecting missing printed text on a card with a template image according to claim 3, characterized in that: The method of step 4 is: determine a cropping area according to the card image after perspective transformation, crop the card image to be detected, and ensure that the cropped area contains the complete card.

5. The method for detecting missing printed text on a card with a template image according to claim 1, characterized in that: The template image in step 6 is an image provided to the printing device. The specific position of each line of text in the template image is obtained according to the printing rules, or the position of each line of text is obtained according to the text line detection algorithm. Each line of text is regarded as a text block.

6. A method for detecting missing printed text on a card with a template image according to claim 1, characterized in that: Based on the text block matching, the text block is segmented into individual characters, and steps 8 and 9 are performed on the characters to obtain a difference map.

7. A card printed text missing detection device with a template image, characterized in that: The invention comprises an imaging device, a memory and a processor, wherein the imaging device is used to image a manufactured card to obtain an image to be detected and to exchange the image to be detected with the memory, the memory stores a card printed text missing detection program designed by using a card printed text missing detection method with a template image as described in any one of claims 1 to 6, and the processor is communicatively connected with the memory to run the card printed text missing detection program to output a detection result.

Citation Information

Patent Citations

  • Text image synthesis method and device, equipment, storage medium and program product

    CN114332895A

  • Card identification method, card identification model training method and electronic equipment

    CN115880695A