CN113591506A - Robust two-dimensional code DataMatrix decoding method and system - Google Patents

Robust two-dimensional code DataMatrix decoding method and system Download PDF

Info

Publication number
CN113591506A
CN113591506A CN202110887858.4A CN202110887858A CN113591506A CN 113591506 A CN113591506 A CN 113591506A CN 202110887858 A CN202110887858 A CN 202110887858A CN 113591506 A CN113591506 A CN 113591506A
Authority
CN
China
Prior art keywords
image
dimensional code
scanning
white
robust
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.)
Pending
Application number
CN202110887858.4A
Other languages
Chinese (zh)
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.)
Shenzhen Jieenshi Intelligent Technology Co ltd
Original Assignee
Shenzhen Jieenshi Intelligent 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 Shenzhen Jieenshi Intelligent Technology Co ltd filed Critical Shenzhen Jieenshi Intelligent Technology Co ltd
Priority to CN202110887858.4A priority Critical patent/CN113591506A/en
Publication of CN113591506A publication Critical patent/CN113591506A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods 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/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods 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/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1443Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods 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/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1452Methods for optical code recognition including a method step for retrieval of the optical code detecting bar code edges

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (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)
  • Character Input (AREA)

Abstract

The invention relates to a robust two-dimensional code DataMatrix decoding method, which comprises the following steps: preprocessing an image, removing noise, accurately positioning a two-dimensional code, performing perspective or affine transformation, scanning and obtaining a decoding character string; by the method, common decoding problems such as code element loss, serious and uneven illumination distribution, scratches, super-large noise, noise similar to the code elements, metal dot matrix codes and the like can be efficiently solved, and therefore competitiveness in the two-dimensional code decoding field is greatly improved.

Description

