Graphic code generation method and equipment

By dividing data segments and calculating the error tolerance rate of the original text content, and encoding the QR code with the display area size, the problem of excessive QR code density affecting the recognition rate is solved, and the recognition accuracy is improved.

CN119150903APending Publication Date: 2024-12-17RAJAX NETWORK &TECHNOLOGY (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410963876.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-17
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

When generating QR codes, the original text input by the user is long and the characters are many, resulting in the generated QR code density which affects the recognition rate.

Method used

By dividing the original text content in data segments, the adapted graphic code version and fault tolerance are calculated, and the target graphic code is encoded according to the size of the display area to generate the target graphic code.

Benefits of technology

Dynamically determine the graphic code version and fault tolerance, generate graphic codes with moderate density, and improve the recognition accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150903A_ABST
    Figure CN119150903A_ABST
Patent Text Reader

Abstract

The invention provides a graphic code generation method and equipment, and the method comprises the steps: carrying out the data segment division of original text content for generating a target graphic code, and obtaining a data segment list; calculating a target graphic code version matched with the original text content based on the data segment list; calculating a target error-tolerant rate matched with the original text content based on the data segment list, the target graphic code version and scene parameters used for representing an applicable scene of the target graphic code; and encoding the original text content according to the target graphic code version and the target error-tolerant rate by referring to the size of the display area of the target graphic code to generate the target graphic code. As the graphic code version and the error-tolerant rate of the original text content can be dynamically determined, compared with the related technology, the density of the graphic code generated by adopting the scheme of the invention is moderate, and the accuracy of subsequent recognition of the generated graphic code is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to a method and device for generating a graphic code. Background Art

[0002] Two-dimensional code / two-dimensional bar code (2-dimensional bar code) uses certain geometric shapes to record data symbol information in black and white distributed in a plane (two-dimensional direction) according to a certain pattern. It can be automatically read by image input equipment or photoelectric scanning equipment to realize automatic information processing.

[0003] Currently, when generating a QR code, if the original text input by the user is long and contains many characters, the density of the generated QR code will be relatively high, which will affect the recognition rate of the QR code. Summary of the invention

[0004] The present application proposes a method and device for generating a graphic code, which can alleviate the technical problem in the related art that when the original text input by the user is long and has many characters, the density of the generated graphic code is high, which affects the recognition rate.

[0005] The first embodiment of the present application proposes a method for generating a graphic code, comprising:

[0006] Dividing the original text content used to generate the target graphic code into data segments to obtain a data segment list;

[0007] Calculating a target graphic code version matching the original text content based on the data segment list;

[0008] Calculating a target error tolerance rate matching the original text content based on the data segment list, the target graphic code version, and a scene parameter for characterizing an applicable scene of the target graphic code;

[0009] Referring to the size of the display area of ​​the target graphic code, the original text content is encoded according to the target graphic code version and the target error tolerance rate to generate the target graphic code.

[0010] In one or more embodiments, dividing the original text content into data segments to obtain a data segment list includes:

[0011] Determining the text type of the original text content;

[0012] Obtain the length of a single data segment corresponding to the text type;

[0013] The original text content is divided into data segments according to the length of the single data segment to obtain the data segment list.

[0014] In one or more embodiments, calculating a target graphic code version matching the original text content based on the data segment list includes:

[0015] Obtaining an adapted graphic code version from a plurality of preset graphic code versions, wherein the length of data bits that can be accommodated by the graphic code corresponding to the adapted graphic code version and the preset initial fault tolerance rate is greater than or equal to a final data bit length determined based on the adapted graphic code version and the data segment list;

[0016] The adapted graphic code version is used as the target graphic code version.

[0017] In one or more embodiments, obtaining an adapted graphic code version from a plurality of preset graphic code versions includes:

[0018] For an Nth graphic code version among the multiple graphic code versions, calculating a current length of data bits that can be accommodated by the graphic code corresponding to the Nth graphic code version and the preset initial error tolerance rate;

[0019] In the case where the current length is less than the current data bit length determined based on the Nth graphic code version and the data segment list, updating N=N+1, and returning to the step of calculating the current length of the data bits that can be accommodated by the graphic code corresponding to the Nth graphic code version and the preset initial error tolerance rate;

[0020] In the case that the current length is greater than or equal to the current data bit length, the Nth graphic code version is used as the adapted graphic code version.

[0021] In one or more embodiments, the method further comprises:

[0022] In the case where the Nth graphic code version is the smallest graphic code version among the multiple graphic code versions and the current length is less than the current data bit length, calling a preset short link conversion service to shorten the length of the original text content to obtain shortened original text content;

[0023] In the case where the current length is less than the data bit length determined based on the minimum graphic code version and the shortened original text content, performing the step of updating N=N+1;

[0024] In the case that the current length is greater than or equal to the current data bit length determined based on the minimum graphic code version and the shortened original text content, the minimum graphic code version is used as the adapted graphic code version.

[0025] In one or more embodiments, the method further comprises:

[0026] In the case that the current length is greater than or equal to the current data bit length determined based on the minimum graphic code version and the shortened original text content, a mapping relationship between the shortened original text content and the original text content is established and saved.

[0027] In one or more embodiments, calculating a target error tolerance rate matching the original text content based on the data segment list, the target graphic code version, and a scene parameter for characterizing an applicable scene of the target graphic code includes:

[0028] Querying a preconfigured mapping relationship to obtain a minimum error tolerance rate corresponding to the graphic code carrier and the usage scenario included in the scenario parameters;

[0029] When the minimum fault tolerance rate is less than the initial preset fault tolerance rate, the minimum fault tolerance rate is used as the target fault tolerance rate;

[0030] When the minimum fault tolerance rate is greater than or equal to the initial preset fault tolerance rate, an adaptive fault tolerance rate is selected from multiple fault tolerance rates, and the length of data bits that can be accommodated by the graphic code corresponding to the target graphic code version and the adaptive fault tolerance rate is less than the data bit length determined by the target graphic code version and the data segment list; the adaptive fault tolerance rate is used as the target fault tolerance rate.

[0031] In one or more embodiments, referring to the size of the display area of ​​the target graphic code, encoding the original text content according to the target graphic code version and the target error tolerance rate to generate the target graphic code includes:

[0032] Determining a scaling base based on the size of the display area; and calculating a module parameter for characterizing a distribution density of a graphic code data module based on the target graphic code version and the target error tolerance rate;

[0033] Calculating the ratio of the scaling base and the module parameter to obtain a scaling factor of the graphic code image;

[0034] The target graphic code is drawn based on the module parameters and the graphic code scaling factor.

[0035] The second embodiment of the present application provides a graphic code generating device, including:

[0036] A division module, used for dividing the original text content used to generate the target graphic code into data segments to obtain a data segment list;

[0037] A first calculation module, configured to calculate a target graphic code version matching the original text content based on the data segment list;

[0038] A second calculation module, configured to calculate a target error tolerance rate matching the original text content based on the data segment list, the target graphic code version, and a scene parameter for characterizing an applicable scene of the target graphic code;

[0039] A generating module is used to refer to the size of the display area of ​​the target graphic code, encode the original text content according to the target graphic code version and the target error tolerance rate, and generate the target graphic code.

[0040] A third aspect of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect.

[0041] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the program is executed by a processor to implement the method described in the first aspect.

[0042] The fifth aspect of the present application provides a computer program product, including a computer program / instruction, which implements the method described in the first aspect when executed by a processor.

[0043] The technical solution provided in the embodiments of the present application has at least the following technical effects or advantages:

[0044] The graphic code generation method provided in this embodiment includes dividing the original text content used to generate the target graphic code into data segments to obtain a data segment list; calculating the target graphic code version matching the original text content based on the data segment list; calculating the target fault tolerance matching the original text content based on the data segment list, the target graphic code version and the scene parameters used to characterize the applicable scene of the target graphic code; referring to the size of the display area of ​​the target graphic code, encoding the original text content according to the target graphic code version and the target fault tolerance to generate the target graphic code. Since the graphic code version and the fault tolerance of the original text content can be determined dynamically, the density of the graphic code generated by the solution of this application is relatively moderate compared to the related art, which helps to improve the accuracy of the subsequent recognition of the generated graphic code.

[0045] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] By reading the detailed description of the preferred embodiment below, various other advantages and benefits will become clear to those of ordinary skill in the art. The accompanying drawings are only used for the purpose of illustrating the preferred embodiment and are not considered to be limitations of the present application. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings.

