CN118070826B - Two-dimensional code repairing method, device, terminal equipment and storage medium - Google Patents
Two-dimensional code repairing method, device, terminal equipment and storage medium Download PDFInfo
- Publication number
- CN118070826B CN118070826B CN202410472224.6A CN202410472224A CN118070826B CN 118070826 B CN118070826 B CN 118070826B CN 202410472224 A CN202410472224 A CN 202410472224A CN 118070826 B CN118070826 B CN 118070826B
- Authority
- CN
- China
- Prior art keywords
- dimensional code
- image set
- image
- identifiable
- unidentifiable
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 80
- 238000012795 verification Methods 0.000 claims abstract description 72
- 238000012545 processing Methods 0.000 claims abstract description 57
- 230000008439 repair process Effects 0.000 claims abstract description 32
- 238000004422 calculation algorithm Methods 0.000 claims description 25
- 238000010586 diagram Methods 0.000 claims description 10
- 238000003708 edge detection Methods 0.000 claims description 7
- 230000008569 process Effects 0.000 description 11
- 230000006870 function Effects 0.000 description 9
- 238000012937 correction Methods 0.000 description 8
- 238000012549 training Methods 0.000 description 6
- 238000004458 analytical method Methods 0.000 description 5
- 238000004891 communication Methods 0.000 description 5
- 230000007547 defect Effects 0.000 description 5
- 241000283070 Equus zebra Species 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 3
- 238000013528 artificial neural network Methods 0.000 description 2
- 238000013135 deep learning Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 238000013508 migration Methods 0.000 description 2
- 230000005012 migration Effects 0.000 description 2
- 240000004282 Grewia occidentalis Species 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 230000000295 complement effect Effects 0.000 description 1
- 238000006073 displacement reaction Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 239000011159 matrix material Substances 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000002715 modification method Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
- 239000013589 supplement Substances 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/14—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
- G06K7/1404—Methods for optical code recognition
- G06K7/146—Methods for optical code recognition the method including quality enhancement steps
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/14—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
- G06K7/1404—Methods for optical code recognition
- G06K7/1408—Methods for optical code recognition the method being specifically adapted for the type of code
- G06K7/1417—2D bar codes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/14—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
- G06K7/1404—Methods for optical code recognition
- G06K7/1439—Methods for optical code recognition including a method step for retrieval of the optical code
- G06K7/1452—Methods for optical code recognition including a method step for retrieval of the optical code detecting bar code edges
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/14—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
- G06K7/1404—Methods for optical code recognition
- G06K7/146—Methods for optical code recognition the method including quality enhancement steps
- G06K7/1478—Methods for optical code recognition the method including quality enhancement steps adapting the threshold for pixels in a CMOS or CCD pixel sensor for black and white recognition
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Electromagnetism (AREA)
- General Health & Medical Sciences (AREA)
- Toxicology (AREA)
- Artificial Intelligence (AREA)
- Computer Vision & Pattern Recognition (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Image Processing (AREA)
Abstract
The invention relates to the field of image processing, and discloses a two-dimensional code repairing method, a device, terminal equipment and a storage medium, wherein the method comprises the following steps: acquiring and intercepting images with two-dimensional codes through preset acquisition equipment to obtain a two-dimensional code image set; according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set; and performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result. The method solves the problems that the two-dimensional code cannot be repaired in time when damaged and the repair cost is high, and improves the efficiency of repairing the two-dimensional code.
Description
Technical Field
The present invention relates to the field of image processing, and in particular, to a two-dimensional code repairing method, device, terminal equipment, and storage medium.
Background
Because the two-dimension code is commonly used, the information storage amount is large, and the two-dimension code is provided with an error correction mechanism, the two-dimension code is commonly used in the commodity transfer link of logistics and factories, and therefore the accurate identification of the two-dimension code becomes a very important key link.
In the link of commodity circulation and goods handing over of mill, because the problem of handling process, so the damage of two-dimensional code is unavoidable, and to the modification method of two-dimensional code, what is commonly used at present is:
(1) Adding error correction codes into the two-dimensional codes, and decoding the two-dimensional codes with defects by using redundant information such as the error correction codes is only suitable for repairing the two-dimensional codes with smaller defect areas, and is not suitable for repairing the two-dimensional codes with larger defect areas or damaged key positioning codes;
(2) The processing method is obtained through a large number of model training by using a popular neural network or deep learning, and needs professional development and a large number of data to train and cooperate with a high-performance server for processing, so that the method has high cost and is not beneficial to scenes such as poor signals in warehouse factories, easy deployment and low cost;
(3) The method needs a high-performance camera and stably identifies images, and is suitable for the scenes needing to be quickly identified by a fixed machine, such as an AGV robot or a fixed code scanning door.
The foregoing is provided merely for the purpose of facilitating understanding of the technical solutions of the present invention and is not intended to represent an admission that the foregoing is prior art.
Disclosure of Invention
The invention mainly aims to provide a two-dimensional code repairing method, a device, terminal equipment and a storage medium, and aims to solve the technical problems that when a two-dimensional code is damaged, the two-dimensional code cannot be repaired in time and the repairing cost is high.
In order to achieve the above object, the present invention provides a two-dimensional code repairing method, which includes:
Acquiring and intercepting images with two-dimensional codes through preset acquisition equipment to obtain a two-dimensional code image set;
according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set;
And performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result.
Optionally, the step of identifying through a preset barcode image processing library according to the two-dimensional code image set to obtain the identifiable two-dimensional code image set and the unidentifiable two-dimensional code image set includes:
identifying the two-dimensional code image set through the bar code image processing library to obtain an identification result, wherein the identification result comprises one or more of a first identifiable image set and an unidentifiable image set;
performing coverage replacement according to the unrecognizable image set to obtain a replaced unrecognizable image set, and decoding the replaced unrecognizable image set to obtain a second identifiable image set and a unrecognizable two-dimensional code image set;
Analyzing the first identifiable image set and the second identifiable image set to obtain feature codes of the first identifiable image set and the second identifiable image set;
And verifying the feature codes of the first identifiable image set and the second identifiable image set through a two-dimensional code template database, and outputting the data sets which pass the verification in the first identifiable image set and the second identifiable image set as identifiable two-dimensional code image sets.
Optionally, the step of performing overlay replacement according to the unrecognizable image set to obtain a replaced unrecognizable image set, and decoding the replaced unrecognizable image set to obtain a second identifiable image set and a unrecognizable two-dimensional code image set includes:
generating a replacement two-dimensional code image set through the two-dimensional code template database according to the unrecognizable image set;
Performing coverage replacement on the unrecognizable image set through the replacement two-dimensional code image set to obtain a replaced unrecognizable image set;
And decoding the replaced unrecognizable image set to obtain the second identifiable image set and the unrecognizable two-dimensional code image set.
Optionally, the step of performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result includes:
gray processing is carried out on the unidentifiable two-dimensional code image set, and a black-white binary image is obtained;
calculating the number of image code elements according to the black-white binary image, and analyzing according to the plumpness of the image code elements and a preset plumpness threshold value to obtain a damaged code element set;
repairing the damaged code element set through an interpolation algorithm to obtain a repaired unidentifiable two-dimensional code image set;
And decoding and verifying the repaired unidentifiable two-dimensional code image set and the unidentifiable two-dimensional code image set to obtain a verification result.
Optionally, the step of performing gray processing on the unidentifiable two-dimensional code image set to obtain a black-and-white binary image includes:
converting the image in the unidentifiable two-dimensional code image set into a gray image;
traversing pixel points in the gray level image to obtain pixel values of the gray level image, and comparing the pixel values through a preset pixel threshold value to obtain a comparison result;
Binarizing the pixel value according to the comparison result to obtain a binarized pixel value;
And generating a black-and-white binary image according to the binarized pixel value.
Optionally, the step of calculating the number of the image symbols according to the black-white binary image and analyzing according to the plumpness of the image symbols and a preset plumpness threshold value to obtain a damaged symbol set includes:
detecting the black-and-white binary image through an edge detection Sobel algorithm to obtain an image frame;
calculating an image grid in the image frame based on a template matching algorithm to obtain a code element pixel template, a two-dimensional code version and a template code element position plan;
Calculating the plumpness of the image code element through the code element pixel template, the two-dimensional code version and the template code element position plane diagram;
And analyzing according to the fullness of the image code element through the fullness threshold value to obtain a damaged code element set.
Optionally, the step of performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result further includes:
classifying based on the verification result to obtain a two-dimensional code image set with restoration failure;
And generating alarm information according to the two-dimensional code image set with the repair failure, and sending the alarm information to a corresponding user terminal.
The embodiment of the invention also provides a two-dimensional code repairing device, which comprises:
the acquisition module is used for acquiring and intercepting images with the two-dimensional codes through preset acquisition equipment to obtain a two-dimensional code image set;
the identification module is used for carrying out identification through a preset bar code picture processing library according to the two-dimensional code image set to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set;
and the verification module is used for carrying out image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and carrying out decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result.
The embodiment of the invention also provides a terminal device which comprises a memory, a processor and a two-dimensional code repairing program stored in the memory and capable of running on the processor, wherein the two-dimensional code repairing program realizes the steps of the two-dimensional code repairing method when being executed by the processor.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium is stored with a two-dimensional code repairing program, and the two-dimensional code repairing program realizes the steps of the two-dimensional code repairing method when being executed by a processor.
According to the two-dimensional code repairing method, the device, the terminal equipment and the storage medium, images with two-dimensional codes are acquired and intercepted through the preset acquisition equipment, and a two-dimensional code image set is obtained; according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set; and performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result. Therefore, a two-dimensional code image set is obtained through the acquisition equipment, an identifiable two-dimensional code image set and an unidentifiable two-dimensional code image set are obtained based on the two-dimensional code image set through identification, the unidentifiable two-dimensional code image set is repaired, and finally the repaired unidentifiable two-dimensional code image set and the repaired identifiable image set are decoded and verified to obtain a verification result. The two-dimensional code repairing method and device solve the problems that the two-dimensional code cannot be repaired in time and the repairing cost is high when damaged, and improve the two-dimensional code repairing efficiency.
Drawings
FIG. 1 is a schematic diagram of a functional module of a terminal device to which a two-dimensional code repairing device of the present invention belongs;
FIG. 2 is a flow chart of an exemplary embodiment of a two-dimensional code repair method according to the present invention;
FIG. 3 is a schematic diagram of a damaged two-dimensional code image according to the two-dimensional code repairing method of the invention;
FIG. 4 is a flowchart of another exemplary embodiment of a two-dimensional code repair method according to the present invention;
FIG. 5 is a flowchart of another exemplary embodiment of a two-dimensional code repair method according to the present invention;
FIG. 6 is a schematic diagram of each module in the system according to the two-dimensional code repairing method of the present invention;
Fig. 7 is an overall schematic diagram of the two-dimensional code repairing method of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The main solutions of the embodiments of the present invention are: identifying the two-dimensional code image set through the bar code image processing library to obtain an identification result, wherein the identification result comprises one or more of a first identifiable image set and an unidentifiable image set; performing coverage replacement according to the unrecognizable image set to obtain a replaced unrecognizable image set, and decoding the replaced unrecognizable image set to obtain a second identifiable image set and a unrecognizable two-dimensional code image set; analyzing the first identifiable image set and the second identifiable image set to obtain feature codes of the first identifiable image set and the second identifiable image set; And verifying the feature codes of the first identifiable image set and the second identifiable image set through a two-dimensional code template database, and outputting the data sets which pass the verification in the first identifiable image set and the second identifiable image set as identifiable two-dimensional code image sets. Generating a replacement two-dimensional code image set through the two-dimensional code template database according to the unrecognizable image set; performing coverage replacement on the unrecognizable image set through the replacement two-dimensional code image set to obtain a replaced unrecognizable image set; and decoding the replaced unrecognizable image set to obtain the second identifiable image set and the unrecognizable two-dimensional code image set. Gray processing is carried out on the unidentifiable two-dimensional code image set, and a black-white binary image is obtained; calculating the number of image code elements according to the black-white binary image, and analyzing according to the plumpness of the image code elements and a preset plumpness threshold value to obtain a damaged code element set; repairing the damaged code element set through an interpolation algorithm to obtain a repaired unidentifiable two-dimensional code image set; and decoding and verifying the repaired unidentifiable two-dimensional code image set and the unidentifiable two-dimensional code image set to obtain a verification result. Converting the image in the unidentifiable two-dimensional code image set into a gray image; traversing pixel points in the gray level image to obtain pixel values of the gray level image, and comparing the pixel values through a preset pixel threshold value to obtain a comparison result; Binarizing the pixel value according to the comparison result to obtain a binarized pixel value; and generating a black-and-white binary image according to the binarized pixel value. Detecting the black-and-white binary image through an edge detection Sobel algorithm to obtain an image frame; calculating an image grid in the image frame based on a template matching algorithm to obtain a code element pixel template, a two-dimensional code version and a template code element position plan; calculating the plumpness of the image code element through the code element pixel template, the two-dimensional code version and the template code element position plane diagram; and analyzing according to the fullness of the image code element through the fullness threshold value to obtain a damaged code element set. Classifying based on the verification result to obtain a two-dimensional code image set with restoration failure; and generating alarm information according to the two-dimensional code image set with the repair failure, and sending the alarm information to a corresponding user terminal. Therefore, the problems that the two-dimensional code cannot be repaired in time and the repair cost is high when damaged are solved, the two-dimensional code is repaired, and the two-dimensional code repairing efficiency is improved. Based on the scheme of the invention, the two-dimensional code repairing method is designed from the problems that the cost of two-dimensional code repairing software is high and training data is depended in reality, the hardware cost is high for the continuous flow recognition, or only a positioning frame is required, the bias and the environment constraint are often present in an actual scene, the quick and effective recognition cannot be carried out aiming at the specific scene, and the efficiency is low, the effectiveness of the two-dimensional code repairing method is verified when the two-dimensional code is repaired, and finally the efficiency of two-dimensional code repairing through the method is obviously improved.
Technical terms related to the embodiment of the invention:
code element: a symbol is the smallest unit in information transmission for representing a number, text or other symbol, and in digital communication, a symbol typically represents one bit (bit), i.e. binary 0 or 1, and during modulation and demodulation, a symbol may represent a plurality of bits by different modulation schemes, e.g. in a 4QAM modulation scheme, a symbol may represent 2 bits, and in a 16QAM modulation scheme, a symbol may represent 4 bits.
Sobel algorithm: the Sobel algorithm is a classical image edge detection algorithm, which is commonly used in the fields of computer vision and image processing, and can effectively detect edges in images based on the gray scale gradient of the images.
ZXing: ZXing is an open-source, multi-format, multi-purpose bar code, two-dimensional code image processing library written in Java, but also supports migration of other languages, such as C++, python, etc., ZXing is an abbreviation of "Zebra Crossing", meaning zebra stripes, symbolizing across different programming languages, platforms and application areas.
According to the embodiment of the invention, due to the fact that the two-dimension code is commonly used, the information storage amount is large, the information storage amount is provided with an error correction mechanism, not only is daily life used, but also is very common in a commodity circulation and factory cargo handover link, so that accurate identification of the two-dimension code becomes a very important key link, the problem that the two-dimension code cannot be identified due to damage of the two-dimension code in the related technology is possibly encountered when the two-dimension code is identified, and the common repairing method is high in cost and cannot guarantee the repairing accuracy, so that the problem of low efficiency exists in the mode.
Therefore, in the embodiment of the invention, from the problems that the cost of two-dimensional code repairing software is high and training data is depended in reality, or the hardware cost is high for continuous flow identification, or only a positioning frame can be solved, and the specific scene is often biased and environment-constrained, the quick and effective identification cannot be carried out aiming at the specific scene, so that the efficiency is low, the two-dimensional code repairing method is designed, the effectiveness of the two-dimensional code repairing method is verified when the two-dimensional code is repaired, and finally the two-dimensional code repairing efficiency is obviously improved through the two-dimensional code repairing method.
Specifically, referring to fig. 1, fig. 1 is a schematic diagram of a functional board of a terminal device to which the two-dimensional code repairing device of the present invention belongs. The two-dimensional code repairing device can be independent of a device of the terminal equipment, capable of repairing the two-dimensional code, and can be borne on the terminal equipment in a hardware or software mode. The terminal equipment can be intelligent mobile equipment with a data processing function such as a mobile phone and a tablet personal computer, and can also be fixed terminal equipment or a server with a data processing function.
In this embodiment, the terminal device to which the two-dimensional code repairing apparatus belongs at least includes an output module 110, a processor 120, a memory 130 and a communication module 140.
The memory 130 stores an operating system and a two-dimensional code repairing program, and the two-dimensional code repairing device can acquire and intercept images with two-dimensional codes through preset acquisition equipment to obtain a two-dimensional code image set; according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set; and performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result. Performing two-dimensional code repair by the two-dimensional code repair program, and storing information such as a repair result in the memory 130; the output module 110 may be a display screen or the like. The communication module 140 may include a WIFI module, a mobile communication module, a bluetooth module, and the like, and communicates with an external device or a server through the communication module 140.
Wherein the two-dimensional code repairing program in the memory 130 realizes the following steps when being executed by the processor:
Acquiring and intercepting images with two-dimensional codes through preset acquisition equipment to obtain a two-dimensional code image set;
according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set;
And performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result.
Further, the two-dimensional code repairing program in the memory 130 further realizes the following steps when executed by the processor:
identifying the two-dimensional code image set through the bar code image processing library to obtain an identification result, wherein the identification result comprises one or more of a first identifiable image set and an unidentifiable image set;
performing coverage replacement according to the unrecognizable image set to obtain a replaced unrecognizable image set, and decoding the replaced unrecognizable image set to obtain a second identifiable image set and a unrecognizable two-dimensional code image set;
Analyzing the first identifiable image set and the second identifiable image set to obtain feature codes of the first identifiable image set and the second identifiable image set;
And verifying the feature codes of the first identifiable image set and the second identifiable image set through a two-dimensional code template database, and outputting the data sets which pass the verification in the first identifiable image set and the second identifiable image set as identifiable two-dimensional code image sets.
Further, the two-dimensional code repairing program in the memory 130 further realizes the following steps when executed by the processor:
generating a replacement two-dimensional code image set through the two-dimensional code template database according to the unrecognizable image set;
Performing coverage replacement on the unrecognizable image set through the replacement two-dimensional code image set to obtain a replaced unrecognizable image set;
And decoding the replaced unrecognizable image set to obtain the second identifiable image set and the unrecognizable two-dimensional code image set.
Further, the two-dimensional code repairing program in the memory 130 further realizes the following steps when executed by the processor:
gray processing is carried out on the unidentifiable two-dimensional code image set, and a black-white binary image is obtained;
calculating the number of image code elements according to the black-white binary image, and analyzing according to the plumpness of the image code elements and a preset plumpness threshold value to obtain a damaged code element set;
repairing the damaged code element set through an interpolation algorithm to obtain a repaired unidentifiable two-dimensional code image set;
And decoding and verifying the repaired unidentifiable two-dimensional code image set and the unidentifiable two-dimensional code image set to obtain a verification result.
Further, the two-dimensional code repairing program in the memory 130 further realizes the following steps when executed by the processor:
converting the image in the unidentifiable two-dimensional code image set into a gray image;
traversing pixel points in the gray level image to obtain pixel values of the gray level image, and comparing the pixel values through a preset pixel threshold value to obtain a comparison result;
Binarizing the pixel value according to the comparison result to obtain a binarized pixel value;
And generating a black-and-white binary image according to the binarized pixel value.
Further, the two-dimensional code repairing program in the memory 130 further realizes the following steps when executed by the processor:
detecting the black-and-white binary image through an edge detection Sobel algorithm to obtain an image frame;
calculating an image grid in the image frame based on a template matching algorithm to obtain a code element pixel template, a two-dimensional code version and a template code element position plan;
Calculating the plumpness of the image code element through the code element pixel template, the two-dimensional code version and the template code element position plane diagram;
And analyzing according to the fullness of the image code element through the fullness threshold value to obtain a damaged code element set.
Further, the two-dimensional code repairing program in the memory 130 further realizes the following steps when executed by the processor:
classifying based on the verification result to obtain a two-dimensional code image set with restoration failure;
And generating alarm information according to the two-dimensional code image set with the repair failure, and sending the alarm information to a corresponding user terminal.
According to the scheme, specifically, the image with the two-dimensional code is acquired and intercepted through the preset acquisition equipment, so that a two-dimensional code image set is obtained; according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set; and performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result. The method comprises the steps of obtaining a two-dimensional code image set through acquisition equipment, obtaining an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set based on the two-dimensional code image set through identification, repairing the unrecognizable two-dimensional code image set, and finally decoding and verifying the repaired unrecognizable two-dimensional code image set and the repaired identifiable two-dimensional code image set to obtain a verification result. Based on the scheme of the invention, the two-dimensional code repairing method is designed from the problems that the cost of two-dimensional code repairing software is high and training data is depended in reality, the hardware cost is high for the continuous flow recognition, or only a positioning frame is required, the bias and the environment constraint are often present in an actual scene, the quick and effective recognition cannot be carried out aiming at the specific scene, and the efficiency is low, the effectiveness of the two-dimensional code repairing method is verified when the two-dimensional code is repaired, and finally the efficiency of two-dimensional code repairing through the method is obviously improved.
The method embodiments of the present invention are presented based on the above-described terminal device architecture but not limited to the above-described framework.
Referring to fig. 2, fig. 2 is a flowchart of an exemplary embodiment of a two-dimensional code repairing method according to the present invention. The two-dimensional code repairing method comprises the following steps:
step S01, acquiring and intercepting images with two-dimensional codes through preset acquisition equipment to obtain a two-dimensional code image set;
The execution subject of the method of the embodiment may be a two-dimensional code repairing device, or may be a two-dimensional code repairing terminal device or a server, and the two-dimensional code repairing device is exemplified by the two-dimensional code repairing device, and the two-dimensional code repairing device may be integrated on a terminal device with a data processing function.
Before the scheme of the invention starts to be explained, it should be clear that, because the two-dimensional code is generated and identified with higher convenience and the storage amount of information is large, the two-dimensional code is widely used, not only in daily life, but also in one of very important links in the goods handing-over link of logistics and factories, but also in the handling process of logistics scenes, damage to images is difficult to avoid, for example, as shown in fig. 3, a is a normal two-dimensional code, b is a two-dimensional code with at least one or more positioning points and other symbols damaged by transverse lines and vertical lines, c is a two-dimensional code with at least one or more positioning points and other symbols penetrated by curve simulation nails, d is a two-dimensional code with lost frame and beaten scene by a printer, and multiple columns of symbols and positioning codes are damaged, which can lead to the problem that the two-dimensional code cannot be identified in the use process, so repair or remaking is required, but at present, the two-dimensional code repair mode is commonly used: the method comprises the steps of (1) adding error correction codes into two-dimensional codes, decoding the two-dimensional codes with redundant information such as error correction codes, wherein the method is only suitable for repairing two-dimensional codes with smaller defect areas, but not suitable for repairing two-dimensional codes with larger defect areas or damaged key positioning codes, (2) obtaining processing results through a great deal of training by using a popular neural network or deep learning, wherein the method requires professional development and a great deal of data to train and process by matching with a high-performance server, has high cost, is unfavorable for scenes such as warehouse factories and the like with poor signals, needs easy deployment and low cost, and (3) utilizes a rapid camera to rapidly identify a plurality of images, and then utilizes modes such as filtering functions, image cutting and the like to repair the images in a plurality of image comparison modes, but the method needs a high-performance camera and stably identifies the images.
In this embodiment, image acquisition is performed through a preset acquisition device, where the acquisition device may be a mobile device with a communication function and image acquisition, such as a mobile phone and a tablet, or may be a professional image acquisition device, such as a camera, where after a corresponding image is obtained, some other images may exist except for a two-dimensional code on the image, so that an image screenshot is required to be performed to capture the two-dimensional code in the image, so as to obtain a two-dimensional code image set.
Step S02, identifying through a preset bar code picture processing library according to the two-dimensional code image set to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set;
after the two-dimensional code image set is obtained, the two-dimensional code image set can be identified, but before identification, it should be clear that the two-dimensional code image set contains identifiable two-dimensional code images and unrecognizable two-dimensional code images, and the repairing method of the embodiment is mainly aimed at repairing unrecognizable two-dimensional codes, so that the images in the two-dimensional code image set are identified one by one through a preset bar code image processing library, the two-dimensional code image set is divided into the identifiable two-dimensional code image set and the unrecognizable two-dimensional code image set, wherein the bar code image processing library comprises, but is not limited to, image processing libraries such as ZXing and ZBar, and ZXing ('Zebra Crossing') is an open-source one-dimensional/two-dimensional bar code image processing library with multiple formats, and supports multiple platforms including Java, C++, python and the like. It provides the function of identifying and generating one-dimensional/two-dimensional bar codes, can be used in various environments such as mobile application, web application and the like, and ZBar is another open-source bar Code picture processing library, which focuses on the identification of bar codes, and similar to ZXing, ZBar also supports the identification of various bar Code types, including one-dimensional bar codes (such as Code 128, EAN-13, UPC-A and the like) and two-dimensional bar codes (such as QR codes, datse:Sub>A Matrix and the like), ZBar provides se:Sub>A C language library, and provides migration versions for different platforms, including Linux, windows, mac OS and the like.
And S03, performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result.
After the unidentifiable two-dimensional code image set is obtained, the unidentifiable two-dimensional code image set can be repaired to obtain a repair result, and it is clear that in a logistics scene, the two-dimensional code has more damage types, some of the two-dimensional code can be completely repaired, and some of the two-dimensional code can not be identified after repair, so that the obtained repair result is divided into a successfully repaired image set and a failed repaired image set, and for this, each two-dimensional code image in the repair result and the two-dimensional code image set which is previously determined to be identifiable are verified, the specific verification method can be as follows: in a specific logistics use scenario, since the logistics transportation, the goods stacking and the goods storage are mostly pipeline engineering, the specific goods information and the two-dimension code identification result can be used for verification, and whether the two-dimension code corresponds to the goods information or not is verified.
Specifically, in the step S03, the step of performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result further includes:
step S04, classifying based on the verification result to obtain a two-dimensional code image set with failed restoration;
and step S05, generating alarm information according to the two-dimensional code image set with the repair failure, and sending the alarm information to a corresponding user side.
In specific two-dimensional code restoration, images with restoration success and restoration failure exist, for the images with restoration success, the images with restoration success can be added into an identifiable two-dimensional code image set for use, and for the image set with restoration failure, in order to prevent the image set with restoration failure from being put into subsequent use and causing the flow of business to be blocked, alarm information is generated based on the two-dimensional code image set with restoration failure and is notified to a corresponding user side, so that management staff or corresponding business staff can supplement damaged two-dimensional codes to avoid untimely data updating.
According to the scheme, specifically, the image with the two-dimensional code is acquired and intercepted through the preset acquisition equipment, so that a two-dimensional code image set is obtained; according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set; and performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result. Therefore, a two-dimensional code image set is obtained through the acquisition equipment, an identifiable two-dimensional code image set and an unidentifiable two-dimensional code image set are obtained based on the two-dimensional code image set through identification, the unidentifiable two-dimensional code image set is repaired, and finally the repaired unidentifiable two-dimensional code image set and the repaired identifiable image set are decoded and verified to obtain a verification result. The two-dimensional code repairing method and device solve the problems that the two-dimensional code cannot be repaired in time and the repairing cost is high when damaged, and improve the two-dimensional code repairing efficiency.
Referring to fig. 4, fig. 4 is a flowchart illustrating another exemplary embodiment of a two-dimensional code repairing method according to the present invention.
Based on the embodiment shown in fig. 2, the step S02 of identifying the two-dimensional code image set through a preset barcode image processing library to obtain the identifiable two-dimensional code image set and the unidentifiable two-dimensional code image set includes:
Step S021, identifying the two-dimensional code image set through the bar code picture processing library to obtain an identification result, wherein the identification result comprises one or more of a first identifiable image set and an unidentifiable image set;
step S022, performing coverage replacement according to the unrecognizable image set to obtain a replaced unrecognizable image set, and decoding the replaced unrecognizable image set to obtain a second identifiable image set and a unrecognizable two-dimensional code image set;
Step S023, analyzing the first identifiable image set and the second identifiable image set to obtain feature codes of the first identifiable image set and the second identifiable image set;
Step S024, verifying the feature codes of the first identifiable image set and the second identifiable image set through a two-dimensional code template database, and outputting the data sets verified in the first identifiable image set and the second identifiable image set as identifiable two-dimensional code image sets.
In specific image recognition, under the condition that the system acquires the authority of the camera, the camera can be triggered by an interface to acquire a frame of picture containing the two-dimensional code, the picture is stored back into a cache of a server, and all the two-dimensional code images in the cache are two-dimensional code image sets;
Identifying the two-dimensional code image set, wherein ZXing is preferentially used in the identification process, then trying ZBar and the like to identify the two-dimensional code to obtain two identification results of the two-dimensional code, wherein the two identification results are identifiable and unrecognizable, and two image sets, namely a first identifiable image set and a unrecognizable image set, are obtained according to the two identification results;
In the unrecognizable image set, identification can be completed without restoration possibly existing in some image sets, namely unrecognizable images with objective factors possibly exist in the unrecognizable image set, at the moment, covering and replacing the images in the unrecognizable image set, then decoding the covered unrecognizable image set again to check whether the covered unrecognizable image set can be identified or not, and obtaining a second identifiable image set and an unrecognizable two-dimensional code image set;
The second identifiable image set and the first identifiable image set are in an identifiable state, at the moment, all the identifiable image sets can be initially verified, and then the data sets which are verified in the first identifiable image set and the second identifiable image set are output as identifiable two-dimensional code image sets;
the two-dimensional code image set can be identified and the unidentifiable two-dimensional code image set can be obtained through the operations of the steps.
Specifically, the step S022, performing overlay replacement according to the unrecognizable image set, to obtain a replaced unrecognizable image set, and decoding the replaced unrecognizable image set, to obtain a second identifiable image set and a unrecognizable two-dimensional code image set, includes:
Step S0221, generating a replacement two-dimensional code image set through the two-dimensional code template database according to the unrecognizable image set;
Step S0222, performing coverage replacement on the unrecognizable image set through the replacement two-dimensional code image set, and obtaining a replaced unrecognizable image set;
And step S0223, decoding the replaced unidentifiable image set to obtain the second unidentifiable image set and the unidentifiable two-dimensional code image set.
Calling templates of the existing two-dimensional codes of the template library to generate images based on the unrecognizable image set, and specifically generating a two-dimensional code template image containing two-dimensional code frames, version information, error correction levels and locators according to preset features of each two-dimensional code;
Then, the two-dimensional code template image is utilized to carry out trial coverage on the obtained two-dimensional code image according to the frame, the locator, the version information and the code elements of the error correction level position, and a decoding program is called to carry out trial decoding after replacing the covered two-dimensional code image;
if the two-dimensional code frame fails, the two-dimensional code frame is rotated for 90 degrees and then is identified again, so that the two-dimensional code frame is at most 3 times, if the two-dimensional code frame cannot be decoded after 3 times, an unidentifiable two-dimensional code image set is output, and for a picture which can be decoded successfully, a second identifiable image set is output.
According to the scheme, the two-dimensional code image set is specifically identified through the bar code image processing library, so that an identification result is obtained, wherein the identification result comprises one or more of a first identifiable image set and an unidentifiable image set; performing coverage replacement according to the unrecognizable image set to obtain a replaced unrecognizable image set, and decoding the replaced unrecognizable image set to obtain a second identifiable image set and a unrecognizable two-dimensional code image set; analyzing the first identifiable image set and the second identifiable image set to obtain feature codes of the first identifiable image set and the second identifiable image set; and verifying the feature codes of the first identifiable image set and the second identifiable image set through a two-dimensional code template database, and outputting the data sets which pass the verification in the first identifiable image set and the second identifiable image set as identifiable two-dimensional code image sets.
Referring to fig. 5, fig. 5 is a flowchart illustrating another exemplary embodiment of a two-dimensional code repairing method according to the present invention.
Based on the embodiment shown in fig. 2, the step S03 is to perform image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and perform decoding verification on the unidentifiable two-dimensional code image set and the restoration result, where the step of obtaining a verification result includes:
Step S031, gray processing is carried out on the unidentifiable two-dimensional code image set, and a black-and-white binary image is obtained;
step S032, calculating the number of image code elements according to the black-white binary image, and analyzing according to the fullness of the image code elements and a preset fullness threshold value to obtain a damaged code element set;
Step S033, repairing the damaged code element set through an interpolation algorithm to obtain a repaired unidentifiable two-dimensional code image set;
And step S034, decoding and verifying the repaired unidentifiable two-dimensional code image set and the identifiable two-dimensional code image set to obtain a verification result.
After the unidentifiable two-dimensional code image set is obtained, the image in the image set is required to be repaired, and at the moment, gray processing is carried out on the two-dimensional code image to obtain a black-and-white binary image, wherein the gray processing is a process of converting a color image into a black-and-white (gray) image, and in the gray image, the brightness value of each pixel only depends on the brightness of the corresponding pixel in the original color image without considering color information. The purpose of this is typically to simplify the image processing task, reduce the computational complexity, or emphasize the brightness variation of the image while ignoring the color;
calculating through black-and-white binary images after gray level to obtain the number of image symbols in the images, carrying out threshold analysis on the plumpness of the image symbols in the images through a preset plumpness threshold, and outputting the image symbols lower than the plumpness threshold as a damaged symbol set;
based on an improved interpolation algorithm, carrying out complementary processing on the damaged code element set according to pixels, so that the two-dimensional code can be restored from the outline to the detailed code element, and a repaired unidentifiable two-dimensional code image set is obtained;
After the repair operation is executed, all the two-dimensional code images cannot be repaired, so that further verification is needed, and at the moment, a final verification result is obtained by decoding and verifying the repaired unidentifiable two-dimensional code image set and the unidentifiable two-dimensional code image set.
Specifically, in the step S031, the step of performing gray-scale processing on the unidentifiable two-dimensional code image set to obtain a black-and-white binary image includes:
step S0311, converting the image in the unidentifiable two-dimensional code image set into a gray image;
Step S0312, traversing pixel points in the gray level image to obtain pixel values of the gray level image, and comparing the pixel values through a preset pixel threshold value to obtain a comparison result;
step S0313, binarizing the pixel value according to the comparison result to obtain a binarized pixel value;
Step S0314, generating a black-and-white binary image according to the binarized pixel value.
The specific steps for obtaining the black-and-white binary image can be as follows: converting the image in the unrecognizable image set into a gray image, wherein the conversion process is to convert the image into the gray image through a Python and an OpenCV library in the embodiment, so as to obtain the gray image;
Since there are specific pixels in the gray image, and each pixel represents a point in the image, which is the smallest unit in the image, with a specific position and value, where a pixel value (pixel value) is a value representing an attribute or feature of a pixel, typically expressed as a gray value (for a gray image) or a color value (for a color image);
at this time, the pixel values can be compared through a preset pixel threshold value, so that a comparison result can be obtained, and binarization is carried out on the comparison result, specifically, one pixel value lower than the pixel threshold value is the other pixel value higher than the pixel threshold value, so that a binarized pixel value is obtained;
And finally, generating an image based on the binarized pixel value to obtain a black-white binary image.
More specifically, the step S032 calculates the number of image symbols according to the black-white binary image, and analyzes the number of image symbols according to the fullness of the image symbols and a preset fullness threshold, so as to obtain a corrupted symbol set, where the step of obtaining the corrupted symbol set includes:
step S0321, detecting the black-and-white binary image through an edge detection Sobel algorithm to obtain an image frame;
Step S0322, calculating an image grid in the image frame based on a template matching algorithm to obtain a code element pixel template, a two-dimensional code version and a template code element position plan;
step S0323, calculating the plumpness of the image code element through the code element pixel template, the two-dimensional code version and the template code element position plane diagram;
And step S0324, analyzing through the fullness threshold according to the fullness of the image code element to obtain a damaged code element set.
The image contour is rapidly processed through an edge detection Sobel algorithm, and a two-dimensional code frame contour is determined;
Based on the calculation processing of the adjusted template matching algorithm on the two-dimensional code image grid size, the method is used for obtaining the average symbol pixel size, the two-dimensional code version, the minimum grid plan of the theoretical symbol position and the possibly damaged symbol, and specifically the step of obtaining the damaged symbol is as follows in the embodiment: the obtained black-and-white binary image can be directly calculated to obtain the number of code elements by using a connected region algorithm, wherein the average pixel size of each code element = the number of pixels of the two-dimensional code image/the number of code elements;
Then, judging and obtaining all possible lossy code element sets according to the fullness of the code elements (obtained by using the number of black pixel contained in the code elements/the average pixel size according to the code elements) and a preset threshold value;
finally, for repair of various loss types, it can be understood that: judging whether the code element is lossy or not according to the plumpness of a specific threshold value aiming at the loss of the dotting type; for the penetrability frame loss, continuous specific fullness symbols are obtained according to the connectivity analysis, and are subjected to damage judgment, and the repair processing is directly carried out on the damaged symbols according to pixel colors.
According to the scheme, specifically, gray processing is carried out on the unidentifiable two-dimensional code image set to obtain a black-white binary image; calculating the number of image code elements according to the black-white binary image, and analyzing according to the plumpness of the image code elements and a preset plumpness threshold value to obtain a damaged code element set; repairing the damaged code element set through an interpolation algorithm to obtain a repaired unidentifiable two-dimensional code image set; and decoding and verifying the repaired unidentifiable two-dimensional code image set and the unidentifiable two-dimensional code image set to obtain a verification result. Therefore, the two-dimensional code can not be identified, the problems that the two-dimensional code can not be repaired in time and the repair cost is high when damaged are solved, and the two-dimensional code repair efficiency is improved.
Further explaining the invention, the invention can be understood as a two-dimensional code repairing system which is shown in fig. 6 and consists of a camera shooting module, a two-dimensional code decoding output module, a two-dimensional code template management module, a two-dimensional code analysis matching module and a two-dimensional code image repairing module;
specifically, the functions of each module are respectively as follows:
1. camera shooting module: the method has the main functions of acquiring pictures containing two-dimensional codes;
2. two-dimensional code template management module: the method has the main functions of storing the two-dimensional code template and corresponding information such as feature codes, versions, code element numbers and the like;
3. Two-dimensional code analysis matching module: mainly classifying and identifying unidentifiable two-dimensional codes, and performing displacement and identification on positioning points and version position code pixels;
4. Two-dimensional code image restoration module: after the gray processing of the image, identifying the graticule code element pixels, judging the code element plumpness threshold value and the code element pixel loss characteristics, and then repairing;
5. Two-dimensional code decoding output module: calling a public method to decode the two-dimension code mainly according to the input picture;
More specifically, the operation of the whole system module is shown in fig. 7, and fig. 7 is a flowchart of the operation of the whole system according to the two-dimensional code repairing method of the present invention.
Firstly, acquiring a two-dimensional code image through a camera shooting module;
Then, decoding the acquired two-dimensional code image in a two-dimensional code standard decoding mode to obtain a recognizable and unrecognizable two-dimensional code image set;
Then, verifying the two-dimensional code feature code and the existing template of the version of the identifiable two-dimensional code image, and outputting the decoding content of the two-dimensional code when the verification is passed (namely, when the feature code is consistent);
Then, acquiring the existing two-dimensional code feature code and version information of the system for the unidentifiable two-dimensional code image, performing four-corner positioning replacement on the two-dimensional code feature code and version information, and then decoding the two-dimensional code feature code and version information, and classifying the two-dimensional code feature code and version information as the identifiable two-dimensional code image if the two-dimensional code feature code and version information can be identified;
finally, two-dimensional code restoration is executed for the two-dimensional code image which is still unrecognizable, and the method specifically comprises the following steps:
(1) Processing the gray level of the two-dimensional code according to a preset threshold value; (2) Extracting the code elements of the image through a connected region algorithm to obtain a code element set, and calculating the average pixel size of the code elements, (3) extracting a lossy code element set in the code element set through a preset plumpness and gray value, (4) repairing the code elements according to a preset characteristic value, and (5) obtaining a repairing result and then performing decoding verification again.
According to the scheme, specifically, the image with the two-dimensional code is acquired and intercepted through the preset acquisition equipment, so that a two-dimensional code image set is obtained; according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set; and performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result. Therefore, a two-dimensional code image set is obtained through the acquisition equipment, an identifiable two-dimensional code image set and an unidentifiable two-dimensional code image set are obtained based on the two-dimensional code image set through identification, the unidentifiable two-dimensional code image set is repaired, and finally the repaired unidentifiable two-dimensional code image set and the repaired identifiable image set are decoded and verified to obtain a verification result. The two-dimensional code repairing method and device solve the problems that the two-dimensional code cannot be repaired in time and the repairing cost is high when damaged, and improve the two-dimensional code repairing efficiency.
In addition, the embodiment of the invention also provides a two-dimensional code repairing device, which comprises:
the acquisition module is used for acquiring and intercepting images with the two-dimensional codes through preset acquisition equipment to obtain a two-dimensional code image set;
the identification module is used for carrying out identification through a preset bar code picture processing library according to the two-dimensional code image set to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set;
and the verification module is used for carrying out image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and carrying out decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result.
In addition, the embodiment of the invention also provides a terminal device, which comprises a memory, a processor and a two-dimensional code repairing program stored on the memory and capable of running on the processor, wherein the two-dimensional code repairing program realizes the steps of the two-dimensional code repairing method when being executed by the processor.
Because the two-dimensional code repairing program is executed by the processor and adopts all the technical schemes of all the embodiments, the two-dimensional code repairing program at least has all the beneficial effects brought by all the technical schemes of all the embodiments and is not described in detail herein.
In addition, the embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium is stored with a two-dimensional code repairing program, and the two-dimensional code repairing program realizes the steps of the two-dimensional code repairing method when being executed by a processor.
Because the two-dimensional code repairing program is executed by the processor and adopts all the technical schemes of all the embodiments, the two-dimensional code repairing program at least has all the beneficial effects brought by all the technical schemes of all the embodiments and is not described in detail herein.
Compared with the prior art, the two-dimensional code repairing method, the device, the terminal equipment and the storage medium provided by the embodiment of the invention acquire and intercept images with the two-dimensional code through the preset acquisition equipment to obtain a two-dimensional code image set; according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set; and performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result. Therefore, the problems that the two-dimensional code cannot be repaired in time and the repair cost is high when damaged are solved, the two-dimensional code is repaired, and the two-dimensional code repairing efficiency is improved. Based on the scheme of the invention, the two-dimensional code repairing method is designed from the problems that the cost of two-dimensional code repairing software is high and training data is depended in reality, the hardware cost is high for the continuous flow recognition, or only a positioning frame is required, the bias and the environment constraint are often present in an actual scene, the quick and effective recognition cannot be carried out aiming at the specific scene, and the efficiency is low, the effectiveness of the two-dimensional code repairing method is verified when the two-dimensional code is repaired, and finally the efficiency of two-dimensional code repairing through the method is obviously improved.
Compared with the prior art, the embodiment of the invention has the following advantages:
1. The two-dimensional code analysis matching module can quickly replace code elements such as a locator and a version number of the two-dimensional code on the premise of not performing a large number of machine learning according to the characteristics of the two-dimensional code picture recorded in advance, and according to the technical characteristics, the method can effectively aim at scenes which cannot be identified by the two-dimensional code due to the loss of the version number and the locator, improve the identification rate, and intercept the two-dimensional code which can be identified but does not accord with the system, so that the system is protected from specific attack;
2. Through gray processing of a specific threshold value, after grating processing is carried out on code elements of the two-dimensional code, all code elements of the two-dimensional code can be accurately obtained, whether the code elements are damaged or not can be judged according to gray values and plumpness of each code element, and then the code elements are repaired by combining special code element loss characteristics.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but 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 stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as above, comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, a controlled terminal, or a network device, etc.) to perform the method of each embodiment of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.
Claims (7)
1. The two-dimensional code repairing method is characterized by comprising the following steps of:
Acquiring and intercepting images with two-dimensional codes through preset acquisition equipment to obtain a two-dimensional code image set;
according to the two-dimensional code image set, identifying through a preset bar code picture processing library to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set;
The step of acquiring the identifiable two-dimensional code image set and the unidentifiable two-dimensional code image set comprises the following steps of:
identifying the two-dimensional code image set through the bar code image processing library to obtain an identification result, wherein the identification result comprises one or more of a first identifiable image set and an unidentifiable image set;
Generating a replacement two-dimensional code image set through a two-dimensional code template database according to the unrecognizable image set, performing coverage replacement on the unrecognizable image set through the replacement two-dimensional code image set to obtain a replaced unrecognizable image set, and decoding the replaced unrecognizable image set to obtain a second identifiable image set and a unrecognizable two-dimensional code image set;
Analyzing the first identifiable image set and the second identifiable image set to obtain feature codes of the first identifiable image set and the second identifiable image set;
Verifying the feature codes of the first identifiable image set and the second identifiable image set through a two-dimensional code template database, and outputting the data sets which pass the verification of the first identifiable image set and the second identifiable image set as identifiable two-dimensional code image sets;
Performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result;
the step of performing image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and performing decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result comprises the following steps:
gray processing is carried out on the unidentifiable two-dimensional code image set, and a black-white binary image is obtained;
calculating the number of image code elements according to the black-white binary image, and analyzing according to the plumpness of the image code elements and a preset plumpness threshold value to obtain a damaged code element set;
repairing the damaged code element set through an interpolation algorithm to obtain a repaired unidentifiable two-dimensional code image set;
And decoding and verifying the repaired unidentifiable two-dimensional code image set and the unidentifiable two-dimensional code image set to obtain a verification result.
2. The two-dimensional code repairing method according to claim 1, wherein the step of performing gray-scale processing on the unidentifiable two-dimensional code image set to obtain a black-and-white binary image comprises:
converting the image in the unidentifiable two-dimensional code image set into a gray image;
traversing pixel points in the gray level image to obtain pixel values of the gray level image, and comparing the pixel values through a preset pixel threshold value to obtain a comparison result;
Binarizing the pixel value according to the comparison result to obtain a binarized pixel value;
And generating a black-and-white binary image according to the binarized pixel value.
3. The two-dimensional code repairing method according to claim 1, wherein the step of calculating the number of image symbols according to the black-and-white binary image and analyzing according to the fullness of the image symbols and a preset fullness threshold to obtain a damaged symbol set comprises:
detecting the black-and-white binary image through an edge detection Sobel algorithm to obtain an image frame;
calculating an image grid in the image frame based on a template matching algorithm to obtain a code element pixel template, a two-dimensional code version and a template code element position plan;
Calculating the plumpness of the image code element through the code element pixel template, the two-dimensional code version and the template code element position plane diagram;
And analyzing according to the fullness of the image code element through the fullness threshold value to obtain a damaged code element set.
4. The two-dimensional code repairing method according to claim 1, wherein the steps of performing image repairing on the unidentifiable two-dimensional code image set to obtain a repairing result, performing decoding verification on the unidentifiable two-dimensional code image set and the repairing result, and obtaining a verification result further comprise:
classifying based on the verification result to obtain a two-dimensional code image set with restoration failure;
And generating alarm information according to the two-dimensional code image set with the repair failure, and sending the alarm information to a corresponding user terminal.
5. Two-dimensional code prosthetic devices, its characterized in that, two-dimensional code prosthetic devices includes:
the acquisition module is used for acquiring and intercepting images with the two-dimensional codes through preset acquisition equipment to obtain a two-dimensional code image set;
the identification module is used for carrying out identification through a preset bar code picture processing library according to the two-dimensional code image set to obtain an identifiable two-dimensional code image set and an unrecognizable two-dimensional code image set;
The identification module is further used for identifying the two-dimensional code image set through the bar code image processing library to obtain an identification result, wherein the identification result comprises one or more of a first identifiable image set and an unrecognizable image set;
Generating a replacement two-dimensional code image set through a two-dimensional code template database according to the unrecognizable image set, performing coverage replacement on the unrecognizable image set through the replacement two-dimensional code image set to obtain a replaced unrecognizable image set, and decoding the replaced unrecognizable image set to obtain a second identifiable image set and a unrecognizable two-dimensional code image set;
Analyzing the first identifiable image set and the second identifiable image set to obtain feature codes of the first identifiable image set and the second identifiable image set;
Verifying the feature codes of the first identifiable image set and the second identifiable image set through a two-dimensional code template database, and outputting the data sets which pass the verification of the first identifiable image set and the second identifiable image set as identifiable two-dimensional code image sets;
The verification module is used for carrying out image restoration on the unidentifiable two-dimensional code image set to obtain a restoration result, and carrying out decoding verification on the unidentifiable two-dimensional code image set and the restoration result to obtain a verification result;
the verification module is further used for carrying out gray processing on the unidentifiable two-dimensional code image set to obtain a black-white binary image;
calculating the number of image code elements according to the black-white binary image, and analyzing according to the plumpness of the image code elements and a preset plumpness threshold value to obtain a damaged code element set;
repairing the damaged code element set through an interpolation algorithm to obtain a repaired unidentifiable two-dimensional code image set;
And decoding and verifying the repaired unidentifiable two-dimensional code image set and the unidentifiable two-dimensional code image set to obtain a verification result.
6. A terminal device, characterized in that the terminal device comprises a memory, a processor and a two-dimensional code repair program stored on the memory and operable on the processor, the two-dimensional code repair program implementing the steps of the two-dimensional code repair method according to any one of claims 1-4 when executed by the processor.
7. A computer-readable storage medium, wherein a two-dimensional code repair program is stored on the computer-readable storage medium, and the two-dimensional code repair program, when executed by a processor, implements the steps of the two-dimensional code repair method according to any one of claims 1 to 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410472224.6A CN118070826B (en) | 2024-04-19 | 2024-04-19 | Two-dimensional code repairing method, device, terminal equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410472224.6A CN118070826B (en) | 2024-04-19 | 2024-04-19 | Two-dimensional code repairing method, device, terminal equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN118070826A CN118070826A (en) | 2024-05-24 |
CN118070826B true CN118070826B (en) | 2024-07-23 |
Family
ID=91100472
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410472224.6A Active CN118070826B (en) | 2024-04-19 | 2024-04-19 | Two-dimensional code repairing method, device, terminal equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118070826B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2004362603A (en) * | 1992-09-28 | 2004-12-24 | Olympus Corp | Reproducing device |
CN116309117A (en) * | 2023-01-16 | 2023-06-23 | 瑞芯微电子股份有限公司 | Two-dimensional code image restoration and identification method and device, electronic equipment and storage medium |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111597847A (en) * | 2019-02-20 | 2020-08-28 | 中科院微电子研究所昆山分所 | Two-dimensional code identification method, device and equipment and readable storage medium |
CN112215030B (en) * | 2020-10-28 | 2022-06-10 | 天津大学 | Restoration and identification method based on cylindrical surface two-dimensional code |
CN117034982B (en) * | 2023-10-10 | 2023-12-29 | 成都新西旺自动化科技有限公司 | Two-dimensional code identification method and device with automatic repair function |
-
2024
- 2024-04-19 CN CN202410472224.6A patent/CN118070826B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2004362603A (en) * | 1992-09-28 | 2004-12-24 | Olympus Corp | Reproducing device |
CN116309117A (en) * | 2023-01-16 | 2023-06-23 | 瑞芯微电子股份有限公司 | Two-dimensional code image restoration and identification method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN118070826A (en) | 2024-05-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
USRE44139E1 (en) | Method and apparatus for decoding mixed code | |
US7702162B2 (en) | Mixed code, and method and apparatus for generating the same | |
US20140119647A1 (en) | Method and Apparatus for Decoding Mixed Code | |
US20120213429A1 (en) | System and method for extracting flowchart information from digital images | |
CN113392669B (en) | Image information detection method, detection device and storage medium | |
CN111553363B (en) | End-to-end seal identification method and system | |
CN111626941A (en) | Document correction method based on deep learning semantic segmentation | |
CN109101855B (en) | Lost positioning frame two-dimensional code identification method based on opencv | |
US8249364B2 (en) | Method for resolving contradicting output data from an optical character recognition (OCR) system, wherein the output data comprises more than one recognition alternative for an image of a character | |
CN110210467B (en) | Formula positioning method of text image, image processing device and storage medium | |
CN118070826B (en) | Two-dimensional code repairing method, device, terminal equipment and storage medium | |
CN111507119A (en) | Identification code identification method and device, electronic equipment and computer readable storage medium | |
CN107330470B (en) | Method and device for identifying picture | |
CN111414889A (en) | Financial statement identification method and device based on character identification | |
CN113792677B (en) | Table identification method and device, computer equipment and storage medium | |
CN116029777A (en) | Anti-counterfeiting bill generation method, device, equipment and medium | |
CN112967166A (en) | OpenCV-based automatic image watermark identification processing method and system | |
CN118037552A (en) | Two-dimensional code defect repairing method, device, equipment and medium | |
KR102682942B1 (en) | Method and device for identification barcode image | |
CN116071835B (en) | Face recognition attack post screening method and device and electronic equipment | |
CN111681161B (en) | Restoration method and device for folded two-dimensional code image and computer readable storage medium | |
CN114494243A (en) | Two-dimensional code picture detection method and electronic equipment | |
CN118053227A (en) | Hotel access control system utilizing two-dimension code recognition technology | |
Chen et al. | Drone-Assisted QR Code Recognition Method for Warehouse Management | |
CN116738486A (en) | Image data desensitization method and system |
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 |