Robust two-dimensional code DataMatrix decoding method and system
Technical Field
The invention relates to the technical field of machine vision and image recognition, in particular to a robust two-dimensional code DataMatrix decoding method and system.
Background
Although two-dimensional code decoding methods are numerous at home and abroad, almost all algorithms face the problem of insufficient robustness. For example, when the two-dimensional code is a lattice code or other complex conditions, most algorithms either consume too long decoding time or consume large decoding time and fluctuation or cannot decode at all, when the conditions of severe uneven illumination, overexposure or darkness of the image, severe noise interference, and over-blurring of the image are encountered. In order to meet the requirements of the industrial field on the algorithm: the robustness is extremely strong, the speed is high, the consumed time is stable, and a robust two-dimensional code DataMatrix decoding method is needed.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a robust two-dimensional code DataMatrix decoding method and a robust two-dimensional code DataMatrix decoding system, aiming at the above defects in the prior art.
The technical scheme adopted by the invention for solving the technical problems is as follows:
a robust two-dimensional code DataMatrix decoding method is constructed, wherein the method comprises the following steps:
s1: image preprocessing:
acquiring an image, and converting the acquired image into a binary image;
s2: noise removal:
denoising the obtained binary image;
s3: two-dimensional code accurate positioning:
positioning the precise positions of the four angle vertexes of the two-dimensional code;
s4: perspective or affine transformation:
correcting the four vertexes obtained by positioning;
s5: scanning:
dividing a grid code scanning two-dimensional code;
s6: and obtaining a decoding character string.
The robust two-dimensional code DataMatrix decoding method of the present invention, wherein the step S1: the image preprocessing comprises the following specific steps:
converting the three-channel color picture into a gray scale image by adopting a set proportion;
dividing the gray scale image into a plurality of small intervals, and carrying out binarization in each interval to obtain a binary image W _ IMG;
counting white pixel points at the edge of the binary image W _ IMG, judging whether the pixel points are white codes under black or white codes under white, and if the pixel points are the white codes under black, reversing the color;
then carrying out global scanning on the binary image W _ IMG to connect white pixel points or remove the white pixel points;
and outputting the preprocessed image.
The robust two-dimensional code DataMatrix decoding method of the present invention, wherein the step S3: the two-dimension code accurate positioning method comprises the following specific steps:
starting from four corners of the two-dimensional code image, combining every two adjacent two images in 8 directions, searching 8 points meeting the set requirement in the set area, determining 4 intersection points P4 by using four line segments of the 8 points, and determining four line segments L4 by using P4.
The robust two-dimensional code DataMatrix decoding method of the present invention, wherein the setting requirement includes:
the minimum value of the distances between the point and the four corners of the set area is less than a set value;
the minimum distance between the point and the image edge is less than a set value;
the density of white pixels near a point is higher than a set value.
The robust two-dimensional code DataMatrix decoding method of the present invention, wherein the step S4: the perspective or affine transformation comprises the following specific steps:
counting an included angle theta of the line segments of the opposite side by four line segments L4;
calculating the average length M _ L of each line segment of the four line segments L4;
if the included angle theta of the side line section is larger than a set value, the worst point is removed from the P4, and a fourth point meeting the parallelogram is generated according to the position relation of the remaining three points to obtain a new P4;
generating a new four-point N _ P4 according to the average length M _ L;
the W _ IMG is image transformed using a perspective transformation from P4 to N _ P4.
The robust two-dimensional code DataMatrix decoding method of the present invention, wherein the step S5: the scanning comprises the following specific steps:
and performing scanning circulation operation by adopting a conventional grid dividing mode, outputting a character string if the operation is successful, positioning the position of the two-dimensional code virtual edge code element if the operation is failed, generating a new scanning grid by utilizing the position, enabling the centers of the grids to be the centers of the virtual edge code elements, performing scanning circulation operation, and outputting the character string if the operation is successful.
The invention relates to a robust two-dimensional code DataMatrix decoding method, wherein the scanning cycle operation comprises the following steps:
giving a plurality of groups: parameter 1: area _ thres of white area to area of grid within single grid, parameter 2: size _ thres of single grid relative W _ IMG;
with the two parameters different, a different grid map D _ IMG is scanned out and decoded.
A robust two-dimensional code DataMatrix decoding system is used for realizing the robust two-dimensional code DataMatrix decoding method, and comprises an image preprocessing unit, an image denoising unit, a two-dimensional code accurate positioning unit, a perspective or affine transformation unit, a scanning unit and a decoding character string output unit;
the image preprocessing unit is used for acquiring an image and converting the acquired image into a binary image;
the image denoising unit is used for denoising the obtained binary image;
the two-dimension code accurate positioning unit is used for positioning the accurate positions of four angle vertexes of the two-dimension code;
the perspective or affine transformation unit is used for correcting the four vertexes obtained by positioning;
the scanning unit is used for dividing grid code scanning two-dimensional codes;
and the decoding character string output unit is used for outputting code scanning to obtain a decoding character string.
The robust two-dimensional code DataMatrix decoding system comprises an image preprocessing unit, a data decoding unit and a data decoding unit, wherein the image preprocessing unit comprises:
converting the three-channel color picture into a gray scale image by adopting a set proportion;
dividing the gray scale image into a plurality of small intervals, and carrying out binarization in each interval to obtain a binary image W _ IMG;
counting white pixel points at the edge of the binary image W _ IMG, judging whether the pixel points are white codes under black or white codes under white, and if the pixel points are the white codes under black, reversing the color;
then carrying out global scanning on the binary image W _ IMG to connect white pixel points or remove the white pixel points;
and outputting the preprocessed image.
The robust two-dimensional code DataMatrix decoding system comprises a two-dimensional code accurate positioning unit, a two-dimensional code image acquisition unit, a two-dimensional code image acquisition unit and a two-dimensional code image acquisition unit, wherein the two-dimensional code accurate positioning unit starts from four corners of a two-dimensional code image, combines every two adjacent two of the four corners to form 8 directions, searches 8 points meeting the set requirement in a set area, forms four line segments by the 8 points, determines 4 intersection points P4, and determines four line segments L4 by the P4;
the perspective or affine transformation unit calculates an included angle theta between the line segments of the opposite sides by four line segments L4, calculates an average length M _ L of each line segment of four line segments L4, if the included angle theta between the line segments of the opposite sides is larger than a set value, eliminates the worst point in P4, generates a fourth point meeting the parallelogram by the position relation of the remaining three points to obtain a new P4, generates a new four point N _ P4 according to the average length M _ L, and performs image transformation on W _ IMG by adopting perspective transformation from P4 to N _ P4;
the scanning unit performs scanning circulation operation by adopting a conventional grid dividing mode, outputs character strings if the scanning unit succeeds, positions the positions of the two-dimensional code virtual edge code elements if the scanning unit fails, generates new scanning grids by utilizing the positions, enables the centers of the grids to be the centers of the virtual edge code elements, performs scanning circulation operation, and outputs the character strings if the scanning unit succeeds.
The invention has the beneficial effects that: by the method, common decoding problems such as code element loss, serious and uneven illumination distribution, scratches, super-large noise, noise similar to the code elements, metal dot matrix codes and the like can be efficiently solved, and therefore competitiveness in the two-dimensional code decoding field is greatly improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the present invention will be further described with reference to the accompanying drawings and embodiments, wherein the drawings in the following description are only part of the embodiments of the present invention, and for those skilled in the art, other drawings can be obtained without inventive efforts according to the accompanying drawings:
fig. 1, fig. 2, fig. 3 and fig. 4 are decoding effect diagrams of various situations of the robust two-dimensional code DataMatrix decoding method according to the preferred embodiment of the present invention;
FIG. 5 is a flowchart of a robust two-dimensional code DataMatrix decoding method in accordance with a preferred embodiment of the present invention;
FIG. 6 is a flowchart of a robust two-dimensional code DataMatrix decoding method S1 according to a preferred embodiment of the invention;
fig. 7 is a flowchart of a robust two-dimensional code DataMatrix decoding method S4 according to a preferred embodiment of the invention;
fig. 8 is a schematic block diagram of a robust two-dimensional code DataMatrix decoding system according to a preferred embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention, and it is obvious that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without inventive step, are within the scope of the present invention.
The robust two-dimensional code DataMatrix decoding method according to the preferred embodiment of the present invention is shown in fig. 5, and referring to fig. 1-4, 6 and 7, the method includes the following steps:
s1: image preprocessing:
acquiring an image, and converting the acquired image into a binary image;
s2: noise removal:
denoising the obtained binary image;
s3: two-dimensional code accurate positioning:
positioning the precise positions of the four angle vertexes of the two-dimensional code;
s4: perspective or affine transformation:
correcting the four vertexes obtained by positioning;
s5: scanning:
dividing a grid code scanning two-dimensional code;
s6: obtaining a decoding character string;
by applying the method, common decoding problems such as code element loss, serious and uneven illumination distribution, scratches, super-large noise, noise similar to the code elements, metal dot matrix codes and the like can be efficiently solved, so that the competitiveness in the field of two-dimensional code decoding is greatly improved;
according to the mode of the application:
the decoding result for the case of fig. 1 is: RDQ50A1XY10529A2542 AAAA;
the decoding result for the case of fig. 2 is: 9-07907.05;
the decoding result for the case of fig. 3 is: T592M612AN 78;
the decoding result for the case of fig. 4 is: 001808508811036000027188.
preferably, S1: the image preprocessing comprises the following specific steps:
converting the three-channel color picture into a gray scale image by adopting a set proportion;
dividing the gray scale image into a plurality of small intervals, and carrying out binarization in each interval to obtain a binary image W _ IMG;
counting white pixel points at the edge of the binary image W _ IMG, judging whether the pixel points are white codes under black or white codes under white, and if the pixel points are the white codes under black, reversing the color;
then carrying out global scanning on the binary image W _ IMG to connect white pixel points or remove the white pixel points;
outputting the preprocessed image;
and converting the three-channel color picture into a gray scale image by adopting a proper proportion. And dividing the gray-scale image into a plurality of small intervals, and carrying out binarization in each interval to obtain a binary image W _ IMG, so that the influence of uneven illumination distribution can be effectively reduced. And counting white pixel points at the edge of the W _ IMG, judging whether the white pixel points are black bottom white codes or white bottom black codes, and if the white pixel points are the black bottom white codes, reversing the color. And (3) in the W _ IMG full image scanning, white pixel points are connected, or the white pixel points are removed, so that the problem of the hollow circle of the dot code can be effectively solved.
Preferably, S3: the two-dimension code accurate positioning method comprises the following specific steps:
starting from four corners of a two-dimensional code image, combining every two adjacent two images in 8 directions, searching 8 points meeting the set requirement in a set area, determining 4 intersection points P4 by using four line segments of the 8 points, and determining four line segments L4 by using P4; the setting requirements include:
the minimum value of the distances between the point and the vertexes of the four corners of the set area is smaller than a set value;
the minimum distance between the point and the image edge is less than a set value;
the density of white pixels near a point is higher than a set value.
From 8 directions in four corners, the most suitable 8 points are searched, and the conditions are met: 1. the point is close enough to the four corner vertices of the region; 2. the point is close enough to the image edge; 3. the white pixels near the point are dense. For example, from the top left vertex LU of W _ IMG to the bottom left vertex LD of W _ IMG, which is a scanning direction ORIENT, the y-direction scanning range may be half the height of W _ IMG, and the x-direction scanning range may be half the width of W _ IMG. Starting from the top left vertex LU, the scanning range is scanned point by point. A white pixel point P is found so that it meets the prior condition. Such a P may be one of 8 points, with the same other seven directions being similar. Four line segments with 8 points are used for determining 4 intersection points P4, and four line segments L4 are determined by P4;
preferably, S4: the perspective or affine transformation comprises the following specific steps:
counting an included angle theta of the line segments of the opposite side by four line segments L4;
calculating the average length M _ L of each line segment of the four line segments L4;
if the included angle theta of the side line section is larger than a set value, the worst point is removed from the P4, and a fourth point meeting the parallelogram is generated according to the position relation of the remaining three points to obtain a new P4;
generating a new four-point N _ P4 according to the average length M _ L;
the W _ IMG is image transformed using a perspective transformation from P4 to N _ P4.
From the four line segments L4, two opposite side line segment angles are determined, and the average length M _ L is determined. The best two are taken from L4, i.e. the three points that determine P4 is best. And (3) calculating the included angle of opposite sides in L4, if the included angle is larger than a fixed value, eliminating the worst point in P4, generating a fourth point meeting the parallelogram according to the position relation of the rest three points to obtain a new P4, generating a new four-point N _ P4 by M _ L, and performing image transformation on W _ IMG by adopting perspective transformation from P4 to N _ P4.
Preferably, S5: the scanning comprises the following specific steps:
and performing scanning circulation operation by adopting a conventional grid dividing mode, outputting a character string if the operation is successful, positioning the position of the two-dimensional code virtual edge code element if the operation is failed, generating a new scanning grid by utilizing the position, enabling the centers of the grids to be the centers of the virtual edge code elements, performing scanning circulation operation, and outputting the character string if the operation is successful.
Preferably, the scan cycle operation comprises the method of:
giving a plurality of groups: parameter 1: area _ thres of white area to area of grid within single grid, parameter 2: size _ thres of single grid relative W _ IMG;
with the two parameters different, a different grid map D _ IMG is scanned out and decoded.
And (4) adopting a common grid division to carry out scanning circulation, and outputting the character string if the scanning circulation is successful. In a scan loop, given the parameter area _ thres (the ratio of white area to grid area within a single grid), the parameter size _ thres (the size of a single grid relative to W _ IMG), a different grid map D _ IMG is scanned as the two parameters differ. However, the edges of this grid pattern may be different from the edges of the two-dimensional code, although the two-dimensional code edges only serve as a positioning effect. Therefore, a new edge can be generated according to the old edge, and then the new edge is used for replacing the old edge, so that a new grid graph D _ IMG can be obtained, the new grid graph D _ IMG is decoded, a character string is output when the new grid graph D _ IMG is successful, and the scanning cycle is exited.
When the scanning cycle is completed through all parameter combinations, part of pictures with poor photographing conditions still cannot be decoded. In this case, the number of pixels occupied by the two-dimensional code symbol is too small, such as only 2 × 2, or the internal symbol is shifted due to the case of serious uneven distribution of light, which causes an error in the ordinary grid division method. For this case, we use an adaptive meshing method for the scanning cycle. Firstly, a grid with a fixed size is adopted to scan the edge, and the number of white pixel points of the grid is counted during each scanning, so that the edge where the two-dimensional code virtual edge is located can be determined, and the position where the virtual edge code element is located can be determined at the same time. With the position, new scan grids can be generated such that the grid centers are exactly the dashed edge symbol centers. The subsequent grid correction and grid decoding are still the same as the common method, when the grid decoding is successful, the character string is output, and the scanning cycle is exited
A robust two-dimensional code DataMatrix decoding system is used for realizing the robust two-dimensional code DataMatrix decoding method, as shown in FIG. 8, and comprises an image preprocessing unit 1, an image denoising unit 2, a two-dimensional code accurate positioning unit 3, a perspective or affine transformation unit 4, a scanning unit 5 and a decoded character string output unit 6;
the image preprocessing unit 1 is used for acquiring an image and converting the acquired image into a binary image;
the image denoising unit 2 is used for denoising the obtained binary image;
the two-dimension code accurate positioning unit 3 is used for positioning the accurate positions of four angle vertexes of the two-dimension code;
a perspective or affine transformation unit 4 for correcting the four vertexes obtained by positioning;
the scanning unit 5 is used for dividing grid code scanning two-dimensional codes;
a decoding character string output unit 6, configured to output a code scanning to obtain a decoding character string;
by the method, common decoding problems such as code element loss, serious and uneven illumination distribution, scratches, super-large noise, noise similar to the code elements, metal dot matrix codes and the like can be efficiently solved, and therefore competitiveness in the two-dimensional code decoding field is greatly improved.
Preferably, when the image preprocessing unit 1 performs image preprocessing:
converting the three-channel color picture into a gray scale image by adopting a set proportion;
dividing the gray scale image into a plurality of small intervals, and carrying out binarization in each interval to obtain a binary image W _ IMG;
counting white pixel points at the edge of the binary image W _ IMG, judging whether the pixel points are white codes under black or white codes under white, and if the pixel points are the white codes under black, reversing the color;
then carrying out global scanning on the binary image W _ IMG to connect white pixel points or remove the white pixel points;
outputting the preprocessed image;
and converting the three-channel color picture into a gray scale image by adopting a proper proportion. And dividing the gray-scale image into a plurality of small intervals, and carrying out binarization in each interval to obtain a binary image W _ IMG, so that the influence of uneven illumination distribution can be effectively reduced. And counting white pixel points at the edge of the W _ IMG, judging whether the white pixel points are black bottom white codes or white bottom black codes, and if the white pixel points are the black bottom white codes, reversing the color. And (3) in the W _ IMG full image scanning, white pixel points are connected, or the white pixel points are removed, so that the problem of the hollow circle of the dot code can be effectively solved.
Preferably, the two-dimensional code accurate positioning unit 3 starts from four corners of the two-dimensional code image, combines every two adjacent two-dimensional code images in 8 directions, searches for 8 points meeting the setting requirement in the setting area, determines 4 intersection points P4 by using four line segments of the 8 points, and determines four line segments L4 by using the P4;
the perspective or affine transformation unit 4 is used for counting an included angle theta of a line segment at the opposite side by four line segments L4, calculating the average length M _ L of each line segment of four line segments L4, if the included angle theta of the line segment at the opposite side is larger than a set value, eliminating the worst point in P4, generating a fourth point meeting the parallelogram by the position relation of the remaining three points to obtain a new P4, generating a new four point N _ P4 according to the average length M _ L, and performing image transformation on W _ IMG by adopting perspective transformation from P4 to N _ P4;
and the scanning unit 5 performs scanning circulation operation by adopting a conventional grid division mode, outputs character strings if the scanning circulation operation is successful, positions the positions of the two-dimensional code virtual edge code elements if the scanning circulation operation is failed, generates new scanning grids by utilizing the positions, enables the centers of the grids to be just the centers of the virtual edge code elements, performs scanning circulation operation again, and outputs the character strings if the scanning circulation operation is successful.
It will be understood that modifications and variations can be made by persons skilled in the art in light of the above teachings and all such modifications and variations are intended to be included within the scope of the invention as defined in the appended claims.