[0047] In the attached picture:

[0048] Figure 1 A schematic diagram showing an application scenario provided by an embodiment of the present application;

[0049] Figure 2 A schematic diagram of a flow chart of a method for generating a graphic code provided in an embodiment of the present application is shown;

[0050] Figure 3 Another schematic diagram of a flow chart of a method for generating a graphic code provided in an embodiment of the present application is shown;

[0051] Figure 4 A schematic diagram showing the structure of a graphic code generating device provided in an embodiment of the present application is shown;

[0052] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present application is shown;

[0053] Figure 6 A schematic diagram of a storage medium provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0054] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0055] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by technicians in the field to which this application belongs.

[0056] In order to facilitate understanding of the embodiments of the present application, some terms involved in the present application are explained below.

[0057] QR code density: It is affected by the size and distance of each square of the same color. The smaller the square of the same color and the closer the distance between two squares of the same color, the higher the density, and the lower the recognition speed and ratio.

[0058] Version: Also known as the QR code specification, there are different versions from 1 to 40. Each version has its own code element structure (modules). Different versions have different QR code capacity. The higher the version, the larger the QR code capacity, that is, the more content it can carry. In layman's terms, different versions store different amounts of data. For example, version 1 is a 21*21 matrix, version 2 is a 25*25 matrix, version 3 is a 29*29 matrix, and so on. Each additional version adds 4 code element structures on each side compared to the previous version.

