Two-dimensional code information processing method, electronic equipment and readable storage medium
By processing the QR code generation information, the QR code with a smaller data volume than the original information is solved, resulting in low scanning efficiency and low recognition accuracy due to large amount of QR code data, and achieving more efficient and accurate resource access.
Patent Information
- Application Number
- CN202411728894.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-28
AI Technical Summary
When the QR code data volume is large, the pattern complexity and density increase, resulting in low scanning efficiency and low recognition accuracy.
By performing data processing on the first information used to generate the QR code, the second information whose data amount is smaller than the original information is obtained, and a QR code is generated based on the second information, so that the user can access resources corresponding to the first information by scanning the QR code. Data processing methods include data simplification, compression and external link address processing.
It reduces the amount of information in the QR code, simplifies the QR code pattern, reduces the density, and improves the efficiency and identification accuracy of scanning the QR code for resource access.
Smart Images

Figure CN119721104A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of two-dimensional codes, and in particular to a two-dimensional code information processing method, an electronic device, and a readable storage medium. Background Art
[0002] As a fast and convenient way to store and transmit information, QR Code has been widely used in modern society. However, when the amount of data included in the QR Code is large, the complexity and density of the QR Code pattern will increase, resulting in low efficiency in scanning QR Codes to access resources and low recognition accuracy. Summary of the invention
[0003] In order to solve at least one of the above technical problems, the present disclosure provides a two-dimensional code information processing method, an electronic device and a readable storage medium. The technical solution is as follows: In a first aspect, an embodiment of the present disclosure provides a method for processing information of a two-dimensional code, including: Acquire first information for generating a QR code; Based on a number of characters included in the first information, data processing is performed on the first information to obtain second information; the data volume of the second information is smaller than the data volume of the first information; A QR code is generated based on the second information, so that a user can access resources corresponding to the first information through the second information when scanning the QR code.
[0004] In a feasible embodiment, the performing data processing on the first information based on a number of characters included in the first information to obtain the second information includes, when it is determined that the character length of the first information is greater than a preset threshold, performing at least one of the following: Based on the levels of the characters included in the first information in the preset generation rule of the two-dimensional code, the first information is subjected to data simplification processing to obtain second information; Based on the character frequency of each character in the first information, the first information is subjected to data compression processing to obtain second information; The first information is linked to an external link address, and the external link address is used as the second information.
[0005] In a feasible embodiment, the step of performing data processing on the first information based on a number of characters included in the first information to obtain the second information includes: Traversing the characters in the first information, and determining the character frequency of each character based on the number of times each character appears; Constructing a binary tree with the characters as nodes based on the character frequencies; From the root node to the leaf node of the binary tree, assign a corresponding code to each character; Replacing characters in the first information with codes corresponding thereto to obtain second information; The characters in the first information include all characters in the first information, or characters in the first information used to form a parameter part of a uniform resource locator (URL).
[0006] In a feasible embodiment, constructing a binary tree with the characters as nodes based on the character frequencies includes: Generate a node for each character, and sort the nodes based on the frequency of the character to obtain an ordered set; Repeat the following operations for the nodes included in the ordered set until one node remains: merge the two nodes with the lowest character frequency to generate a new node.
[0007] In a feasible embodiment, assigning a corresponding code to each character from the root node to the leaf node of the binary tree includes performing the following operations for each character: Starting from the root node of the binary tree, traverse each layer of nodes of the binary tree until the leaf node of the binary tree to determine the path of the character; Determine the encoding of the character based on a preset allocation rule of the encoding and the path of the character; The preset allocation rule of the code includes: if the next layer node is located on the left side of the parent node, a first value is allocated; if the next layer node is located on the right side of the parent node, a second value is allocated.
[0008] In a feasible embodiment, the method further includes: receiving an access request sent by a user when scanning the QR code, decoding second information carried in the access request based on a pre-stored binary tree structure and a coding table to obtain the first information; the binary tree structure and the coding table are generated based on characters in the first information; Resources corresponding to the first information are displayed.
[0009] In a feasible embodiment, the step of performing data processing on the first information based on a number of characters included in the first information to obtain the second information includes: Acquire parameter information in the first information, where the first information includes a URL; Based on a preset generation rule of the QR code, determining the level of each parameter in the parameter information; the level includes a first level corresponding to a mandatory parameter and a second level corresponding to a non-mandatory parameter; generating second information based on the parameters of the first level; Among them, for the same first information, there is an association relationship between the first-level parameters and the second-level parameters.
[0010] In a feasible embodiment, the generating a QR code based on the second information includes: Based on the version and error correction level of the two-dimensional code, generate a data codeword and an error correction codeword of the second information; Based on a preset generation rule of the two-dimensional code, the data codewords and the error correction codewords are arranged into a two-dimensional code matrix to generate a final two-dimensional code; The version and / or the error correction level are related to the data processing method.
[0011] In a second aspect, an embodiment of the present disclosure provides an electronic device, comprising at least one transceiver and at least one processor coupled to the at least one transceiver, wherein the at least one processor is configured to execute the steps of the method provided in the first aspect and any embodiment thereof.
[0012] In a third aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method provided in the first aspect and any embodiment thereof are implemented.
[0013] In a fourth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, characterized in that when the computer program is executed by a processor, the steps of the method provided in the first aspect and any embodiment thereof are implemented.
[0014] The technical solution provided by the embodiments of the present disclosure has the following beneficial effects: The disclosed embodiments provide a two-dimensional code information processing method, an electronic device, and a readable storage medium. Specifically, when first information for generating a two-dimensional code is obtained, the first information can be processed based on a number of characters included in the first information to obtain second information, and a two-dimensional code is generated based on the second information, so that a user can access resources corresponding to the first information through the second information when scanning the two-dimensional code; wherein the data volume of the second information is less than the data volume of the first information. The implementation of the disclosed embodiments can reduce the amount of information of the URL used to generate the two-dimensional code, simplify the pattern of the two-dimensional code and reduce the density of the two-dimensional code pattern, and improve the efficiency of scanning the two-dimensional code to access resources and the recognition accuracy of the two-dimensional code. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for describing the embodiments of the present disclosure are briefly introduced below.
[0016] Figure 1A schematic diagram of a flow chart of a two-dimensional code information processing method provided in an embodiment of the present disclosure; Figure 2 A schematic diagram of constructing a binary tree provided in an embodiment of the present disclosure; Figure 3 A schematic diagram of determining a character corresponding to a code provided by an embodiment of the present disclosure; Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0017] The embodiments of the present disclosure are described below in conjunction with the drawings in the present disclosure. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present disclosure and do not constitute a limitation on the technical solutions of the embodiments of the present disclosure.
[0018] It will be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present disclosure refer to that the corresponding features can be implemented as the displayed features, information, data, steps, operations, elements and / or components, but do not exclude the implementation as other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element may be directly connected or coupled to the other element, or it may refer to that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" may be implemented as "A", or as "B", or as "A and B".
[0019] In order to make the objectives, technical solutions and advantages of the present disclosure more clear, the embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.
[0020] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present disclosure and the technical effects produced by the technical solutions of the present disclosure. It should be noted that the following embodiments can refer to, draw on or combine with each other, and the same terms, similar features and similar implementation steps in different embodiments will not be described repeatedly.
[0021] The following describes the information processing method of the two-dimensional code provided in the embodiment of the present disclosure.
[0022] Specifically, Figure 1As shown, the information processing method of the two-dimensional code provided in the embodiment of the present disclosure includes S101 to S103: S101. Obtain first information for generating a QR code.
[0023] Optionally, a QR code, also known as a two-dimensional barcode, is a readable barcode technology that is extended from a one-dimensional barcode. A QR code uses a certain geometric pattern to be distributed in a plane (two-dimensional direction) according to a certain rule, forming a black and white pattern to record data symbol information. The QR code is scanned by a device to identify the binary data recorded in its length and width, thereby obtaining the information contained therein.
[0024] Optionally, the QR code has the ability to store a large amount of data, which may include text and URLs (Uniform Resource Locator), etc. As a data encoding method, the QR code can not only store URL links, but also various non-URL data. Non-URL data may include, but is not limited to, text information, pictures, audio, video, files, etc. Among them, the non-URL data may also be uploaded to a network server to encode the URL of the non-URL data into the QR code. For example, when the audio is large and it is difficult to encode the audio data directly through the QR code, the URL of the audio file may be encoded into the QR code. After the user scans the encoded QR code, the audio resource may be accessed through a browser or a specific application. In the disclosed embodiment, the first information used to generate the QR code may include a URL or a non-URL, which may be adjusted according to actual needs.
[0025] S102. Based on a number of characters included in the first information, perform data processing on the first information to obtain second information; the data volume of the second information is smaller than the data volume of the first information.
[0026] Optionally, when the first information is information in the form of text, such as a URL, text information, etc., the characters can be directly obtained from the first information; when the first information is information in the form of non-text, such as a picture, audio, video, etc., the characters can be data obtained after recognizing the first information to obtain text.
[0027] Optionally, data processing methods may include multiple methods, such as simplifying and compressing data, extracting key information, using external link addresses, etc. By processing the first information, the amount of information used to generate the QR code can be reduced, thereby simplifying the generated QR code.
[0028] S103: Generate a QR code based on the second information, so that a user can access resources corresponding to the first information through the second information when scanning the QR code.
[0029] Optionally, when scanning the QR code, the user can recover the first information through the second information and then access the resources corresponding to the first information.
[0030] In the disclosed embodiments, the reduction in the data stored in the QR code can reduce the number of pixels in the QR code, making the QR code pattern more concise, clear and more readable, and also reducing the storage space occupied, thereby improving the scanning speed and accuracy of the scanning device, so that users can identify and read the QR code content more quickly. The reduction in the amount of information in the QR code can reduce the possibility of decoding errors or duplicate data due to excessive data volume, which is conducive to improving the stability and reliability of the QR code and ensuring that users can smoothly access the required information or services.
[0031] In a feasible embodiment, in S102, data processing is performed on the first information based on a number of characters included in the first information to obtain the second information, including executing at least one of the following steps A1 to A3 when it is determined that the character length of the first information is greater than a preset threshold: Step A1: Based on the levels of the characters included in the first information in the preset generation rules of the two-dimensional code, the first information is subjected to data simplification processing to obtain the second information.
[0032] Step A2: Based on the character frequency of each character in the first information, perform data compression processing on the first information to obtain second information.
[0033] Step A3: link the first information to an external link address, and use the external link address as the second information.
[0034] Optionally, when counting the character length of the first information, the characters included in the first information may be divided into valid characters and invalid characters.
[0035] Take the first information as URL as an example: in the URL, the URL consists of a protocol (https), a domain name, a path, a query string, and other parts. In the URL, the parameter part starts with a question mark (?), and an ampersand (&) is used to separate different parameters; each parameter consists of a key and a value, and the two are connected by an equal sign (=); wherein, considering that when multiple parameters need to be passed, the character length of the URL will increase significantly, the embodiment of the disclosure can set valid characters to include parameters, and non-valid characters to include characters used to separate parameters and connect parameters. When counting the character length of the first information, valid characters can be counted, and when the number of valid characters is greater than a preset threshold, it is determined that the character length of the first information is greater than the preset threshold. In an example, for a URL, valid characters can include variable characters, and non-valid characters are other characters in the characters constituting the URL except for valid characters; variable characters refer to different characters in different URLs, such as the parameter won (such as the work order number) may be different in different URLs. At this time, the character corresponding to the parameter won is a variable character, and the same domain name in different URLs can be regarded as a non-variable character.
[0036] Take the first information as an example: when the first information is processed based on characters, it is necessary to identify the image to obtain the characters recorded in the image. However, it is difficult to achieve 100% accuracy in character recognition. In order to improve the accuracy of the processing used to generate the two-dimensional code information, the characters recognized from the image can be distinguished to see whether they are valid, such as by analyzing the context information and other means to determine whether each character is a valid character; the characters recognized from the image can also be corrected. Exemplarily, there are some interfering lines in the image, resulting in errors, omissions or additions in the recognized characters. For example, the character factor recorded in the image may be underlined, and the character "f" therein may be recognized as "E", or the character "_" may be added. At this time, the recognized characters can be distinguished and corrected to see whether they are valid, and "E" can be corrected to "f", and "_" can be determined as a non-valid character.
[0037] In the embodiment of the present disclosure, data processing can be performed on the first information with a long character length, aiming to reduce the amount of information ultimately used to generate the QR code and simplify the QR code. Optionally, the data processing can be performed in at least one of the following ways: Method 1, information simplification: The principle of information simplification is to simplify, abstract or extract key information from the first information to shorten the information length in the QR code. Specifically, the characters can be graded based on the preset generation rules of the QR code, and data simplification can be performed based on the level of the characters. For example, the sentence "This clothes drying machine has a drying function", in which keyword analysis is performed on the sentence, and the keywords "clothes drying machine" and "drying" can be obtained. Therefore, the keywords can be set to the required first level, and other characters or words can be set to the non-required second level. Therefore, a complex sentence can be simplified into two simple words "clothes drying machine" and "drying". In one example, the preset generation rules of the QR code include multiple rules such as data encoding, error correction encoding, data layout, format information, positioning pattern, and color contrast. The above-mentioned sentence processing example can be a type of format information rule.
[0038] Method 2: Data compression: The principle of data compression is to use a data compression algorithm to encode the first information to compress the original information and reduce the amount of information used to generate the QR code. The data compression algorithm can be to use the frequency of occurrence of characters in the first information as a weight, generate a code by constructing a Huffman tree, and obtain a compression result with the shortest code length.
[0039] Method three, external link address: The overly long first information can be stored in a website (such as a URL), and the generated QR code can point to this website. After the user scans the QR code, the complete information can be obtained through network access. Exemplarily, the first information can be stored in the second information, and the second information is a short URL, and the second information points to the complete link (first information) on the external server. In the embodiment of the present disclosure, in order to simplify the URL in the QR code, a URL shortening service can be used to convert the long URL into a short URL, thereby reducing the complexity of the QR code and the space occupied.
[0040] The data compression method provided in the embodiment of the present disclosure is described in detail below.
[0041] In a feasible embodiment, in S102, based on a number of characters included in the first information, data processing is performed on the first information to obtain the second information, including steps B1 to B4: Step B1, traverse the characters in the first information, and determine the character frequency of each character based on the number of times each character appears.
[0042] Optionally, when counting character frequencies, count all different characters in the text (such as a URL) and their occurrence times. Assume that the original data "aaabcdacbb" corresponds to a string containing the character set {a,b,c,d}, and the frequency of each character is: a: 0.4, b: 0.3, c: 0.2, and d: 0.1 (a appears 4 times, b appears 3 times, c appears 2 times, and d appears 1 time).
[0043] The characters in the first information include all characters in the first information, or characters in the first information that are used to form the parameter part of the uniform resource locator URL. Optionally, in the embodiment of the present disclosure, considering that when the first information is a URL, the components that vary greatly and have a greater impact on the character length include query parameters, in order to improve data processing, data compression processing can be performed on the characters in the parameter part of the URL, that is, the data compression processing can obtain a URL that only encodes the parameter part, and generate a QR code based on the URL after the encoding of this part.
[0044] Step B2: constructing a binary tree with the characters as nodes based on the character frequencies.
[0045] Optionally, the generation of a binary tree depends on a specific representation method of the binary tree, such as a recursive algorithm, a traversal algorithm, an algorithm based on specific rules (such as a complete binary tree generation algorithm, other types of binary tree generation algorithms), a serialization / deserialization algorithm, etc. Exemplarily, the data compression algorithm used may be Huffman coding combined with LZ77 and LZ78 algorithms.
[0046] Optionally, in step B2, constructing a binary tree with the characters as nodes based on the character frequencies includes steps B21 to B22: Step B21: Generate a node for each character, and sort the nodes based on the character frequency to obtain an ordered set.
[0047] Step B22: Repeat the following operations for the nodes included in the ordered set until one node remains: merge the two nodes with the lowest character frequency to generate a new node.
[0048] Optionally, in the generated binary tree, the leaf nodes (i.e., the original nodes that have not been merged) include nodes corresponding to the characters that appear in the first information. For example, the original data VICTORIA includes a total of 8 characters, but only 7 types of characters, i.e., 7 leaf nodes. The corresponding ordered set is {V, C, T, O, R, A, I}. When merging nodes, two nodes can be merged at a time to balance the node weights of the generated binary tree. For example, if we merge node V and node C, we get node VC with a weight of 2, and get an ordered set {T, O, R, A, I, VC}; if we merge node T and node O, we get node TO with a weight of 2, and get an ordered set {R, A, I, VC, TO}; if we merge nodes R and A, we get node {RA} with a weight of 2, and get an ordered set {I, VC, TO, RA}; if we merge node I and node VC, we get node IVC with a weight of 4, and get an ordered set {TO, RA, IVC}; if we merge node TO and node RA, we get node TORA with a weight of 4, and get an ordered set {IVC, TORA}; if we merge node IVC and node TORA, we get node IVCTORA with a weight of 8 (that is, the root node). At this point, the binary tree constructed is as follows: Figure 2 shown.
[0049] Optional, by Figure 2 From the example shown, it can be found that the nodes with the lowest character frequency may include more than two nodes. For example, the character frequencies (i.e., weights) of nodes V, C, T, O, R, and A are all the lowest 1, and two of them can be randomly selected to be merged. Optionally, in order to improve the accuracy of decoding, the nodes can also be sorted based on weights in a certain sorting method, such as sorting the nodes with the same value according to the order of the 26 letters, the number of strokes, etc. Optionally, when sorting, the nodes with the smaller number of characters in the same node are sorted first, such as nodes I, VC, TO, and RA, whose weights are all 2, and node I is sorted before other nodes corresponding to two characters.
[0050] Step B3: assign a corresponding code to each character from the root node to the leaf node of the binary tree.
[0051] Optionally, when assigning a corresponding code to each character, it is done for each character, such as the example in step B2 above, which includes 7 characters, then the code corresponding to each character can be obtained; wherein, character I appears twice in the original data, but character I only corresponds to one code.
[0052] Optionally, in step B3, assigning a corresponding code to each character from the root node to the leaf node of the binary tree includes performing the following operations from step B31 to step B32 for each character: Step B31, starting from the root node of the binary tree, traverse each layer of nodes of the binary tree until the leaf node of the binary tree to determine the path of the character.
[0053] Step B32: Determine the encoding of the character based on the preset encoding allocation rule and the path of the character.
[0054] The preset allocation rule of the code includes: if the next layer node is located on the left side of the parent node, a first value is allocated; if the next layer node is located on the right side of the parent node, a second value is allocated.
[0055] For example, the first value is 0 and the second value is 1 for illustration (the values of the values are only an example, which can be adjusted according to actual needs, and the embodiments of the present disclosure are not limited to this): Figure 3 In the example shown, when determining the encoding of the character C, the path of the character is left-left-right, then the encoding of the character C can be 001; when determining the encoding of the character O, the path of the character is right-left-right, then the encoding of the character O can be 101, and so on, the encodings corresponding to the 7 characters can be obtained.
[0056] Optional, such as Figure 3 As shown, the root node is IVCTORA, which, when serving as a parent node, includes two child nodes, namely, node IVC and child node TORA; and in the binary tree, there are 7 leaf nodes, namely, VCTORAI.
[0057] Step B4: Replace the characters in the first information with the corresponding codes to obtain the second information.
[0058] For example, Figure 2 and Figure 3 In the example shown, for the original data VICTORIA, the second information 000 111 001 100 101 110 01 111 can be obtained by replacement.
[0059] The above steps B1 to B4 are described below with a feasible example.
[0060] Step B1: Count character frequencies Traverse the text or data to be encoded and count the number of times each character (or symbol) appears, that is, the frequency, also known as the character frequency. Store the characters and their frequencies in a list, or use a priority queue (min heap) to optimize subsequent steps.
[0061] Example: Assume the text is "this is an example for huffman encoding", the character frequencies are as follows (sorted by character): 'a': 3-'c': 1-'d': 1-'e': 3-'f': 1-'g': 1-'h': 2-'i': 3-'l': 1-'m': 2-'n': 4-'o': 2-'p': 1-'s': 2-' ': 6-'t': 1-'x': 1.
[0062] Optionally, the representation of character frequency may be normalized so as to be simply represented as the number of occurrences. The above example is a representation of the number of occurrences.
[0063] Step B21: Construct a minimum heap Add each character and its frequency as a node to the minimum heap, and sort the nodes in the heap by frequency.
[0064] Step B22: Merge nodes Repeat the following steps until there is only one node left in the minimum heap (the root of the Huffman tree): Take the two nodes with the lowest frequencies (the least important characters at the moment) from the heap, create a new internal node whose frequency is the sum of the frequencies of these two nodes, and make these two nodes the children of the new node. Add the new node to the heap.
[0065] The example build process: Initial heap (sorted by frequency): ['c','d','g','l','p','t','x','h','m','o','s','a','e','i','n',' ']. Merge 'c' and 'd' to get a new node 'cd' (frequency 2), and the heap is updated to ['g','l','p','t','x','h','m','o','s','cd','a','e','i','n',' ']. Repeat the merging until there is only one node left (assumed to be the root node).
[0066] Step B3: Assign codes from root node to leaf nodes Starting from the root node, assign '0' to the left and '1' to the right. For each leaf node (i.e. the original character), record the path (code) from the root node to the leaf node.
[0067] Encoding in the example: Assuming that the final Huffman tree structure has been constructed, the character 'i' (assuming the path is left-left-left) is encoded as '000'; for the character ' ' (space), assuming the path is right-right-right-right-right-right, its encoding is '111111'.
[0068] Step B4: Encode the text Using the generated Huffman coding table, replace each character in the original text with its corresponding encoding.
[0069] Example: Original text: "i " (i and space), encoded text: "000 111111".
[0070] In a feasible embodiment, the provided method further includes S104 to S105: S104. Receive an access request sent by a user when scanning the QR code, and decode the second information carried in the access request based on a pre-stored binary tree structure and a coding table to obtain the first information; the binary tree structure and the coding table are generated based on the characters in the first information.
[0071] S105: Display resources corresponding to the first information.
[0072] Optionally, the data compression operation performed through the above steps B1 to B4 can obtain a string that seems meaningless after compression. After a QR code is generated based on the string, the user can scan the QR code and decompress (decode) the second information using a pre-stored binary tree structure and coding table on the IOT server to restore the original data (such as obtaining the complete first information). At this time, the user's perception is that the corresponding resource of the first information is accessed by scanning the QR code.
[0073] Optionally, in Huffman coding, the key is usually a character or symbol in the original data, and the value is the Huffman code corresponding to these characters or symbols. These key-value pairs are usually stored in the form of a coding table, which can be an array, a hash table, or other data structure, depending on the implementation.
[0074] The following is a detailed description of the information simplification method provided in the embodiments of the present disclosure.
[0075] In a feasible embodiment, in S102, based on a number of characters included in the first information, data processing is performed on the first information to obtain the second information, including steps C1 to C3: Step C1, obtaining parameter information in the first information, where the first information includes a URL.
[0076] Step C2: based on the preset generation rule of the QR code, determine the level of each parameter in the parameter information; the level includes a first level corresponding to the mandatory parameters and a second level corresponding to the non-mandatory parameters.
[0077] Step C3: Generate second information based on the parameters of the first level.
[0078] Among them, for the same first information, there is an association relationship between the first-level parameters and the second-level parameters.
[0079] For example, the URL is used for illustration: https: / / saas-help-uat.keyoo.com / productGuide / index.html?won=1200096721&model=GW-1295&mc=310211286001&pk=a14P0bNnVGK&mac=F2500F02C0A5 The parameter information is explained as follows: https: / / saas-help-uat.keyoo.com / productGuide / index.html is the basic URL. In the data processing of the first information, considering that the basic URL has little influence on the character length, in some examples, in order to reduce the computational complexity of data processing and improve the accuracy of the processing results, the basic URL may not be simplified.
[0080] won is the work order number, a total of 10 digits, pure digital information, the first 2 digits distinguish the order type, the last 8 digits are the serial number. Generated by the SAP system, the work order number for product production is: 1200096721.
[0081] model is the product model, for example: GW-1295.
[0082] mc is the material code, a total of 12 digits, pure digital information, used to distinguish the material code corresponding to the equipment. Generated by the SAP system, the corresponding material code is 310211286001.
[0083] pk is the product's Key (ProductKey), including 11 bits, one of the device certificate information. When a product is created, the Life IoT platform issues a globally unique identifier for the product, for example: a14P0bNnVGK.
[0084] mac is the Bluetooth MAC address, which is 12 digits in total and is a combination of letters A to F and numbers 0 to 9, and complies with the definition rules of the Bluetooth Technology Alliance. For example: F2500F02C0A5.
[0085] SN is the unique code of the device, such as MAT0100399240430000016. The SN code is not included in the URL example above. In one example, when accessing the management interface of a device, the URL may include the SN parameter; when accessing a normal web page, the URL may not include the SN parameter.
[0086] Optionally, when simplifying information, each parameter information can be divided into levels. For example, when accessing a device, the SN code is a mandatory parameter (it can identify the unique device that needs to be accessed), and the parameter can be set to the first level, while mac, pk, etc. are non-mandatory parameters, and the parameters can be set to the second level. Based on the level division, only the first-level parameters can be stored in the QR code, that is, the second information only includes parameters of the first level. Then, when the user scans the QR code generated based on the second information, the other parameters of the second level can be automatically associated in the IOT server according to the first-level parameter SN code to obtain the complete first information. Specifically, the IOT management background can be associated with the SAP system, and the relevant information fields in the first information can be queried through the first-level parameters.
[0087] Optionally, the setting of parameter level is related to the characteristics of the URL being accessed, and the higher the level, the more unique the parameter indication is. For example, in a URL, two different parameters can be used to indicate a resource to be accessed, and the level of the two parameters can be set to the first level, and the level of the other parameters can be set to the second level.
[0088] In a feasible embodiment, generating a two-dimensional code based on the second information in S103 includes steps D1 to D2: Step D1: Generate a data codeword and an error correction codeword of the second information based on the version and error correction level of the two-dimensional code.
[0089] The version and / or the error correction level are related to the data processing method.
[0090] Step D2: Based on the preset generation rule of the two-dimensional code, the data codewords and the error correction codewords are arranged in a two-dimensional code matrix to generate a final two-dimensional code.
[0091] Optionally, the version of the QR code refers to the size of the QR code, which can determine the number of grids in the QR code matrix and affect the amount of information that the QR code can store. Among them, the version of the QR code ranges from 1-40, and each additional version increases the horizontal and vertical dimensions of the QR code by 4 grids. Exemplarily, the calculation formula for the QR code grid is (V-1)*4+21, where V is the version number, such as a QR code with version number 1, which consists of 21*21 grids, and a QR code with version number 2, which consists of 25*25 grids. It can be understood that the higher the version of the QR code, the larger the size of the QR code, and the more data that can be stored.
[0092] Optionally, the error correction level may include four levels, from low to high, namely L (low), M (medium), Q (higher), and H (higher). Different error correction levels provide different numbers of error correction codewords, and the presence of error correction codewords can improve the fault tolerance of the QR code.
[0093] Optionally, in the data used to generate the QR code, the data codeword is used to store actual data information, and the error correction codeword is used to restore information when part of the QR code is damaged.
[0094] In one example, when the data processing method is to simply use an external link address, since the external link address is relatively concise, a lower version of the QR code can be used. Accordingly, in the embodiment of the present disclosure, considering that the information indicated by the generated QR code is relatively concise, partial damage (such as the lack of a certain information) has a greater impact on the accuracy of QR code recognition. Therefore, when determining to use a lower version of the QR code based on a relatively simple data processing method, a higher error correction level can be set to ensure the accuracy of QR code recognition while reducing the amount of data used to generate the QR code.
[0095] Optionally, the data codeword can be obtained based on the second information by information encoding, binary representation, data grouping and formatting, etc. The error correction codeword can be generated by polynomial division, the error correction level determines the number of error correction codewords, and different error correction levels correspond to different error correction capabilities.
[0096] Among them, when the data codewords and error correction codewords are obtained, they can be placed alternately in the two-dimensional code matrix according to the generation rules of the two-dimensional code, so as to ensure that when the two-dimensional code is partially blocked or damaged, the code reader can still recover enough data codewords through the error correction codewords to decode the original data.
[0097] It should be noted that in the optional embodiments of the present disclosure, the information involved (such as URLs, QR codes and other related data), when the above embodiments of the present disclosure are applied to specific products or technologies, needs to obtain permission or consent from the user, and the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions. In other words, if the embodiments of the present disclosure involve data related to the object, these data need to be obtained with the authorization and consent of the object and in compliance with the relevant laws, regulations and standards of the country and region.
[0098] An embodiment of the present disclosure provides a two-dimensional code information processing device, which may include: an acquisition module, a data processing module, and a generation module.
[0099] Among them, the acquisition module is used to acquire first information used to generate a QR code; the data processing module is used to perform data processing on the first information based on a number of characters included in the first information to obtain second information; the data volume of the second information is smaller than the data volume of the first information; the generation module is used to generate a QR code based on the second information, so that the user can access the resources corresponding to the first information through the second information when scanning the QR code.
[0100] The device of the embodiments of the present disclosure can execute the method provided by the embodiments of the present disclosure, and the implementation principles are similar. The actions performed by each module in the device of each embodiment of the present disclosure correspond to the steps in the method of each embodiment of the present disclosure. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.
[0101] The modules involved in the embodiments described in the present disclosure may be implemented by software. The name of the module does not limit the module itself in some cases. For example, the acquisition module may also be described as a "module for acquiring the first information for generating a QR code", "a first module", etc.
[0102] In the embodiment of the present disclosure, an electronic device is provided, which can be a smart lock or a terminal device. The host of the device includes a memory, a processor and a computer program stored in the memory. The processor executes the above computer program to implement the steps of the information processing method of the QR code. Compared with the related art, the following can be achieved: when the first information (such as URL) used to generate the QR code is obtained, the embodiment of the present disclosure can perform data processing on the first information based on several characters included in the first information to obtain the second information, and generate the QR code based on the second information, so that the user can access the resources corresponding to the first information through the second information when scanning the QR code; wherein the data volume of the second information is less than the data volume of the first information. The implementation of the present disclosure can reduce the amount of information of the URL used to generate the QR code, simplify the pattern of the QR code and reduce the density of the QR code pattern, improve the efficiency of scanning the QR code to access resources and the recognition accuracy of the QR code.
[0103] In an alternative embodiment, an electronic device is provided, such as Figure 4 As shown, Figure 4The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present disclosure.
[0104] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present invention. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0105] The bus 4002 may include a path to transmit information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0106] The memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.
[0107] The memory 4003 is used to store the computer program for executing the embodiment of the present disclosure, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the above method embodiment.
[0108] Among them, electronic devices include but are not limited to: cloud platforms and IOT servers.
[0109] An embodiment of the present disclosure provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.
[0110] The embodiments of the present disclosure also provide a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiments when executed by a processor.
[0111] The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than that shown or described in the text.
[0112] It should be understood that, although the flowchart of the embodiment of the present disclosure indicates each operation step by arrows, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present disclosure, the implementation steps in each flowchart can be executed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage in these sub-steps or stages can also be executed at different times. In scenarios with different execution times, the execution order of these sub-steps or stages can be flexibly configured according to demand, and the embodiment of the present disclosure does not limit this.
[0113] The above is only an optional implementation method for some implementation scenarios of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the scheme of the present disclosure, other similar implementation methods based on the technical ideas of the present disclosure are also within the protection scope of the embodiments of the present disclosure.
Claims
1. A two-dimensional code information processing method, characterized in that: include: Acquire first information for generating a QR code; Based on a number of characters included in the first information, data processing is performed on the first information to obtain second information; The data volume of the second information is smaller than the data volume of the first information; A QR code is generated based on the second information, so that a user can access resources corresponding to the first information through the second information when scanning the QR code.
2. The method according to claim 1, characterized in that The step of performing data processing on the first information based on a number of characters included in the first information to obtain the second information includes, when it is determined that the character length of the first information is greater than a preset threshold, performing at least one of the following: Based on the levels of the characters included in the first information in the preset generation rule of the two-dimensional code, the first information is subjected to data simplification processing to obtain second information; Based on the character frequency of each character in the first information, the first information is subjected to data compression processing to obtain second information; The first information is linked to an external link address, and the external link address is used as the second information.
3. The method according to claim 1, characterized in that The step of performing data processing on the first information based on a number of characters included in the first information to obtain the second information includes: Traversing the characters in the first information, and determining the character frequency of each character based on the number of times each character appears; Constructing a binary tree with the characters as nodes based on the character frequencies; From the root node to the leaf node of the binary tree, assign a corresponding code to each character; Replacing characters in the first information with codes corresponding thereto to obtain second information; The characters in the first information include all characters in the first information, or characters in the first information used to form a parameter part of a uniform resource locator (URL).
4. The method according to claim 3, characterized in that The step of constructing a binary tree with the characters as nodes based on the character frequencies includes: Generate a node for each character, and sort the nodes based on the frequency of the character to obtain an ordered set; Repeat the following operations for the nodes included in the ordered set until one node remains: merge the two nodes with the lowest character frequency to generate a new node.
5. The method according to claim 3, characterized in that: The step of assigning a corresponding code to each character from the root node to the leaf node of the binary tree includes performing the following operations for each character: Starting from the root node of the binary tree, traverse each layer of nodes of the binary tree until the leaf node of the binary tree to determine the path of the character; Determine the encoding of the character based on a preset allocation rule of the encoding and the path of the character; The preset allocation rule of the code includes: if the next layer node is located on the left side of the parent node, a first value is allocated; if the next layer node is located on the right side of the parent node, a second value is allocated.
6. The method according to any one of claims 3 to 5, characterized in that The method further comprises: receiving an access request sent by a user when scanning the QR code, decoding second information carried in the access request based on a pre-stored binary tree structure and a coding table to obtain the first information; the binary tree structure and the coding table are generated based on characters in the first information; Resources corresponding to the first information are displayed.
7. The method according to claim 1 or 2, characterized in that: The step of performing data processing on the first information based on a number of characters included in the first information to obtain the second information includes: Acquire parameter information in the first information, where the first information includes a URL; Based on a preset generation rule of the QR code, determining the level of each parameter in the parameter information; the level includes a first level corresponding to a mandatory parameter and a second level corresponding to a non-mandatory parameter; generating second information based on the parameters of the first level; Among them, for the same first information, there is an association relationship between the first-level parameters and the second-level parameters.
8. The method according to claim 1 or 2, characterized in that: The generating a two-dimensional code based on the second information includes: Based on the version and error correction level of the two-dimensional code, generate a data codeword and an error correction codeword of the second information; Based on a preset generation rule of the two-dimensional code, the data codewords and the error correction codewords are arranged into a two-dimensional code matrix to generate a final two-dimensional code; The version and / or the error correction level are related to the data processing method.
9. An electronic device, characterized in that: The electronic device comprises at least one transceiver and at least one processor coupled to the at least one transceiver, wherein the at least one processor is configured to perform the steps of the method according to any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.