Claims (10)

1. A robust two-dimensional code DataMatrix decoding method is characterized by comprising the following steps:
s1: image preprocessing:
acquiring an image, and converting the acquired image into a binary image;
s2: noise removal:
denoising the obtained binary image;
s3: two-dimensional code accurate positioning:
positioning the precise positions of the four angle vertexes of the two-dimensional code;
s4: perspective or affine transformation:
correcting the four vertexes obtained by positioning;
s5: scanning:
dividing a grid code scanning two-dimensional code;
s6: and obtaining a decoding character string.
2. The robust two-dimensional code DataMatrix decoding method according to claim 1, wherein said S1: the image preprocessing comprises the following specific steps:
converting the three-channel color picture into a gray scale image by adopting a set proportion;
dividing the gray scale image into a plurality of small intervals, and carrying out binarization in each interval to obtain a binary image W _ IMG;
counting white pixel points at the edge of the binary image W _ IMG, judging whether the pixel points are white codes under black or white codes under white, and if the pixel points are the white codes under black, reversing the color;
then carrying out global scanning on the binary image W _ IMG to connect white pixel points or remove the white pixel points;
and outputting the preprocessed image.
3. The robust two-dimensional code DataMatrix decoding method according to claim 2, wherein said S3: the two-dimension code accurate positioning method comprises the following specific steps:
starting from four corners of the two-dimensional code image, combining every two adjacent two images in 8 directions, searching 8 points meeting the set requirement in the set area, determining 4 intersection points P4 by using four line segments of the 8 points, and determining four line segments L4 by using P4.
4. The robust two-dimensional code DataMatrix decoding method of claim 3, wherein said setting requirement comprises:
the minimum value of the distances between the point and the four corners of the set area is less than a set value;
the minimum distance between the point and the image edge is less than a set value;
the density of white pixels near a point is higher than a set value.
5. The robust two-dimensional code DataMatrix decoding method of claim 3, wherein said S4: the perspective or affine transformation comprises the following specific steps:
counting an included angle theta of the line segments of the opposite side by four line segments L4;
calculating the average length M _ L of each line segment of the four line segments L4;
if the included angle theta of the side line section is larger than a set value, the worst point is removed from the P4, and a fourth point meeting the parallelogram is generated according to the position relation of the remaining three points to obtain a new P4;
generating a new four-point N _ P4 according to the average length M _ L;
the W _ IMG is image transformed using a perspective transformation from P4 to N _ P4.
6. The robust two-dimensional code DataMatrix decoding method of claim 5, wherein said S5: the scanning comprises the following specific steps:
and performing scanning circulation operation by adopting a conventional grid dividing mode, outputting a character string if the operation is successful, positioning the position of the two-dimensional code virtual edge code element if the operation is failed, generating a new scanning grid by utilizing the position, enabling the centers of the grids to be the centers of the virtual edge code elements, performing scanning circulation operation, and outputting the character string if the operation is successful.
7. The robust two-dimensional code DataMatrix decoding method of claim 6, wherein said scan loop operation comprises the method of:
giving a plurality of groups: parameter 1: area _ thres of white area to area of grid within single grid, parameter 2: size _ thres of single grid relative W _ IMG;
with the two parameters different, a different grid map D _ IMG is scanned out and decoded.
8. A robust two-dimensional code DataMatrix decoding system is used for realizing the robust two-dimensional code DataMatrix decoding method of any one of claims 1 to 7, and is characterized by comprising an image preprocessing unit, an image denoising unit, a two-dimensional code accurate positioning unit, a perspective or affine transformation unit, a scanning unit and a decoding character string output unit;
the image preprocessing unit is used for acquiring an image and converting the acquired image into a binary image;
the image denoising unit is used for denoising the obtained binary image;
the two-dimension code accurate positioning unit is used for positioning the accurate positions of four angle vertexes of the two-dimension code;
the perspective or affine transformation unit is used for correcting the four vertexes obtained by positioning;
the scanning unit is used for dividing grid code scanning two-dimensional codes;
and the decoding character string output unit is used for outputting code scanning to obtain a decoding character string.
9. The robust two-dimensional code DataMatrix decoding system according to claim 8, wherein said image preprocessing unit, when performing image preprocessing:
converting the three-channel color picture into a gray scale image by adopting a set proportion;
dividing the gray scale image into a plurality of small intervals, and carrying out binarization in each interval to obtain a binary image W _ IMG;
counting white pixel points at the edge of the binary image W _ IMG, judging whether the pixel points are white codes under black or white codes under white, and if the pixel points are the white codes under black, reversing the color;
then carrying out global scanning on the binary image W _ IMG to connect white pixel points or remove the white pixel points;
and outputting the preprocessed image.
10. The robust two-dimensional code DataMatrix decoding system according to claim 9, wherein the two-dimensional code accurate positioning unit searches 8 points meeting the setting requirement in the setting area from four corners of the two-dimensional code image, two adjacent two-dimensional codes are combined to form 8 directions, and determines 4 intersection points P4 and P4 to form four line segments L4 from four line segments of the 8 points;
the perspective or affine transformation unit calculates an included angle theta between the line segments of the opposite sides by four line segments L4, calculates an average length M _ L of each line segment of four line segments L4, if the included angle theta between the line segments of the opposite sides is larger than a set value, eliminates the worst point in P4, generates a fourth point meeting the parallelogram by the position relation of the remaining three points to obtain a new P4, generates a new four point N _ P4 according to the average length M _ L, and performs image transformation on W _ IMG by adopting perspective transformation from P4 to N _ P4;
the scanning unit performs scanning circulation operation by adopting a conventional grid dividing mode, outputs character strings if the scanning unit succeeds, positions the positions of the two-dimensional code virtual edge code elements if the scanning unit fails, generates new scanning grids by utilizing the positions, enables the centers of the grids to be the centers of the virtual edge code elements, performs scanning circulation operation, and outputs the character strings if the scanning unit succeeds.
CN202110887858.4A 2021-08-03 2021-08-03 Robust two-dimensional code DataMatrix decoding method and system Pending CN113591506A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110887858.4A CN113591506A (en) 2021-08-03 2021-08-03 Robust two-dimensional code DataMatrix decoding method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110887858.4A CN113591506A (en) 2021-08-03 2021-08-03 Robust two-dimensional code DataMatrix decoding method and system

Publications (1)

Publication Number Publication Date
CN113591506A true CN113591506A (en) 2021-11-02

Family

ID=78254603

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110887858.4A Pending CN113591506A (en) 2021-08-03 2021-08-03 Robust two-dimensional code DataMatrix decoding method and system

Country Status (1)

Country Link
CN (1) CN113591506A (en)

Similar Documents

Publication Publication Date Title
US9135489B2 (en) System for decoding two dimensional code and method thereof
US10095903B2 (en) Block decoding method and system for two-dimensional code
US7780084B2 (en) 2-D barcode recognition
US7606439B2 (en) Method for extracting raw data from an image resulting from a camera shot
KR100828539B1 (en) Detection method of two dimensional code, detection device thereof, and storage medium having detection program storaged therein
US5742041A (en) Method and apparatus for locating and decoding machine-readable symbols, including data matrix symbols
EP3309703A1 (en) Method and system for decoding qr code based on weighted average grey method
US6758399B1 (en) Distortion correction method in optical code reading
US9177188B2 (en) Method and system for detecting detection patterns of QR code
JP2007213359A (en) Two-dimensional code detection system and two-dimensional code detection program
JPH0612515A (en) Method and apparatus for decoding two-dimensional bar code using ccd/cmd camera
JP2016139026A (en) Image formation device
CN105975894B (en) A kind of one-dimension code recognizer based on auto-adaptable image edge detection and mapping model
CN110647795A (en) Form recognition method
CN108256375B (en) One-dimensional bar code scanning method
CN115170669A (en) Identification and positioning method and system based on edge feature point set registration and storage medium
CN113392669B (en) Image information detection method, detection device and storage medium
CN113591506A (en) Robust two-dimensional code DataMatrix decoding method and system
JP4335229B2 (en) QR code recognition device, QR code recognition device control method, QR code recognition device control program, and computer-readable recording medium recording the same
CN111336949A (en) Spatial coding structured light three-dimensional scanning method and system
CN112800798B (en) Aztec code positioning method
CN101908144B (en) Bar code image correction method and correction point acquisition method
CN110263597B (en) Quick and accurate QR (quick response) code correction method and system
Liu et al. Detection algorithm of 2D barcode under complex background
CN109784121B (en) Dot-peep DPM code identification method and device

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