A discrete data storage method based on data error correction and loss prevention
By adopting a discrete data storage method based on data error correction in QR code technology, setting encoding rules and data storage strategies, the problem of data in QR code technology is solved, and the QR code generation and scanning process is realized data storage reliability and scan results accuracy.
Patent Information
- Application Number
- CN202411377735.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-09-30
AI Technical Summary
The lack of effective discrete data storage schemes in the existing QR code technology, resulting in the inconsistent correspondence between the original data and the generated QR code image, and the inability to correct the content during subsequent scanning or the deviation occurs during rescanning, especially in the area where the QR code is blocked. The result cannot be recognized for a long time.
Using a discrete data storage method based on data error correction, the encoding rules are set by obtaining the parameter information of the QR code editing tool in the client, black and white and color QR code images are generated, and the corresponding data storage strategy is set according to the content to be encoded. Set the threshold relationship between the error correction code area and the occlusion area to ensure the reliability of data storage.
During the QR code generation and scanning process, the reliability of data storage can be effectively guaranteed, the accuracy of scanning results can be ensured, and identification bias caused by data incorrectness can be avoided.
Smart Images

Figure CN118941437B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of two-dimensional codes, and in particular to a discrete data storage method based on data error correction and loss prevention. Background Art
[0002] The QR code technology originated in the late 1980s. There are more than 250 QR codes in the world, including more than 20 common technical standards such as PDF417, QR Code (Quick Response), Code49 Code16K, CodeOne, etc. QR codes are the most commonly used in daily scanning. From 1997 to 2012, my country successively issued five national standards for QR codes: PDF417, QR Code (Quick Response Code), Hanxin Code, GM Code (Grid Matrix Code) and CM Code (Compact Matrix Code). Among them, QR Code is the most widely used QR code because of its advantages of fast reading speed, large information capacity, small space occupation, strong confidentiality and high reliability.
[0003] QR codes are divided into ordinary QR codes and dynamic QR codes. Generally speaking, ordinary QR codes only encode information such as text, URLs, and phone numbers. They do not support images, audio, and video. After the QR code is generated, the content cannot be changed. When the information content is large, the generated QR code pattern is complex and not easy to identify and print, so it is also called a static QR code. The advantage of a static QR code is that it can be identified without an Internet connection. However, sometimes it is often necessary to print out a QR code in offline scenarios for users to scan, or in some operational scenarios, it is necessary to collect data and analyze the user's scanning situation. Ordinary QR codes cannot provide these functions. At this time, dynamic QR codes must be used.
[0004] Whether it is a static QR code or a dynamic QR code, the QR code tool version used in the generation process is not unified, and the original data and the generated QR code image need to be saved. Since the QR code images are mostly generated in the client with the QR code generation tool installed, and the original data and the generated QR code image are discrete, the main function of the QR code generation tool focuses on how to generate the QR code image and use it for printing and scanning. There is currently no storage solution for discrete data in the entire QR code generation process. At the same time, since the QR code generation tool installed in the client is generally open, if a reasonable and reliable storage solution is not designed, the original data will be tampered with without reason or the original data will not correspond to the generated QR code image. Then, when the user scans the code later, if there are too many blocked areas or the scanning result cannot be recognized in a single time, then when the QR code image and the original data are corrected or re-scanned, the user will not be able to re-scan the result or the re-scanned result will be biased.
[0005] Therefore, there is an urgent need for a discrete data storage solution for data error correction and loss prevention. Summary of the invention
[0006] The purpose of the present invention is to provide a discrete data storage method based on data error correction and loss prevention, which can ensure the reliability of data storage during the two-dimensional code generation process.
[0007] The present invention solves the technical problem and adopts the following technical solution:
[0008] A discrete data storage method based on data error correction and loss prevention comprises the following steps:
[0009] Obtain the current QR code editing tool in the client, and set a first encoding rule for generating a black and white QR code image based on parameter information of the current QR code editing tool, and set a second encoding rule for generating a color QR code image;
[0010] Based on the content to be encoded, a first data storage strategy corresponding to the first encoding rule and a second data storage strategy corresponding to the second encoding rule are set;
[0011] Set the error correction code area and error correction rate of different contents to be encoded in the generated two-dimensional code image, and set the corresponding relationship between the threshold of the blocked area when the two-dimensional code image is scanned;
[0012] When the content to be encoded is obtained, the corresponding encoding rule is called to generate a black and white two-dimensional code image or a color two-dimensional code image, and the content to be encoded is stored according to the corresponding data storage strategy;
[0013] When it is detected that the two-dimensional code image is scanned, the blocked area is obtained, and based on the corresponding relationship, it is determined whether to directly decode the two-dimensional code image, or to call a corresponding data storage strategy for decoding.
[0014] As a further optimization, the parameter information of the current QR code editing tool includes: the first maximum data code length, the first error correction code length and the module position occupied by a single byte under the first encoding rule, and the second maximum data code length, the second error correction code length and the module position occupied by a single byte under the second encoding rule.
[0015] As a further optimization, based on the first maximum data code length, the first maximum error correction code length and the module position occupied by a single byte under the first coding rule, the second maximum data code length, the second error correction code length and the module position occupied by a single byte under the second coding rule are set.
[0016] As a further optimization, the setting of the second maximum data code length under the second coding rule means: setting the second maximum data code length to eight times the first maximum data code length;
[0017] The setting of the second error correction code length under the second coding rule means: setting the second error correction code length to eight times the first error correction code length;
[0018] The single byte contains eight bits, each bit in the single byte under the first encoding rule occupies one module position, and setting the module position occupied by the single byte under the second encoding rule means: setting the module position occupied by the single byte to occupy one module position.
[0019] As a further optimization, when setting the first encoding rule for generating a black and white QR code image based on the parameter information of the current QR code editing tool and setting the second encoding rule for generating a color QR code image, a byte threshold of the bytes contained in the encoded content is set.
[0020] As a further optimization, when the content to be encoded is obtained, calling the corresponding encoding rule to generate a black and white two-dimensional code image or a color two-dimensional code image means:
[0021] When the bytes contained in the content to be encoded are less than the byte threshold, the first encoding rule is called to generate a black and white two-dimensional code image. When the bytes contained in the content to be encoded are greater than or equal to the byte threshold, the second encoding rule is called to generate a color two-dimensional code image.
[0022] As a further optimization, the first data storage strategy refers to:
[0023] When the bytes contained in the content to be encoded are less than the byte threshold, the content to be encoded is classified, a first storage unit is set in the current two-dimensional code editing tool of the client, and the content to be encoded is stored in the first storage unit based on the category of the content to be encoded, and the content to be encoded in the first storage unit is allowed to be modified;
[0024] Export the black and white QR code image from the QR code editing tool to the print list of the client. If the content to be encoded in a category in the first storage unit is modified, regenerate the black and white QR code image and replace the black and white QR code image under the category in the print list.
[0025] The second data storage strategy refers to:
[0026] When the bytes contained in the content to be encoded are greater than or equal to the byte threshold, a second storage unit and a third storage unit are set on the client in addition to the current QR code editing tool, and the content to be encoded is stored in the second storage unit, and the color QR code image is stored in the third storage unit, and a mapping relationship between the content to be encoded and the color QR code image is established based on the content to be encoded. Under this mapping relationship, when the content to be encoded in the second storage unit is modified, the color QR code image generated in the third storage unit does not change.
[0027] As a further optimization, when the content to be encoded is obtained, before calling the second encoding rule to generate a color two-dimensional code image, it also includes:
[0028] Expand the grayscale value of each module under the first coding rule by 2*2 to form the grayscale value of each module under the second coding rule;
[0029] Create a mapping table from 256 grayscale values to RGB colors.
[0030] As a further optimization, when a color QR code image is detected to be scanned and decoded, it includes:
[0031] Obtain the color value of the image block in the color QR code image, perform smoothing, and obtain the median value of the mapping table from 256 gray values to RGB colors;
[0032] According to the mapping table of 256 gray values to RGB colors, inversely solve the gray values;
[0033] The color two-dimensional code image is decoded based on the second encoding rule.
[0034] The beneficial effect of the present invention is as follows: through the above-mentioned discrete data storage method based on data error correction and anti-loss, first, the current two-dimensional code editing tool in the client is obtained, and based on the parameter information of the current two-dimensional code editing tool, a first encoding rule for generating a black and white two-dimensional code image is set, and a second encoding rule for generating a color two-dimensional code image is set; secondly, based on the content to be encoded, a first data storage strategy corresponding to the first encoding rule and a second data storage strategy corresponding to the second encoding rule are set; then, the error correction code area and error correction rate of different contents to be encoded in the generated two-dimensional code image are set, and the corresponding relationship of the threshold value of the blocked area when the two-dimensional code image is scanned is set; then, when the content to be encoded is obtained, the corresponding encoding rule is called to generate a black and white two-dimensional code image or a color two-dimensional code image, and the content to be encoded is stored according to the corresponding data storage strategy; finally, when it is detected that the two-dimensional code image is scanned, the blocked area is obtained, and based on the corresponding relationship, it is determined whether to directly decode the two-dimensional code image, or to call the corresponding data storage strategy for decoding.
[0035] Therefore, during the entire two-dimensional code generation and scanning process, the present invention can, based on the original data to be encoded of different lengths, separately store the original data to be encoded and the corresponding two-dimensional code images generated according to different data storage strategies, and can ensure the reliability of data storage during the two-dimensional code generation process. Moreover, the same version of the two-dimensional code editing tool can be used to complete the two-dimensional code image generation process of all types and lengths of data to be encoded. At the same time, when the two-dimensional code image is subsequently scanned, the two-dimensional code image that is inaccurately or cannot be corrected can be matched with the original data to be encoded based on the data storage strategy, so as to further ensure the accuracy of the scanning result. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 The present invention is a flowchart of a discrete data storage method based on data error correction and loss prevention in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0038] Example
[0039] This embodiment provides a discrete data storage method based on data error correction and loss prevention. Figure 1 , wherein the method comprises the following steps:
[0040] S1, obtaining the current two-dimensional code editing tool in the client, and setting a first encoding rule for generating a black and white two-dimensional code image based on parameter information of the current two-dimensional code editing tool, and setting a second encoding rule for generating a color two-dimensional code image;
[0041] S2, setting a first data storage strategy corresponding to the first encoding rule and a second data storage strategy corresponding to the second encoding rule based on the content to be encoded;
[0042] S3, setting the error correction code area and error correction rate of different contents to be encoded in the generated two-dimensional code image, and setting the corresponding relationship between the threshold of the blocked area when the two-dimensional code image is scanned;
[0043] S4. When the content to be encoded is obtained, the corresponding encoding rule is called to generate a black and white two-dimensional code image or a color two-dimensional code image, and the content to be encoded is stored according to the corresponding data storage strategy;
[0044] S5. When it is detected that the two-dimensional code image is scanned, the blocked area is obtained, and based on the corresponding relationship, it is determined to directly decode the two-dimensional code image, or it is determined to call a corresponding data storage strategy for decoding.
[0045] In this embodiment, the QR code editing tool targets different standards, and there are different versions under each standard. For example, this embodiment can target the IOS 18004 standard. Under this standard, there are different versions of QR code editing tools. Under each version, for content data to be encoded with a shorter data length, that is, data containing fewer bytes, since one byte contains eight bits and each bit needs to occupy a module position, when the data length is long, it is easy to cause insufficient module position. The existing conventional practice is to use other versions to perform additional QR code encoding processes. In this way, for users, a client installing different versions of QR code editing tools will take up more memory space, thereby affecting the running speed of other threads of the client. Therefore, in this embodiment, for content to be encoded with a longer data length, other versions of the QR code editing tool will not be used additionally when performing QR code encoding.
[0046] Therefore, in this embodiment, the parameter information of the current QR code editing tool is first obtained, that is, the first maximum data code length and the first error correction code length in each version under the IOS18004 standard are obtained, and what is subsequently generated is a black and white QR code image, and for the first maximum data code length and the first error correction code length, what is subsequently generated is a color QR code image. Therefore, on this basis, the parameter information of the current QR code editing tool may include: the first maximum data code length, the first error correction code length, and the module position occupied by a single byte under the first encoding rule, and the second maximum data code length, the second error correction code length, and the module position occupied by a single byte under the second encoding rule.
[0047] In actual use, the second maximum data code length, the second error correction code length, and the module position occupied by a single byte under the second coding rule can be set based on the first maximum data code length, the first maximum error correction code length, and the module position occupied by a single byte under the first coding rule. Specifically, the second maximum data code length under the second coding rule is set to eight times the first maximum data code length; the second error correction code length under the second coding rule is set to eight times the first error correction code length; the single byte contains eight bits, and each bit in the single byte under the first coding rule occupies one module position, and the module position occupied by a single byte under the second coding rule is set to one module position.
[0048] In this way, the data to be encoded of different data lengths can be unified in one standard version, and flexibly encoded according to actual encoding requirements without the need to install and switch other versions, thereby effectively reducing the running burden of other threads of the client.
[0049] It should be pointed out that in this embodiment, different encoding rules can be used for encoding and decoding based on the actual situation of the content to be encoded. Therefore, when the first encoding rule for generating a black-and-white two-dimensional code image is set based on the parameter information of the current two-dimensional code editing tool, and the second encoding rule for generating a color two-dimensional code image is set, a byte threshold of the bytes contained in the encoded content can be set. For the number of bytes contained, after obtaining the content to be encoded, the bytes can be compared with the byte threshold to determine whether to generate a black-and-white two-dimensional code image or a color two-dimensional code image. Therefore, in this embodiment, when the content to be encoded is obtained, calling the corresponding encoding rule to generate a black-and-white two-dimensional code image or a color two-dimensional code image means:
[0050] When the bytes contained in the content to be encoded are less than the byte threshold, the first encoding rule is called to generate a black and white two-dimensional code image. When the bytes contained in the content to be encoded are greater than or equal to the byte threshold, the second encoding rule is called to generate a color two-dimensional code image.
[0051] It should be pointed out that if the required two-dimensional code image to be generated is a black-and-white two-dimensional code image, it may also correspond to different types of content to be encoded, such as text, website and telephone, etc. For different types of content to be encoded, if a black-and-white two-dimensional code image is generated, the generated image is one-to-one corresponding to the original content to be encoded, that is, if the content to be encoded is modified, the corresponding subsequently generated black-and-white two-dimensional code image will inevitably change. Therefore, in the process of generating a black-and-white two-dimensional code image, it is necessary to use the first data storage strategy, that is, the first data storage strategy. Therefore, in this embodiment, the first data storage strategy refers to:
[0052] When the bytes contained in the content to be encoded are less than the byte threshold, the content to be encoded is classified, a first storage unit is set in the current two-dimensional code editing tool of the client, and the content to be encoded is stored in the first storage unit based on the category of the content to be encoded, and the content to be encoded in the first storage unit is allowed to be modified;
[0053] The black and white QR code image is exported from the QR code editing tool to the client's print list. If the content to be encoded in a category in the first storage unit is modified, the black and white QR code image is regenerated and replaces the black and white QR code image under the category in the print list.
[0054] For the first data storage strategy, the generated black and white QR code can be directly used for printing for users to scan. The current conventional black and white QR code storage solution is to directly store it in the specified folder of the client, and the original content to be encoded (such as text, URL, etc.) is typed by the user or pasted from other locations. For the generated black and white QR code, if it is kept in the folder, it will need to be called when it needs to be printed later, and general folders are open and easy to be obtained. If the acquisition operation is not authorized by the user, the illegal user can use the generated black and white QR code as an intermediate jump tool to achieve its scanning index purpose. Therefore, in this embodiment, the black and white QR code image will only exist in the print list and can be directly used for subsequent printing. Since a client will not use different versions of QR code editing tools for simultaneous encoding, there will be no printing backlog problem.
[0055] In addition, if the required two-dimensional code image to be generated is a color two-dimensional code image, although there may be multiple types of content to be encoded, such as audio and video, in this two-dimensional code generation scheme, due to the encoding characteristics, once the color two-dimensional code image is generated, it will not change due to the modification of the content to be encoded. Therefore, there is no need to classify these contents to be encoded again. If a color two-dimensional code image is generated, the generated image does not change, and the original encoded content is variable, that is: if the content to be encoded is modified, the corresponding subsequently generated color two-dimensional code image will not change. Therefore, in the process of generating a color two-dimensional code image, it is necessary to use a second data storage strategy, that is, a second data storage strategy. Therefore, in this embodiment, the second data storage strategy refers to:
[0056] When the bytes contained in the content to be encoded are greater than or equal to the byte threshold, a second storage unit and a third storage unit are set on the client in addition to the current QR code editing tool, and the content to be encoded is stored in the second storage unit, and the color QR code image is stored in the third storage unit, and a mapping relationship between the content to be encoded and the color QR code image is established based on the content to be encoded. Under this mapping relationship, when the content to be encoded in the second storage unit is modified, the color QR code image generated in the third storage unit does not change.
[0057] In the actual application process, the maximum data code length and error correction code length are increased for the generation process of the color two-dimensional code image, and the module position is also adjusted. On this basis, the gray value of each module can be expanded. However, even if it is expanded, it still belongs to a grayscale image. Since the gray values before and after are close, the gray value of the image acquisition may change under the influence of the subsequent scanning light, thereby causing errors. Therefore, it is necessary to establish a mapping table of 256 gray values to RGB colors before generating and saving the color two-dimensional code image. Therefore, in this embodiment, when the content to be encoded is obtained, before calling the second encoding rule to generate the color two-dimensional code image, it can also include:
[0058] Expand the grayscale value of each module under the first coding rule by 2*2 to form the grayscale value of each module under the second coding rule;
[0059] Create a mapping table from 256 grayscale values to RGB colors.
[0060] Correspondingly, in order to optimize the color difference problem of the image acquisition color two-dimensional code image, the acquired color two-dimensional code image needs to be processed. Therefore, when it is detected that the color two-dimensional code image is scanned and decoded, it can include:
[0061] Obtain the color value of the image block in the color QR code image, perform smoothing, and obtain the median value of the mapping table from 256 gray values to RGB colors;
[0062] According to the mapping table of 256 gray values to RGB colors, inversely solve the gray values;
[0063] The color two-dimensional code image is decoded based on the second encoding rule.
[0064] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A discrete data storage method based on data error correction and loss prevention, characterized in that: The steps include: Obtain the current QR code editing tool in the client, and set a first encoding rule for generating a black and white QR code image based on parameter information of the current QR code editing tool, and set a second encoding rule for generating a color QR code image; Based on the content to be encoded, a first data storage strategy corresponding to the first encoding rule and a second data storage strategy corresponding to the second encoding rule are set; Set the error correction code area and error correction rate of different contents to be encoded in the generated two-dimensional code image, and set the corresponding relationship between the threshold of the blocked area when the two-dimensional code image is scanned; When the content to be encoded is obtained, the corresponding encoding rule is called to generate a black and white two-dimensional code image or a color two-dimensional code image, and the content to be encoded is stored according to the corresponding data storage strategy; When it is detected that the two-dimensional code image is scanned, the blocked area is obtained, and based on the corresponding relationship, it is determined whether to directly decode the two-dimensional code image, or to call a corresponding data storage strategy for decoding; When setting the first encoding rule for generating a black and white two-dimensional code image based on the parameter information of the current two-dimensional code editing tool and setting the second encoding rule for generating a color two-dimensional code image, a byte threshold of bytes contained in the encoded content is set; The above-mentioned when the content to be encoded is obtained, calling the corresponding encoding rule to generate a black-and-white two-dimensional code image or a color two-dimensional code image means that when the bytes contained in the content to be encoded are less than the byte threshold, calling the first encoding rule to generate a black-and-white two-dimensional code image, and when the bytes contained in the content to be encoded are greater than or equal to the byte threshold, calling the second encoding rule to generate a color two-dimensional code image; The first data storage strategy refers to: When the bytes contained in the content to be encoded are less than the byte threshold, the content to be encoded is classified, a first storage unit is set in the current two-dimensional code editing tool of the client, and the content to be encoded is stored in the first storage unit based on the category of the content to be encoded, and the content to be encoded in the first storage unit is allowed to be modified; Export the black and white QR code image from the QR code editing tool to the print list of the client. If the content to be encoded in a category in the first storage unit is modified, regenerate the black and white QR code image and replace the black and white QR code image under the category in the print list. The second data storage strategy refers to: When the bytes contained in the content to be encoded are greater than or equal to the byte threshold, a second storage unit and a third storage unit are set on the client in addition to the current QR code editing tool, and the content to be encoded is stored in the second storage unit, and the color QR code image is stored in the third storage unit, and a mapping relationship between the content to be encoded and the color QR code image is established based on the content to be encoded. Under this mapping relationship, when the content to be encoded in the second storage unit is modified, the color QR code image generated in the third storage unit does not change.
2. A discrete data storage method based on data error correction and loss prevention according to claim 1, characterized in that: The parameter information of the current QR code editing tool includes: the first maximum data code length, the first error correction code length and the module position occupied by a single byte under the first encoding rule, and the second maximum data code length, the second error correction code length and the module position occupied by a single byte under the second encoding rule.
3. A discrete data storage method based on data error correction and loss prevention according to claim 2, characterized in that: Based on the first maximum data code length, the first maximum error correction code length and the module position occupied by a single byte under the first coding rule, the second maximum data code length, the second error correction code length and the module position occupied by a single byte under the second coding rule are set.
4. A discrete data storage method based on data error correction and loss prevention according to claim 3, characterized in that: The setting of the second maximum data code length under the second coding rule means: setting the second maximum data code length to eight times the first maximum data code length; The setting of the second error correction code length under the second coding rule means: setting the second error correction code length to eight times the first error correction code length; The single byte contains eight bits, each bit in the single byte under the first encoding rule occupies one module position, and setting the module position occupied by the single byte under the second encoding rule means: setting the module position occupied by the single byte to occupy one module position.
5. The discrete data storage method based on data error correction and loss prevention according to claim 1 is characterized in that: When the content to be encoded is obtained, before calling the second encoding rule to generate a color two-dimensional code image, the method further includes: Expand the grayscale value of each module under the first coding rule by 2*2 to form the grayscale value of each module under the second coding rule; Create a mapping table from 256 grayscale values to RGB colors.
6. The discrete data storage method based on data error correction and loss prevention according to claim 1, characterized in that: When a color QR code image is detected and decoded, it includes: Obtain the color value of the image block in the color QR code image, perform smoothing, and obtain the median value of the mapping table from 256 gray values to RGB colors; According to the mapping table of 256 gray values to RGB colors, inversely solve the gray values; The color two-dimensional code image is decoded based on the second encoding rule.
Citation Information
Patent Citations
Two-dimensional code coding method adopting layered structure and decoding method thereof
CN106682716A
Two-dimensional code generation method, two-dimensional code identification method, two-dimensional code and equipment
CN110517052A
