CN109948762A - Method and apparatus for generating two dimensional code - Google Patents

Method and apparatus for generating two dimensional code Download PDF

Info

Publication number
CN109948762A
CN109948762A CN201711383739.5A CN201711383739A CN109948762A CN 109948762 A CN109948762 A CN 109948762A CN 201711383739 A CN201711383739 A CN 201711383739A CN 109948762 A CN109948762 A CN 109948762A
Authority
CN
China
Prior art keywords
code word
error correction
data
correction code
coding region
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201711383739.5A
Other languages
Chinese (zh)
Inventor
闫宇昊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201711383739.5A priority Critical patent/CN109948762A/en
Publication of CN109948762A publication Critical patent/CN109948762A/en
Pending legal-status Critical Current

Links

Landscapes

  • Error Detection And Correction (AREA)

Abstract

The embodiment of the present application discloses the method and apparatus for generating two dimensional code.One specific embodiment of this method includes: to obtain information to be stored;Based on predetermined error-correction level and two dimensional code version, binary data corresponding with information to be stored and error correction code word are determined;Binary data and error correction code word are converted to the data and error correction code word of N scale, wherein N is greater than 2 natural numbers;The data of N scale and error correction code word are filled into coding region;Coding region is masked to generate two dimensional code using mask graph.The embodiment increases the information storage of two dimensional code.

Description

