A two-dimensional code decoding method, device, equipment and readable storage medium

By acquiring the virtual and real edge information of the DM code, calculating the number of modules, and combining it with error correction technology, the problem of low decoding accuracy of DM codes in industrial and printing applications is solved, achieving higher fault tolerance and accuracy.

CN120337957BActive Publication Date: 2025-12-12SUNLUX IOT TECHNOLOGY (GUANGDONG) INC
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510367237.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-26
Publication Date
2025-12-12
Estimated Expiration
2045-03-26

AI Technical Summary

Technical Problem

Existing DM code decoding methods suffer from low decoding accuracy and low fault tolerance in industrial and printing applications due to the loss of virtual edge modules.

Method used

By acquiring the virtual and real edges of the image to be decoded, the number of second modules is calculated using the length of the real edges and the module length. Decoding is then performed in conjunction with error correction techniques, and the number of modules is dynamically adjusted to improve the robustness and accuracy of decoding.

Benefits of technology

It improves the decoding error tolerance and accuracy of DM codes in printing and industrial environments, and reduces the production management risks caused by decoding errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120337957B_ABST
    Figure CN120337957B_ABST
Patent Text Reader

Abstract

The application discloses a two-dimensional code decoding method, device and equipment and a readable storage medium, and comprises the following steps: acquiring a to-be-decoded image, performing global binarization and barcode positioning on the to-be-decoded image, acquiring a virtual edge of the to-be-decoded image, acquiring a first module number of the to-be-decoded image based on the virtual edge, and decoding the to-be-decoded image based on the first module number; if the decoding fails, acquiring a first real edge and a second real edge of the to-be-decoded image based on the barcode positioning, acquiring a real edge length and a module length based on the first real edge and the second real edge; acquiring a second module number based on the real edge length and the module length, and decoding the to-be-decoded image based on the second module number. According to the application, the second module number is calculated according to the real edge length after the virtual edge positioning decoding fails, and the decoding is performed again, so that even if part is lost or the module number is calculated incorrectly due to printing or industrial environment factors, the two-dimensional code can be decoded again through the real edge, and the robustness and fault tolerance of the decoding are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of two-dimensional code decoding, in particular to a two-dimensional code decoding method, device and equipment and readable storage medium. BACKGROUND

[0002] DM code (Data Matrix Code) is a two-dimensional code widely used in industrial and printing fields, and its main features are high data density, strong damage resistance and small space occupation. DM code has wide application in industrial manufacturing, logistics management, electronic component identification, medical equipment tracking and other fields. For example, it is used for part identification and automatic management, improves production efficiency and quality traceability; it is used for product packaging and label identification, facilitates inventory management and product anti-counterfeiting; or it is used for identifying and tracking small electronic components to improve supply chain management efficiency. Although DM code decoding technology has been relatively mature, due to the influence of printing or industrial environment, the virtual edge of DM code may be partially lost, resulting in incorrect module number calculation and affecting the accuracy of decoding.

[0003] The existing DM code decoding method obtains the module number by positioning the virtual edge of the DM code, and corrects the DM code through the Reed-Solomon error correction mechanism to complete the DM code decoding. However, in industrial and printing applications, when the virtual edge module number is lost, the Reed-Solomon error correction mechanism cannot be used for error correction decoding, resulting in low decoding accuracy and low fault tolerance. SUMMARY

[0004] The present application provides a two-dimensional code decoding method, device, equipment and readable storage medium to improve the decoding fault tolerance and accuracy of DM code.

[0005] In order to solve the above technical problems, the present application provides a two-dimensional code decoding method, comprising:

[0006] Obtaining a to-be-decoded image, performing global binarization and barcode positioning on the to-be-decoded image, obtaining the virtual edge of the to-be-decoded image, obtaining the first module number of the to-be-decoded image based on the virtual edge, and decoding the to-be-decoded image based on the first module number;

[0007] If the decoding fails, the first real edge and the second real edge of the to-be-decoded image are obtained based on the barcode positioning, the real edge length and the module length are obtained based on the first real edge and the second real edge, the second module number is obtained based on the real edge length and the module length, and the to-be-decoded image is decoded based on the second module number.

