CN111553317B - Anti-fake code acquisition method and device, computer equipment and storage medium - Google Patents

Anti-fake code acquisition method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN111553317B
CN111553317B CN202010407200.4A CN202010407200A CN111553317B CN 111553317 B CN111553317 B CN 111553317B CN 202010407200 A CN202010407200 A CN 202010407200A CN 111553317 B CN111553317 B CN 111553317B
Authority
CN
China
Prior art keywords
image
target
counterfeiting
gray
template
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010407200.4A
Other languages
Chinese (zh)
Other versions
CN111553317A (en
Inventor
马浩浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Huilang Times Technology Co Ltd
Original Assignee
Beijing Huilang Times Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Huilang Times Technology Co Ltd filed Critical Beijing Huilang Times Technology Co Ltd
Priority to CN202010407200.4A priority Critical patent/CN111553317B/en
Publication of CN111553317A publication Critical patent/CN111553317A/en
Application granted granted Critical
Publication of CN111553317B publication Critical patent/CN111553317B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/06009Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
    • G06K19/06037Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/018Certifying business or products
    • G06Q30/0185Product, service or business identity fraud
    • G06T5/70
    • G06T5/73
    • G06T5/77
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/25Determination of region of interest [ROI] or a volume of interest [VOI]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/148Segmentation of character regions
    • G06V30/153Segmentation of character regions using recognition of characters or words
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition

Abstract

The invention discloses an anti-fake code acquisition method, an anti-fake code acquisition device, computer equipment and a storage medium. The method comprises the following steps: acquiring a picture to be identified, and determining a matched template picture according to the picture to be identified; intercepting a target anti-counterfeiting image containing anti-counterfeiting codes in the picture to be identified, and intercepting a matched target template image in the template picture according to the target anti-counterfeiting image; and eliminating the background pattern in the target anti-counterfeiting image according to the target template image so as to acquire a target image to be identified and identify an anti-counterfeiting code in the target image to be identified. By using the technical scheme of the embodiment of the invention, the background of the anti-fake code can be removed, the display effect of the anti-fake code is enhanced, and the accuracy of anti-fake code identification is improved.

Description

Anti-fake code acquisition method and device, computer equipment and storage medium
Technical Field
The embodiment of the invention relates to an image processing technology, in particular to an anti-fake code acquisition method, an anti-fake code acquisition device, computer equipment and a storage medium.
Background
Financial security is an important component of national security, and the importance of various paper and electronic security documents, whether for traditional commerce or electronic commerce, is self-evident. Along with the development of bill anti-counterfeiting technology, anti-counterfeiting codes play an important role in bill anti-counterfeiting. In the application of the anti-counterfeiting code, the anti-counterfeiting code in the bill is firstly identified, then the identified anti-counterfeiting code is compared with a preset anti-counterfeiting code, and when the comparison is consistent, the subsequent operation is executed on the bill.
In the prior art, the security codes in the ticket are typically identified by OCR (optical character recognition ) technology. In carrying out the invention, the inventors have found that the prior art has the following drawbacks: when the character pressing exists at the position of the anti-counterfeiting code or the background is complex, the accuracy of recognizing the anti-counterfeiting code by using the OCR technology is low, and the recognition effect is poor.
Disclosure of Invention
The embodiment of the invention provides an anti-counterfeiting code acquisition method, an anti-counterfeiting code acquisition device, computer equipment and a storage medium, so that the background of the anti-counterfeiting code is removed, the display effect of the anti-counterfeiting code is enhanced, and the accuracy of anti-counterfeiting code identification is improved.
In a first aspect, an embodiment of the present invention provides a method for acquiring an anti-pseudo code, where the method includes:
acquiring a picture to be identified, and determining a matched template picture according to the picture to be identified;
intercepting a target anti-counterfeiting image containing anti-counterfeiting codes in the picture to be identified, and intercepting a matched target template image in the template picture according to the target anti-counterfeiting image;
and eliminating the background pattern in the target anti-counterfeiting image according to the target template image so as to acquire a target image to be identified and identify an anti-counterfeiting code in the target image to be identified.
In a second aspect, an embodiment of the present invention further provides an apparatus for acquiring an anti-pseudo code, where the apparatus includes:
the image acquisition module is used for acquiring an image to be identified and determining a matched template image according to the image to be identified;
the image intercepting module is used for intercepting a target anti-counterfeiting image containing anti-counterfeiting codes in the image to be identified and intercepting a matched target template image in the template image according to the target anti-counterfeiting image;
and the anti-counterfeiting code identification module is used for eliminating the background pattern in the target anti-counterfeiting image according to the target template image so as to acquire a target image to be identified and identify the anti-counterfeiting code in the target image to be identified.
In a third aspect, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the method for acquiring the anti-pseudo code according to any one of the embodiments of the present invention when the processor executes the program.
In a fourth aspect, embodiments of the present invention further provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform a method for acquiring anti-counterfeiting code according to any one of the embodiments of the present invention.
According to the embodiment of the invention, the image to be identified and the matched template image are respectively intercepted, the target anti-counterfeiting image and the target template image are obtained, and the background pattern in the target anti-counterfeiting image is eliminated according to the target template image, so that the identification of the anti-counterfeiting code is facilitated. The problems that in the prior art, when the character pressing or background patterns exist at the positions of the anti-counterfeiting codes, the accuracy of recognizing the anti-counterfeiting codes by using an OCR technology is low and the recognition effect is poor are solved, the background removal of the anti-counterfeiting codes is realized, the display effect of the anti-counterfeiting codes is enhanced, and the effect of the accuracy of recognizing the anti-counterfeiting codes is improved.
Drawings
Fig. 1a is a flowchart of a method for acquiring anti-fake codes according to a first embodiment of the present invention;
FIG. 1b is a schematic illustration of an image to be identified of a target suitable for use in an embodiment of the present invention;
FIG. 1c is a schematic diagram of a target security gray scale image suitable for use in embodiments of the present invention;
FIG. 1d is a schematic illustration of a gray scale image of a target template suitable for use in embodiments of the present invention;
FIG. 1e is a schematic representation of a negative image of a target template gray scale image suitable for use in embodiments of the present invention;
fig. 2a is a flowchart of a method for acquiring anti-counterfeiting code according to a second embodiment of the present invention;
FIG. 2b is a schematic diagram of a target security image after performing a mottle removal process according to an embodiment of the present invention;
FIG. 2c is a schematic diagram of a target security image after performing a tone scale adjustment process according to an embodiment of the present invention;
FIG. 2d is a flow chart of a method for obtaining anti-counterfeiting codes suitable for use in the specific application scenario of the present invention;
fig. 3 is a schematic structural diagram of an apparatus for acquiring an anti-counterfeit code according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a computer device in a fourth embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
Example 1
Fig. 1a is a flowchart of an anti-counterfeit code acquisition method according to an embodiment of the present invention, where the method may be applied to identifying an anti-counterfeit code in a ticket, and the method may be performed by an anti-counterfeit code acquisition device, which may be implemented by software and/or hardware, and typically may be integrated in a computer device, typically in a print controller.
As shown in fig. 1a, the technical solution of the embodiment of the present invention specifically includes the following steps:
s110, acquiring a picture to be identified, and determining a matched template picture according to the picture to be identified.
The picture to be identified is a picture containing an anti-counterfeiting code and needing to be identified by the anti-counterfeiting code, for example, a bill picture containing the anti-counterfeiting code; the template picture is an original picture which is matched with the picture to be identified but does not contain anti-counterfeiting codes, for example, an original picture of a bill, namely, a bill picture which does not contain anti-counterfeiting codes; particularly, when the picture to be identified and the template picture are generated by the picture shooting device, shooting parameters such as contrast, saturation, exposure, brightness, white balance and the like are all set to be the same value, so that the uniformity of the pictures is ensured. In the embodiment of the invention, the types, sources and sizes of the picture to be identified and the template picture are not limited.
After obtaining a picture to be identified containing an anti-fake code, a template picture matched with the picture to be identified is required to be obtained; specifically, the matched template picture can be obtained by obtaining the type of the picture to be identified, the type of the picture to be identified can be obtained by obtaining the attribute information of the picture to be identified, or by identifying the picture to be identified, for example, when the picture to be identified is obtained, if the attribute information of the picture to be identified is obtained as a reimbursement receipt, or the typeface of the reimbursement receipt is identified in the picture to be identified, the template picture with the type of reimbursement receipt is searched.
In an optional embodiment of the present invention, the determining a matching template picture according to the picture to be identified may include: and determining a template picture matched with the picture to be identified by a mean square error method. The mean square error method is to calculate the difference between standard deviations of two pictures to obtain the matching degree of the two pictures, and the smaller the absolute value of the difference is, the higher the matching degree of the two pictures is, so that the template picture with the smallest absolute value of the difference with the picture to be identified can be searched in each template picture by the mean square error method to be used as the template picture matched with the picture to be identified.
S120, intercepting a target anti-counterfeiting image containing anti-counterfeiting codes in the picture to be identified, and intercepting a matched target template image in the template picture according to the target anti-counterfeiting image.
The anti-counterfeiting code can be a character string formed by elements such as characters and/or numbers. The target anti-counterfeiting image is a picture which is cut out from the picture to be identified and contains an anti-counterfeiting code part, and the target template image is an image which is cut out from the template picture and is matched with the target anti-counterfeiting image. The target anti-counterfeiting image and the target template image have the same shape (for example, are rectangular, circular and other polygons), and the size of the target template image is larger than or equal to that of the target anti-counterfeiting image so as to ensure that the target template image comprises all background patterns of the target anti-counterfeiting image; the size and the shape of the target anti-counterfeiting image and the target template image are not limited by the embodiment of the invention.
S130, eliminating the background pattern in the target anti-counterfeiting image according to the target template image so as to obtain a target image to be identified, and identifying an anti-counterfeiting code in the target image to be identified.
The background pattern in the target anti-counterfeiting image can be factors influencing the identification accuracy of the anti-counterfeiting code, such as patterns, ground colors, characters and the like, and the background pattern needs to be removed so as to enhance the display effect of the anti-counterfeiting code in the target anti-counterfeiting image, thereby improving the identification accuracy of the anti-counterfeiting code. The target image to be identified is an image obtained by removing the background pattern in the target anti-counterfeiting image. Fig. 1b provides a schematic diagram of an image to be identified of a target, as shown in fig. 1b, the image to be identified of the target only includes anti-counterfeiting codes, and does not include background patterns, the definition of the anti-counterfeiting codes is higher, and correspondingly, the accuracy of the anti-counterfeiting codes identified according to the image to be identified of the target is higher.
In the embodiment of the invention, the background pattern in the target anti-counterfeiting image is removed through the target template image to obtain the target image to be identified, and the target image to be identified is identified to obtain the anti-counterfeiting code.
In an optional embodiment of the present invention, the removing the background pattern in the target anti-counterfeit image according to the target template image includes: respectively carrying out graying treatment on the target anti-counterfeiting image and the target template image to obtain a target anti-counterfeiting gray level image and a target template gray level image; converting the target template gray level image into a negative image, and performing color reduction treatment on the target anti-counterfeiting gray level image according to the negative image so as to eliminate image elements which are the same as the target template gray level image in the target anti-counterfeiting gray level image.
The graying process is a process of converting the target anti-counterfeit image and the target template image into a gray image, and the color value of each pixel on the gray image is also called a gray value, which can refer to the shade degree of color, generally ranges from 0 to 255, and can define that the gray value of white is 255 and the gray value of black is 0. Graying processing can be performed by a component method, a maximum value method, an average value method, a weighted average method or the like, wherein the component method is to respectively take the values of R, G and B components of each pixel in an image as the gray values of three gray images, and one gray image is selected according to the setting; the maximum value method is to take the maximum value of R, G and B three component values of each pixel in the image as the gray value of each pixel in the gray image; the average value method is to average the R, G and B three component values of each pixel in the image, and the average value is used as the gray value of each pixel in the gray image; the weighted average method is to perform weighted average on three components with different weights, and the obtained weighted average is used as the gray value of each pixel in the gray image. In the embodiment of the present invention, the manner of the graying process is not particularly limited.
The target anti-counterfeiting gray scale image is an image obtained after the target anti-counterfeiting image is subjected to graying treatment, and fig. 1c provides a schematic diagram of the target anti-counterfeiting gray scale image, and as shown in fig. 1c, the target anti-counterfeiting gray scale image has no color, and comprises an anti-counterfeiting code and a background pattern.
The target template gray level image is an image obtained after the target template image is subjected to graying treatment, and fig. 1d provides a schematic diagram of the target template gray level image, as shown in fig. 1d, the target template gray level image has no color, and is matched with the target anti-counterfeiting gray level image in fig. 1c, and does not comprise anti-counterfeiting codes, but only comprises background patterns.
The negative image is an image obtained after performing negative image processing on the target template image, and the negative image processing is a process of inverting the color of the image, for example, when the gray value of a pixel at a certain point in the target template image is 255, the point is a white point, and after performing negative image processing on the target template image, the gray value of the pixel at the point is changed to 0, and the point is changed to a black point. FIG. 1e provides a schematic representation of a negative image, as shown in FIG. 1e, with the negative image having a color that is opposite to the target template image schematic of FIG. 1 d. The color reduction treatment is a process of whitening a background and changing the brightness of the background, and in the embodiment of the invention, the negative image of the target template gray level image is covered on the target anti-counterfeiting gray level image to offset the image elements which are the same as the target template gray level image in the target anti-counterfeiting gray level image, so that the effect of removing the background pattern is obtained.
In the embodiment of the invention, the background pattern in the target anti-counterfeiting image is removed through the target template image, the target anti-counterfeiting image and the target template image can be converted into the target anti-counterfeiting gray image and the target template gray image, the target template gray image is converted into the negative image, and the same image elements in the target anti-counterfeiting gray image are counteracted by the negative image, so that the background pattern of the target anti-counterfeiting gray image is removed, and the display effect of the anti-counterfeiting code is highlighted.
According to the technical scheme, the target anti-counterfeiting image and the target template image are obtained by respectively intercepting the picture to be identified and the matched template picture, and the background pattern in the target anti-counterfeiting image is eliminated according to the target template image, so that identification of anti-counterfeiting codes is facilitated. The problems that in the prior art, when the character pressing or background patterns exist at the positions of the anti-counterfeiting codes, the accuracy of recognizing the anti-counterfeiting codes by using an OCR technology is low and the recognition effect is poor are solved, the background removal of the anti-counterfeiting codes is realized, the display effect of the anti-counterfeiting codes is enhanced, and the effect of the accuracy of recognizing the anti-counterfeiting codes is improved.
Example two
Fig. 2a is a flowchart of an anti-counterfeit code obtaining method according to a second embodiment of the present invention, where a process of eliminating a background pattern in a target anti-counterfeit image according to a target template image is further embodied, and steps of performing mottle elimination and tone adjustment on the target anti-counterfeit image are added on the basis of the above embodiment.
Correspondingly, as shown in fig. 2a, the technical solution of the embodiment of the present invention specifically includes the following steps:
s210, acquiring a picture to be identified.
S220, determining a template picture matched with the picture to be identified through a mean square error method.
S230, intercepting a target anti-counterfeiting image containing anti-counterfeiting codes in the picture to be identified, and intercepting a matched target template image in the template picture according to the target anti-counterfeiting image.
S240, eliminating the background pattern in the target anti-counterfeiting image according to the target template image.
Accordingly, S240 further includes:
s241, respectively carrying out graying treatment on the target anti-counterfeiting image and the target template image so as to obtain a target anti-counterfeiting gray level image and a target template gray level image.
S242, converting the target template gray level image into a negative image, and performing color reduction treatment on the target anti-counterfeiting gray level image according to the negative image so as to eliminate image elements which are the same as the target template gray level image in the target anti-counterfeiting gray level image.
Wherein S242 further comprises:
s2420, changing the gray value of each pixel in the target template gray image by the following formula:
Gray i =255-Gray i
wherein i is E [1, N]N represents the number of pixels in the Gray image of the target template, gray i ' represents the Gray value of the ith pixel in the target template Gray image before modification, gray i And representing the gray value of the ith pixel in the changed target template gray image.
In the embodiment of the invention, the target template gray image can be converted into the negative image by changing the gray value of each pixel in the target template gray image, the gray value of each pixel in the target template gray image can be 0-255, and 255 can be used for representing white, and 0 can be used for representing black, so that the gray value of each pixel in the target template gray image is changed into the difference value between 255 and the original gray value, and the negative image can be obtained.
S2421, changing the gray value of each pixel in the target anti-counterfeiting gray image through the following formula:
Gray1 i =|Gray1 i ′-Gray i |
wherein Gray1 i ' represents the Gray value of the ith pixel in the target anti-counterfeiting Gray image before modification, gray1 i And representing the gray value of the ith pixel in the changed target anti-counterfeiting gray image.
In the embodiment of the invention, the color reduction processing can be performed by calculating the absolute value of the difference value of each pixel of the changed target template gray level image and the target anti-counterfeiting gray level image and changing the gray level value of each pixel in the target anti-counterfeiting gray level image into the absolute value. However, the specific process of the color reduction treatment is not limited in this embodiment, and the gray value of each pixel in the target anti-counterfeit gray image can be changed by other calculation formulas.
Alternatively, when the sizes of the target anti-counterfeit gray image and the target template gray image are different, the image with smaller size may be expanded first, and the gray value of the expanded portion may be set to a preset gray value, for example, the preset gray value may be set to 255. And calculating the absolute value of the pixel value difference between the expanded image and the other image, and changing the gray value of each pixel in the target anti-counterfeiting gray image into the absolute value, thereby eliminating the background pattern in the target anti-counterfeiting gray image.
S250, performing variegation elimination treatment on the target anti-counterfeiting image after the background pattern is eliminated.
The stray color elimination can be to eliminate stray colors such as noise points, lines and the like in the target anti-counterfeiting image. The variegation elimination processing can be realized by means of Gaussian blur, binarization processing and the like, and the Gaussian blur is applied to an image algorithm, so that the image has a blurred effect, the image noise can be reduced, and the level of detail can be reduced; the binarization processing can enable the pixel value of each pixel in the target anti-counterfeiting image to be 0 or 255, so that the target anti-counterfeiting image has a non-black or white effect, and the anti-counterfeiting code and the background can be further separated. The binarization processing needs to obtain a binarization threshold value firstly, and the method for obtaining the binarization threshold value comprises the following steps: 127 (the number of 0-255) can be taken directly; the average value of the pixel values of all pixels in the target anti-counterfeiting image can be taken; the binarization threshold value can be obtained through a pixel value histogram of each pixel in the target anti-counterfeiting image.
The embodiment of the invention does not limit the specific process of binarization processing, does not limit the mode and the specific process of variegation elimination processing, and any technical scheme capable of eliminating image variegation in the prior art is within the protection scope of the embodiment of the invention. Fig. 2b provides a schematic diagram of the target anti-counterfeit image after the process of eliminating the mottle, as shown in fig. 2b, after the process of eliminating the mottle, the noise and the line in the background of the target anti-counterfeit image are further removed.
And S260, performing color level adjustment processing on the target anti-counterfeiting image subjected to the variegation elimination processing.
The color level can refer to the brightness of the color in the image, and the color level adjustment is to adjust the brightness of the color in the target anti-counterfeiting image. The color level can be adjusted by methods such as opening and closing operation, median filtering and the like, and the opening operation can be used for eliminating small objects in the image, separating the objects at fine points and smoothing the boundary of a larger object without obviously changing the area of the objects; the closing operation may filter the image by filling in the reentrant corners of the image, may fill in small holes, and may close small cracks, while maintaining the overall position and shape. The median filtering can remove the solitary noise, and can maintain the edge characteristics of the image without causing significant blurring of the image.
In the embodiment of the invention, the light pixels in the target anti-counterfeiting image can be removed by performing the tone scale adjustment, and the anti-counterfeiting code part is deepened, so that the display effect of the anti-counterfeiting code is enhanced. Fig. 2c provides a schematic diagram of the target anti-counterfeiting image after the color level adjustment, as shown in fig. 2c, and lines of the anti-counterfeiting code in the target anti-counterfeiting image in fig. 2c are further deepened compared with the target anti-counterfeiting image in fig. 2 b.
It should be noted that, the first performing the mottle eliminating process and then performing the tone adjustment process is only one implementation manner of the embodiment of the present invention, and the first performing the tone adjustment process and then performing the mottle eliminating process may also be performed, and the embodiment of the present invention does not limit the order of the mottle eliminating process and the tone adjustment process.
S270, acquiring an image to be identified of the target, and identifying an anti-fake code in the image to be identified of the target.
According to the technical scheme, the target anti-counterfeiting image and the target template image are intercepted in the picture to be identified and the template picture matched with the picture to be identified, gray processing is carried out on the target anti-counterfeiting image and the target template image, the obtained target template gray image is converted into a negative image, the background pattern in the target anti-counterfeiting gray image is removed according to the negative image, and the target anti-counterfeiting image after the background pattern is removed is subjected to variegation elimination and color level adjustment so as to identify anti-counterfeiting codes. The problems that in the prior art, when the character pressing or background patterns exist at the positions of the anti-counterfeiting codes, the accuracy of recognizing the anti-counterfeiting codes by using an OCR technology is low and the recognition effect is poor are solved, the background of the anti-counterfeiting codes is removed, the interference of noise, variegation and the like is removed, the display effect of the anti-counterfeiting codes is enhanced, and therefore the effect of the accuracy of recognizing the anti-counterfeiting codes is improved.
Specific application scenario 1
In a specific application scenario of the present invention, fig. 2d provides a flowchart of a method for obtaining anti-counterfeiting code, as shown in fig. 2d, where the method specifically includes:
s1, acquiring a picture to be identified, intercepting a target anti-counterfeiting image according to the bill type corresponding to the picture to be identified, and selecting a matched template picture.
S2, intercepting a target template image according to the template image.
S3, carrying out gray processing on the target anti-counterfeiting image to obtain the target anti-counterfeiting gray image.
S4, carrying out graying treatment on the target template image to obtain the target template gray image.
S5, converting the gray level image of the target template into a negative image.
S6, performing color reduction treatment on the target anti-counterfeiting gray level image according to the negative image, and eliminating image elements in the target anti-counterfeiting gray level image, which are identical to the gray level image of the target template.
S7, performing the process of eliminating the variegation on the target anti-counterfeiting gray level image subjected to the color reduction process.
S8, performing tone scale adjustment processing on the target anti-counterfeiting gray scale image subjected to the impurity color removal processing.
And S9, performing character recognition on the target anti-counterfeiting gray level image subjected to the tone adjustment treatment, and obtaining an anti-counterfeiting code corresponding to the target anti-counterfeiting gray level image.
According to the technical scheme, the target anti-counterfeiting image and the target template image are intercepted in the picture to be identified and the template picture matched with the picture to be identified, gray processing is carried out on the target anti-counterfeiting image and the target template image, the obtained target template gray image is converted into a negative image, the background pattern in the target anti-counterfeiting gray image is removed according to the negative image, and the target anti-counterfeiting image after the background pattern is removed is subjected to variegation elimination and color level adjustment so as to identify anti-counterfeiting codes. The problems that in the prior art, when the character pressing or background patterns exist at the positions of the anti-counterfeiting codes, the accuracy of recognizing the anti-counterfeiting codes by using an OCR technology is low and the recognition effect is poor are solved, the background of the anti-counterfeiting codes is removed, the interference of noise, variegation and the like is removed, the display effect of the anti-counterfeiting codes is enhanced, and therefore the effect of the accuracy of recognizing the anti-counterfeiting codes is improved.
Example III
Fig. 3 is a schematic structural diagram of an apparatus for acquiring an anti-counterfeit code according to a third embodiment of the present invention, where the apparatus may be integrated in a computer device. The device comprises: a picture acquisition module 310, an image capture module 320, and an anti-counterfeit code identification module 330. Wherein:
the image acquisition module 310 is configured to acquire an image to be identified, and determine a matched template image according to the image to be identified;
the image capturing module 320 is configured to capture a target anti-counterfeiting image including an anti-counterfeiting code in the image to be identified, and capture a matched target template image in the template image according to the target anti-counterfeiting image;
and the anti-counterfeiting code identification module 330 is used for eliminating the background pattern in the target anti-counterfeiting image according to the target template image so as to acquire a target image to be identified and identify the anti-counterfeiting code in the target image to be identified.
According to the technical scheme, the target anti-counterfeiting image and the target template image are obtained by respectively intercepting the picture to be identified and the matched template picture, and the background pattern in the target anti-counterfeiting image is eliminated according to the target template image, so that identification of anti-counterfeiting codes is facilitated. The problems that in the prior art, when the character pressing or background patterns exist at the positions of the anti-counterfeiting codes, the accuracy of recognizing the anti-counterfeiting codes by using an OCR technology is low and the recognition effect is poor are solved, the background removal of the anti-counterfeiting codes is realized, the display effect of the anti-counterfeiting codes is enhanced, and the effect of the accuracy of recognizing the anti-counterfeiting codes is improved.
On the basis of the above embodiment, the image obtaining module 310 includes:
and the template picture determining unit is used for determining the template picture matched with the picture to be identified through a mean square error method.
Based on the above embodiment, the anti-counterfeit code identification module 330 includes:
the graying processing unit is used for respectively carrying out graying processing on the target anti-counterfeiting image and the target template image so as to obtain a target anti-counterfeiting gray level image and a target template gray level image;
the color reduction processing unit is used for converting the target template gray level image into a negative image, and performing color reduction processing on the target anti-counterfeiting gray level image according to the negative image so as to eliminate the image elements which are the same as the target template gray level image in the target anti-counterfeiting gray level image.
On the basis of the above embodiment, the apparatus further includes:
and the variegation elimination processing module is used for performing variegation elimination processing on the target anti-counterfeiting image after the background pattern is eliminated.
On the basis of the above embodiment, the apparatus further includes:
and the color level adjustment processing module is used for performing color level adjustment processing on the target anti-counterfeiting image after the variegation elimination processing.
On the basis of the above embodiment, the color-reduction processing unit includes:
a negative image conversion subunit, configured to change the gray value of each pixel in the target template gray image according to the following formula:
Gray i =255-Gray i
wherein i is E [1, N]N represents the number of pixels in the Gray image of the target template, gray i ' represents the Gray value of the ith pixel in the target template Gray image before modification, gray i And representing the gray value of the ith pixel in the changed target template gray image.
On the basis of the above embodiment, the color-reduction processing unit includes:
a gray value changing subunit, configured to change the gray value of each pixel in the target anti-counterfeit gray image according to the following formula:
Gray1 i =|Gray1 i ′-Gray i |
wherein Gray1 i ' represents the Gray value of the ith pixel in the target anti-counterfeiting Gray image before modification, gray1 i And representing the gray value of the ith pixel in the changed target anti-counterfeiting gray image.
The anti-fake code acquisition device provided by the embodiment of the invention can execute the anti-fake code acquisition method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 4 is a schematic structural diagram of a computer device according to a fourth embodiment of the present invention, and as shown in fig. 4, the computer device includes a processor 70, a memory 71, an input device 72 and an output device 73; the number of processors 70 in the computer device may be one or more, one processor 70 being taken as an example in fig. 4; the processor 70, memory 71, input means 72 and output means 73 in the computer device may be connected by a bus or other means, in fig. 4 by way of example.
The memory 71 is used as a computer readable storage medium, and may be used to store a software program, a computer executable program, and a module, such as a module corresponding to the anti-counterfeit code acquisition method in the embodiment of the present invention (for example, the picture acquisition module 310, the image capturing module 320, and the anti-counterfeit code identification module 330 in the anti-counterfeit code acquisition device). The processor 70 executes various functional applications of the computer device and data processing, that is, implements the above-described anti-pseudo code acquisition method, by running software programs, instructions, and modules stored in the memory 71. The method comprises the following steps:
acquiring a picture to be identified, and determining a matched template picture according to the picture to be identified;
intercepting a target anti-counterfeiting image containing anti-counterfeiting codes in the picture to be identified, and intercepting a matched target template image in the template picture according to the target anti-counterfeiting image;
and eliminating the background pattern in the target anti-counterfeiting image according to the target template image so as to acquire a target image to be identified and identify an anti-counterfeiting code in the target image to be identified.
The memory 71 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functions; the storage data area may store data created according to the use of the terminal, etc. In addition, memory 71 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 71 may further include memory remotely located relative to processor 70, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 72 may be used to receive entered numeric or character information and to generate key signal inputs related to user settings and function control of the computer device. The output means 73 may comprise a display device such as a display screen.
Example five
A fifth embodiment of the present invention also provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform a method of acquiring security code, the method comprising:
acquiring a picture to be identified, and determining a matched template picture according to the picture to be identified;
intercepting a target anti-counterfeiting image containing anti-counterfeiting codes in the picture to be identified, and intercepting a matched target template image in the template picture according to the target anti-counterfeiting image;
and eliminating the background pattern in the target anti-counterfeiting image according to the target template image so as to acquire a target image to be identified and identify an anti-counterfeiting code in the target image to be identified.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present invention is not limited to the above-described method operations, and may also perform related operations in the method for acquiring the security code provided in any embodiment of the present invention.
From the above description of embodiments, it will be clear to a person skilled in the art that the present invention may be implemented by means of software and necessary general purpose hardware, but of course also by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, etc., and include several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments of the present invention.
It should be noted that, in the embodiment of the above-mentioned anti-counterfeiting code acquisition device, each unit and module included are only divided according to the functional logic, but are not limited to the above-mentioned division, so long as the corresponding functions can be realized; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.

Claims (9)

1. The method for acquiring the anti-fake code is characterized by comprising the following steps of:
acquiring a picture to be identified, and determining a matched template picture according to the picture to be identified;
intercepting a target anti-counterfeiting image containing anti-counterfeiting codes in the picture to be identified, and intercepting a matched target template image in the template picture according to the target anti-counterfeiting image;
removing background patterns in the target anti-counterfeiting image according to the target template image to obtain a target image to be identified, and identifying anti-counterfeiting codes in the target image to be identified;
the eliminating the background pattern in the target anti-counterfeiting image according to the target template image comprises the following steps:
respectively carrying out graying treatment on the target anti-counterfeiting image and the target template image to obtain a target anti-counterfeiting gray level image and a target template gray level image;
converting the target template gray level image into a negative image, and performing color reduction treatment on the target anti-counterfeiting gray level image according to the negative image so as to eliminate image elements which are the same as the target template gray level image in the target anti-counterfeiting gray level image.
2. The method of claim 1, wherein the determining a matching template picture from the picture to be identified comprises:
and determining a template picture matched with the picture to be identified by a mean square error method.
3. The method of claim 1, further comprising, after eliminating a background pattern in the target security image from the target template image:
and performing variegation elimination treatment on the target anti-counterfeiting image after the background pattern is eliminated.
4. The method of claim 3, further comprising, after subjecting the target security image after the background pattern is removed to a mottle removal process:
and performing color level adjustment processing on the target anti-counterfeiting image after the variegation elimination processing.
5. The method of claim 1, wherein said converting said target template grayscale image to a negative image comprises:
changing the gray value of each pixel in the target template gray image by the following formula:
Gray i =255-Gray i
wherein i is E [1, N]N represents the number of pixels in the Gray image of the target template, gray i Representing the Gray value of the ith pixel in the Gray image of the target template before modification i Representing the changed placeAnd the gray value of the ith pixel in the target template gray image.
6. The method of claim 5, wherein said performing a color reduction process on said target security gray scale image from said negative image comprises:
changing the gray value of each pixel in the target anti-counterfeiting gray image through the following formula:
Gray1 i =|Gray1 i -Gray i |
wherein Gray1 i Gray1 representing the Gray value of the ith pixel in the target anti-counterfeit Gray image before modification i And representing the gray value of the ith pixel in the changed target anti-counterfeiting gray image.
7. An acquisition device of anti-counterfeiting code, characterized by comprising:
the image acquisition module is used for acquiring an image to be identified and determining a matched template image according to the image to be identified;
the image intercepting module is used for intercepting a target anti-counterfeiting image containing anti-counterfeiting codes in the image to be identified and intercepting a matched target template image in the template image according to the target anti-counterfeiting image;
the anti-fake code identification module is used for eliminating background patterns in the target anti-fake image according to the target template image so as to acquire a target image to be identified and identify anti-fake codes in the target image to be identified;
the anti-counterfeiting code identification module comprises:
the graying processing unit is used for respectively carrying out graying processing on the target anti-counterfeiting image and the target template image so as to obtain a target anti-counterfeiting gray level image and a target template gray level image;
the color reduction processing unit is used for converting the target template gray level image into a negative image, and performing color reduction processing on the target anti-counterfeiting gray level image according to the negative image so as to eliminate the image elements which are the same as the target template gray level image in the target anti-counterfeiting gray level image.
8. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of acquiring anti-counterfeiting code according to any one of claims 1 to 6 when the program is executed by the processor.
9. A storage medium containing computer executable instructions which, when executed by a computer processor, are for performing the method of acquiring anti-counterfeiting code according to any one of claims 1 to 6.
CN202010407200.4A 2020-05-14 2020-05-14 Anti-fake code acquisition method and device, computer equipment and storage medium Active CN111553317B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010407200.4A CN111553317B (en) 2020-05-14 2020-05-14 Anti-fake code acquisition method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010407200.4A CN111553317B (en) 2020-05-14 2020-05-14 Anti-fake code acquisition method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111553317A CN111553317A (en) 2020-08-18
CN111553317B true CN111553317B (en) 2023-08-08

Family

ID=72002803

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010407200.4A Active CN111553317B (en) 2020-05-14 2020-05-14 Anti-fake code acquisition method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111553317B (en)

Citations (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102305664A (en) * 2011-05-19 2012-01-04 中国农业大学 Thermal imaging temperature measurement and fault location inspection system
CN102663337A (en) * 2012-03-16 2012-09-12 江南大学 Method for quick Data Matrix two-dimensional barcode identifying under simple condition background
CN102682266A (en) * 2012-05-17 2012-09-19 西北工业大学 Cylindrical surface bidimensional bar code reading method based on image splicing
CN102930277A (en) * 2012-09-19 2013-02-13 上海珍岛信息技术有限公司 Character picture verification code identifying method based on identification feedback
CN103116751A (en) * 2013-01-24 2013-05-22 河海大学 Automatic license plate character recognition method
CN103514448A (en) * 2013-10-24 2014-01-15 北京国基科技股份有限公司 Method and system for navicular identification
CN104463795A (en) * 2014-11-21 2015-03-25 高韬 Processing method and device for dot matrix type data matrix (DM) two-dimension code images
CN104915668A (en) * 2015-05-29 2015-09-16 深圳泓数科技有限公司 Character information identification method for medical image and device thereof
CN105335744A (en) * 2015-11-10 2016-02-17 佛山科学技术学院 One-dimensional code region location based on image backbone extraction strip distribution features
CN105447489A (en) * 2015-11-13 2016-03-30 浙江传媒学院 Character and background adhesion noise elimination method for image OCR system
CN106886996A (en) * 2017-02-10 2017-06-23 九次方大数据信息集团有限公司 Dividing method and device based on mathematical operation identifying code image
CN107392877A (en) * 2017-07-11 2017-11-24 中国科学院电子学研究所苏州研究院 A kind of single polarization diameter radar image puppet coloured silkization method
CN107609193A (en) * 2017-10-16 2018-01-19 杭州时间线信息科技有限公司 The intelligent automatic processing method and system of picture in a kind of suitable commodity details page
CN107622247A (en) * 2017-09-26 2018-01-23 华东师范大学 A kind of positioning of express waybill and extracting method
CN108230536A (en) * 2017-12-28 2018-06-29 王道顺 One kind is to light variable security index identification method and device
CN108984577A (en) * 2018-02-07 2018-12-11 广州集创佳禾知识产权运营有限公司 Commodity patent acquisition methods and system on a kind of line based on machine recognition
CN110097056A (en) * 2018-01-30 2019-08-06 江苏博智软件科技股份有限公司 A kind of method for recognizing verification code based on intelligent pattern algorithm
CN110428264A (en) * 2019-07-22 2019-11-08 杭州沃朴物联科技有限公司 Fake method, device, equipment and medium are tested in identification based on dot matrix screen antifalsification label
CN110569907A (en) * 2019-09-10 2019-12-13 网易(杭州)网络有限公司 method and device for identifying splicing pattern, computer storage medium and electronic equipment

Patent Citations (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102305664A (en) * 2011-05-19 2012-01-04 中国农业大学 Thermal imaging temperature measurement and fault location inspection system
CN102663337A (en) * 2012-03-16 2012-09-12 江南大学 Method for quick Data Matrix two-dimensional barcode identifying under simple condition background
CN102682266A (en) * 2012-05-17 2012-09-19 西北工业大学 Cylindrical surface bidimensional bar code reading method based on image splicing
CN102930277A (en) * 2012-09-19 2013-02-13 上海珍岛信息技术有限公司 Character picture verification code identifying method based on identification feedback
CN103116751A (en) * 2013-01-24 2013-05-22 河海大学 Automatic license plate character recognition method
CN103514448A (en) * 2013-10-24 2014-01-15 北京国基科技股份有限公司 Method and system for navicular identification
CN104463795A (en) * 2014-11-21 2015-03-25 高韬 Processing method and device for dot matrix type data matrix (DM) two-dimension code images
CN104915668A (en) * 2015-05-29 2015-09-16 深圳泓数科技有限公司 Character information identification method for medical image and device thereof
CN105335744A (en) * 2015-11-10 2016-02-17 佛山科学技术学院 One-dimensional code region location based on image backbone extraction strip distribution features
CN105447489A (en) * 2015-11-13 2016-03-30 浙江传媒学院 Character and background adhesion noise elimination method for image OCR system
CN106886996A (en) * 2017-02-10 2017-06-23 九次方大数据信息集团有限公司 Dividing method and device based on mathematical operation identifying code image
CN107392877A (en) * 2017-07-11 2017-11-24 中国科学院电子学研究所苏州研究院 A kind of single polarization diameter radar image puppet coloured silkization method
CN107622247A (en) * 2017-09-26 2018-01-23 华东师范大学 A kind of positioning of express waybill and extracting method
CN107609193A (en) * 2017-10-16 2018-01-19 杭州时间线信息科技有限公司 The intelligent automatic processing method and system of picture in a kind of suitable commodity details page
CN108230536A (en) * 2017-12-28 2018-06-29 王道顺 One kind is to light variable security index identification method and device
CN110097056A (en) * 2018-01-30 2019-08-06 江苏博智软件科技股份有限公司 A kind of method for recognizing verification code based on intelligent pattern algorithm
CN108984577A (en) * 2018-02-07 2018-12-11 广州集创佳禾知识产权运营有限公司 Commodity patent acquisition methods and system on a kind of line based on machine recognition
CN110428264A (en) * 2019-07-22 2019-11-08 杭州沃朴物联科技有限公司 Fake method, device, equipment and medium are tested in identification based on dot matrix screen antifalsification label
CN110569907A (en) * 2019-09-10 2019-12-13 网易(杭州)网络有限公司 method and device for identifying splicing pattern, computer storage medium and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
赵艳芹 ; 童朝娣 ; 张恒 ; .基于LeNet-5卷积神经网络的车牌字符识别.黑龙江科技大学学报.2019,(03),第132-136页. *

Also Published As

Publication number Publication date
CN111553317A (en) 2020-08-18

Similar Documents

Publication Publication Date Title
JP3768052B2 (en) Color image processing method, color image processing apparatus, and recording medium therefor
WO2017121018A1 (en) Method and apparatus for processing two-dimensional code image, and terminal and storage medium
US8035871B2 (en) Determining target luminance value of an image using predicted noise amount
JP3078844B2 (en) How to separate foreground information in a document from background information
CN109993161B (en) Text image rotation correction method and system
US20050249429A1 (en) Method, apparatus, and program for image processing
CN110390643B (en) License plate enhancement method and device and electronic equipment
CN109903294B (en) Image processing method and device, electronic equipment and readable storage medium
CN111259891B (en) Method, device, equipment and medium for identifying identity card in natural scene
CN110598566A (en) Image processing method, device, terminal and computer readable storage medium
CN112396050B (en) Image processing method, device and storage medium
CN113592776A (en) Image processing method and device, electronic device and storage medium
CN109741273A (en) A kind of mobile phone photograph low-quality images automatically process and methods of marking
CN113487473B (en) Method and device for adding image watermark, electronic equipment and storage medium
CN111445402B (en) Image denoising method and device
CN111553317B (en) Anti-fake code acquisition method and device, computer equipment and storage medium
CN112749696A (en) Text detection method and device
CN115410191A (en) Text image recognition method, device, equipment and storage medium
CN114267035A (en) Document image processing method and system, electronic device and readable medium
JP3830350B2 (en) Color image processing method, color image processing apparatus, program, and recording medium
CN112508024A (en) Intelligent identification method for embossed seal font of electrical nameplate of transformer
CN112532938A (en) Video monitoring system based on big data technology
CN108960222B (en) Image binarization method, device, equipment and storage medium
CN116704513B (en) Text quality detection method, device, computer equipment and storage medium
CN110807747B (en) Document image noise reduction method based on foreground mask

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant