CN116451721B - Method and device for decoding, electronic equipment and storage medium - Google Patents

Method and device for decoding, electronic equipment and storage medium Download PDF

Info

Publication number
CN116451721B
CN116451721B CN202310731680.3A CN202310731680A CN116451721B CN 116451721 B CN116451721 B CN 116451721B CN 202310731680 A CN202310731680 A CN 202310731680A CN 116451721 B CN116451721 B CN 116451721B
Authority
CN
China
Prior art keywords
code
identified
boundary
boundary line
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310731680.3A
Other languages
Chinese (zh)
Other versions
CN116451721A (en
Inventor
黄金煌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Unigroup Tsingteng Microsystems Co Ltd
Original Assignee
Beijing Unigroup Tsingteng Microsystems Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Unigroup Tsingteng Microsystems Co Ltd filed Critical Beijing Unigroup Tsingteng Microsystems Co Ltd
Priority to CN202310731680.3A priority Critical patent/CN116451721B/en
Publication of CN116451721A publication Critical patent/CN116451721A/en
Application granted granted Critical
Publication of CN116451721B publication Critical patent/CN116451721B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/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
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/06009Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
    • G06K19/06037Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Health & Medical Sciences (AREA)
  • Electromagnetism (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Multimedia (AREA)
  • Image Analysis (AREA)

Abstract

The application relates to the technical field of two-dimensional bar code recognition, and discloses a decoding method, which comprises the following steps: the direction of the real edge of the DM code to be identified and the module size of the DM code to be identified in the direction of the real edge are obtained. And obtaining the boundary line clusters of the DM code to be identified according to the direction of the real edge and the size of the module. The border cluster includes all border lines of the DM code to be identified. And constructing a sampling grid based on the boundary clusters, and decoding the DM code to be identified according to the sampling grid. In this way, even in the case that the locator of the DM code to be recognized, the auxiliary railway line is contaminated and damaged, all boundary lines of the DM code to be recognized can be obtained through the direction of the real side and the module size. The sampling grid is constructed through the boundary line, so that the DM code to be identified can be decoded, and the identification capability of the DM code is improved. The application also discloses a device for decoding, electronic equipment and a storage medium.

Description

Method and device for decoding, electronic equipment and storage medium
Technical Field
The present application relates to the field of two-dimensional barcode recognition technologies, and for example, to a method and apparatus for decoding, an electronic device, and a storage medium.
Background
DM (Data matrix) codes are one of the most commonly used two-dimensional bar codes in the field of bar code recognition. Problems such as partial reflection, offset, shielding, printing defects and the like are frequently encountered in a real life scene, so that decoding of a DM code with the problems is easy to cause. In order to decode the DM code, the related art generally decodes the DM code with the locator and the auxiliary railway line intact, so as to complete the auxiliary railway line location and DM code version estimation. And decoding is difficult in the case of complex severe environments such as incomplete locators and complete fouling of auxiliary railway lines. Making the DM code less recognizable.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the application and thus may include information that does not form the prior art that is already known to those of ordinary skill in the art.
Disclosure of Invention
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview, and is intended to neither identify key/critical elements nor delineate the scope of such embodiments, but is intended as a prelude to the more detailed description that follows.
The embodiment of the disclosure provides a method and a device for decoding, electronic equipment and a storage medium, so that the identification capability of a DM code in a complex severe environment can be improved.
In some embodiments, a method for decoding, comprises: the direction of the real edge of the DM code to be identified and the module size of the DM code to be identified in the direction of the real edge are obtained. And acquiring boundary clusters of the DM code to be identified according to the direction of the real edge and the size of the module, wherein the boundary clusters comprise all boundary lines of the DM code to be identified. And constructing a sampling grid based on the boundary clusters, and decoding the DM code to be identified according to the sampling grid.
In some embodiments, obtaining the direction of the real edge of the DM code to be identified includes: and positioning the DM code to be identified by using a preset locator to obtain the direction of the real edge of the DM code to be identified.
In some embodiments, obtaining the module size of the DM code to be identified in the direction of the real edge includes: and determining a corresponding region of the preset locator in the DM code to be identified as a target region. And obtaining boundary points of the DM code to be identified in the target area. Projecting the boundary points on the edge of a preset locator in the same direction as the real edge according to the projection direction to obtain a plurality of projection data; the projection direction is the direction perpendicular to the real side of the DM code. The projection data is the number of boundary points projected on the edge. And acquiring the size of the module according to the projection data.
In some embodiments, obtaining the boundary point of the DM code to be identified in the target area includes: and acquiring the gray value of each pixel point in the target area, and determining the pixel point with the gray value exceeding a preset value as a boundary point.
In some embodiments, according to the projection data acquisition module size, comprising: and acquiring peak-to-peak distances among the projection data, and determining the minimum peak-to-peak distance as the module size.
In some embodiments, obtaining the boundary cluster of the DM code to be identified according to the direction of the real edge and the module size includes: the edge of the preset locator in the same direction as the real edge is determined as a first boundary line, and the first boundary line is determined as a searched boundary line. Moving the first boundary line by a preset pixel along the direction perpendicular to the real edge to obtain a second boundary line; the preset pixel is the module size. Performing a preset operation on the second boundary line; the preset operation includes: determining a region within a left preset threshold and a right preset threshold of the second boundary line as a search range; the preset threshold is the module size of a preset multiple; searching boundary points in the same direction as the direction of the real edge in the searching range; fitting the searched boundary points to obtain a third boundary line, and determining the second boundary line as a searched boundary line; the third boundary line is determined as the second boundary line. In the case where the total number of searched boundary lines is greater than the preset number, the execution of the preset operation is stopped, and the first boundary line and all the second boundary lines are determined as boundary clusters.
In some embodiments, decoding the DM code to be identified according to the sampling grid includes: and acquiring the version information range of the DM code to be identified. The version information range includes a plurality of version information. And decoding the different versions of the DM code to be identified by utilizing the sampling grid according to the sequence from low version information to high version information until the decoding is successful.
In some embodiments, the apparatus for decoding includes a processor and a memory storing program instructions, the processor being configured to perform the method for decoding described above when the program instructions are executed.
In some embodiments, the electronic device comprises the above-described means for decoding.
In some embodiments, the storage medium stores program instructions that, when executed, perform the method for decoding described above.
The method and device for decoding, the electronic device and the storage medium provided by the embodiment of the disclosure can realize the following technical effects: the direction of the real side of the DM code to be identified and the module size of the DM code to be identified in the direction of the real side are obtained. And obtaining the boundary line clusters of the DM code to be identified according to the direction of the real edge and the size of the module. The border cluster includes all border lines of the DM code to be identified. And constructing a sampling grid based on the boundary clusters, and decoding the DM code to be identified according to the sampling grid. In this way, even in the case that the locator of the DM code to be recognized, the auxiliary railway line is contaminated and damaged, all boundary lines of the DM code to be recognized can be obtained through the direction of the real side and the module size. The sampling grid is constructed through all boundary lines, so that the DM code to be identified can be decoded, and the identification capability of the DM code is improved.
The foregoing general description and the following description are exemplary and explanatory only and are not restrictive of the application.
Drawings
One or more embodiments are illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements, and in which like reference numerals refer to similar elements, and in which:
FIG. 1 is a schematic diagram of a method for decoding provided by an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of an application of an L-shaped locator of a DM code to be identified;
FIG. 3 is a schematic view of a boundary point projection of a DM code to be identified;
FIG. 4 is a schematic diagram of the construction of a sampling grid;
FIG. 5 is a schematic diagram of another method for decoding provided by an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Reference numerals:
1: a vertical side; 2: a horizontal edge; 3: a vertical solid edge; 4: a horizontal solid edge; 5: the length of the horizontal edge; 6: the length of the vertical edge; 7: an included angle between the horizontal side and the vertical side; 8: defect length of vertical side; 9: defect length of horizontal edge; 10: an auxiliary railway line; 11: horizontal border clusters; 12: a vertical border cluster; 13: the columns are expanded.
Detailed Description
So that the manner in which the features and techniques of the disclosed embodiments can be understood in more detail, a more particular description of the embodiments of the disclosure, briefly summarized below, may be had by reference to the appended drawings, which are not intended to be limiting of the embodiments of the disclosure. In the following description of the technology, for purposes of explanation, numerous details are set forth in order to provide a thorough understanding of the disclosed embodiments. However, one or more embodiments may still be practiced without these details. In other instances, well-known structures and devices may be shown simplified in order to simplify the drawing.
The terms first, second and the like in the description and in the claims of the embodiments of the disclosure and in the above-described figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe embodiments of the present disclosure. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion.
The term "plurality" means two or more, unless otherwise indicated.
In the embodiment of the present disclosure, the character "/" indicates that the front and rear objects are an or relationship. For example, A/B represents: a or B.
The term "and/or" is an associative relationship that describes an object, meaning that there may be three relationships. For example, a and/or B, represent: a or B, or, A and B.
The term "corresponding" may refer to an association or binding relationship, and the correspondence between a and B refers to an association or binding relationship between a and B.
As shown in conjunction with fig. 1, an embodiment of the present disclosure provides a method for decoding, the method comprising:
in step S101, the electronic device obtains the direction of the real side of the DM code to be identified and the module size of the DM code to be identified in the direction of the real side.
Step S102, the electronic equipment acquires the boundary line clusters of the DM code to be identified according to the direction of the real edge and the size of the module. Wherein the boundary clusters comprise all boundary lines of the DM code to be identified.
Step S103, the electronic device constructs a sampling grid based on the boundary clusters.
Step S104, the electronic equipment decodes the DM code to be identified according to the sampling grid.
By adopting the method for decoding provided by the embodiment of the disclosure, the direction of the real side of the DM code to be identified and the module size of the DM code to be identified in the direction of the real side are obtained. And obtaining the boundary line clusters of the DM code to be identified according to the direction of the real edge and the size of the module. The border cluster includes all border lines of the DM code to be identified. And constructing a sampling grid based on the boundary clusters, and decoding the DM code to be identified according to the sampling grid. In this way, even in the case that the locator of the DM code to be recognized, the auxiliary railway line is contaminated and damaged, all boundary lines of the DM code to be recognized can be obtained through the direction of the real side and the module size. The sampling grid is constructed through all boundary lines, so that the DM code to be identified can be decoded, and the identification capability of the DM code is improved.
Further, the electronic device obtaining the direction of the real edge of the DM code to be identified includes: and the electronic equipment positions the DM code to be identified by using a preset locator to obtain the direction of the real edge of the DM code to be identified.
In some embodiments, the predetermined locator is an L-shaped locator of the DM code to be identified. The sides of the L-shaped locator include a horizontal side and a vertical side.
In some embodiments, the sides of the L-shaped locator are straight lines. The electronic equipment judges whether the edge of the L-shaped locator is a straight line or not through a preset algorithm. The preset algorithm is a least square method of a straight line.
Referring to fig. 2, fig. 2 is a schematic diagram illustrating an application of an L-type locator for a DM code to be identified according to an embodiment of the present disclosure. The L-shaped locator in fig. 2 includes a vertical side 1 and a horizontal side 2. The real edges of the DM code to be identified include a vertical real edge 3 and a horizontal real edge 4. The vertical edge 1 of the L-shaped locator is attached to the vertical real edge 3 of the DM code to be identified, and the horizontal edge 2 of the L-shaped locator is attached to the horizontal real edge 4 of the DM code to be identified. The length 5 of the horizontal side and the length 6 of the vertical side of the L-shaped locator are both greater than a preset length threshold. The included angle 7 between the horizontal and vertical sides of the L-shaped locator is greater than a preset angle threshold. Wherein the length threshold is 15 pixels and the angle threshold is 30 °. The defect length 8 of the horizontal side of the L-shaped locator is not more than 1/2 of the length of the horizontal side. The defect length 9 of the vertical side of the L-shaped locator is no more than 1/2 of the length of the vertical side. The lowest recognition accuracy supported by the method for decoding in the embodiments of the present disclosure is the shortest length of the edge of the L-shaped locator. For example, the minimum version information of the DM code to be identified is 10×10 modules, i.e., each column/row in the DM code to be identified includes 10 modules, and the minimum identification accuracy supported is 3 pixels per module, and the shortest length is 30 pixels.
Further, the electronic device obtains a module size of the DM code to be identified in a direction of the real edge, including: and the electronic equipment determines the corresponding area of the preset locator in the DM code to be identified as a target area. And obtaining boundary points of the DM code to be identified in the target area. Projecting the boundary points on the edge of a preset locator in the same direction as the real edge according to the projection direction to obtain a plurality of projection data; the projection direction is the direction perpendicular to the real side of the DM code. The projection data is the number of boundary points projected on the edge of the locator. And acquiring the size of the module according to the projection data. Wherein, the preset locator is an L-shaped locator.
In some embodiments, the real edges of the DM code to be identified include vertical real edges and horizontal real edges. The direction of the real side of the DM code to be recognized includes the direction of the vertical real side and the direction of the horizontal real side. In some embodiments, the direction of the vertical solid side is a vertical boundary direction and the direction of the horizontal solid side is a horizontal boundary direction.
Further, the preset locators are L-shaped locators, and the edges of the L-shaped locators comprise vertical edges and horizontal edges. The electronic device determines a corresponding region of a preset locator in the DM code to be identified as a target region, and comprises: the electronic device obtains a length of a vertical side and a length of a horizontal side of the L-shaped locator. The area between the length of the vertical side and the length of the horizontal side is determined as the target area.
In some embodiments, the module sizes include a horizontal direction module size and a vertical direction module size. The module size of the DM code to be identified in the direction of the horizontal real side is the module size in the horizontal direction, and the module size of the DM code to be identified in the direction of the vertical real side is the module size in the vertical direction.
Optionally, in the case that the acquired module size is the module size in the horizontal direction, the direction of the real side of the DM code to be identified is the direction of the horizontal real side, and the projection direction is the direction perpendicular to the horizontal real side of the DM code, that is, the vertical side direction of the L-shaped locator.
In some embodiments, the electronic device obtains the horizontal direction module size of the DM code to be identified by: and the electronic equipment determines the corresponding area of the L-shaped locator in the DM code to be identified as a target area. And obtaining boundary points of the DM code to be identified in the target area. And projecting the boundary points on the horizontal edge of the L-shaped locator according to the projection direction to obtain a plurality of projection data. The projection direction is the vertical side direction of the L-shaped locator, and the projection data is the number of boundary points projected on the horizontal side of the L-shaped locator. And acquiring the size of the horizontal module according to the projection data.
Optionally, in the case that the acquired module size is the vertical direction module size, the direction of the real side of the DM code to be identified is the direction of the vertical real side, and the projection direction is the direction perpendicular to the vertical real side of the DM code, that is, the horizontal side direction of the L-shaped locator.
In some embodiments, the electronic device obtains the vertical direction module size of the DM code to be identified by: and the electronic equipment determines the corresponding area of the L-shaped locator in the DM code to be identified as a target area. And obtaining boundary points of the DM code to be identified in the target area. And projecting the boundary points on the vertical edge of the L-shaped locator according to the projection direction to obtain a plurality of projection data. The projection direction is the horizontal side direction of the L-shaped locator, and the projection data is the number of boundary points projected on the vertical side of the L-shaped locator. And acquiring the size of the vertical module according to the projection data.
Further, the electronic device obtaining the boundary point of the DM code to be identified in the target area includes: the electronic equipment acquires the gray value of each pixel point in the target area, and determines the pixel point with the gray value exceeding a preset value as a boundary point.
Further, the electronic device obtains the size of the module according to the projection data, including: the electronic equipment acquires the peak-to-peak distance between the projection data, and the minimum peak-to-peak distance is determined as the module size.
Further, the electronic device obtaining a peak-to-peak distance between each projection data includes: the electronic device obtains a signal waveform diagram corresponding to each projection data, and determines the distance between the abscissas of each projection data in the signal waveform diagram as the peak-to-peak distance.
In some embodiments, the projection data includes 3 sets of data, namely "8", "2", and "4". Projection data "8" is used to characterize the number of boundary points projected on the edge of the L-shaped locator as 8. The abscissa of the projection data "8" in the signal waveform is 0, the abscissa of the projection data "2" in the signal waveform is "6", and the abscissa of the projection data "4" in the signal waveform is 12. The interval between the abscissa of the projection data "8" in the signal waveform diagram and the abscissa of the projection data "2" in the signal waveform diagram is 6, i.e., the peak-to-peak interval is 6.
In some embodiments, the peak-to-peak spacing is an integer multiple of the module size. Taking the minimum peak-to-peak spacing as the module size. The remaining peak-to-peak spacing is used to verify the correctness of the module size. The correctness of the module size is verified by: and obtaining the multiple relation between the peak-to-peak distance and the size of the module, and determining that verification is passed under the condition that the multiple relation is an integer.
In some embodiments, before the sampling grid is constructed, a boundary cluster of DM codes to be identified needs to be determined. And determining the boundary clusters requires first determining the direction of the real edges and the module size. For example: in the case of determining the horizontal boundary clusters of the DM code to be identified, the direction of the horizontal real side and the horizontal direction module size need to be determined first. And when the size of the horizontal direction module is obtained, determining a target area from the DM code to be identified through the L-shaped locator. A plurality of boundary points are then determined from the target region. And projecting the boundary points on the horizontal edge of the L-shaped locator according to the projection direction to obtain a plurality of projection data. The projection direction is the vertical side direction of the L-shaped locator, and the projection data is the number of boundary points projected on the horizontal side of the L-shaped locator. And determining the minimum peak-to-peak distance as the module size in the horizontal direction by acquiring the peak-to-peak distance between the projection data. Referring to fig. 3, fig. 3 is a schematic view illustrating a boundary point projection of a DM code to be identified according to an embodiment of the present disclosure. Before the sampling grid is constructed, the boundary clusters of the DM code to be identified need to be determined. And determining the boundary clusters requires first determining the direction of the real edges and the module size. In fig. 3, in the case of acquiring the size of the horizontal direction module, the target area is determined from the DM code to be identified by the L-shaped locator. A plurality of boundary points are then determined from the target region, and white triangles in fig. 3 are used to characterize the determined boundary points. And projecting the boundary points on the horizontal edge of the L-shaped locator according to the vertical edge direction of the L-shaped locator to obtain a plurality of projection data. And determining the minimum peak-to-peak distance as the module size in the horizontal direction by acquiring the peak-to-peak distance between the projection data.
Further, the electronic device obtains the boundary line cluster of the DM code to be identified according to the direction of the real edge and the module size, including: the electronic device determines an edge of a preset locator in the same direction as the real edge as a first boundary line, and determines the first boundary line as a searched boundary line. The first boundary line is moved by a preset pixel along the direction perpendicular to the real edge, and a second boundary line is obtained. The preset pixel is the module size. And performing a preset operation on the second boundary line. The preset operation comprises the following steps: determining a region within a left preset threshold and a right preset threshold of the second boundary line as a search range; the preset threshold is the module size of a preset multiple; searching boundary points in the same direction as the direction of the real edge in the searching range; and fitting the searched boundary points to obtain a third boundary line, and determining the second boundary line as a searched boundary line. The third boundary line is determined as the second boundary line. In the case where the total number of searched boundary lines is greater than the preset number, the execution of the preset operation is stopped, and the first boundary line and all the second boundary lines are determined as boundary clusters.
Optionally, the search sequence of the boundary clusters is not sequential, and the clusters can be searched in a segmented manner. Thus, larger image perspective distortion can be supported, and the decoding success rate of the DM code to be identified can be improved.
Further, the electronic device fits the searched boundary points to obtain a third boundary line, including: the electronic equipment fits the boundary points through a preset algorithm to obtain a linear equation, and the distance between each boundary point and the linear equation is calculated. And if the distance exceeding the preset number is within the preset range, determining that the fitting is successful, and determining the linear equation as a third boundary line. Wherein the preset algorithm is a least square method.
Further, the boundary clusters include vertical boundary clusters and horizontal boundary clusters.
Optionally, under the condition that the electronic device acquires the vertical boundary line cluster, the direction of the real side is the direction of the vertical real side, and the module size is the module size in the horizontal direction. The edge of the preset locator which is in the same direction as the vertical real edge is a vertical edge. The direction perpendicular to the vertical real edge is the horizontal boundary direction. The boundary point which is in the same direction as the vertical real edge is a vertical boundary point.
In some embodiments, the module size is m, then the preset pixel is m pixels, the preset threshold is 0.5m, and the preset number of bars is 28. In the case where the boundary cluster is a vertical boundary cluster, the electronic device determines a vertical edge of a preset locator as a first boundary line and determines the first boundary line as a searched boundary line. The first boundary line is shifted by m pixels in the horizontal boundary direction, and a second boundary line is obtained. And performing a preset operation on the second boundary line. The preset operation comprises the following steps: an area within 0.5m around the second boundary line is determined as a search range. And searching the vertical boundary points in the searching range, fitting the searched vertical boundary points to obtain a third boundary line, and determining the second boundary line as a searched boundary line. The third boundary line is determined as the second boundary line, and the preset operation is repeatedly performed. In the case where the total number of searched boundary lines is greater than 28, the execution of the preset operation is stopped. And determining the first boundary line and all the second boundary lines as vertical boundary clusters.
Optionally, under the condition that the electronic device acquires the horizontal boundary line cluster, the direction of the real side is the direction of the horizontal real side, and the module size is the module size in the vertical direction. The side of the preset locator which is in the same direction with the horizontal real side is the horizontal side. The direction perpendicular to the horizontal solid edge is the vertical boundary direction. The boundary point in the same direction as the horizontal real edge is the horizontal boundary point.
In some embodiments, the module size is m, then the preset pixel is m pixels, the preset threshold is 0.5m, and the preset number of bars is 28. In the case that the boundary cluster is a horizontal boundary cluster, the electronic device determines a horizontal edge of a preset locator as a first boundary line and determines the first boundary line as a searched boundary line. The first boundary line is moved by m pixels in the vertical boundary direction, and a second boundary line is obtained. And performing a preset operation on the second boundary line. The preset operation comprises the following steps: an area within 0.5m around the second boundary line is determined as a search range. And searching the horizontal boundary points in the searching range, fitting the searched horizontal boundary points to obtain a third boundary line, and determining the second boundary line as a searched boundary line. The third boundary line is determined as the second boundary line, and the preset operation is repeatedly performed. In the case where the total number of searched boundary lines is greater than 28, the execution of the preset operation is stopped. And determining the first boundary line and all the second boundary lines as horizontal boundary clusters.
In some embodiments, the DM code to be identified includes a vertical solid side, a horizontal solid side, and an auxiliary railway line. The auxiliary railway line is composed of modules with black and white phases. The sampling grid on the DM code to be identified is made up of boundary clusters, including horizontal boundary clusters and vertical boundary clusters. Wherein the horizontal boundary line cluster includes a plurality of horizontal boundary lines and the vertical boundary line cluster includes a plurality of vertical boundary lines. Optionally, an extension column is also included in the sampling grid. The extension column is used to characterize the highest version information of the DM code to be identified. Under the condition that the number of the modules of the DM code to be identified is odd, extension columns are added into the horizontal boundary line clusters and the vertical boundary line clusters in the sampling grid, so that the number of the modules of the DM code to be identified is ensured to be even. Referring to fig. 4, fig. 4 is a schematic diagram of the construction of a sampling grid according to an embodiment of the present disclosure. In fig. 4, the DM code to be identified includes a vertical solid side, a horizontal solid side, and an auxiliary railway line 10. The auxiliary railway line 10 is composed of modules with alternating black and white. The sampling grid on the DM code to be identified is made up of boundary clusters, including horizontal boundary clusters 11 and vertical boundary clusters 12. Wherein the horizontal border cluster 11 comprises a plurality of horizontal border lines and the vertical border cluster 11 comprises a plurality of vertical border lines. The extension column 13 is used to characterize the highest version information of the DM code to be identified. In the case that the number of modules of the DM code to be identified is odd, extension columns 13 are added to both the horizontal boundary clusters and the vertical boundary clusters in the sampling grid, so as to ensure that the number of modules of the DM code to be identified is even. This ensures the validity of the version information of the DM code to be recognized.
In some embodiments, the boundary clusters include horizontal boundary clusters and vertical boundary clusters. Constructing a sampling grid based on boundary clusters, comprising: the grid formed by dividing the horizontal boundary clusters and the vertical boundary clusters is determined as a sampling grid.
Further, the electronic device decodes the DM code to be identified according to the sampling grid, including: the electronic equipment acquires the version information range of the DM code to be identified; the version information range includes a plurality of version information. And decoding the different versions of the DM code to be identified by utilizing the sampling grid according to the sequence from low version information to high version information until the decoding is successful.
In some embodiments, the version information of the DM code to be identified includes a plurality of 10×10 modules, 12×12 modules, 14×14 modules, 16×16 modules, 18×18 modules, or 20×20 modules, etc. Wherein, in case that the version information of the DM code to be recognized is 10×10 modules, it is determined that the number of modules on the boundary line of the DM code to be recognized is 10, and the number of horizontal boundary lines and the number of vertical boundary lines are 11. The number of modules in the version information of the DM code to be identified is even, and the lowest version information of the DM code to be identified is 10 multiplied by 10.
Further, the electronic device obtains a version information range of the DM code to be identified, including: the electronic equipment acquires the highest version information of the DM code to be identified, and determines the preset lowest version information, the highest version information and the version information from the preset lowest version information to the highest version information as the version information range.
Further, the electronic device obtains the highest version information of the DM code to be identified, including: the electronic equipment determines the number of modules according to the number of boundary lines in the boundary line cluster; when the number of the modules is an even number which is more than or equal to 10, the number of the modules is determined as the number of the target modules, and the version information corresponding to the number of the target modules is determined as the highest version information of the DM code to be identified. And/or when the number of the modules is an odd number greater than 10, determining an even number which is greater than the number of the modules and is closest to the number of the modules as the number of the target modules, and determining version information corresponding to the number of the target modules as the highest version information of the DM code to be identified.
In some embodiments, version information corresponding to the number of target modules is obtained by: and matching version information corresponding to the number of the target modules from a preset database. The preset database stores the corresponding relation between the number of the target modules and version information.
In some embodiments, where the number of modules is 16, 16 is an even number greater than 10. And determining 16 as the number of target modules, matching version information corresponding to the number 16 of target modules with '16×16 modules' from a preset database, and determining the version information '16×16 modules' as the highest version information of the DM code to be identified. When the number of modules is 27, 27 is an odd number greater than 10. And determining an even number 28 which is larger than the number of the modules and is closest to the number of the modules as the number of the target modules, and matching version information corresponding to the number of the target modules 28 as 28 multiplied by 28 modules from a preset database, wherein the version information of the 28 multiplied by 28 modules is determined as the highest version information of the DM code to be identified.
As shown in conjunction with fig. 5, an embodiment of the present disclosure provides a method for decoding, the method comprising:
step S501, the electronic device obtains the direction of the horizontal real side of the DM code to be identified and the module size of the DM code to be identified in the direction of the horizontal real side; and acquiring the direction of the vertical real edge of the DM code to be identified and the module size of the DM code to be identified in the direction of the vertical real edge.
Step S502, the electronic equipment acquires a horizontal boundary line cluster of a DM code to be identified according to the direction of the horizontal real edge and the module size of the horizontal direction; and acquiring a vertical boundary line cluster of the DM code to be identified according to the direction of the vertical real side and the size of the vertical direction module.
In step S503, the electronic device constructs a sampling grid based on the horizontal boundary clusters and the vertical boundary clusters.
Step S504, the electronic device decodes the DM code to be identified according to the sampling grid.
By adopting the method for decoding provided by the embodiment of the disclosure, even under the condition that the locator and the auxiliary railway line of the DM code to be identified are polluted and damaged, all horizontal boundary lines and vertical boundary lines of the DM code to be identified can be obtained through the direction of the real side and the module size. The DM code to be identified can be decoded by constructing sampling grids through all horizontal boundary lines and vertical boundary lines, so that the identification capability of the DM code in a complex severe environment is improved.
In some embodiments, the module size of the DM code to be identified in the direction of the horizontal real side is a horizontal direction module size, and the module size of the DM code to be identified in the direction of the vertical real side is a vertical direction module size.
As shown in connection with fig. 6, an embodiment of the present disclosure provides an electronic device 600 that includes a processor (processor) 604 and a memory (memory) 601. Optionally, the electronic device may also include a communication interface (Communication Interface) 602 and a bus 603. The processor 604, the communication interface 602, and the memory 601 may communicate with each other via the bus 603. The communication interface 602 may be used for information transfer. The processor 604 may invoke logic instructions in the memory 601 to perform the method for decoding of the above-described embodiments.
By adopting the electronic equipment provided by the embodiment of the disclosure, the direction of the real side of the DM code to be identified and the module size of the DM code to be identified in the direction of the real side are obtained. And obtaining the boundary line clusters of the DM code to be identified according to the direction of the real edge and the size of the module. The border cluster includes all border lines of the DM code to be identified. And constructing a sampling grid based on the boundary clusters, and decoding the DM code to be identified according to the sampling grid. In this way, even in the case that the locator of the DM code to be recognized, the auxiliary railway line is contaminated and damaged, all boundary lines of the DM code to be recognized can be obtained through the direction of the real side and the module size. The DM code to be identified can be decoded by utilizing the sampling grid constructed based on the boundary wire clusters, so that the identification capability of the DM code in a complex severe environment is improved.
Further, the logic instructions in the memory 601 described above may be implemented in the form of software functional units and may be stored in a computer readable storage medium when sold or used as a stand alone product.
The memory 601 serves as a computer readable storage medium, and may be used to store a software program, a computer executable program, and program instructions/modules corresponding to the methods in the embodiments of the present disclosure. The processor 604 executes the functional applications and data processing by running the program instructions/modules stored in the memory 601, i.e. implements the method for decoding in the above-described embodiments.
The memory 601 may include a storage program area and a storage data area, wherein the storage program area may store an application program required to operate at least one function; the storage data area may store data created according to the use of the terminal device, etc. In addition, the memory 601 may include a high-speed random access memory, and may also include a nonvolatile memory.
Optionally, the electronic device is a code scanning device, a computer or a server.
The embodiment of the disclosure provides a storage medium storing program instructions which, when executed, perform the above-described method for decoding.
The disclosed embodiments provide a computer program product comprising a computer program stored on a computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, cause the computer to perform the above-described method for decoding.
The computer readable storage medium may be a transitory computer readable storage medium or a non-transitory computer readable storage medium.
Embodiments of the present disclosure may be embodied in a software product stored on a storage medium, including one or more instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of a method according to embodiments of the present disclosure. And the aforementioned storage medium may be a non-transitory storage medium including: a plurality of media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or a transitory storage medium.
The above description and the drawings illustrate embodiments of the disclosure sufficiently to enable those skilled in the art to practice them. Other embodiments may involve structural, logical, electrical, process, and other changes. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the sequence of operations may vary. Portions and features of some embodiments may be included in, or substituted for, those of others. Moreover, the terminology used in the present application is for the purpose of describing embodiments only and is not intended to limit the claims. As used in the description of the embodiments and the claims, the singular forms "a," "an," and "the" (the) are intended to include the plural forms as well, unless the context clearly indicates otherwise. Similarly, the term "and/or" as used in this disclosure is meant to encompass any and all possible combinations of one or more of the associated listed. Furthermore, when used in the present disclosure, the terms "comprises," "comprising," and/or variations thereof, mean that the recited features, integers, steps, operations, elements, and/or components are present, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. Without further limitation, an element defined by the phrase "comprising one …" does not exclude the presence of other like elements in a process, method or apparatus comprising such elements. In this context, each embodiment may be described with emphasis on the differences from the other embodiments, and the same similar parts between the various embodiments may be referred to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method sections disclosed in the embodiments, the description of the method sections may be referred to for relevance.
Those of skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. The skilled artisan may use different methods for each particular application to achieve the described functionality, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. It will be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the apparatus and unit described above may refer to the corresponding process in the foregoing method embodiment, which is not repeated herein.
In the embodiments disclosed herein, the disclosed methods, articles of manufacture (including but not limited to devices, apparatuses, etc.) may be practiced in other ways. For example, the apparatus embodiments described above are merely illustrative, and for example, the division of the units may be merely a logical function division, and there may be additional divisions when actually implemented, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form. The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to implement the present embodiment. In addition, each functional unit in the embodiments of the present disclosure may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of methods and computer program products according to embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. In the description corresponding to the flowcharts and block diagrams in the figures, operations or steps corresponding to different blocks may also occur in different orders than that disclosed in the description, and sometimes no specific order exists between different operations or steps. For example, two consecutive operations or steps may actually be performed substantially in parallel, they may sometimes be performed in reverse order, which may be dependent on the functions involved. Each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.

Claims (8)

1. A method for decoding, comprising:
acquiring the direction of a real edge of a DM code to be identified and the module size of the DM code to be identified in the direction of the real edge;
obtaining boundary clusters of the DM code to be identified according to the direction of the real edge and the size of the module; the boundary line cluster comprises all boundary lines of the DM code to be identified;
constructing a sampling grid based on the boundary clusters;
decoding the DM code to be identified according to the sampling grid;
the method for acquiring the real edge direction of the DM code to be identified comprises the following steps: positioning the DM code to be identified by using a preset locator to obtain the direction of the real edge of the DM code to be identified;
according to the direction of the real edge and the size of the module, obtaining the boundary line cluster of the DM code to be identified comprises the following steps: determining an edge of a preset locator in the same direction as the real edge as a first boundary line, and determining the first boundary line as a searched boundary line; moving the first boundary line by a preset pixel along the direction perpendicular to the real edge to obtain a second boundary line; the preset pixels are of a module size; performing a preset operation on the second boundary line; the preset operation includes: determining a region within a left preset threshold and a right preset threshold of the second boundary line as a search range; the preset threshold is the module size of a preset multiple; searching boundary points in the same direction as the direction of the real edge in the searching range; fitting the searched boundary points to obtain a third boundary line, and determining the second boundary line as a searched boundary line; determining the third boundary line as a second boundary line;
in the case where the total number of searched boundary lines is greater than the preset number, the execution of the preset operation is stopped, and the first boundary line and all the second boundary lines are determined as boundary clusters.
2. The method of claim 1, wherein obtaining the module size of the DM code to be identified in the direction of the real edge comprises:
determining a corresponding region of a preset locator in the DM code to be identified as a target region;
acquiring boundary points of a DM code to be identified in a target area;
projecting the boundary points on the edge of a preset locator in the same direction as the real edge according to the projection direction to obtain a plurality of projection data; the projection direction is a direction perpendicular to the real edge of the DM code; the projection data is the number of boundary points projected on the edge;
and acquiring the size of the module according to the projection data.
3. The method of claim 2, wherein obtaining boundary points of the DM code to be identified in the target area comprises:
acquiring gray values of all pixel points in a target area;
and determining the pixel points with gray values exceeding the preset value as boundary points.
4. The method of claim 2, wherein, based on the projection data acquisition module size, comprising:
obtaining the peak-to-peak distance between the projection data;
the smallest peak-to-peak distance is determined as the module size.
5. The method of claim 1, wherein decoding the DM code to be identified according to the sampling grid comprises:
acquiring a version information range of a DM code to be identified; the version information range includes a plurality of version information;
and decoding the different versions of the DM code to be identified by utilizing the sampling grid according to the sequence from low version information to high version information until the decoding is successful.
6. An apparatus for decoding comprising a processor and a memory storing program instructions, wherein the processor is configured to perform the method for decoding of any of claims 1 to 5 when the program instructions are executed.
7. An electronic device comprising the apparatus for decoding as claimed in claim 6.
8. A storage medium storing program instructions which, when executed, perform the method for decoding of any one of claims 1 to 5.
CN202310731680.3A 2023-06-20 2023-06-20 Method and device for decoding, electronic equipment and storage medium Active CN116451721B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310731680.3A CN116451721B (en) 2023-06-20 2023-06-20 Method and device for decoding, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310731680.3A CN116451721B (en) 2023-06-20 2023-06-20 Method and device for decoding, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN116451721A CN116451721A (en) 2023-07-18
CN116451721B true CN116451721B (en) 2023-09-26

Family

ID=87132502

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310731680.3A Active CN116451721B (en) 2023-06-20 2023-06-20 Method and device for decoding, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116451721B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20050092335A (en) * 2004-03-15 2005-09-21 셴젠 시스칸 테크놀러지 코오퍼레이션 리미티드 Two-dimensional bar code and associated codingdecoding method
CN113313226A (en) * 2021-07-29 2021-08-27 北京紫光青藤微系统有限公司 Method and device for determining DM code version information, equipment and storage medium
CN114492706A (en) * 2022-04-15 2022-05-13 北京紫光青藤微系统有限公司 Method and device for estimating size of DM code module, decoding device and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20050092335A (en) * 2004-03-15 2005-09-21 셴젠 시스칸 테크놀러지 코오퍼레이션 리미티드 Two-dimensional bar code and associated codingdecoding method
CN113313226A (en) * 2021-07-29 2021-08-27 北京紫光青藤微系统有限公司 Method and device for determining DM code version information, equipment and storage medium
CN114492706A (en) * 2022-04-15 2022-05-13 北京紫光青藤微系统有限公司 Method and device for estimating size of DM code module, decoding device and storage medium

Also Published As

Publication number Publication date
CN116451721A (en) 2023-07-18

Similar Documents

Publication Publication Date Title
CN113673655B (en) Method and device for determining decoding direction of two-dimensional code, electronic equipment and medium
CN113313226B (en) Method and device for determining DM code version information, equipment and storage medium
US9367782B2 (en) High capacity 2D color barcode and method for decoding the same
EP0999519A1 (en) Distortion correction method in optical code reading
CN109919992B (en) Method for estimating depth in image
JP7026165B2 (en) Text recognition method and text recognition device, electronic equipment, storage medium
CN113822091B (en) Method and device for correcting errors of two-dimensional code pattern, electronic equipment and storage medium
CN116739022B (en) Decoding method and device for bar code image and electronic equipment
CN116451721B (en) Method and device for decoding, electronic equipment and storage medium
CN114758145A (en) Image desensitization method and device, electronic equipment and storage medium
Bodnár et al. A novel method for barcode localization in image domain
CN114492706B (en) Method and device for estimating module size of DM (direct memory access) code, decoding equipment and storage medium
CN104217189A (en) Self-learning identification method of barcode used for test strip
CN102467664A (en) Method and device for assisting with optical character recognition
CN111133474B (en) Image processing apparatus, image processing method, and computer-readable recording medium
CN113822092B (en) Method and apparatus for positioning position detection pattern, electronic device, and medium
CN107016317B (en) Bar code decoding method and device
CN105303148A (en) Bar code scanning method and device
CN114564978B (en) Method and device for decoding two-dimensional code, electronic equipment and storage medium
CN114943241B (en) Method for repairing bar code image, electronic equipment and storage medium
CN113420580B (en) Method and device for positioning auxiliary locator of two-dimensional code, two-dimensional code scanning equipment and storage medium
CN112434700A (en) License plate recognition method, device, equipment and storage medium
CN118013991A (en) Method and device for acquiring direction of locator and electronic equipment
CN116842977B (en) Bar code identification method
JPH09185726A (en) Ruled line removing method

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