[0008] The application can obtain the first real edge and the second real edge by using the barcode positioning after the virtual edge positioning decoding fails, obtain the real edge length and the module length according to the first real edge and the second real edge, and then calculate the second module number and re-decode, so that even if part is lost or the module number is calculated incorrectly due to printing or industrial environment factors, the real edge can be used for secondary decoding, the robustness and fault tolerance of decoding are improved, and the production management risk caused by decoding errors is reduced.

[0009] Further, the first real edge and the second real edge of the to-be-decoded image are obtained based on the real edge barcode positioning, and the real edge length and the module length are obtained based on the first real edge and the second real edge, including:

[0010] A binary image of the to-be-decoded image is obtained, barcode positioning is performed based on the binary image, and the first real edge and the second real edge are obtained.

[0011] The target real edge is determined based on the first real edge and the second real edge, and the real edge length is determined based on the target real edge.

[0012] Two corner points of the real edge and the virtual edge are determined based on the first real edge and the second real edge, and the module length is obtained based on the two corner points.

[0013] The application can accurately position the real edge and its intersection, the method can more accurately measure the actual edge length and the module length, provides a basis for accurate calculation of the subsequent module number, thereby enhancing the accuracy of decoding data, and avoiding decoding failure caused by incomplete edge information.

[0014] Further, the target real edge is determined based on the first real edge and the second real edge, and the real edge length is determined based on the target real edge, including:

[0015] The lengths of the first real edge and the second real edge are compared, and the longer edge is taken as the target real edge.

[0016] The real edge length is determined based on the target real edge.

[0017] The application can select the longer edge as the target by comparing the lengths of the two real edges, which can reduce the error caused by local damage or loss. The longer edge usually has more complete edge information, so using this edge can help more accurately determine the module size and improve the overall decoding accuracy and stability.

[0018] Further, the two corner points of the real edge and the virtual edge are determined based on the first real edge and the second real edge, and the module length is obtained based on the two corner points, including:

[0019] determine a real edge intersection point based on the first real edge and the second real edge, and determine two angle points of the real edge and the virtual edge based on the real edge intersection point and the real edge length;

[0020] search along a preset direction from the angle point as a starting point, stop searching when a first arbitrary color module is acquired, and record a search end point;

[0021] acquire a module length based on the starting point and the search end point.

[0022] The application ensures more accurate module size calculation and improves the accuracy of two-dimensional code decoding by determining the intersection position of the real edge and the virtual edge and estimating the module length by searching for the first color inversion module.

[0023] Further, the second module number is acquired based on the real edge length and the module length, and the image to be decoded is decoded based on the second module number, including:

[0024] the second module number is acquired based on the real edge length and the module length;

[0025] black and white point information is acquired based on the second module number, and the black and white point information is converted into binary information;

[0026] data reverse operation and error correction operation are performed on the binary information to acquire a decoding result.

[0027] The application can make up for the module number calculation error caused by the missing of the virtual edge information by decoding based on the second module number calculated from the real edge. Meanwhile, the accuracy and robustness of decoding are further improved by combining error correction technology to reversely restore and correct errors, which provides effective guarantee for high reliability decoding in industrial and printing environments.

[0028] Further, after the decoding result is acquired, the method further includes:

[0029] if the decoding result is decoding failure, a third module number is acquired by subtracting a preset first value from the second module number;

[0030] the image to be decoded is decoded based on the third module number.

[0031] The application tries to restore correct data by dynamically correcting the module number. The flexible adjustment mechanism effectively improves the fault tolerance of the system in the case of serious edge information loss or more noise, and reduces the decoding failure rate caused by inaccurate module number estimation.

[0032] Further, the obtaining the image to be decoded, performing global binarization and barcode positioning on the image to be decoded, obtaining the virtual edge of the image to be decoded, obtaining the first module number of the image to be decoded based on the virtual edge, and decoding the image to be decoded based on the first module number, comprises:

[0033] performing global binarization on the image to be decoded to obtain a binarized image;

[0034] performing barcode positioning based on the binarized image to obtain the virtual edge of the image to be decoded;

[0035] obtaining the black and white module interval number of the virtual edge, and obtaining the first module number based on the black and white module interval number;

[0036] decoding the image to be decoded based on the first module.

[0037] The application can recognize the module number of the image to be decoded based on the virtual edge positioning under the condition that the image quality is good and the virtual edge information is complete, so that high-speed and efficient decoding can be realized according to the module number.

[0038] In a second aspect, the application provides a two-dimensional code decoding device, comprising a virtual edge decoding module and a real edge decoding module.

[0039] The virtual edge decoding module is configured to obtain an image to be decoded, perform global binarization and barcode positioning on the image to be decoded, obtain the virtual edge of the image to be decoded, obtain the first module number of the image to be decoded based on the virtual edge, and decode the image to be decoded based on the first module number.

[0040] The real edge decoding module is configured to, if the decoding fails, obtain the first real edge and the second real edge of the image to be decoded based on the barcode positioning, obtain the real edge length and the module length based on the first real edge and the second real edge, obtain the second module number based on the real edge length and the module length, and decode the image to be decoded based on the second module number.

[0041] In a third aspect, the application further provides a terminal device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor executes the computer program to implement the two-dimensional code decoding method.

[0042] In a fourth aspect, the application further provides a computer readable storage medium, which comprises a stored computer program, and when the computer program runs, the computer readable storage medium controls the device where the computer readable storage medium is located to execute the two-dimensional code decoding method. BRIEF DESCRIPTION OF DRAWINGS

[0043] Figure 1A flowchart of a two-dimensional code decoding method provided by an embodiment of the present application is shown in FIG. 1.

[0044] Figure 2 Another flowchart of a two-dimensional code decoding method provided by an embodiment of the present application is shown in FIG. 2.

[0045] Figure 3 A structural diagram of a two-dimensional code decoding device provided by an embodiment of the present application is shown in FIG. 3. DETAILED DESCRIPTION

[0046] The specific embodiments of the present application are described in further detail below with reference to the accompanying drawings and embodiments. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.

[0047] The terms "first" and "second" and the like in the specification and claims of the present application and the accompanying drawings are used to distinguish different objects, and are not used to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, product or device.

[0048] Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The appearance of the phrase in various places in the specification does not necessarily all refer to the same embodiment, nor is it necessarily mutually exclusive of other embodiments. It is explicitly and implicitly understood that the embodiments described herein can be combined with other embodiments.

[0049] Embodiment 1

[0050] Reference is made to Figure 1 , Figure 1 A flowchart of a two-dimensional code decoding method provided by an embodiment of the present application is shown in FIG. 1. The present application provides a two-dimensional code decoding method, which includes steps 101 to 102, as follows:

[0051] Step 101: Acquire a to-be-decoded image, perform global binarization and barcode positioning on the to-be-decoded image, acquire a virtual edge of the to-be-decoded image, acquire a first module number of the to-be-decoded image based on the virtual edge, and perform decoding on the to-be-decoded image based on the first module number;

[0052] In the embodiment, the obtaining of the to-be-decoded image, global binarization of the to-be-decoded image, barcode positioning, obtaining of the virtual edge of the to-be-decoded image, obtaining of the first module number based on the virtual edge, and decoding of the to-be-decoded image based on the first module number, comprises:

[0053] global binarization of the to-be-decoded image to obtain a binarized image;

[0054] barcode positioning based on the binarized image to obtain a virtual edge of the to-be-decoded image;

[0055] obtaining of the black-and-white module interval number of the virtual edge, and obtaining of the first module number based on the black-and-white module interval number;

[0056] decoding of the to-be-decoded image based on the first module.

[0057] In the embodiment, the to-be-decoded image is globally binarized to generate a binarized image. The binarization divides the image pixels into two categories (generally black and white) to facilitate subsequent barcode positioning and module boundary identification.

[0058] In the embodiment, the generated binarized image is analyzed by using a barcode positioning algorithm to determine the position of the barcode in the image. In the barcode positioning process, the virtual edge of the DM code in the image is obtained by using the feature information of the DM code, that is, the boundary of the barcode is determined by judging the continuous black-and-white regions in the image, so that the interference information in the image is eliminated and the edge region of the two-dimensional code is accurately extracted, thereby laying a foundation for the calculation of the module number.

[0059] In the embodiment, the number of modules is determined by counting the interval number of black-and-white modules on the obtained virtual edge. Specifically, the first module number is obtained by counting the interval number based on the feature that black and white colors appear alternately on the virtual edge. For example, if the black-and-white interval is 10, the first module number is 10.

[0060] In the embodiment, by using the relatively stable black-and-white module interval information in the virtual edge, the module number of the DM code can be accurately obtained in the case that the image quality is high and the virtual edge information is complete, thereby providing a basis for subsequent decoding work.

[0061] In the embodiment, the to-be-decoded image is sampled according to the first module number, that is, the black-and-white point information at the corresponding positions is read by equidistant sampling in the image according to the module interval. The black-and-white point information obtained by sampling is converted into binary data (generally, black corresponds to 0 and white corresponds to 1). The converted binary data is subjected to a data reverse operation, and at the same time, error correction is performed by combining a pre-set error correction rule (such as the Reed-Solomon error correction mechanism), so that correct decoding data is finally obtained.

[0062] In the embodiment, the black and white point information is read by taking points at intervals of 10*10 modules, the black point is assigned a value of 0, and the white point is assigned a value of 1.

[0063] In the embodiment, when the virtual edge information is complete and has no loss, the DM code data can be quickly and accurately decoded.

[0064] Step 102: If the decoding fails, a first real edge and a second real edge of the image to be decoded are obtained based on barcode positioning, a real edge length and a module length are obtained based on the first real edge and the second real edge, a second module number is obtained based on the real edge length and the module length, and the image to be decoded is decoded based on the second module number.

[0065] In the embodiment, the first real edge and the second real edge of the image to be decoded are obtained based on real edge barcode positioning, and the real edge length and the module length are obtained based on the first real edge and the second real edge, including:

[0066] A binary image of the image to be decoded is obtained, barcode positioning is performed based on the binary image, and a first real edge and a second real edge are obtained.

[0067] A target real edge is determined based on the first real edge and the second real edge, and a real edge length is determined based on the target real edge.

[0068] Two corner points of the real edge and the virtual edge are determined based on the first real edge and the second real edge, and the module length is obtained based on the two corner points.

[0069] In the embodiment, a binary image of the image to be decoded is obtained, then a barcode positioning algorithm is used to process the binary image, edge information in the DM code region is extracted, and then the first real edge and the second real edge in the image are respectively positioned.

[0070] In the embodiment, the binary image improves the contrast of the black and white edges in the image, and ensures that the real edge information can be accurately extracted in the barcode positioning process.

[0071] In the embodiment, the target real edge is determined based on the first real edge and the second real edge, and the real edge length is determined based on the target real edge, including:

[0072] The lengths of the first real edge and the second real edge are compared, and the longer edge is taken as the target real edge.

[0073] The real edge length is determined based on the target real edge.

[0074] In this embodiment, based on the obtained first real edge and second real edge, the length of the two edges is compared to determine the target real edge as the one that is more complete and longer.

[0075] In this embodiment, by comparing the lengths of the two real edges and selecting the longer edge as the target, the error caused by local damage or loss can be reduced. The longer edge generally has more complete edge information, so using this edge helps to more accurately determine the module size and improve the overall decoding accuracy and stability.

[0076] In this embodiment, the determination of the two corner points of the real edge and the virtual edge based on the first real edge and the second real edge, and the acquisition of the module length based on the two corner points, include:

[0077] Determining the intersection of the real edges based on the first real edge and the second real edge, and determining the two corner points of the real edge and the virtual edge based on the intersection of the real edges and the length of the real edge;

[0078] Starting from the corner point and searching along a predetermined direction, stopping the search when the first module of any color is obtained, and recording the search endpoint;

[0079] Acquiring the module length based on the starting point and the search endpoint.

[0080] In this embodiment, the first real edge and the second real edge are used to further determine the intersection of the real edge and the virtual edge, i.e. the position of the two corner points. In specific implementation, the intersection of the two real edges is calculated first, and then the two corner points of the intersection of the virtual edge and the real edge are determined based on this. Then, one of the corner points is taken as the starting point, and the search is performed along the predetermined search direction (generally along the direction of the real edge extension) until the first color (black or white) changes is found. The search endpoint is recorded. The distance between the starting point and the endpoint is used as the average length of a single module, i.e. the module length.

[0081] In this embodiment, by determining the intersection of the real edge and the virtual edge and the corresponding corner points, the key information of the DM code edge region can be accurately captured, and the size of a single module can be accurately calculated using color changes.