[0059] Error tolerance rate: The ratio of dirty or damaged codes that can be tolerated, and the QR code can automatically restore data at this ratio. Error tolerance rate can also be called error correction rate, which means that the QR code can still be scanned normally after being blocked, and the maximum area that can be blocked is the error tolerance rate. The higher the error tolerance rate, the larger the part of the QR code image that can be blocked. The error tolerance rate has 4 levels, and users can choose the corresponding level according to the usage environment. As the level is increased, the error correction capability is also improved accordingly, but as the amount of data will increase, the code size will also increase.

[0060] Image size (image dimensions): The size of an image, expressed in pixels. In actual applications, the size of a QR code depends on how much content the QR code contains and what the content is. If it is text information, it needs to be larger, because the more characters a QR code contains, the denser the QR code matrix will be. When the density of the QR code is relatively high, it needs to be printed larger so as not to affect the scanning effect.

[0061] Encoding: Encode the text content in the form of a QR code.

[0062] Decode: Decode the QR code to obtain the content.

[0063] A QR code, also known as a two-dimensional barcode, uses certain geometric shapes to distribute black and white graphics in a plane (in two-dimensional direction) according to a certain pattern to record data symbol information. The code is compiled by cleverly using the concept of "0" and "1" bit streams that form the basis of the computer's internal logic, and uses several geometric shapes corresponding to binary to represent textual numerical information.

[0064] In the related art, in a method for generating a QR code, a unique version, fault tolerance rate and other parameters affecting the density of the QR code are pre-set in the software code for generating the QR code. These parameters will not change accordingly due to the different lengths of the original text content input by the user. Therefore, no matter what the length of the original text content input by the user is, the version and fault tolerance rate used in the process of generating the QR code, which are parameters affecting the density of the QR code, are the same. This often results in the density of the generated QR code being too high, affecting the recognition rate and recognition speed of the QR code.

[0065] In another method for generating a QR code, after the user inputs the original text content, the user specifies the version, fault tolerance rate and other parameters that affect the density of the QR code. Limited by the user's knowledge, the user himself may not understand the impact of different versions or different fault tolerance rates on the density of the QR code. Therefore, even if the user is supported to specify the version, fault tolerance rate and other parameters that affect the density of the QR code, the density of the QR code finally generated is not appropriate, and ultimately affects the recognition rate and recognition speed of the QR code.

[0066] In order to solve the technical problems existing in the related art, the embodiment of the present application provides a method and device for generating a graphic code, the method comprising dividing the original text content used to generate the target graphic code into data segments to obtain a data segment list; calculating the target graphic code version matching the original text content based on the data segment list; calculating the target fault tolerance matching the original text content based on the data segment list, the target graphic code version and the scene parameters used to characterize the applicable scene of the target graphic code; referring to the size of the display area of ​​the target graphic code, encoding the original text content according to the target graphic code version and the target fault tolerance to generate the target graphic code. Since the graphic code version and the fault tolerance of the original text content can be determined dynamically, the density of the graphic code generated by the scheme of the present application is relatively moderate compared with the related art, which helps to improve the accuracy of the subsequent recognition of the generated graphic code.

[0067] refer to Figure 1 , Figure 1 An application scenario involved in the embodiment of the present application is shown. Figure 1 As shown, the application scenarios corresponding to the graphic code generation method provided in the embodiment of the present application may include: a cloud server 10 and an electronic device 20.

[0068] The electronic device 20 can be used as the execution subject of the embodiment of the present application. The electronic device 20 can be implemented as a server, a server cluster, a terminal device, etc. The electronic device 20 can display a software interaction interface to the user based on the user's operation request. A text content input box is displayed on the software interaction interface, and the user can enter the original text content that needs to generate a QR code through the text content input box. After obtaining the original text content input by the user, the electronic device 20 sends the original content to the cloud server 10. It should be understood that the original text content here includes but is not limited to any content that can extract text to generate a QR code, such as address links, pictures, text, etc.

[0069] The cloud server 10, which may also be referred to as a "cloud" or a "cloud platform", may be used to receive and store original text content from the electronic device 20, segment the original text content, calculate a target graphic code version and a target error tolerance, and finally generate a target graphic code. In the application, the original content includes but is not limited to hypertext links, pictures, etc.

[0070] A method, device, storage medium and program product for generating a graphic code according to an embodiment of the present application will be described below in conjunction with the accompanying drawings.

[0071] See also Figure 2 , Figure 2 A schematic diagram of a flow chart of a method for generating a graphic code according to an embodiment of the present application is shown as follows: Figure 2 As shown, the method may include the following steps:

[0072] Step 201: divide the original text content used to generate the target graphic code into data segments to obtain a data segment list.

[0073] In this embodiment, the original text content may include pure digital content, mixed text and digital content, or pure text content. It should be understood that the text here may include a letter string and / or a Chinese character string, which is not specifically limited in this embodiment.

[0074] In this embodiment, dividing the original text content into data segments refers to dividing the original text content according to the set text length, and dividing the original text content into multiple continuous data segments. The set text length can be manually pre-configured or automatically determined in real time.

[0075] After the real-time automatic determination, an optional implementation is given below. Specifically, step 201 may include the following steps:

[0076] Determine the text type of the original text content;

[0077] Get the length of a single data segment corresponding to the text type;

[0078] The original text content is divided into data segments according to the length of a single data segment to obtain a data segment list.

[0079] In this embodiment, the text type includes but is not limited to a pure numeric type, a mixed type of letters and numbers, and a pure text type. It should be understood that when the original text content is pure numeric content, the text type of the original text content is a pure numeric type; when the original text content is a mixed type of letters and numbers, the text type of the original text content is a mixed type of letters and numbers; when the original text content is a pure text type, the text type of the original text content is a pure text type.

[0080] In this embodiment, the length of a single data segment refers to the minimum division unit of the text content of the text type, and the length of a single data segment can be expressed in bits. In the application, the length of the single data segment corresponding to each text type can be pre-configured. For example, the length of the single data segment of a pure digital type can be configured to be 8 bits, the length of the single data segment of a mixed text and digital type can be configured to be 5 bits, the length of the single data segment of a pure text type can be configured to be 10 bits, and so on. It should also be understood that while configuring the length of the single data segment corresponding to each text type, the corresponding relationship between the text type and the corresponding single data segment length should also be stored, so that after determining the text type of the original text content, the length of the single data segment corresponding to the text type of the original text content can be obtained by querying the corresponding relationship.

[0081] In this embodiment, when the original text content is divided into data segments according to the length of a single data segment, each data segment is obtained by dividing it one by one from the first text of the original text content with the length of a single data segment as a unit. For example, the original text content is "I love my home and I love my motherland". In this original text content, each character occupies 8 bits. Assuming that the length of a single data segment corresponding to the original text content is 16 bits, then I love, my, my home, I love me, my motherland and my country are each a data segment.

[0082] Step 202: Calculate a target graphic code version that matches the original text content based on the data segment list.

[0083] In this embodiment, an initial error tolerance rate is preset, and the target graphic code version can be determined based on the initial error tolerance rate.

[0084] In one or more embodiments, step 202 may include the following steps:

[0085] Obtaining an adapted graphic code version from a plurality of preset graphic code versions, wherein the length of data bits that can be accommodated by the graphic code corresponding to the adapted graphic code version and the preset initial fault tolerance rate is greater than or equal to the final data bit length determined based on the adapted graphic code version and the data segment list;

[0086] The adapted graphic code version is used as the target graphic code version.

[0087] It should be understood that the calculation of the length of data bits that the graphic code corresponding to the graphic code version and the error tolerance rate can accommodate based on the graphic code version and the error tolerance rate is a technology that has been disclosed in the relevant technology. To avoid redundancy, it will not be explained in detail here.

[0088] The final data bit length determined by the adapted graphic code version and the data segment list = the sum of the data bit length represented by the adapted graphic code version, the data bit length corresponding to the data segment list and the preset length threshold. In the application, the preset length threshold can be preset manually based on experience, such as setting the preset length threshold = 4.

[0089] Among them, the data bit length corresponding to the data segment list = the sum of the data bit lengths of each data segment. Still referring to the example of the original text content of "I love my home and I love my motherland" mentioned above, the data segment list obtained by dividing this original text content is I love, my, my home, I love me, my motherland and country, that is, this data segment list includes six data segments, so the data bit length corresponding to this data segment list = 6*16 = 96 bits. Here, it is applied that although the length of the last data segment in the data segment list is 8 bits, which is less than 16 bits, when calculating the data segment list, it is still calculated as 16 bits.

[0090] In one or more embodiments, obtaining an adapted graphic code version from multiple graphic code versions in a traversal manner, specifically, obtaining an adapted graphic code version from multiple preset graphic code versions may include the following steps:

[0091] For an Nth graphic code version among the multiple graphic code versions, calculating a current length of data bits that can be accommodated by the graphic code corresponding to the Nth graphic code version and a preset initial error tolerance rate;

[0092] When the current length is less than the current data bit length determined based on the Nth graphic code version and the data segment list, N=N+1 is updated, and the step of calculating the current length of the data bits that can be accommodated by the graphic code corresponding to the Nth graphic code version and the preset initial error tolerance rate is returned;

[0093] When the current length is greater than or equal to the current data bit length, the Nth graphic code version is used as the adapted graphic code version.

[0094] Wherein N is a positive integer.

[0095] In the application, the traversal starts from the minimum graphic code version among multiple graphic code versions by default. When judging the minimum graphic code, if the current length calculated based on the minimum graphic code version is less than the current data bit length, the original text content can be shortened first, and then re-judged whether the minimum graphic code version meets the requirements based on the shortened original text content. The original text content is shortened for the minimum graphic code version to match the minimum graphic code version with the original text content as much as possible, which helps to achieve the requirements of finding a graphic code version that meets the requirements and simplifying the graphic code version to improve the recognition efficiency of the graphic code.

[0096] In specific implementation, in one or more optional embodiments, the method may further include the following steps:

[0097] When the Nth graphic code version is the smallest graphic code version among the multiple graphic code versions and the current length is less than the current data bit length, calling a preset short link conversion service to shorten the length of the original text content to obtain the shortened original text content;

[0098] When the current length is less than the data bit length determined based on the minimum graphic code version and the shortened original text content, performing a step of updating N=N+1;

[0099] When the current length is greater than or equal to the current data bit length determined based on the minimum graphic code version and the shortened original text content, the minimum graphic code version is used as the adapted graphic code version.

[0100] In this embodiment, after calling the preset short link conversion service to shorten the original text content to the shortened original text content, when the current length is greater than or equal to the current data bit length determined based on the minimum graphic code version and the shortened original text content, a mapping relationship between the original text content and the shortened original text content can also be established. In this way, after the user subsequently scans the graphic code generated based on the shortened original text content, the mapping relationship can be used to directly jump to display information related to the original text content to the user.

[0101] Step 203: Calculate a target error tolerance rate matching the original text content based on the data segment list, the target graphic code version, and the scene parameter used to characterize the applicable scene of the target graphic code.

[0102] In this embodiment, the applicable scenarios include online scenarios and offline scenarios. The online scenario refers to the scenario where the quality of the QR code will not deteriorate due to the environment in which the QR code is used, and ultimately the recognition rate of the QR code will not be affected. In the online scenario, the QR code is usually stored in the device, and the QR code can be displayed through the display interface of the device according to actual usage requirements. For example, the payment code of the QR code displayed by the merchant through the mobile phone interface. The offline scenario refers to the scenario where the quality of the QR code will deteriorate due to the environment in which the QR code is used, and ultimately the recognition rate of the QR code will be affected. In the offline scenario, the QR code is usually displayed in the form of posters, plastic film packaging, etc., so as the use time increases, the clarity of the QR code in the offline scenario may gradually decrease.

[0103] In one or more optional embodiments, step 203 may include the following steps:

[0104] Querying a pre-configured mapping relationship to obtain a minimum error tolerance rate corresponding to the graphic code carrier and the usage scenario included in the scene parameters;

[0105] When the minimum fault tolerance rate is less than the initial preset fault tolerance rate, the minimum fault tolerance rate is used as the target fault tolerance rate;

[0106] When the minimum fault tolerance rate is greater than or equal to the initial preset fault tolerance rate, an adaptive fault tolerance rate is selected from multiple fault tolerance rates, and the length of data bits that can be accommodated by the graphic code corresponding to the target graphic code version with the adaptive fault tolerance rate is smaller than the data bit length determined by the target graphic code version and the data segment list; the adaptive fault tolerance rate is used as the target fault tolerance rate.

[0107] The graphic code carrier is the object that finally contains the graphic code. In applications, the graphic code carrier includes but is not limited to a table, a display screen, a poster, etc.

[0108] When selecting an adaptive fault tolerance rate from multiple fault tolerance rates, each of the multiple fault tolerance rates can be traversed one by one, for example, each fault tolerance rate can be traversed one by one in order from small to large, so as to select an adaptive fault tolerance rate from the multiple fault tolerance rates.

[0109] Step 204 , referring to the size of the display area of ​​the target graphic code, encoding the original text content according to the target graphic code version and the target error tolerance rate, and generating the target graphic code.

[0110] In this embodiment, the background is pre-configured with multiple display area sizes for users to choose from. Users can choose a display area size that meets their needs from the multiple display area sizes according to their needs.

[0111] In one or more optional embodiments, step 204 may include the following steps:

[0112] Determine the scaling base based on the size of the display area; and calculate the module parameter for characterizing the distribution density of the graphic code data module based on the target graphic code version and the target error tolerance rate;

[0113] Calculate the ratio of the scaling base and the module parameter to obtain the scaling factor of the graphic code image;

[0114] Draw the target graphic code based on the module parameters and the graphic code scaling factor.

[0115] In an application, the maximum value of the width and height of the display area can be used as the scaling base.

[0116] The graphic code generation method provided by the embodiment of the present application includes dividing the original text content used to generate the target graphic code into data segments to obtain a data segment list; calculating the target graphic code version matching the original text content based on the data segment list; calculating the target fault tolerance matching the original text content based on the data segment list, the target graphic code version and the scene parameters used to characterize the applicable scene of the target graphic code; referring to the size of the display area of ​​the target graphic code, encoding the original text content according to the target graphic code version and the target fault tolerance to generate the target graphic code. Since the graphic code version and the fault tolerance of the original text content can be determined dynamically, the density of the graphic code generated by the solution of the present application is relatively moderate compared to the related art, which helps to improve the accuracy of the subsequent recognition of the generated graphic code.

[0117] The present application also provides a method for generating a graphic code. Figure 3 As shown, the method may include the following steps:

[0118] Step 301: Obtain a QR code generation request, which includes the text content encoded in the QR code, the QR code carrier and usage scenario, and the size of the QR code display area.

[0119] Step 302: Generate a data segment list of a corresponding type according to the text content type of the text content.

[0120] Step 303: Calculate the QR code version according to the data segment list and the initial error tolerance rate.

[0121] Step 304: recalculate the appropriate fault tolerance rate according to the preset QR code version, the fault tolerance rate mapping table and the initial fault tolerance rate.

[0122] Step 305: Generate data bits according to the new final QR code version, fault tolerance rate, and data length.

[0123] Step 306: Generate a two-dimensional code image according to the terminal pixel requirement and the two-dimensional code data bits.

[0124] in:

[0125] The process of generating a data segment list includes:

[0126] The data bit length stored in each data segment of each text type conversion is different.

[0127] Text types, including pure numbers, alphanumeric types, and binary types.

[0128] The type of request is determined based on the text content, and a data segment list with a preset type and data segment length is generated.

[0129] The process of calculating the QR code version includes:

[0130] Set the initial fault tolerance rate. The initial fault tolerance rate is system preset.

[0131] According to the initial fault tolerance rate, the code is traversed from the minimum version of the QR code in a loop, and the data bit length that can be accommodated by the current traversal QR code version and the fault tolerance rate is calculated.

[0132] Obtain the total data bit length required based on the current QR code version and data segment list.

[0133] If the total data bit length is less than the data bit length that the current traversal QR code version and the error tolerance can accommodate, the current QR code version is taken as the final version. Otherwise, the text content is converted into a new shorter text content through the preset short link service. Continue to execute the process from the beginning.

[0134] The process of regaining the fault tolerance may include:

[0135] Different QR code carriers and usage scenarios are mapped to different QR code error tolerances, which is called a mapping table. For example, mobile terminals, electronic screens and other carriers and online media usage environments map the minimum QR code error tolerance.

[0136] The minimum fault tolerance rate is taken out from the mapping table according to the requested QR code carrier and usage scenario. If the minimum fault tolerance rate is greater than the initial fault tolerance rate, the fault tolerance rate is increased cyclically starting from the initial fault tolerance rate to calculate the length that the QR code and the fault tolerance rate can accommodate, and the data bit length and the accommodated length are compared. When the maximum fault tolerance rate in the cyclic traversal process can accommodate the data bit length, this fault tolerance rate is taken as the final fault tolerance rate.

[0137] If the minimum fault tolerance rate is less than the initial fault tolerance rate, the minimum fault tolerance rate is taken as the final fault tolerance rate.

[0138] The process of generating a QR code image may include:

[0139] The maximum value of the width and height of the QR code area in the QR code generation request is taken as the scaling base.

[0140] The scaling factor of the QR code image is taken as the scaling factor of the scaling base and the module bit ratio in the QR code data segment.

[0141] Draw the QR code image according to the module bit in the QR code data segment and the QR code image scaling factor.

[0142] The present application also provides a graphic code generation device, which is used to execute the graphic code generation method provided in any of the above embodiments. Figure 4 As shown, the device comprises:

[0143] A division module 41 is used to divide the original text content used to generate the target graphic code into data segments to obtain a data segment list;

[0144] A first calculation module 42, configured to calculate a target graphic code version matching the original text content based on the data segment list;

[0145] A second calculation module 43, used to calculate a target error tolerance rate matching the original text content based on the data segment list, the target graphic code version and a scene parameter used to characterize an applicable scene of the target graphic code;

[0146] The generating module 44 is used to refer to the size of the display area of ​​the target graphic code, encode the original text content according to the target graphic code version and the target error tolerance rate, and generate the target graphic code.

[0147] In one or more embodiments, the partitioning module 41 is used to:

[0148] Determining the text type of the original text content;

[0149] Obtain the length of a single data segment corresponding to the text type;

[0150] The original text content is divided into data segments according to the length of the single data segment to obtain the data segment list.

[0151] In one or more embodiments, the first calculation module 42 is used to:

[0152] Obtaining an adapted graphic code version from a plurality of preset graphic code versions, wherein the length of data bits that can be accommodated by the graphic code corresponding to the adapted graphic code version and the preset initial fault tolerance rate is greater than or equal to a final data bit length determined based on the adapted graphic code version and the data segment list;