Method and apparatus for generating two dimensional code
Technical field
The invention relates to field of computer technology, and in particular to Internet technical field, it is more particularly, to raw At the method and apparatus of two dimensional code.
Background technique
It is in recent years with the two dimensional code that quick response matrix code (Quick Response Code, also known as QR Code) is representative Come a kind of coding mode to come into vogue, since it can store information in both direction (or dimension), and can deposit The information such as number, Chinese character, picture are stored up, therefore, two dimensional code is widely used in more and more fields.
The two dimensional code of the prior art usually used geometric figure corresponding with binary digit indicates text and numerical value Information, and by image input device or scanning device automatically identifying and reading to realize automatically processing for information.
Summary of the invention
The embodiment of the present application proposes the method and apparatus for generating two dimensional code.
In a first aspect, the embodiment of the present application provides a kind of method for generating two dimensional code, two dimensional code includes code area Domain, this method comprises: obtaining information to be stored;Based on predetermined error-correction level and two dimensional code version, determine with wait store The corresponding binary data of information and error correction code word;Binary data and error correction code word are converted to the data of N scale With error correction code word, wherein N is greater than 2 natural numbers;The data of N scale and error correction code word are filled into coding region;Using covering Mould figure is masked to generate two dimensional code coding region.
In some embodiments, corresponding with information to be stored based on predetermined error-correction level and the determination of two dimensional code version Binary data and error correction code word, comprising: convert binary code word data for information to be stored;According to predetermined Error-correction level generate binary error correction code word;By binary code word data and binary error correction code word by predetermined The pre-defined rule of two dimensional code version carry out interspersed placement, to generate binary data and error correction code word.
In some embodiments, the data of N scale and error correction code word are filled into coding region, comprising: for N carry Each code word data or error correction code word in the data and error correction code word of system, determine the filling face of the code word data or error correction code word Color, and identified Fill Color is filled into coding region for the code word data or the pre-set position of error correction code word Place, wherein the corresponding relationship between the number that N scale uses and Fill Color is preset.
In some embodiments, the data of N scale and error correction code word are filled into coding region, comprising: for N carry Each code word data or error correction code word in the data and error correction code word of system, determine the filling shape of the code word data or error correction code word Shape, and identified filling shape is filled into coding region for the code word data or the pre-set position of error correction code word Place, wherein the corresponding relationship between the number that N scale uses and filling shape is preset.
In some embodiments, the data of N scale and error correction code word are filled into coding region, comprising: for N carry Each code word data or error correction code word in the data and error correction code word of system, determine the filling material of the code word data or error correction code word Material, and identified packing material is filled into coding region for the code word data or the pre-set position of error correction code word Place, wherein the corresponding relationship between the number that N scale uses and packing material is preset.
In some embodiments, coding region is masked to generate two dimensional code using mask graph, comprising: using every A predetermined pattern figure is masked the module figure of coding region and generates result figure;According to preset condition to each knot Fruit figure scores, and the result graphic hotsopt two dimensional code minimum based on score value.
In some embodiments, the data of N scale and error correction code word are the data and error correction code word of the quaternary, using every A predetermined pattern figure is masked the module figure of coding region, comprising:, will for each module figure of coding region The corresponding code word data of module figure or error correction code word to 2 remainders to determine the first numerical value, by predetermined pattern figure with should The mask value of the identical module figure in the position of module figure is determined as second value;First numerical value and second value progress is different Or processing is to determine third value;It is not 0 in response to third value, to the code word data or error correcting code for being filled into the module figure Word is negated.
Second aspect, the embodiment of the present application provide a kind of for generating the device of two dimensional code, and two dimensional code includes code area Domain, the device include: acquiring unit, are configured to obtain information to be stored;Determination unit is configured to based on predetermined Error-correction level and two dimensional code version determine binary data corresponding with information to be stored and error correction code word;Converting unit is matched Set the data and error correction code word for binary data and error correction code word to be converted to N scale, wherein N is natural greater than 2 Number;Fills unit is configured to the data of N scale and error correction code word being filled into coding region;Mask unit is configured to Coding region is masked to generate two dimensional code using mask graph.
In some embodiments, determination unit includes: conversion module, is configured to convert binary system for information to be stored Code word data;Generation module is configured to generate binary error correction code word according to predetermined error-correction level;Interspersed mould Block is configured to the pre- set pattern by binary code word data and binary error correction code word by predetermined two dimensional code version Interspersed placement is carried out, then to generate binary data and error correction code word.
In some embodiments, fills unit includes: color filling module, be configured to for N scale data and Each code word data or error correction code word in error correction code word, determine the Fill Color of the code word data or error correction code word, and by institute Determining Fill Color is filled into coding region at the code word data or the pre-set position of error correction code word, wherein N Corresponding relationship between the number that scale uses and Fill Color is preset.
In some embodiments, fills unit include: shape filling module, be configured to for N scale data and Each code word data or error correction code word in error correction code word, determine the filling shape of the code word data or error correction code word, and by institute Determining filling shape is filled into coding region at the code word data or the pre-set position of error correction code word, wherein N Corresponding relationship between the number that scale uses and filling shape is preset.
In some embodiments, fills unit include: material filling module, be configured to for N scale data and Each code word data or error correction code word in error correction code word, determine the packing material of the code word data or error correction code word, and by institute Determining packing material is filled into coding region at the code word data or the pre-set position of error correction code word, wherein N Corresponding relationship between the number that scale uses and packing material is preset.
In some embodiments, mask unit includes: mask module, is configured to using each predetermined pattern figure to volume The module figure in code region is masked and generates result figure;Generation module is configured to according to preset condition to each knot Fruit figure scores, and the result graphic hotsopt two dimensional code minimum based on score value.
In some embodiments, the data of N scale and error correction code word are the data and error correction code word of the quaternary, mask mould Block includes: mask operation submodule, is configured to each module figure for coding region, by the corresponding number of module figure It, will be identical as the position of the module figure in predetermined pattern figure according to code word or error correction code word to 2 remainders to determine the first numerical value The mask value of module figure be determined as second value;First numerical value and second value are subjected to exclusive or processing to determine third number Value;It is not 0 in response to third value, the code word data or error correction code word that are filled into the module figure is negated.
Method and apparatus provided by the embodiments of the present application for generating two dimensional code, it is corresponding with information to be stored by determination Binary data and error correction code word, and binary data and error correction code word are converted to the data and error correction of N scale The data of N scale and error correction code word are then filled into coding region by code word, are finally masked generation two to coding region Code is tieed up, to increase the information storage of two dimensional code.
Detailed description of the invention
By reading a detailed description of non-restrictive embodiments in the light of the attached drawings below, the application's is other Feature, objects and advantages will become more apparent upon:
Fig. 1 is that this application can be applied to exemplary system architecture figures therein;
Fig. 2 is the flow chart according to one embodiment of the method for generating two dimensional code of the application;
Fig. 3 is the schematic diagram according to an application scenarios of the method for generating two dimensional code of the application;
Fig. 4 is the flow chart according to another embodiment of the method for generating two dimensional code of the application;
Fig. 5 is the structural schematic diagram according to one embodiment of the device for generating two dimensional code of the application;
Fig. 6 is adapted for the structural schematic diagram for the computer system for realizing the terminal of the embodiment of the present application.
Specific embodiment
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Convenient for description, part relevant to related invention is illustrated only in attached drawing.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 shows the method for generating two dimensional code or the device for generating two dimensional code that can apply the application The exemplary system architecture 100 of embodiment.
As shown in Figure 1, system architecture 100 may include terminal device 101,102,103, network 104 and server 105. Network 104 between terminal device 101,102,103 and server 105 to provide the medium of communication link.Network 104 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 101,102,103 and be interacted by network 104 with server 105, to receive or send out Send message etc..Various telecommunication customer end applications can be installed, such as two dimensional code is generated/swept on terminal device 101,102,103 Retouch tool, shopping class application, searching class application, instant messaging tools, mailbox client, social platform software etc..
Terminal device 101,102,103 can be various electronic equipments, including but not limited to smart phone, tablet computer, E-book reader, MP3 player (Moving Picture Experts Group Audio Layer III, dynamic image Expert's compression standard audio level 3), MP4 (Moving Picture Experts Group Audio Layer IV, dynamic shadow As expert's compression standard audio level 4) player, pocket computer on knee and desktop computer etc..
Server 105 can be to provide the server of various services, for example, generate and read two dimensional code and provide support Background server.Server 105 can be analyzed and processed the data such as the information received, and raw based on analysis and processing result At two dimensional code.
It should be noted that for generating the method for two dimensional code generally by server 105 provided by the embodiment of the present application It executes, correspondingly, the device for generating two dimensional code is generally positioned in server 105.
It should be understood that the number of terminal device, network and server in Fig. 1 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.
With continued reference to Fig. 2, the process of one embodiment of the method for generating two dimensional code according to the application is shown 200.The method for being used to generate two dimensional code, comprising the following steps:
Step 201, information to be stored is obtained.
In the present embodiment, the method for generating two dimensional code runs electronic equipment (such as clothes shown in FIG. 1 thereon Business device) it can be obtained by wired connection mode or radio connection from user terminal (for example, terminal device shown in FIG. 1) Take the information to be stored on two dimensional code to be stored in.It should be pointed out that above-mentioned radio connection can include but is not limited to 3G/4G connection, WiFi connection, bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection and Other currently known or exploitation in the future radio connections.
It should be appreciated that above-mentioned electronic equipment other than obtaining from user terminal wait store information, can also be deposited from local Reservoir or remote memory obtain information to be stored, when above-mentioned electronic equipment obtains when storing information from local storage, net Network (for example, network 104 shown in FIG. 1) can be omitted.
Step 202, be based on predetermined error-correction level and two dimensional code version, determine corresponding with information to be stored two into The data and error correction code word of system.
In the present embodiment, above-mentioned electronic equipment (such as server shown in FIG. 1) can predefine error-correction level and Then two dimensional code version encodes the information to be stored that step 201 obtains according to error-correction level and two dimensional code version, generate Binary data and error correction code word.
In order to make two dimensional code be not to lose data when being damaged (for example, partial information missing), error correction is generallyd use Algorithm generates error correction code word, and after error correction code word is added to code word data, obtains binary data and error correction code word.It presses According to recoverable code word ratio, error correction can be divided into four kinds of error-correction levels (respectively error-correction level L, M, Q and H), for example, error correction The code word of grade L corresponding 7% restores ratio, and the code word of error-correction level H corresponding 30% restores ratio, in the embodiment of the present application, Error-correction level can be the error-correction level that preassigned error-correction level is either defaulted.Two dimensional code has 40 kinds of versions, respectively The version of 1~edition 4 of version 0, two dimensional code determines the size of two dimensional code, for example, version 1 represents 21 modules × 21 module (these In, module refers to the graph block that expressing information is used in two dimensional code, hereinafter also referred to module figure) two dimensional code, and edition 40 It represents 177 modules × 177 modules two dimensional code, in the embodiment of the present application, can select accommodate wait store according to error-correction level The minimum two dimensional code version of information.
Step 203, binary data and error correction code word are converted to the data and error correction code word of N scale, wherein N For greater than 2 natural numbers.
It in the present embodiment, can be true by step 202 for generating the electronic equipment of the method operation of two dimensional code thereon Fixed binary data and error correction code word are converted to the data and error correcting code of N scale (for example, the quaternary, octal system etc.) Word.
Step 204, the data of N scale and error correction code word are filled into coding region.
In the present embodiment, above-mentioned electronic equipment can fill out the data for the N scale that step 203 is converted and error correction code word It is charged in coding region, here, coding region, which refers in two dimensional code, not to be occupied by functional graphic, for data and error correcting code The region that word is encoded, functional graphic refer in two dimensional code for positioning the figure with feature identification (for example, position sensing figure Shape, positioning pattern, correction graph etc.).
Step 205, coding region is masked to generate two dimensional code using mask graph.
In the present embodiment, in order to which the data for coding region of balancedly arranging and error correction code word are to improve the readable of two dimensional code Property, above-mentioned electronic equipment can be used mask graph and be masked operation to filled coding region, after being then based on mask Coding region generate two dimensional code.
It is the one of the application scenarios 300 of the method according to the present embodiment for generating two dimensional code with continued reference to Fig. 3, Fig. 3 A schematic diagram.In the application scenarios 300 of Fig. 3, electronic equipment first according to error-correction level and two dimensional code version to acquisition to Storage information carries out coding and determines binary data and error correction code word, is later converted into binary data and error correction code word Then the data of the quaternary and error correction code word are filled into coding region (wherein, module by the data and error correction code word of the quaternary Figure CW1~CW4The number 0~3 used respectively with quaternary coding is corresponding), finally coding region is masked and generates lattice Formula information (when two dimensional code version is 8~edition 40 of version, going back build version information) and functional graphic, form two dimensional code.
Method provided by the embodiments of the present application for generating two dimensional code, by the way that information to be stored is converted to N scale Data and error correction code word generate two dimensional code, increase the information storage of two dimensional code.
With further reference to Fig. 4, it illustrates the processes 400 of another embodiment of the method for generating two dimensional code.It should For generating the process 400 of the method for two dimensional code, comprising the following steps:
Step 401, information to be stored is obtained.
In the present embodiment, the method for generating two dimensional code runs electronic equipment (such as clothes shown in FIG. 1 thereon Business device) it can be obtained by wired connection mode or radio connection from user terminal (for example, terminal device shown in FIG. 1) Take the information to be stored on two dimensional code to be stored in.
Step 402, binary code word data is converted by information to be stored.
In the present embodiment, the information to be stored obtained based on step 401, above-mentioned electronic equipment (such as clothes shown in FIG. 1 Business device) coded character set can be determined first, it is then binary system by information coding to be stored according to determining coded character set Code word data.Here, coded character set may include digital data (for example, number 0~9), alphanumeric data (example Such as, number 0~9, capitalization A~Z etc.), octet type data (for example, ascii character-set), chinese character (for example, The character set that GB2312 graphic character code table indicates) etc..
Step 403, binary error correction code word is generated according to predetermined error-correction level.
In the present embodiment, the electronic equipment that the method for generating two dimensional code is run thereon can predefine error correction Then grade generates error correction code word according to determining error-correction level and binary code word data, wherein according to recoverable code Word ratio, error correction can be divided into four kinds of error-correction levels, respectively error-correction level L, M, Q and H.
Step 404, by binary code word data and binary error correction code word by predetermined two dimensional code version Pre-defined rule carries out interspersed placement, to generate binary data and error correction code word.
It in the present embodiment, can be raw by step 402 for generating the electronic equipment of the method operation of two dimensional code thereon At code word data and step 403 generate error correction code word according to predetermined error-correction level and two dimensional code version requirement into Row is interspersed to be placed, and binary data and error correction code word are obtained.
Step 405, binary data and error correction code word are converted to the data and error correction code word of N scale, wherein N For greater than 2 natural numbers.
In the present embodiment, in the present embodiment, the electronic equipment that the method for generating two dimensional code is run thereon can N scale (for example, the quaternary, octal system etc.) is converted to the binary data and error correction code word that obtain step 404 Data and error correction code word.
Step 406, each code word data or error correction code word in the data for N scale and error correction code word, determining should The Fill Color of code word data or error correction code word, and identified Fill Color is filled into coding region for the numeric data code At word or the pre-set position of error correction code word, wherein the corresponding relationship between the number that N scale uses and Fill Color is It is preset.
In the present embodiment, the method for generating two dimensional code run electronic equipment thereon can preset N into Corresponding relationship between the position system coding number used and Fill Color, and each code word data is determined based on above-mentioned corresponding relationship Or the corresponding Fill Color of error correction code word, then determining Fill Color is filled into coding region for the code word data or In the pre-set module figure of error correction code word.For example, can be preset for the data of the quaternary and error correction code word Number 0~3 is corresponded with four kind of Fill Color (such as white, red, green, black), in this way, work as a code word data or It, can be to the code word data or the module filling graph white of error correction code word corresponding position when error correction code word is encoded as 0;When one When code word data or error correction code word are encoded as 1, it can be filled out to the module figure of the code word data or error correction code word corresponding position Fill red;..., and so on.
Step 407, it is masked using module figure of each predetermined pattern figure to coding region and generates result figure Shape.
In the present embodiment, in order to which the data for coding region of balancedly arranging and error correction code word are to improve the readable of two dimensional code Property, the method for generating two dimensional code runs electronic equipment thereon can be successively using different mask graphs to step 406 filled coding regions are masked operation and generate result figure.
As an example, table one shows common mask graph with reference to (binary system being placed in format information is joined Examine) and mask graph formation condition, mask graph is by will be in coding region (not including format information and version information) Those conditions are that genuine module graphic definition is dark and generation.Shown in condition, the line position that i represents module figure is set, j The column position of module figure is represented, operator is divided exactly in div representative, and mod represents the remainder after dividing exactly.Successively using shown in table one 8 kinds of mask graphs are masked operation to coding region to obtain 8 result figures.
The formation condition of one mask graph of table
In some optional implementations of the present embodiment, the data and error correction code word of N scale are the number of the quaternary According to error correction code word, be masked using module figure of each predetermined pattern figure to coding region, comprising: for code area Each module figure in domain will by the corresponding code word data of module figure or error correction code word to 2 remainders to determine the first numerical value The mask value of module figure identical with the position of the module figure is determined as second value in predetermined pattern figure;By the first number Value and second value carry out exclusive or processing to determine third value;It is not 0 in response to third value, to being filled into the module figure Code word data or error correction code word negated.
As an example, it is described in detail by taking the module figure that code word data is 2, Fill Color is green as an example. Firstly, the quaternary numerical value (that is, 2) of the code word data obtains the first numerical value (that is, 0) 2 remainders, and by mask graph (example Such as, the mask pattern that binary reference is 000) in mask value (for example, condition is true, mask value 0) at same position make For second value;Then, the first numerical value and second value carry out XOR operation, third value are obtained, due to third number here Value is 0, therefore the quaternary numerical value and Fill Color of the code word data of the module figure remain unchanged.And for having the same Another module figure of code word data and Fill Color, the mask value in mask pattern at same position are 1 (that is, condition is It is false), so that obtaining third value is 1, therefore can the quaternary numerical value (that is, 2) to the code word data of the module figure negate (negating here, refer to that step-by-step negates after quaternary numerical value is converted to binary numeral) obtains negated data Code word (negated quaternary numerical value is 1), and the Fill Color of the module figure is replaced with into negated code word data pair The Fill Color answered, for example, it is red.
Step 408, it scores according to preset condition each result figure, and raw based on the minimum result figure of score value At two dimensional code.
In the present embodiment, the electronic equipment that the method for generating two dimensional code is run thereon can be according to preset condition (for example, the block of the identical module figure composition of the identical module map figurate number of module graphic color adjacent in row/column, color The ratio of module figure etc. of different colours in size, entire result figure) scored to each result it is (i.e. pre- to meeting If the module figure of condition is scored), then using the result figure of score value minimum (that is, masking effect is best) as exposure mask after Figure, while generating format information (when two dimensional code version is 8~edition 40 of version, also build version information) and functional diagram Shape forms two dimensional code.
Figure 4, it is seen that the side for being used to generate two dimensional code compared with the corresponding embodiment of Fig. 2, in the present embodiment The process 400 of method highlights the step of being filled into coding region to the data and Error Correction of Coding of N scale.The present embodiment as a result, The scheme of description can store more information in coding region by using different colors, to increase two dimensional code Information storage.
Although implementation shown in Fig. 4 is illustrated the situation using different Fill Color filling coding regions, this Embodiment is not limited to this for application.It should be appreciated that can also be filled by other suitable modes to coding region, ability The technical staff in domain can be configured according to the needs of practical application scene.
In some embodiments of the present application, the data of N scale and error correction code word are filled into coding region, comprising: The each code word data or error correction code word in data and error correction code word for N scale, determines the code word data or error correcting code The filling shape of word, and by identified filling shape be filled into coding region for the code word data or error correction code word it is preparatory At the position of setting, wherein the corresponding relationship between the number that N scale uses and filling shape is preset.For example, The filling figure such as circle, triangle, rectangle can be used to indicate that N scale encodes the number used.
In some embodiments of the present application, the data of N scale and error correction code word are filled into coding region, comprising: The each code word data or error correction code word in data and error correction code word for N scale, determines the code word data or error correcting code The packing material of word, and by identified packing material be filled into coding region for the code word data or error correction code word it is preparatory At the position of setting, wherein the corresponding relationship between the number that N scale uses and packing material is preset.For example, Can be used different packing materials (material that can be detected by special light, for example, reflection infrared ray material, Reflect the material etc. of ultraviolet light) indicate that N scale encodes the number that uses.It is all compared with Fill Color or filling shape The wave band gap of such as ultraviolet light, infrared ray light is bigger, therefore, by using can reflect ultraviolet light, infrared ray etc. The material of light, which generates two dimensional code, can make two dimensional code be easier to distinguish.
In addition, respectively describing in above-described embodiment using any one in Fill Color, filling shape and packing material It plants to indicate that N scale encodes the number used, but the embodiment of the present application is not limited to this.For example, in some of the application In embodiment, it can be used at least two in Fill Color, filling shape and packing material to indicate that N scale coding uses Number (for example, white circle represents 0, white triangles shape represents 1, and black circle represents 2, and black triangle represents 3 etc.), So as to further increase the information storage of two dimensional code.
In addition, the embodiment of the present application also provides a kind of method for parsing two dimensional code, for parsing above-mentioned each implementation The two dimensional code generated in example.
The method for being used to parse two dimensional code includes: recognition format information (and version information, if there is version information Words) determine that the error-correction level of two dimensional code and mask graph refer to (and two dimensional code version);Use determining mask images reference pair The mask graph answered carries out exclusive or processing to the module figure of coding region, eliminates mask;According to the filling of module figure, arrangement Rule recognition module figure, restores the data and error correction code word of the N scale stored on two dimensional code;By N, (N is the nature greater than 2 Number) scale data and error correction code word be converted into binary data and error correction code word;Using corresponding with error-correction level Error correction codeword detection mistake, if it find that mistake then carries out error correction;Finally binary code word data is decoded to obtain two The information stored on dimension code.
With further reference to Fig. 5, as the realization to method shown in above-mentioned each figure, this application provides one kind for generating two One embodiment of the device of code is tieed up, the Installation practice is corresponding with embodiment of the method shown in Fig. 2, which specifically can be with Applied in various electronic equipments.
As shown in figure 5, the present embodiment includes: acquiring unit 501, determination unit for generating the device 500 of two dimensional code 502, converting unit 503, fills unit 504 and mask unit 505.Wherein, acquiring unit 501 is configured to obtain letter to be stored Breath;Determination unit 502 is configured to based on predetermined error-correction level and two dimensional code version, and determination is corresponding with information to be stored Binary data and error correction code word;Converting unit 503 be configured to be converted to binary data and error correction code word N into The data and error correction code word of position system, wherein N is greater than 2 natural numbers;Fills unit 504 be configured to the data of N scale and Error correction code word is filled into coding region;And mask unit 505 be configured to using mask graph to coding region be masked with Generate two dimensional code.
In the present embodiment, wired connection mode can be passed through for generating the receiving unit 501 of the device 500 of two dimensional code Or radio connection from user terminal (for example, terminal device shown in FIG. 1) obtain to be stored on two dimensional code wait deposit Store up information.
In the present embodiment, above-mentioned determination unit 502 can predefine error-correction level and two dimensional code version, then basis The information to be stored that error-correction level and two dimensional code version obtain acquiring unit 501 encodes, generate binary data and Error correction code word.
In the present embodiment, above-mentioned converting unit 503 can by above-mentioned determination unit 502 determine binary data and Error correction code word is converted to the data and error correction code word of N scale (for example, the quaternary, octal system etc.).
In the present embodiment, the data for the N scale that above-mentioned fills unit 504 can convert above-mentioned converting unit 503 and Error correction code word is filled into coding region, and here, coding region, which refers in two dimensional code, not to be occupied by functional graphic, for logarithm According to the region encoded with error correction code word, functional graphic refer in two dimensional code for position with feature identify figure for example, Position sensing figure, positioning pattern, correction graph etc.).
In the present embodiment, in order to coding region of balancedly arranging data and error correction code word to improve the readable of two dimensional code Property, aforementioned mask unit 505 can be used mask graph and be masked operation to filled coding region, be then based on mask Coding region afterwards generates two dimensional code.
In some optional implementations of the present embodiment, above-mentioned determination unit 502 includes conversion module, generation module With interspersed module.Wherein, conversion module is configured to convert binary code word data for information to be stored;Generation module is matched It sets for generating binary error correction code word according to predetermined error-correction level;Interspersed module is configured to binary number Interspersed placement is carried out by the pre-defined rule of predetermined two dimensional code version according to code word and binary error correction code word, to generate two The data and error correction code word of system.
In some optional implementations of the present embodiment, above-mentioned fills unit 504 includes color filling module.Its In, color filling module is configured to the error correction code word of each code word data or error correction code word in the data and to(for) N scale, It determines the Fill Color of the code word data or error correction code word, and identified Fill Color is filled into be directed in coding region and is somebody's turn to do At code word data or the pre-set position of error correction code word, wherein corresponding between the number that N scale uses and Fill Color Relationship is preset.
In some optional implementations of the present embodiment, above-mentioned fills unit 504 includes that shape fills module.Its In, shape filling module is configured to the error correction code word of each code word data or error correction code word in the data and to(for) N scale, It determines the filling shape of the code word data or error correction code word, and identified filling shape is filled into be directed in coding region and is somebody's turn to do At code word data or the pre-set position of error correction code word, wherein corresponding between the number that N scale uses and filling shape Relationship is preset.
In some optional implementations of the present embodiment, above-mentioned fills unit 504 includes that material fills module.Its In, material filling module is configured to the error correction code word of each code word data or error correction code word in the data and to(for) N scale, It determines the packing material of the code word data or error correction code word, and identified packing material is filled into be directed in coding region and is somebody's turn to do At code word data or the pre-set position of error correction code word, wherein corresponding between the number that N scale uses and packing material Relationship is preset.
In some optional implementations of the present embodiment, aforementioned mask unit 505 includes mask module and generation mould Block.Wherein, mask module is configured to be masked and given birth to using module figure of each predetermined pattern figure to coding region At result figure;Generation module is configured to score to each result figure according to preset condition, and minimum based on score value Result graphic hotsopt two dimensional code.
In some optional implementations of the present embodiment, the data and error correction code word of N scale are the number of the quaternary According to error correction code word, mask module includes mask operation submodule.Wherein, mask operation submodule is configured to: for coding Each module figure in region, by the corresponding code word data of module figure or error correction code word to 2 remainders to determine the first numerical value, The mask value of module figure identical with the position of the module figure in predetermined pattern figure is determined as second value;By first Numerical value and second value carry out exclusive or processing to determine third value;It is not 0 in response to third value, to being filled into the module map The code word data or error correction code word of shape are negated.
The device provided by the embodiments of the present application for being used to generate two dimensional code, by the way that information to be stored is converted to N scale Data and error correction code word generate two dimensional code, increase the information storage of two dimensional code.
Below with reference to Fig. 6, it illustrates the computer systems for the device/server for being suitable for being used to realize the embodiment of the present application 600 structural schematic diagram.Device/server shown in Fig. 6 is only an example, should not function to the embodiment of the present application and Use scope brings any restrictions.
As shown in fig. 6, computer system 600 includes central processing unit (CPU) 601, it can be read-only according to being stored in Program in memory (ROM) 602 or be loaded into the program in random access storage device (RAM) 603 from storage section 608 and Execute various movements appropriate and processing.In RAM 603, also it is stored with system 600 and operates required various programs and data. CPU 601, ROM 602 and RAM 603 are connected with each other by bus 604.Input/output (I/O) interface 605 is also connected to always Line 604.
I/O interface 605 is connected to lower component: the importation 606 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 607 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 608 including hard disk etc.; And the communications portion 609 of the network interface card including LAN card, modem etc..Communications portion 609 via such as because The network of spy's net executes communication process.Driver 610 is also connected to I/O interface 605 as needed.Detachable media 611, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 610, in order to read from thereon Computer program be mounted into storage section 608 as needed.
Particularly, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description Software program.For example, embodiment of the disclosure includes a kind of computer program product comprising be carried on computer-readable medium On computer program, which includes the program code for method shown in execution flow chart.In such reality It applies in example, which can be downloaded and installed from network by communications portion 609, and/or from detachable media 611 are mounted.When the computer program is executed by central processing unit (CPU) 601, limited in execution the present processes Above-mentioned function.
It should be noted that computer-readable medium described herein can be computer-readable signal media or meter Calculation machine readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example can be --- but not Be limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.Meter The more specific example of calculation machine readable storage medium storing program for executing can include but is not limited to: have the electrical connection, just of one or more conducting wires Taking formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only storage Device (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device, Or above-mentioned any appropriate combination.In this application, computer readable storage medium can be it is any include or storage journey The tangible medium of sequence, the program can be commanded execution system, device or device use or in connection.And at this In application, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal, Wherein carry computer-readable program code.The data-signal of this propagation can take various forms, including but unlimited In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for By the use of instruction execution system, device or device or program in connection.Include on computer-readable medium Program code can transmit with any suitable medium, including but not limited to: wireless, electric wire, optical cable, RF etc. are above-mentioned Any appropriate combination.
The calculating of the operation for executing the application can be write with one or more programming languages or combinations thereof Machine program code, described program design language include object oriented program language-such as Java, Smalltalk, C+ +, it further include conventional procedural programming language-such as " C " language or similar programming language.Program code can Fully to execute, partly execute on the user computer on the user computer, be executed as an independent software package, Part executes on the remote computer or executes on a remote computer or server completely on the user computer for part. In situations involving remote computers, remote computer can pass through the network of any kind --- including local area network (LAN) Or wide area network (WAN)-is connected to subscriber computer, or, it may be connected to outer computer (such as utilize Internet service Provider is connected by internet).
Flow chart and block diagram in attached drawing are illustrated according to the system of the various embodiments of the application, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of the module, program segment or code include one or more use The executable instruction of the logic function as defined in realizing.It should also be noted that in some implementations as replacements, being marked in box The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually It can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it to infuse Meaning, the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart can be with holding The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer instruction Combination realize.
Being described in unit involved in the embodiment of the present application can be realized by way of software, can also be by hard The mode of part is realized.Described unit also can be set in the processor, for example, can be described as: a kind of processor packet Include acquiring unit, determination unit, converting unit, fills unit and mask unit.Wherein, the title of these units is in certain situation Under do not constitute restriction to the unit itself, for example, acquiring unit is also described as " obtaining the list of information to be stored Member ".
As on the other hand, present invention also provides a kind of computer-readable medium, which be can be Included in device described in above-described embodiment;It is also possible to individualism, and without in the supplying device.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the device, so that should Device: information to be stored is obtained;Based on predetermined error-correction level and two dimensional code version, determination is corresponding with information to be stored Binary data and error correction code word;Binary data and error correction code word are converted to the data and error correction code word of N scale, Wherein, N is greater than 2 natural numbers;The data of N scale and error correction code word are filled into coding region;Using mask graph to volume Code region is masked to generate two dimensional code.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.Those skilled in the art Member is it should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic Scheme, while should also cover in the case where not departing from foregoing invention design, it is carried out by above-mentioned technical characteristic or its equivalent feature Any combination and the other technical solutions formed.Such as features described above has similar function with (but being not limited to) disclosed herein Can technical characteristic replaced mutually and the technical solution that is formed.

Claims (10)

1. a kind of method for generating two dimensional code, the two dimensional code include coding region, which comprises
Obtain information to be stored;
Based on predetermined error-correction level and two dimensional code version, determining binary data corresponding with the information to be stored With error correction code word;
Binary data and error correction code word are converted to the data and error correction code word of N scale, wherein N is certainly greater than 2 So number;
The data of the N scale and error correction code word are filled into the coding region;
The coding region is masked to generate two dimensional code using mask graph.
2. described to be determined based on predetermined error-correction level and two dimensional code version according to the method described in claim 1, wherein Binary data corresponding with the information to be stored and error correction code word, comprising:
Binary code word data is converted by the information to be stored;
Binary error correction code word is generated according to predetermined error-correction level;
By binary code word data and binary error correction code word by the predetermined of predetermined two dimensional code version Rule carries out interspersed placement, to generate binary data and error correction code word.
3. described that the data of the N scale and error correction code word are filled into institute according to the method described in claim 2, wherein State coding region, comprising:
For each code word data or error correction code word in the data and error correction code word of the N scale, the code word data is determined Or the Fill Color of error correction code word, and identified Fill Color is filled into the coding region for the code word data or At the pre-set position of error correction code word, wherein the corresponding relationship between the number that N scale uses and Fill Color is preparatory Setting.
4. described that the data of the N scale and error correction code word are filled into institute according to the method described in claim 2, wherein State coding region, comprising:
For each code word data or error correction code word in the data and error correction code word of the N scale, the code word data is determined Or the filling shape of error correction code word, and identified filling shape is filled into the coding region for the code word data or At the pre-set position of error correction code word, wherein the corresponding relationship between the number that N scale uses and filling shape is preparatory Setting.
5. described that the data of the N scale and error correction code word are filled into institute according to the method described in claim 2, wherein State coding region, comprising:
For each code word data or error correction code word in the data and error correction code word of the N scale, the code word data is determined Or the packing material of error correction code word, and identified packing material is filled into the coding region for the code word data or At the pre-set position of error correction code word, wherein the corresponding relationship between the number that N scale uses and packing material is preparatory Setting.
6. according to the method described in claim 1, wherein, the use mask graph is masked with life the coding region At two dimensional code, comprising:
It is masked using module figure of each predetermined pattern figure to the coding region and generates result figure;
It scores according to preset condition each result figure, and the result graphic hotsopt two dimensional code minimum based on score value.
7. according to the method described in claim 6, wherein, the data and error correction code word of the N scale are the data of the quaternary With error correction code word,
It is described to be masked using module figure of each predetermined pattern figure to the coding region, comprising:
For each module figure of the coding region, the corresponding code word data of module figure or error correction code word are taken to 2 It is remaining to determine the first numerical value, the mask value of module figure identical with the position of the module figure in predetermined pattern figure is determined For second value;First numerical value and the second value are subjected to exclusive or processing to determine third value;In response to described Third value is not 0, is negated to the code word data or error correction code word that are filled into the module figure.
8. a kind of for generating the device of two dimensional code, the two dimensional code includes coding region, and described device includes:
Acquiring unit is configured to obtain information to be stored;
Determination unit is configured to based on predetermined error-correction level and two dimensional code version, the determining and information to be stored Corresponding binary data and error correction code word;
Converting unit is configured to being converted to binary data and error correction code word into the data and error correcting code of N scale Word, wherein N is greater than 2 natural numbers;
Fills unit is configured to the data of the N scale and error correction code word being filled into the coding region;
Mask unit is configured to be masked to generate two dimensional code the coding region using mask graph.
9. a kind of device/server, comprising:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real The now method as described in any in claim 1-7.
10. a kind of computer readable storage medium, is stored thereon with computer program, wherein described program is executed by processor Method of the Shi Shixian as described in any in claim 1-7.
CN201711383739.5A 2017-12-20 2017-12-20 Method and apparatus for generating two dimensional code Pending CN109948762A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711383739.5A CN109948762A (en) 2017-12-20 2017-12-20 Method and apparatus for generating two dimensional code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711383739.5A CN109948762A (en) 2017-12-20 2017-12-20 Method and apparatus for generating two dimensional code

Publications (1)

Publication Number Publication Date
CN109948762A true CN109948762A (en) 2019-06-28

Family

ID=67005250

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711383739.5A Pending CN109948762A (en) 2017-12-20 2017-12-20 Method and apparatus for generating two dimensional code

Country Status (1)

Country Link
CN (1) CN109948762A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110517052A (en) * 2019-08-26 2019-11-29 北京太和互邦科技有限公司 A kind of two-dimensional code generation method, recognition methods, two dimensional code and equipment
CN110517051A (en) * 2019-08-26 2019-11-29 北京太和互邦科技有限公司 A kind of two dimension code generation method, coding/decoding method, two dimensional code and readable storage medium storing program for executing
CN111325299A (en) * 2020-02-18 2020-06-23 上海闻泰信息技术有限公司 Two-dimensional code image generation method and device, computer equipment and storage medium
CN112561016A (en) * 2020-12-23 2021-03-26 杭州天谷信息科技有限公司 Two-dimensional code generation method and system and document anti-counterfeiting method and system
CN114004320A (en) * 2021-10-15 2022-02-01 库卡机器人(广东)有限公司 Graphic code generation method and device, graphic code identification method and device, and electronic equipment
WO2024113874A1 (en) * 2022-11-30 2024-06-06 上海哔哩哔哩科技有限公司 Encoding method and decoding method for annular 2-dimensional bar code

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11502654A (en) * 1995-03-31 1999-03-02 キウィソフト プログラムス リミティッド Machine readable label
CN106156820A (en) * 2015-03-25 2016-11-23 北大方正集团有限公司 two-dimensional code generation method and device
CN106815544A (en) * 2017-01-16 2017-06-09 武汉大学 A kind of information concealing method based on Quick Response Code

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11502654A (en) * 1995-03-31 1999-03-02 キウィソフト プログラムス リミティッド Machine readable label
CN106156820A (en) * 2015-03-25 2016-11-23 北大方正集团有限公司 two-dimensional code generation method and device
CN106815544A (en) * 2017-01-16 2017-06-09 武汉大学 A kind of information concealing method based on Quick Response Code

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
中国物品编码中心: "《二维条码技术与应用》", 31 July 2007 *
杨希玲等: "《物流信息技术》", 31 August 2014, 中国轻工业出版社 *
陈元枝等: "基于Zxing的彩色QR码生成与识别方法", 《桂林电子科技大学学报》 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110517052A (en) * 2019-08-26 2019-11-29 北京太和互邦科技有限公司 A kind of two-dimensional code generation method, recognition methods, two dimensional code and equipment
CN110517051A (en) * 2019-08-26 2019-11-29 北京太和互邦科技有限公司 A kind of two dimension code generation method, coding/decoding method, two dimensional code and readable storage medium storing program for executing
CN110517052B (en) * 2019-08-26 2022-09-23 北京太和互邦科技有限公司 Two-dimensional code generation method, two-dimensional code identification method, two-dimensional code and equipment
CN111325299A (en) * 2020-02-18 2020-06-23 上海闻泰信息技术有限公司 Two-dimensional code image generation method and device, computer equipment and storage medium
CN111325299B (en) * 2020-02-18 2023-07-28 上海闻泰信息技术有限公司 Two-dimensional code image generation method and device, computer equipment and storage medium
CN112561016A (en) * 2020-12-23 2021-03-26 杭州天谷信息科技有限公司 Two-dimensional code generation method and system and document anti-counterfeiting method and system
CN114004320A (en) * 2021-10-15 2022-02-01 库卡机器人(广东)有限公司 Graphic code generation method and device, graphic code identification method and device, and electronic equipment
CN114004320B (en) * 2021-10-15 2023-11-28 库卡机器人(广东)有限公司 Method and device for generating graphic code, method and device for identifying graphic code and electronic equipment
WO2024113874A1 (en) * 2022-11-30 2024-06-06 上海哔哩哔哩科技有限公司 Encoding method and decoding method for annular 2-dimensional bar code

Similar Documents

Publication Publication Date Title
CN109948762A (en) Method and apparatus for generating two dimensional code
US20190164250A1 (en) Method and apparatus for adding digital watermark to video
CN108985066A (en) Intelligent contract security vulnerability detection method, device, terminal and storage medium
CN110263279B (en) Page generation method and device, electronic equipment and computer readable storage medium
CN111242259B (en) Intelligent anti-counterfeiting code encoding and decoding method and system
CN109062560B (en) Method and apparatus for generating information
CN115358911B (en) Screen watermark generation method, device, equipment and computer readable storage medium
CN109947431A (en) A kind of code generating method, device, equipment and storage medium
CN111222611A (en) Stacking type three-dimensional code encoding method, encoding device, decoding method, decoding device and storage medium based on colors
CN110751251B (en) Method and device for generating and transforming two-dimensional code image matrix
CN111142863B (en) Page generation method and device
CN108090468B (en) Method and apparatus for detecting face
US10542176B2 (en) Enhancing graph visualization with supplemental data
CN116052195A (en) Document parsing method, device, terminal equipment and computer readable storage medium
CN110969042A (en) Two-dimensional code identification method and device and hardware device
CN109271826A (en) The method and apparatus of two dimensional code for identification
CN109255417A (en) Method and apparatus for generating two dimensional code
CN110969233A (en) Two-dimensional code generation method and device and hardware device
CN114816382A (en) Method and device for processing page
CN114626968A (en) Watermark embedding method, watermark extracting method and device
CN110378457B (en) Code label generation method and device
CN109472740A (en) The method and apparatus for generating figure based on web front end
CN111797646A (en) Bar code identification method and terminal
CN109003223A (en) Image processing method and device
CN108629530A (en) Information processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190628