[0082] In this embodiment, the acquisition of the second module number based on the real edge length and the module length, and the decoding of the to-be-decoded image based on the second module number, include:

[0083] Acquiring the second module number based on the real edge length and the module length;

[0084] acquire black and white point information based on the second module number, and convert the black and white point information into binary information;

[0085] perform data reverse operation and error correction operation on the binary information to acquire a decoding result.

[0086] In the embodiment, the decoding is performed based on the second module number calculated by the real edge, so that the calculation error of the module number caused by the missing of the virtual edge information is compensated. Meanwhile, the data is reversely recovered and error corrected in combination with the error correction technology, so that the accuracy and robustness of the decoding are further improved, and an effective guarantee is provided for the high-reliability decoding in the industrial and printing environment.

[0087] In the embodiment, the black and white state information of the center position of each module is read by performing equidistant sampling in the image along the horizontal and vertical directions of the DM code according to the obtained second module number. After the sampling, the black and white states are respectively converted into binary information (usually, it is agreed that the black color corresponds to "0" and the white color corresponds to "1"). In this process, the corresponding binary matrix is formed according to the determined module number, so as to ensure the integrity and structure of the data.

[0088] In the embodiment, the accuracy of the sampling point is improved by using the module number re-determined based on the real edge for data sampling, so that the information loss or wrong sampling phenomenon caused by the error of the module division is reduced.

[0089] In the embodiment, the data information converted into binary is firstly subjected to data reverse operation (for example, inversion, decryption or original arrangement of the data according to a predetermined algorithm), so as to be restored to the original encoding state. Subsequently, the data is subjected to error detection and correction by using a preset error correction algorithm (such as Reed-Solomon error correction technology), so as to correct the errors introduced due to the image noise, sampling error or missing of the virtual edge, and finally the correct decoding result is extracted.

[0090] In the embodiment, the data reverse operation ensures that the binary sequence after the module sampling can be correctly read, and the error correction mechanism improves the reliability of the data recovery.

[0091] In the embodiment, after the decoding result is acquired, the following steps are further included:

[0092] If the decoding result is decoding failure, the second module number is reduced by a preset first value to acquire a third module number;

[0093] The image to be decoded is decoded based on the third module number.

[0094] The application attempts to recover correct data by dynamically correcting the module number. The flexible adjustment mechanism effectively improves the fault tolerance of the system in the case of serious missing edge information or more noise, and reduces the decoding failure rate caused by inaccurate module number estimation.

[0095] In the embodiment, after data sampling, data inversion and error correction processing are performed by using the second module number, a decoding result is obtained. If the decoding result meets the preset validity standard, it is directly output; otherwise, decoding fails.

[0096] In the embodiment, if the initial decoding result fails, the second module number calculated based on the actual edge length and the module length is reduced by a preset first value to obtain an adjusted module number, i.e., a third module number.

[0097] In the embodiment, the value can be pre-set or dynamically adjusted according to the actual application scenario.

[0098] In the embodiment, the first value is 2.

[0099] In the embodiment, by reducing the module number, the oversampling problem caused by local virtual edge missing, image distortion or overestimated module spacing is compensated, so that the actual boundary of the module can be more accurately located.

[0100] In the embodiment, the third module number is used as a new sampling basis to perform sampling operation on the image to be decoded again, so as to reconstruct the black and white point information matrix. Data inversion and error correction processing are performed on the binary data obtained by sampling to obtain a new decoding result. If this decoding is successful, the correct data is output; if the decoding still fails, the module number can be adjusted or marked as decoding failure according to the preset strategy.

[0101] Please refer to Figure 2 , Figure 2 Another flowchart of a two-dimensional code decoding method provided by the embodiment of the application is shown in FIG. 4.