[0153] The adapted graphic code version is used as the target graphic code version.

[0154] In one or more embodiments, the first calculation module 42 is used to:

[0155] For an Nth graphic code version among the multiple graphic code versions, calculating a current length of data bits that can be accommodated by the graphic code corresponding to the Nth graphic code version and the preset initial error tolerance rate;

[0156] In the case where the current length is less than the current data bit length determined based on the Nth graphic code version and the data segment list, updating N=N+1, and returning to the step of calculating the current length of the data bits that can be accommodated by the graphic code corresponding to the Nth graphic code version and the preset initial error tolerance rate;

[0157] In the case that the current length is greater than or equal to the current data bit length, the Nth graphic code version is used as the adapted graphic code version.

[0158] In one or more embodiments, the device is also used to:

[0159] In the case where the Nth graphic code version is the smallest graphic code version among the multiple graphic code versions and the current length is less than the current data bit length, calling a preset short link conversion service to shorten the length of the original text content to obtain shortened original text content;

[0160] In the case where the current length is less than the data bit length determined based on the minimum graphic code version and the shortened original text content, performing the step of updating N=N+1;

[0161] In the case that the current length is greater than or equal to the current data bit length determined based on the minimum graphic code version and the shortened original text content, the minimum graphic code version is used as the adapted graphic code version.

[0162] In one or more embodiments, the device is also used to:

[0163] In the case that the current length is greater than or equal to the current data bit length determined based on the minimum graphic code version and the shortened original text content, a mapping relationship between the shortened original text content and the original text content is established and saved.

[0164] In one or more embodiments, the second calculation module 43 is used to:

[0165] Querying a preconfigured mapping relationship to obtain a minimum error tolerance rate corresponding to the graphic code carrier and the usage scenario included in the scenario parameters;

[0166] When the minimum fault tolerance rate is less than the initial preset fault tolerance rate, the minimum fault tolerance rate is used as the target fault tolerance rate;

[0167] When the minimum fault tolerance rate is greater than or equal to the initial preset fault tolerance rate, an adaptive fault tolerance rate is selected from multiple fault tolerance rates, and the length of data bits that can be accommodated by the graphic code corresponding to the target graphic code version and the adaptive fault tolerance rate is less than the data bit length determined by the target graphic code version and the data segment list; the adaptive fault tolerance rate is used as the target fault tolerance rate.

[0168] In one or more embodiments, the generation module 44 is used to:

[0169] Determining a scaling base based on the size of the display area; and calculating a module parameter for characterizing a distribution density of a graphic code data module based on the target graphic code version and the target error tolerance rate;

[0170] Calculating the ratio of the scaling base and the module parameter to obtain a scaling factor of the graphic code image;

[0171] The target graphic code is drawn based on the module parameters and the graphic code scaling factor.

[0172] The present application also provides an electronic device to execute the above-mentioned graphic code generation method. Figure 5 It shows a schematic diagram of an electronic device provided by some embodiments of the present application. Figure 5 As shown, the electronic device 5 includes: a processor 500, a memory 501, a bus 502 and a communication interface 503, wherein the processor 500, the communication interface 503 and the memory 501 are connected via the bus 502; the memory 501 stores a computer program that can be run on the processor 500, and when the processor 500 runs the computer program, the graphic code generation method provided in any of the aforementioned embodiments of the present application is executed.

[0173] The memory 501 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the device network element and at least one other network element is realized through at least one communication interface 503 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.

[0174] The bus 502 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 501 is used to store programs, and the processor 500 executes the programs after receiving execution instructions. The graphic code generation method disclosed in any implementation of the aforementioned embodiment of the present application may be applied to the processor 500, or implemented by the processor 500.

[0175] The processor 500 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 500. The above processor 500 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a readily available programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 501, and the processor 500 reads the information in the memory 501 and completes the steps of the above method in combination with its hardware.

[0176] The electronic device provided in the embodiment of the present application and the graphic code generation method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented therein.

[0177] The present application also provides a computer-readable storage medium corresponding to the graphic code generation method provided in the above embodiment. Figure 6 The computer-readable storage medium shown is a CD 30 on which a computer program (ie, a program product) is stored. When the computer program is run by a processor, the graphic code generation method provided in any of the aforementioned embodiments will be executed.

[0178] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical or magnetic storage media, which are not listed here one by one.

[0179] The computer-readable storage medium provided in the above-mentioned embodiment of the present application and the graphic code generation method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the method adopted, run or implemented by the application program stored therein.

[0180] It should be noted that:

[0181] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known structures and technologies are not shown in detail so as not to obscure the understanding of this description.

[0182] Similarly, it should be understood that in order to streamline the present application and help understand one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present application, the various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following: the claimed application requires more features than the features clearly stated in each claim. More specifically, as reflected in the claims below, the inventive aspects are less than all the features of the single embodiment disclosed above. Therefore, the claims following the specific embodiment are hereby expressly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present application.