[0102] In the embodiment, after inputting a decoded image, global binaryzation is performed, then barcode positioning is performed, the number of first modules is determined by the number of black and white intervals of the dotted line, if the number of black and white intervals is 10, the number of modules is 10, then the black and white point information is read by taking points at intervals of 10*10 modules, the black is assigned a value of 0 and the white is assigned a value of 1, then the information is converted into a binary form, then reverse operation is performed on the data, Redd-Solomon error correction is performed, finally decoding is performed again, if decoding is successful, decoding success information is output, if decoding fails, the lengths of two solid edges are calculated by solid edge positioning, the longer solid edge length is taken as the total length of the solid edge length by comparing the lengths of the two solid edges, and searching is performed along the two directions of the dotted line based on the intersection of the solid edge and the dotted edge to find the first black or white (reverse color) module, then the average length of each module is estimated, then the second module number is estimated by dividing the solid edge length by the average module length, then the black and white point information is read by the number of modules, then the information is converted into a binary form, then reverse operation is performed on the data, Redd-Solomon error correction is performed, finally decoding is performed again, if decoding is successful, decoding success information is output, if decoding fails, a decoding failure flag is output.

[0103] Please refer to Figure 3 , Figure 3 A structure diagram of a two-dimensional code decoding device provided by the embodiment of the application, comprising: a dotted edge decoding module 301 and a solid edge decoding module 302.

[0104] The dotted edge decoding module 301 is configured to acquire a to-be-decoded image, perform global binaryzation and barcode positioning on the to-be-decoded image, acquire a dotted edge of the to-be-decoded image, acquire a first module number of the to-be-decoded image based on the dotted edge, and perform decoding on the to-be-decoded image based on the first module number.

[0105] The solid edge decoding module 302 is configured to, if decoding fails, acquire a first solid edge and a second solid edge of the to-be-decoded image based on barcode positioning, acquire a solid edge length and a module length based on the first solid edge and the second solid edge, acquire a second module number based on the solid edge length and the module length, and perform decoding on the to-be-decoded image based on the second module number.

[0106] In the embodiment of the application, a terminal device is also provided, which comprises a processor, a memory and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the two-dimensional code decoding method described above when executing the computer program.

[0107] In the embodiments of the present application, a computer readable storage medium is also provided, which comprises a stored computer program. When the computer program is run, the computer readable storage medium controls the device where the computer readable storage medium is located to perform the above-mentioned two-dimensional code decoding method.

[0108] For example, the computer program can be divided into one or more modules, which are stored in the memory and executed by the processor to complete the present application. One or more modules can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program in the terminal device.

[0109] The terminal device can be a desktop computer, a notebook computer, a palm computer, a cloud server and other computing devices. The terminal device can include, but is not limited to, a processor, a memory, a display. Those skilled in the art can understand that the above components are only examples of the terminal device and do not constitute a limitation on the terminal device, and the terminal device can include more or fewer components, or combine certain components, or different components, for example, the terminal device can also include an input / output device, a network access device, a bus, etc.

[0110] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor and the like. The processor is the control center of the terminal device, which connects all parts of the terminal device through various interfaces and lines.

[0111] The memory can be used to store computer programs and / or modules, and the processor realizes various functions of the terminal device by running or executing the computer programs and / or modules stored in the memory, and calling data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, a character conversion function, etc.), etc.; and the data storage area can store data created according to the use of the mobile phone (such as audio data, text message data, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0112] Wherein, the module based on the decoding of the two-dimensional code, if realized in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the present application realizes all or part of the processes in the above-mentioned embodiment methods, which can also be completed by a computer program instructing related hardware. The computer program can be stored in a computer readable storage medium, and the computer program can realize the steps of the above-mentioned various method embodiments when executed by a processor. Wherein, the computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms, etc. The computer readable medium can include any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium, etc. Those skilled in the art can understand and implement without paying creative labor.

[0113] The above specific embodiments further illustrate the purpose, technical solutions and beneficial effects of the present application. It should be understood that the above description is only for specific embodiments of the present application and is not intended to limit the protection scope of the present application. It is particularly pointed out that any modification, equivalent replacement, improvement, etc. made by those skilled in the art within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A two-dimensional code decoding method characterized by comprising: The method comprises the following steps: acquiring a to-be-decoded image, performing global binarization and barcode positioning on the to-be-decoded image, acquiring a virtual edge of the to-be-decoded image, acquiring a first module number of the to-be-decoded image based on the virtual edge, and decoding the to-be-decoded image based on the first module number; if the decoding fails, acquiring a first real edge and a second real edge of the to-be-decoded image based on the barcode positioning, and acquiring a real edge length and a module length based on the first real edge and the second real edge, which comprises the following steps: acquiring a binarized image of the to-be-decoded image, performing barcode positioning based on the binarized image, acquiring a first real edge and a second real edge, determining a target real edge based on the first real edge and the second real edge, determining a real edge length based on the target real edge, determining two corner points of the real edge and the virtual edge based on the first real edge and the second real edge, and acquiring the module length based on the two corner points, which comprises the following steps: determining a real edge intersection point based on the first real edge and the second real edge, and determining the two corner points of the real edge and the virtual edge based on the real edge intersection point and the real edge length; starting searching along a preset direction from the corner point, stopping searching when a first module of an arbitrary color is acquired, and recording a search end point; and acquiring the module length based on the start point and the search end point; acquiring a second module number based on the real edge length and the module length, and decoding the to-be-decoded image based on the second module number.

2. The method of claim 1, wherein the two-dimensional code is a QR code. The method comprises the following steps: comparing the lengths of the first real edge and the second real edge, taking the longer one as the target real edge, and determining the real edge length based on the target real edge. The method comprises the following steps:

3. The method of claim 1 or 2, wherein the two-dimensional code is a QR code. acquiring a second module number based on the real edge length and the module length, acquiring black and white point information based on the second module number, and converting the black and white point information into binary information; performing data reverse operation and error correction operation on the binary information to acquire a decoding result. After the decoding result is acquired, the method further comprises the following steps: if the decoding result is decoding failure, subtracting a preset first value from the second module number to acquire a third module number; and decoding the to-be-decoded image based on the third module number. The method comprises the following steps:

4. The method of claim 3, wherein the step of decoding the two-dimensional code comprises the steps of: determining a size of the two-dimensional code; and determining a type of the two-dimensional code. performing global binarization on the to-be-decoded image to acquire a binarized image; performing barcode positioning based on the binarized image to acquire a virtual edge of the to-be-decoded image; acquiring a black and white module interval number of the virtual edge, and acquiring a first module number based on the black and white module interval number; and decoding the to-be-decoded image based on the first module. The method comprises the following steps: a virtual edge decoding module and a real edge decoding module.

5. The method of claim 1, wherein the two-dimensional code decoding method is characterized by, ​ ​ ​ ​ ​ 6. A two-dimensional code decoding apparatus characterized by comprising: ​ ​ The virtual edge decoding module is configured to acquire a to-be-decoded image, perform global binarization and barcode positioning on the to-be-decoded image, acquire a virtual edge of the to-be-decoded image, acquire a first module number of the to-be-decoded image based on the virtual edge, and perform decoding on the to-be-decoded image based on the first module number. The real edge decoding module is configured to, if the decoding fails, acquire a first real edge and a second real edge of the to-be-decoded image based on barcode positioning, and acquire a real edge length and a module length based on the first real edge and the second real edge, including: acquiring a binarized image of the to-be-decoded image, performing barcode positioning based on the binarized image, acquiring a first real edge and a second real edge, determining a target real edge based on the first real edge and the second real edge, determining a real edge length based on the target real edge, determining two corner points of a real edge and a virtual edge based on the first real edge and the second real edge, and acquiring the module length based on the two corner points, including: determining a real edge intersection point based on the first real edge and the second real edge, and determining the two corner points of the real edge and the virtual edge based on the real edge intersection point and the real edge length; starting searching along a preset direction from the corner point, stopping searching when a first module of an arbitrary color is acquired, and recording a search end point; and acquiring the module length based on the start point and the search end point; acquiring a second module number based on the real edge length and the module length, and performing decoding on the to-be-decoded image based on the second module number.

7. A terminal device, characterized by comprising: The computer readable storage medium includes a stored computer program, wherein the computer readable storage medium controls a device where the computer readable storage medium is located to perform a two-dimensional code decoding method according to any one of claims 1 to 6 when the computer program runs.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium includes a stored computer program, wherein the computer readable storage medium controls a device where the computer readable storage medium is located to perform a two-dimensional code decoding method according to any one of claims 1 to 6 when the computer program runs.

Citation Information

Patent Citations

  • Method and device for acquiring DM code area

    CN112069851A

  • Dot-matrix DM two-dimensional code specification determination method and related device

    CN112598100A

  • Two-dimensional code module boundary determination method and device

    CN118228753A