[0183] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present application and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.

[0184] The above is only a preferred specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for generating a graphic code, characterized in that: include: Dividing the original text content used to generate the target graphic code into data segments to obtain a data segment list; Calculating a target graphic code version matching the original text content based on the data segment list; Calculating a target error tolerance rate matching the original text content based on the data segment list, the target graphic code version, and a scene parameter for characterizing an applicable scene of the target graphic code; Referring to the size of the display area of ​​the target graphic code, the original text content is encoded according to the target graphic code version and the target error tolerance rate to generate the target graphic code.

2. The method according to claim 1, characterized in that: The original text content is divided into data segments to obtain a data segment list, including: Determining the text type of the original text content; Obtain the length of a single data segment corresponding to the text type; The original text content is divided into data segments according to the length of the single data segment to obtain the data segment list.

3. The method according to claim 1, characterized in that Calculating a target graphic code version matching the original text content based on the data segment list includes: Obtaining an adapted graphic code version from a plurality of preset graphic code versions, wherein the length of data bits that can be accommodated by the graphic code corresponding to the adapted graphic code version and the preset initial fault tolerance rate is greater than or equal to a final data bit length determined based on the adapted graphic code version and the data segment list; The adapted graphic code version is used as the target graphic code version.

4. The method according to claim 3, characterized in that From multiple preset graphic code versions, obtain the adapted graphic code version, including: For an Nth graphic code version among the multiple graphic code versions, calculating a current length of data bits that can be accommodated by the graphic code corresponding to the Nth graphic code version and the preset initial error tolerance rate; In the case where the current length is less than the current data bit length determined based on the Nth graphic code version and the data segment list, updating N=N+1, and returning to the step of calculating the current length of the data bits that can be accommodated by the graphic code corresponding to the Nth graphic code version and the preset initial error tolerance rate; In the case that the current length is greater than or equal to the current data bit length, the Nth graphic code version is used as the adapted graphic code version.

5. The method according to claim 4, characterized in that The method further comprises: In the case where the Nth graphic code version is the smallest graphic code version among the multiple graphic code versions and the current length is less than the current data bit length, calling a preset short link conversion service to shorten the length of the original text content to obtain shortened original text content; In the case where the current length is less than the data bit length determined based on the minimum graphic code version and the shortened original text content, performing the step of updating N=N+1; In the case that the current length is greater than or equal to the current data bit length determined based on the minimum graphic code version and the shortened original text content, the minimum graphic code version is used as the adapted graphic code version.

6. The method according to claim 5, characterized in that The method further comprises: In the case that the current length is greater than or equal to the current data bit length determined based on the minimum graphic code version and the shortened original text content, a mapping relationship between the shortened original text content and the original text content is established and saved.

7. The method according to any one of claims 1 to 6, characterized in that: Calculating a target error tolerance rate matching the original text content based on the data segment list, the target graphic code version, and a scene parameter for characterizing an applicable scene of the target graphic code, including: Querying a preconfigured mapping relationship to obtain a minimum error tolerance rate corresponding to the graphic code carrier and the usage scenario included in the scenario parameters; When the minimum fault tolerance rate is less than the initial preset fault tolerance rate, the minimum fault tolerance rate is used as the target fault tolerance rate; When the minimum fault tolerance rate is greater than or equal to the initial preset fault tolerance rate, an adaptive fault tolerance rate is selected from multiple fault tolerance rates, and the length of data bits that can be accommodated by the graphic code corresponding to the target graphic code version and the adaptive fault tolerance rate is less than the data bit length determined by the target graphic code version and the data segment list; the adaptive fault tolerance rate is used as the target fault tolerance rate.

8. The method according to any one of claims 1 to 6, characterized in that: Referring to the size of the display area of ​​the target graphic code, encoding the original text content according to the target graphic code version and the target error tolerance rate to generate the target graphic code, including: Determining a scaling base based on the size of the display area; and calculating a module parameter for characterizing a distribution density of a graphic code data module based on the target graphic code version and the target error tolerance rate; Calculating the ratio of the scaling base and the module parameter to obtain a scaling factor of the graphic code image; The target graphic code is drawn based on the module parameters and the graphic code scaling factor.

9. A graphic code generating device, characterized in that: include: A division module, used for dividing the original text content used to generate the target graphic code into data segments to obtain a data segment list; A first calculation module, configured to calculate a target graphic code version matching the original text content based on the data segment list; A second calculation module, configured to calculate a target error tolerance rate matching the original text content based on the data segment list, the target graphic code version, and a scene parameter for characterizing an applicable scene of the target graphic code; A generating module is used to refer to the size of the display area of ​​the target graphic code, encode the original text content according to the target graphic code version and the target error tolerance rate, and generate the target graphic code.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: The processor runs the computer program to implement the method according to any one of claims 1 to 8.