WO2022199471A1 - 一种二维码生成、解码方法、装置及设备 - Google Patents

一种二维码生成、解码方法、装置及设备 Download PDF

Info

Publication number
WO2022199471A1
WO2022199471A1 PCT/CN2022/081625 CN2022081625W WO2022199471A1 WO 2022199471 A1 WO2022199471 A1 WO 2022199471A1 CN 2022081625 W CN2022081625 W CN 2022081625W WO 2022199471 A1 WO2022199471 A1 WO 2022199471A1
Authority
WO
WIPO (PCT)
Prior art keywords
dimensional code
image
position information
code
information
Prior art date
Application number
PCT/CN2022/081625
Other languages
English (en)
French (fr)
Inventor
屠寅海
陶乐
Original Assignee
支付宝(杭州)信息技术有限公司
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 支付宝(杭州)信息技术有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2022199471A1 publication Critical patent/WO2022199471A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/06009Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
    • G06K19/06037Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/06009Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
    • G06K19/06046Constructional details
    • G06K19/06075Constructional details the marking containing means for error correction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/06009Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
    • G06K19/06046Constructional details
    • G06K19/06103Constructional details the marking being embedded in a human recognizable image, e.g. a company logo with an embedded two-dimensional code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/06009Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
    • G06K19/06046Constructional details
    • G06K19/06131Constructional details the marking comprising a target pattern, e.g. for indicating the center of the bar code or for helping a bar code reader to properly orient the scanner or to retrieve the bar code inside of an image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1443Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/146Methods for optical code recognition the method including quality enhancement steps
    • G06K7/1473Methods for optical code recognition the method including quality enhancement steps error correction

Definitions

  • the present application relates to the field of Internet technologies, and in particular, to a method, device, and device for generating and decoding a two-dimensional code.
  • QR codes have become more and more extensive, especially in the fields of mobile payment and online social networking. Due to its large information capacity and fast identification, it has been rapidly popularized in people's daily life.
  • two-dimensional codes have been widely promoted, in traditional two-dimensional codes, the back of each two-dimensional code may represent a file, a page, or an application. Due to its openness, it is easy to become a hotbed of Trojan horse viruses.
  • users scan the code they give up scanning the code out of fear that their mobile phone may be infected with viruses after scanning the code, and the traditional QR code cannot meet the brand promotion of the applet. need.
  • the applet code came into being. Compared with the ordinary two-dimensional code, the applet code looks more beautiful. Moreover, for the applet code, the user can clearly know the scan code before scanning the applet code. Afterwards, you will experience an application of what kind of applet.
  • the embodiments of this specification provide a method, device and device for generating and decoding a two-dimensional code, so as to solve the problem of low recognition rate existing in the existing two-dimensional code identification method.
  • a method for generating a two-dimensional code includes: acquiring a two-dimensional code code of a two-dimensional code image to be generated;
  • the coding adopts a coding algorithm with a preset error tolerance rate to perform error-tolerant coding, and obtains a two-dimensional code code after error-tolerant processing; it is determined that each data information bit of the two-dimensional code code after the fault-tolerant processing corresponds to the generation area of the two-dimensional code image.
  • the shape of the code element includes a dot or an arc; according to the preset arrangement rule of the two-dimensional code, it is determined that each data information bit encoded by the two-dimensional code after the error-tolerant processing corresponds to the generation area determine the second position information of each positioning point in the generation area; based on the first position information, the symbol shape corresponding to each data information bit and the second position of each positioning point information to generate a QR code image.
  • a two-dimensional code decoding method includes: acquiring image information of a two-dimensional code image to be recognized; determining, according to the image information of the two-dimensional code image to be recognized The positioning point position information of each positioning point in the image; based on the positioning point position information, determine the position information of each data information in the image; position information, determine the symbol shape corresponding to each data information bit; the symbol shape includes dots or arcs; according to preset arrangement rules; according to the symbol shape corresponding to each data information bit, generate a two-dimensional code encoding; using a preset decoding algorithm to decode the two-dimensional code encoding to obtain the content information stored in the data information bits.
  • a two-dimensional code generation device includes: a two-dimensional code code acquisition module, used to obtain the two-dimensional code code of the two-dimensional code image to be generated; an error-tolerant encoding module, used for the two-dimensional code
  • the coding adopts a coding algorithm with a preset error-tolerance rate to perform error-tolerant coding, and obtains a two-dimensional code code after error-tolerant processing; the symbol shape determination module is used to determine that each data information bit of the two-dimensional code code after the fault-tolerant processing is in the second position.
  • the first position information determination module is used for determining the error-tolerant processing according to the preset arrangement rule of the two-dimensional code encoding The first position information corresponding to each data information bit encoded by the two-dimensional code is in the generation area; the second position information determination module is used to determine the second position information of each positioning point in the generation area; two-dimensional information A code image generation module, configured to generate a two-dimensional code image based on the first position information, the symbol shape corresponding to each data information bit, and the second position information of each positioning point.
  • a two-dimensional code decoding device includes: an image information acquisition module for acquiring image information of a two-dimensional code image to be identified; a positioning point position information determination module for according to the two-dimensional code to be identified.
  • the image information of the code image to determine the positioning point position information of each positioning point in the to-be-recognized two-dimensional code image; the data information bit position information determination module is used to determine the positioning point position information based on the positioning point information.
  • a symbol shape determination module configured to determine the symbol shape corresponding to each data information bit based on the position information of each data information bit in the image;
  • the code element shape includes dots or arcs;
  • a two-dimensional code code generation module is used to generate a two-dimensional code code according to a preset arrangement rule; a two-dimensional code code is generated according to the code element shape corresponding to each of the data information bits;
  • a decoding module with Decoding the two-dimensional code using a preset decoding algorithm to obtain the content information stored in the data information bits.
  • a two-dimensional code generating device includes: at least one processor; and a memory connected in communication with the at least one processor; wherein, the memory stores data that can be used by the at least one processor
  • the instruction to be executed, the instruction is executed by the at least one processor, so that the at least one processor can: obtain the two-dimensional code encoding of the two-dimensional code image to be generated; use a preset for the two-dimensional code encoding
  • the coding algorithm of the error-tolerance rate performs error-tolerant coding to obtain the two-dimensional code code after the fault-tolerant processing; determining the corresponding symbol shape of each data information bit of the two-dimensional code code after the fault-tolerant processing in the generation area of the two-dimensional code image;
  • the shape of the code element includes a dot or an arc; according to the preset arrangement rule of the two-dimensional code encoding, determine the first position information corresponding to each data information bit encoded by the two-dimensional code after the error-tolerant processing in the generation area Determine the second position information of each positioning
  • a two-dimensional code decoding device includes: at least one processor; and a memory connected in communication with the at least one processor; wherein, the memory stores data that can be accessed by the at least one processor
  • the instruction to be executed, the instruction is executed by the at least one processor, so that the at least one processor can: obtain the image information of the two-dimensional code image to be recognized; according to the image information of the two-dimensional code image to be recognized, Determine the location information of each location in the image to be identified for each location of the two-dimensional code image; determine the location information of each data information in the image based on the location information of the location;
  • the position information of each data information bit in the image determines the symbol shape corresponding to each data information bit; the symbol shape includes dots or arcs; according to preset arrangement rules; according to each of the data
  • the shape of the symbol corresponding to the information bit generates a two-dimensional code code; the two-dimensional code code is decoded by using a preset decoding algorithm to obtain the content information stored in the data information bit.
  • a computer-readable medium provided by an embodiment of the present specification stores computer-readable instructions thereon, and the computer-readable instructions can be executed by a processor to implement a method for generating and decoding a two-dimensional code.
  • An embodiment of the present specification achieves the following beneficial effects: by acquiring the two-dimensional code encoding of the two-dimensional code image to be generated, using an encoding algorithm with a preset error tolerance rate to perform error-tolerant encoding, and obtaining the two-dimensional code encoding after error-tolerant processing; Determine the symbol shape corresponding to each data information bit encoded by the fault-tolerant two-dimensional code in the generation area of the two-dimensional code image; determine the two-dimensional code after the fault-tolerant processing according to the preset arrangement rule of the two-dimensional code encoding The first position information corresponding to each data information bit encoded by the code in the generation area; then determine the second position information of each positioning point in the generation area; then based on the first position information, each data information The shape of the symbol corresponding to the bit and the second position information of each positioning point are used to generate a two-dimensional code image.
  • the generated applet code is circular as a whole, and the data area is a circular ring composed of dots and arcs. And in the blank area with the same interval between the adjacent rings, the middle area and the lower right corner area are used as the logo display area, the data is evenly distributed, and the data error tolerance of each part is consistent. It can generate two-dimensional codes with strong anti-distortion ability and strong anti-pollution ability.
  • FIG. 1 is a schematic flowchart of a method for generating a two-dimensional code according to an embodiment of the present specification
  • FIG. 2 is a schematic structural diagram of a small program code provided by an embodiment of the present specification
  • FIG. 3 is a schematic flowchart of a two-dimensional code decoding method provided by an embodiment of the present specification
  • FIG. 5 is a schematic diagram of a two-dimensional code generation device provided by an embodiment of this specification.
  • FIG. 6 is a schematic diagram of a two-dimensional code decoding device provided by an embodiment of this specification.
  • FIG. 7 is a schematic diagram of generating and decoding a two-dimensional code provided by an embodiment of this specification.
  • Two-dimensional code is also called two-dimensional barcode.
  • the common two-dimensional code is QR Code.
  • the full name of QR is Quick Response. It is a super popular coding method on mobile devices in recent years. It can store more than traditional Bar Code barcodes information, and can also represent more data types.
  • the applet code is attached to the application program compared to the two-dimensional code.
  • the applet code of some chat apps can only be generated and recognized by the chat app, which is more secure. High, and the lower right corner of each applet code is a fixed applet logo, so that more brand information can be transmitted transparently.
  • the existing applet codes still have certain limitations.
  • the anti-image distortion capability of the applet code is insufficient, and the applet code is printed on a flat plane. If the plane where the applet code is located is convex or concave, for example, the QR code is printed on a sphere, the recognition rate of the QR code will drop significantly.
  • the recognition ability of QR codes is very limited.
  • the contamination of a small block at any position may cause the applet code to fail to be recognized.
  • FIG. 1 is a schematic flowchart of a method for generating a two-dimensional code according to an embodiment of the present specification. From a program perspective, the execution body of the process may be a program mounted on an application server or an application client.
  • Step 110 Obtain the two-dimensional code code of the two-dimensional code image to be generated.
  • the two-dimensional code encoding can represent the encoding used to generate the two-dimensional code image, for example, it can be a string of preset digits, such as binary sequence, ternary sequence, etc.
  • a series of two-dimensional code sequences can be obtained.
  • the two-dimensional code here may refer to a small program code, and the small program code may represent a two-dimensional code attached to an original application and used for a certain function.
  • the applet code in instant messaging applications and the applet code in payment applications.
  • the applet code can be used in many scenarios such as ordering, payment, ticket purchase, and medical registration.
  • a two-dimensional code may refer to a two-dimensional code code or a two-dimensional code picture, which may be set according to actual needs, which is not specifically limited in this application.
  • the two-dimensional code information refers to information with actual meaning carried in the two-dimensional code encoding, for example, user center identification information and the like.
  • Step 120 Perform error-tolerant encoding on the two-dimensional code using an encoding algorithm with a preset error-tolerance rate, to obtain a two-dimensional code after error-tolerant processing.
  • Error-tolerant coding can mean that a part of redundant information is added in the encoding process to enhance the anti-error ability, and strive to obtain the maximum gain with the least amount of redundancy, and its anti-error performance is at the expense of encoding efficiency. cost.
  • error-tolerant coding techniques mainly include: Insertion of Synchronization Marks (RM), Data Partitioning (DP), Reversible Length Coding (RVLC), Parameter Sets, Intra-Frame Coding Update Technology, Hierarchical Coding (LC) technique, Multiple Description Coding (MDC) for correlated sub-stream transmission, etc.
  • the fault tolerance rate of a QR code can refer to the fact that even if the generated QR code is partially blocked, or a part of it is not fully displayed, the user can scan it successfully. Rate.
  • Fault-tolerant coding has multiple levels of fault-tolerant, which can also be understood as fault-tolerant coding with multiple levels of redundancy.
  • the fault-tolerant coding of each version corresponds to four fault-tolerant levels of L, M, Q, and H, respectively.
  • L-level fault-tolerant applet code about 10% of the characters can be corrected; for the M-level fault-tolerant applet, about 15% of the characters can be corrected; for the Q-level fault-tolerant applet, about 25% Word codes can be corrected; for H-level fault-tolerant small program codes, about 35% of the word codes can be corrected.
  • H-level fault-tolerant small program codes about 35% of the characters can be corrected. This means that in the best case, when 35% of the small program code is blocked/damaged, the scanning engine can still recognize the information carried by the small program code.
  • the 35% damaged area cannot be a positioning pattern or functional data, but must be a pure coding area, and the erroneous areas must be evenly distributed to be able to The entire QR code is recognized.
  • the error tolerance rate is preset. Once the version and error correction level of the applet code are determined, the corresponding error correction code can be fixed. In the whole process, there is no need to add additional error tolerance information. This ensures that the data corresponding to the coding area is uniform. Therefore, no matter which part of the applet code is blocked, as long as the positioning point is not blocked and the blocked area is less than or equal to 35%, the applet code can still be identified. In addition, in the decoding stage, the error correction code can also be eliminated through corresponding rules to obtain corresponding content information.
  • the data of the generated applet code is evenly distributed, and the data of each part is consistent in fault-tolerance.
  • the use of fixed fault-tolerant fault-tolerant coding can ensure the fault-tolerant ability of the applet code, so that the generated applet code has anti-fouling, anti-distortion, anti-reflection and other capabilities.
  • Step 130 Determine the symbol shape corresponding to each data information bit encoded by the error-tolerant two-dimensional code in the generation area of the two-dimensional code image; the symbol shape includes a dot or an arc.
  • the generation area may represent an area for generating a two-dimensional code.
  • the data information bits may represent points in the applet code used to represent the content information. Specifically, commodity information or other content information may be stored in the data information bit, and the scanning device may acquire the content information stored in the data information bit by scanning the applet code.
  • the generation area of the two-dimensional code may refer to the contour area of the two-dimensional code.
  • the contour area of the two-dimensional code is a circular area with a diameter of 6 cm.
  • the shape of a symbol may refer to the shape of a code block used to carry content information in a two-dimensional code image, such as: dots, squares, rectangles, arcs, and so on.
  • the shape of the symbol may include dots and arcs.
  • the value of each code bit corresponds to the shape of the code element in the applet code.
  • the "1" in the binary sequence indicates that the code element shape is a black dot.
  • "0" in binary is represented as a white dot (the default background color is white at this time), if "1" appears continuously in the binary sequence, it constitutes a black arc.
  • Step 140 According to the preset arrangement rule of the two-dimensional code encoding, determine the first position information corresponding to each data information bit encoded by the two-dimensional code after the error-tolerant processing in the generation area.
  • the first position information may represent the corresponding position of each data information bit in the generation area.
  • the preset arrangement rule may represent a preset ordering rule for QR code encoding.
  • the preset arrangement rule can set the starting code element point in the QR code image corresponding to the QR code encoding, or Set the symbol point in the two-dimensional code image corresponding to each code bit in the two-dimensional code encoding, so that based on the two-dimensional code encoding, according to the preset arrangement rules, it can be determined that each data information bit is specifically in the generation area. s position.
  • Step 150 Determine the second position information of each positioning point in the generation area.
  • the second position information may indicate the corresponding position of each positioning point in the generation area.
  • the positioning point can represent the point where the two-dimensional code is located. Generally, there are four positioning points, including the direction positioning point, and the direction positioning point can mark the direction of the two-dimensional code.
  • the orientation positioning point can be set at the lower right corner of the QR code image, and other positioning points can be set at the upper left corner, the lower left corner and the upper right corner in the generation area of the QR code image, respectively.
  • Step 160 Generate a two-dimensional code image based on the first position information, the symbol shape corresponding to each data information bit, and the second position information of each positioning point.
  • each positioning point and the position information of the valid information bits may be represented by coordinates, or may be represented in the form of a matrix.
  • each positioning point bit and valid information bit in the two-dimensional code can be correspondingly converted into corresponding elements in each row and each column in the matrix. For example: convert the positioning point of the upper left positioning area in the QR code to the element corresponding to the first row and first column in the matrix.
  • a two-dimensional code image may include positioning points for positioning the two-dimensional code and data information bits for carrying content information, wherein the symbol shape of each positioning point is known. After the position information of the bit, the position information of each data information bit, and the symbol shape of each data information bit, the corresponding two-dimensional code image can be generated.
  • each data information bit encoded by the two-dimensional code after the error-tolerant processing is determined corresponding first position information in the generation area; then determine the second position information of each positioning point in the generation area; then based on the first position information, the symbol shape corresponding to each data information bit, and The second position information of each positioning point generates a two-dimensional code image.
  • the shape design of dots and arcs and the use of fixed error-tolerant coding algorithms for coding can generate QR codes with strong anti-distortion and anti-pollution capabilities.
  • the determining the code element shape corresponding to each data information bit encoded by the fault-tolerant two-dimensional code in the generation area of the two-dimensional code image may specifically include: for the two-dimensional code after the fault-tolerant processing. each code bit in the code encoding, determine the order of the code bit in the two-dimensional code encoding after the error-tolerant processing; determine the position of the data information bit corresponding to the order in the two-dimensional code generation area; according to The value of the coded bit determines the shape of the symbol corresponding to the data information bit at the position.
  • using a coding algorithm with a preset error tolerance rate for error-tolerant coding can be understood as using a fixed error-tolerant coding algorithm to convert the data corresponding to the content information into a character string with a preset number of digits, for example: using a fixed error-tolerant coding
  • the algorithm converts the data corresponding to the content information into a binary sequence.
  • the content information may represent the information that the two-dimensional code needs to carry. For example: product information, application function information, platform information, brand information, etc.
  • the characters corresponding to the content information can be divided into groups of three bits, each group of data can be converted into 10-bit binary data, and the remaining one or two bits can be converted into 4- or 7-bit binary data data.
  • each binary bit in a binary sequence has an order in the binary sequence.
  • a binary sequence is 010110101, starting from left to right, the first binary digit in the binary sequence is 0, the second binary digit is 1, the third binary digit is 0...
  • the ninth binary digit is 1.
  • the first binary bit in the binary sequence corresponds to the preset starting point in the data information bits in the two-dimensional code
  • the second binary bit in the binary sequence corresponds to the second point in the data information bits in the two-dimensional code Bit
  • the binary bits in the binary sequence correspond to the corresponding positions in the data information bits in the two-dimensional code respectively.
  • the number of dots corresponding to the arc can be set. For example, at least three black dots can be set to correspond to a segment of the arc, that is, when there are three consecutive arcs in the binary sequence When "1", an arc will be formed.
  • the distance between adjacent dots and the distance between the dots and adjacent arcs can also be set. You can also set the arrangement angle of the dots and arcs, where the arrangement angle can refer to the angle value corresponding to the polar coordinate.
  • the generating area further includes mask information; before the acquiring the two-dimensional code encoding of the two-dimensional code image to be generated, may further include: masking the two-dimensional code encoding according to the mask information. After mask processing, the two-dimensional code code after mask processing is obtained.
  • the mask information can be stored in other points except the positioning point, and how many symbols are needed to store the mask information can be determined according to the capacity or size of the generated two-dimensional code. Two kinds of masks can be stored in a symbol.
  • the area where the data information bits are located may be a digital area, and the area where the positioning point bits are located may be a functional area.
  • Mask processing only masks the digital area where the data information bits are located, and does not affect the functional area where the positioning points are located.
  • the function of the mask can be to make the dots and arcs in the two-dimensional code evenly distributed, so that the accuracy of the two-dimensional code recognition can be improved.
  • the quality of the mask is determined by the mask.
  • the mask may refer to a strategy for changing the values of symbols in the two-dimensional code area according to specific rules.
  • the purpose of using the mask is to adjust the display of each symbol in the two-dimensional code. If a symbol in the two-dimensional code is masked, it can be understood that if the symbol is a white dot before masking, it can become a black dot after masking. In other words, the mask can be understood as modifying the pixel value of the symbol in the two-dimensional code.
  • error-tolerant coding is performed by using a coding algorithm with a preset error-tolerance rate, which can ensure that the data in the generated applet code is evenly distributed, and the data mentioned here may include the content that needs to be carried Corresponding data and metadata of code basic information.
  • the role of the mask is to ensure that the shape or color of the symbols in the generated applet code appears to be evenly distributed.
  • the applet code generated in the above embodiment can be described with reference to FIG. 2 .
  • FIG. 2 is a schematic structural diagram of a small program code provided by an embodiment of the present specification.
  • the overall image of the applet code is a circular ring, and the image of the applet code may include a ring formed by the dots 240 and the arcs 250 , a middle area 220 , and a first positioning point. 210 and the orientation anchor point 230.
  • the ring width of each ring is the same.
  • the ring width of the ring can be understood as the width of the arc 250 , and can also be understood as the diameter length of the dot 240 .
  • the diameter of each dot 240 is equal to the width of the arc 250 .
  • the middle area 220 is concentric with the ring; the middle area 220 is used to display a first logo, and the first logo may be a brand logo; the adjacent rings have the same interval; The interval between the middle area 220 and the circles formed by adjacent symbol shapes is the same as the interval between the adjacent circles. As shown in Figure 1, the background color is white by default, and there are blank spaces between adjacent rings.
  • the background color of the two-dimensional code image and the color of the identification area in the two-dimensional code can be set according to actual application scenarios.
  • the two colors mentioned in the above steps may represent the two colors after binarization, rather than the two colors in the sense of color.
  • the initially generated QR code has multiple colors, and after binarization, there are only two colors.
  • the data area may be three circles composed of dots 240 or arcs 250 for carrying data.
  • Use a fault-tolerant algorithm with a set fault-tolerance efficiency for fault-tolerant coding For example, use a fault-tolerant coding with an overall fault-tolerance rate of 25%.
  • the specific fault-tolerant strategy is (16,8), that is, the valid data is 16 bytes, and a maximum of 8 bytes are supported for error correction.
  • the total length of the data stream is 32 bytes.
  • the direction positioning point 230 in the lower right corner can be used as an auxiliary positioning point to participate in the positioning and decoding of the code, and is also used to display the second mark. Further, the display area of the second mark in the lower right corner can be smaller than the second mark in the middle area. In the display area of one logo, the content in the two LOGO areas can be customized as needed, such as brand, activity logo, etc.
  • the data area can be selected as 3 circles or 4 circles, and the outermost circle (the fourth circle) can be used to carry data, and can also be used as a modification of the applet code image.
  • the generated applet code is in the shape of a circular ring as a whole, and the data area is a circular ring formed by dots and arcs. And in the blank area with the same interval between the adjacent rings, the middle area and the lower right corner area are used as the logo display area, which is coded with fixed fault tolerance, and there is no need to transparently transmit fault tolerance information, so that the data is distributed evenly. It can ensure that the generated two-dimensional code has strong anti-distortion ability, strong anti-fouling ability, and can transparently transmit more brand information.
  • the generated two-dimensional code corresponds to a decoding method:
  • FIG. 3 is a schematic flowchart of a two-dimensional code decoding method according to an embodiment of the present specification. From a program perspective, the execution body of the process may be a program mounted on an application server or an application client.
  • the decoding process in Embodiment 2 corresponds to the encoding process in Embodiment 1.
  • Step 310 Acquire image information of the two-dimensional code image to be recognized.
  • the image information mentioned in this step may represent the information of the two-dimensional code itself that is not limited by the two-dimensional code carrier, such as the information of the two-dimensional code drawn on the computer.
  • the size information of the two-dimensional code the position information of each positioning point, the position information of the data information bit, and the symbol shape and symbol color corresponding to each point in the two-dimensional code.
  • Step 320 According to the image information of the two-dimensional code image to be identified, determine the positioning point position information in the image of each positioning point in the two-dimensional code image to be identified.
  • Step 330 Based on the position information of the positioning point, determine the position information of each data information in the image.
  • the position information of each positioning point can be determined from the image information of the two-dimensional code, the logo display area reserved in the middle is known, and the remaining points except the positioning point and the middle display area can be determined as data information bits .
  • Content information may be stored in the data information bits.
  • the scanning device can obtain the content information stored in the data information bits by scanning the two-dimensional code.
  • Step 340 Based on the position information of each data information bit in the image, determine a symbol shape corresponding to each data information bit; the symbol shape includes a dot or an arc.
  • the shape of the symbol corresponding to each data information bit can be determined from the image information.
  • Step 350 According to a preset arrangement rule; generate a two-dimensional code code according to the shape of the symbol corresponding to each of the data information bits.
  • the preset arrangement rule can be the arrangement rule used when the applet code is generated. When decoding, it is only necessary to perform corresponding analysis according to the arrangement rule used when generating the applet QR code, and then the information bits of each data information bit can be parsed. The symbol shape is parsed into a QR code encoding.
  • Step 360 Decode the two-dimensional code using a preset decoding algorithm to obtain the content information stored in the data information bits.
  • Embodiment 1 should correspond to the decoding algorithm in Embodiment 2. Assuming that the content information is encoded by a fault-tolerant algorithm with a fault tolerance of 25% to obtain a binary sequence, then, when decoding, a fault-tolerant 25% fault-tolerant algorithm should also be used. A fault-tolerant algorithm decodes the binary sequence. It should be noted that the specific selection of the fault-tolerant algorithm can be selected according to the actual application scenario.
  • the image of the two-dimensional code to be identified may be a circular ring; the image includes a first positioning point and a direction positioning point; the upper left corner position, the upper right corner position and the lower left corner position distribution of the image. There is a first positioning point; a direction positioning point is distributed in the lower right corner of the image.
  • the determining, according to the image information of the to-be-recognized two-dimensional code image, the location information of the location of each location in the to-be-recognized two-dimensional code image may specifically include: The positioning point position information, using an adaptive sampling algorithm to determine the position information of each positioning point in the to-be-recognized two-dimensional code image in the image and the position information of each data information in the image .
  • an adaptive sampling algorithm is used to determine the position of the sampling point, and finally a bit stream is obtained by sampling, which can further improve the recognition rate of the nonlinear distortion scene.
  • distortion is some common nonlinear transformations, such as the change of the wrinkle on the surface of the material, and the material is laid on an uneven surface, such as the surface of a cylinder, so that the code changes.
  • the corresponding process is: find four positioning points in the incoming frame image, according to the four positioning points (prefabricated) of the coordinate system on the code and the four positioning points of the image coordinate system.
  • Point calculate the transformation matrix from the coordinate system on the code to the coordinate system on the map; then based on the transformation matrix and the data points (prefab) of the coordinate system on the code, calculate the sampling position of the coordinate system on the map, directly at the corresponding point
  • the 0/1 bit stream is obtained by sampling, and finally the original data is obtained by decoding the bit stream.
  • the first point collected based on the sampling position is directly used as the final sampling point for sampling.
  • the image of the applet code is easily compressed due to the nonlinear distortion scenario. Part of the image is compressed or stretched, causing the shape of some symbols in the applet code image to change, and it is easy to use the wrong sampling point as the final sampling point to collect the wrong bit stream. For example, it was originally an arc, but it was compressed. After that, the collected dots are dots, which leads to the final identification error of the applet code.
  • the embodiment of this specification further improves the sampling method in the decoding method for the applet code on the basis of improving the applet code, and corrects the error based on the adaptive sampling, so as to obtain the correct sampling point position, and sample a bit stream with a higher accuracy rate, thereby improving the identification accuracy rate of the applet code.
  • the determining the position information of each piece of data information in the image based on the position information of the positioning point and adopting an adaptive sampling algorithm may specifically include: determining the position information of the positioning point based on the position information of the positioning point. Identify the first position information of each positioning point in the image coordinate system in the two-dimensional code image; obtain the second position information of each positioning point in the coordinate system on the code; based on the first position information and the first position information Two position information, calculate the transformation matrix between the coordinate system on the code and the image coordinate system; obtain the third position information of each data information bit in the coordinate system on the code; based on the transformation matrix and the third position information position information, to determine the initial sampling point position of each data information in the image coordinate system; based on the adaptive sampling algorithm, correct the initial sampling point position to determine that each data information is located in the image coordinate system
  • the position of the final sampling point in the image; based on the position of the final sampling point, sampling is performed in the to-be-identified image to obtain the position information of each data information bit in the image
  • the coordinate system on the code can represent the coordinate system based on the viewing angle of the code, regardless of any changes.
  • the upper left corner of the circumscribed square of the code is the origin, and a single data point is 1 unit.
  • the coordinate system on the figure can represent the coordinate system based on the viewing angle of the incoming frame image, the coordinate system with the upper left corner of the image as the origin, and each pixel is 1 unit.
  • the error generated by distortion has the following two characteristics: distortion is gradually accumulated, there is always a certain sampling point that is accurate, and then slowly shifts to the exact sampling position, the error of distortion is transitive, a sampling point and the surrounding sampling point The sampling points of , the errors are similar.
  • the ideal sampling point is always at the center of the data point. For example, if it is a black dot, the sampling point should be at the center of the black dot, and if it is an arc, the sampling point should be at the arc. Half the width and half a unit or more on either side of the principle.
  • FIG. 4 is a schematic flowchart of adaptive sampling in a two-dimensional code decoding method provided by an embodiment of the present specification.
  • the historical error can be superimposed after the sampling is started; then initial sampling is performed according to the traditional sampling method, and the initial sampling result is obtained from the initial sampling.
  • the initial sampling result may include black sampling result 1 or white sampling result 0.
  • the sampling point can be corrected to the center of the black dot or to the position of half the width of the small arc and half a unit from the edge.
  • the initial sampling value is 0
  • search for the set distance on both sides in the diameter direction The set distance can be adjusted based on the actual application scenario. If a black block is found after moving the set distance, it can be explained that The sampling result here should be black. Correct the original white sampling point to the ideal sampling position corresponding to the black sampling point. For example, move to the center of the circle corresponding to the black sampling point.
  • Error correction is performed based on historical errors, and after correction, resampling is performed based on new sampling points.
  • error correction can mean correcting the result of the initial sampling. For example, when the initial sampling result is a black dot, the sampling point can be corrected to the center of the black dot or to the position of half the width of the small arc and half a unit from the edge.
  • the initial sampling result is white
  • search for the set distance on both sides in the diameter direction The set distance can be adjusted based on the actual application scenario. If a black block is found after moving the set distance, it means this The sampling point should be black, and the original white sampling point should be corrected to the ideal sampling position of the black sampling point. If it is still a white block after moving the set distance, it can be determined that the position of the initial sampling point does not need to be corrected, and all sampling ends.
  • a final sampling point position is obtained, sampling is performed based on the final sampling point position, a bit stream is obtained, and finally corresponding content information is obtained by decoding.
  • the self-adaptive sampling method is used for decoding, which can improve the recognition accuracy of the applet code.
  • the generated applet code is a circular ring as a whole, and the data area is a circular ring composed of dots and arcs. And in the blank area with the same interval between the adjacent rings, the middle area and the lower right corner area are used as the logo display area, the data is evenly distributed, and the data error tolerance of each part is consistent.
  • using 25% fault-tolerant error-tolerant coding ensures the error-tolerant ability of the code. It can ensure that the generated two-dimensional code has strong anti-distortion ability, strong anti-fouling ability, and can transparently transmit more brand information.
  • the code elements of dark, high light and medium light are used to carry data, which will greatly reduce the cost of small program codes in complex offline environments (such as dark light, reflective scenes, etc.). Identify success rates.
  • the data display of binary images has a higher recognition rate in low-light/high-light scenes.
  • the middle area of the applet code and the direction positioning point area in the lower right corner are set as the area where the logo is displayed, which enriches the information content that the user can directly obtain.
  • two LOGO areas are reserved, which can reveal the main brand and service type, function or activity (such as red envelopes, ordering, etc.) information at the same time. Using a specific design shape is conducive to cultivating the user's scanning habit.
  • FIG. 5 is a schematic diagram of a two-dimensional code generating apparatus provided by an embodiment of the present specification.
  • the device may include: a two-dimensional code encoding acquisition module 510 for acquiring the two-dimensional code encoding of the two-dimensional code image to be generated; an error-tolerant encoding module 520 for using a pre-determined two-dimensional code encoding for the two-dimensional code.
  • the coding algorithm that sets the error-tolerance rate performs error-tolerant coding, and obtains the two-dimensional code encoding after the error-tolerant processing; the symbol shape determination module 530 is used to determine that each data information bit of the two-dimensional code encoding after the fault-tolerant processing is in the two-dimensional code.
  • the corresponding symbol shape in the generation area of the image; the symbol shape includes a dot or an arc; the first position information determination module 540 is used to determine the error-tolerant processing according to the preset arrangement rule of the two-dimensional code encoding.
  • the code element shape determination module 530 may be specifically configured to: for each code bit in the error-tolerant two-dimensional code encoding, determine the code bit in the two-dimensional code after the error-tolerant processing. The sequence in encoding; determining the position of the data information bit corresponding to the sequence in the two-dimensional code generation area; determining the symbol shape corresponding to the data information bit at the position according to the value of the encoding bit.
  • the apparatus may further include: a mask module, configured to perform mask processing on the two-dimensional code according to the mask information to obtain a mask-processed two-dimensional code.
  • a mask module configured to perform mask processing on the two-dimensional code according to the mask information to obtain a mask-processed two-dimensional code.
  • the positioning points may include a first positioning point and a second positioning point; the first positioning points may be respectively distributed in the upper left corner, the upper right corner and the lower left corner of the generation area. ; The second positioning point may be distributed in the lower right corner of the generation area.
  • the two-dimensional code image may include a ring formed by the dot and the arc; the ring width of each ring of the ring is the same.
  • the two-dimensional code image may further include a middle area, and the middle area is concentric with the ring; the middle area may be used to display the first logo; there is a space between the adjacent rings. The same interval; the interval between the middle area and the circle formed by the adjacent symbol shapes is the same as the interval between the adjacent circles.
  • the symbols in the two-dimensional code image may be encoded in two colors.
  • the area corresponding to the direction positioning point may be used to display a second mark; the display area of the second mark is smaller than the display area of the first mark.
  • FIG. 6 is a schematic diagram of a two-dimensional code decoding apparatus provided by an embodiment of the present specification.
  • the device may include: an image information acquisition module 610 for acquiring the image information of the two-dimensional code image to be recognized; a positioning point position information determination module 620 for obtaining the image information of the two-dimensional code image to be recognized Image information, to determine the positioning point position information of each positioning point in the to-be-recognized two-dimensional code image in the image; the data information position information determination module 630 is used to determine each data based on the positioning point position information The position information of the information bits in the image; the symbol shape determination module 640 is configured to determine the symbol shape corresponding to the respective data information bits based on the position information of the respective data information bits in the image; The code element shape includes dots or arcs; the two-dimensional code code generation module 650 is used to generate a two-dimensional
  • the image of the two-dimensional code to be recognized is an annular shape; the image may include a first positioning point and a direction positioning point; the position of the upper left corner, the upper right corner and the lower left corner of the image are distributed. There is a first positioning point; a direction positioning point is distributed in the lower right corner of the image.
  • the data information bit position information determining module 630 may specifically include: a data information bit position information determining unit, configured to use an adaptive sampling algorithm based on the positioning point position information to determine the to-be-identified two-dimensional The position information in the image of each positioning point in the code image and the position information in the image of each data information bit.
  • the data information bit position information determining unit may be specifically configured to: based on the positioning point position information, determine the first position in the image coordinate system of each positioning point in the to-be-recognized two-dimensional code image. position information; obtain the second position information of each positioning point in the coordinate system on the code; calculate the distance between the coordinate system on the code and the image coordinate system based on the first position information and the second position information obtain the third position information of each data information bit in the coordinate system on the code; determine the initial sampling point of each data information bit in the image coordinate system based on the transformation matrix and the third position information position; based on the adaptive sampling algorithm, correct the initial sampling point position to determine the final sampling point position of each data information bit in the image coordinate system; based on the final sampling point position, in the to-be-to-be Sampling is performed in the identification image to obtain the position information of each data information bit in the image.
  • the embodiments of this specification also provide a device corresponding to the above method.
  • FIG. 7 is a schematic diagram of generating and decoding a two-dimensional code provided by an embodiment of this specification.
  • the device 700 may include: at least one processor 710 ; and a memory 730 communicatively connected to the at least one processor; wherein the memory 730 stores information executable by the at least one processor 710 Instruction 720.
  • the instructions are executed by the at least one processor 710, so that the at least one processor 710 can: acquire the two-dimensional code code of the two-dimensional code image to be generated; encode the two-dimensional code Use a coding algorithm with a preset error-tolerance rate to perform error-tolerant coding to obtain a two-dimensional code code after error-tolerant processing; determine the corresponding data information bits of the two-dimensional code code after the fault-tolerant processing in the generation area of the two-dimensional code image.
  • the shape of the code element includes a dot or an arc; according to the preset arrangement rule of the two-dimensional code encoding, it is determined that each data information bit encoded by the two-dimensional code after the error-tolerant processing corresponds to the generation area.
  • first position information determining the second position information of each positioning point in the generation area; based on the first position information, the symbol shape corresponding to each data information bit, and the second position information of each positioning point , to generate a QR code image.
  • the instructions are executed by the at least one processor 710, so that the at least one processor 710 can: acquire the image information of the two-dimensional code image to be recognized; the image information, determine the positioning point position information of each positioning point in the to-be-recognized two-dimensional code image in the image; based on the positioning point position information, determine the position information of each data information in the image ; Based on the position information of the respective data information bits in the image, determine the symbol shape corresponding to the respective data information bits; the symbol shape includes a dot or an arc; according to preset arrangement rules; A two-dimensional code code is generated from the symbol shape corresponding to each of the data information bits; the two-dimensional code code is decoded by using a preset decoding algorithm to obtain the content information stored in the data information bits.
  • the embodiments of the present specification also provide a computer-readable medium corresponding to the above method.
  • Computer readable instructions are stored on the computer readable medium.
  • the computer-readable instructions can be executed by the processor to implement the following methods: obtaining the two-dimensional code encoding of the two-dimensional code image to be generated; using the encoding with a preset error tolerance rate for the two-dimensional code encoding
  • the algorithm performs error-tolerant coding to obtain a two-dimensional code code after error-tolerant processing; determines the code element shape corresponding to each data information bit of the two-dimensional code code after the error-tolerant processing in the generation area of the two-dimensional code image; the code element The shape includes dots or arcs; according to the preset arrangement rules of the two-dimensional code encoding, determine the first position information corresponding to each data information bit encoded by the two-dimensional code after the error-tolerant processing in the generation area; determine the generating second position information of each positioning point in the area; generating a two-dimensional code image based on the first position information, the symbol shape corresponding to each data information bit, and the second position information of each positioning point.
  • the computer-readable instructions can be executed by the processor to implement the following methods: acquiring image information of the two-dimensional code image to be recognized; Identify the positioning point position information of each positioning point in the two-dimensional code image in the image; based on the positioning point position information, determine the position information of each data information bit in the image; based on the each data information bit
  • the position information in the image determines the symbol shape corresponding to each data information bit; the symbol shape includes dots or arcs; according to preset arrangement rules; according to the corresponding data information bits
  • the code element shape generates a two-dimensional code code; the two-dimensional code code is decoded by using a preset decoding algorithm to obtain the content information stored in the data information bits.
  • a Programmable Logic Device (such as a Field Programmable Gate Array (FPGA)) is an integrated circuit whose logic function is determined by user programming of the device.
  • HDL Hardware Description Language
  • ABEL Advanced Boolean Expression Language
  • AHDL Altera Hardware Description Language
  • HDCal JHDL
  • Lava Lava
  • Lola MyHDL
  • PALASM RHDL
  • VHDL Very-High-Speed Integrated Circuit Hardware Description Language
  • Verilog Verilog
  • the controller may be implemented in any suitable manner, for example, the controller may take the form of eg a microprocessor or processor and a computer readable medium storing computer readable program code (eg software or firmware) executable by the (micro)processor , logic gates, switches, application specific integrated circuits (ASICs), programmable logic controllers and embedded microcontrollers, examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicon Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory.
  • the controller may take the form of eg a microprocessor or processor and a computer readable medium storing computer readable program code (eg software or firmware) executable by the (micro)processor , logic gates, switches, application specific integrated circuits (ASICs), programmable logic controllers and embedded microcontrollers
  • ASICs application specific integrated circuits
  • controllers include but are not limited to
  • the controller in addition to implementing the controller in the form of pure computer-readable program code, the controller can be implemented as logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded devices by logically programming the method steps.
  • the same function can be realized in the form of a microcontroller, etc. Therefore, such a controller can be regarded as a hardware component, and the devices included therein for realizing various functions can also be regarded as a structure within the hardware component. Or even, the means for implementing various functions can be regarded as both a software module implementing a method and a structure within a hardware component.
  • a typical implementation device is a computer.
  • the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device Or a combination of any of these devices.
  • embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions
  • the apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include forms of non-persistent memory, random access memory (RAM) and/or non-volatile memory in computer readable media, such as read only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
  • RAM random access memory
  • ROM read only memory
  • flash RAM flash memory
  • Computer-readable media includes both persistent and non-permanent, removable and non-removable media, and storage of information may be implemented by any method or technology.
  • Information may be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media 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 memory technology, Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD), or other optical storage , magnetic tape cartridges, magnetic tape-disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
  • computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.
  • the embodiments of the present application may be provided as a method, a system or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • the application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer.
  • program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types.
  • the application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network.
  • program modules may be located in both local and remote computer storage media including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Health & Medical Sciences (AREA)
  • Electromagnetism (AREA)
  • Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Quality & Reliability (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Image Processing (AREA)

Abstract

本说明书实施例公开了一种二维码生成、解码方法、装置及设备。方法包括:获取待生成二维码图像的二维码编码,采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;再确定所述生成区域中各个定位点位的第二位置信息;然后基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。

Description

一种二维码生成、解码方法、装置及设备 技术领域
本申请涉及互联网技术领域,尤其涉及一种二维码生成、解码方法、装置及设备。
背景技术
近年来,二维码的应用越来越来广泛,尤其是在移动支付和在线社交等领域。由于其较大的信息容量和快速的识别,在人们的日常生活中得到了迅速的普及。尽管目前二维码已经得到了大范围的推广,但是传统的二维码,每张二维码的背后可能代表一个文件,一个页面、又或者是一个应用。由于其开放性,很容易成为木马病毒的温床,用户在扫码时,出于担心扫码之后可能使自己的手机感染病毒而放弃扫码,并且传统的二维码无法满足小程序的品牌宣传需求。
基于上述考虑,小程序码应运而生,小程序码与普通二维码相比,看起来更美观,并且,对于小程序码来说,用户在扫描小程序码之前,就可以明确知道扫码之后将会体验到一个哪种小程序的应用。
因此,在生活中,也需要更加可靠的小程序码生成方案以及解码方案。
发明内容
本说明书实施例提供一种二维码生成、解码方法、装置及设备,以解决现有的二维码识别方法存在的识别率低的问题。
为解决上述技术问题,本说明书实施例是这样实现的:本说明书实施例提供的一种二维码生成方法,包括:获取待生成二维码图像的二维码编码;对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧;根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;确定所述生成区域中各个定位点位的第二位置信息;基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
本说明书实施例提供的一种二维码解码方法,包括:获取待识别二维码图像的图像信息;根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息;基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息;基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧;按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码;采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
本说明书实施例提供的一种二维码生成装置,包括:二维码编码获取模块,用于获取待生成二维码图像的二维码编码;容错编码模块,用于对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;码元形状确定模块,用于确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧;第一位置信息确定模块,用于根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;第二位置信息确定模块,用于确定所述生成区域中各个 定位点位的第二位置信息;二维码图像生成模块,用于基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
本说明书实施例提供的一种二维码解码装置,包括:图像信息获取模块,用于获取待识别二维码图像的图像信息;定位点位置信息确定模块,用于根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息;数据信息位位置信息确定模块,用于基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息;码元形状确定模块,用于基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧;二维码编码生成模块,用于按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码;解码模块,用于采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
本说明书实施例提供的一种二维码生成设备,包括:至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够:获取待生成二维码图像的二维码编码;对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧;根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;确定所述生成区域中各个定位点位的第二位置信息;基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
本说明书实施例提供的一种二维码解码设备,包括:至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够:获取待识别二维码图像的图像信息;根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息;基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息;基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧;按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码;采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
本说明书实施例提供的一种计算机可读介质,其上存储有计算机可读指令,所述计算机可读指令可被处理器执行以实现一种二维码生成、解码方法。
本说明书一个实施例实现了能够达到以下有益效果:通过获取待生成二维码图像的二维码编码,采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;再确定所述生成区域中各个定位点位的第二位置信息;然后基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。这一方案,生成的小程序码整体为圆环状,数据区域是圆点和圆弧构成的圆环。且相邻圆环中间都留有相同间隔的空白区域中,中间区域以及右下角区域作为logo显示区,数据均匀分布,各个部位的数据容错一致。能够生成抗畸变能力强、抗污能力强的二维码。
附图说明
为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本说明书实施例提供的一种二维码生成方法的流程示意图;
图2为本说明书实施例提供的小程序码结构示意图;
图3为本说明书实施例提供的一种二维码解码方法的流程示意图;
图4为本说明书实施例提供的二维码解码方法中自适应采样的流程示意图;
图5是本说明书实施例提供的一种二维码生成装置示意图;
图6是本说明书实施例提供的一种二维码解码装置示意图;
图7是本说明书实施例提供的一种二维码生成、解码示意图。
具体实施方式
为使本说明书一个或多个实施例的目的、技术方案和优点更加清楚,下面将结合本说明书具体实施例及相应的附图对本说明书一个或多个实施例的技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本说明书的一部分实施例,而不是全部的实施例。基于本说明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本说明书一个或多个实施例保护的范围。
二维码又称二维条码,常见的二维码为QR Code,QR全称Quick Response,是一个近几年来移动设备上超流行的一种编码方式,它比传统的Bar Code条形码能存更多的信息,也能表示更多的数据类型。
小程序码在实际应用中,相对于二维码来说,小程序码是依附于应用程序勋在的,例如:一些聊天APP的小程序码只能通过该聊天APP产生并识别,安全性更高,并且每个小程序码右下角都是固定的小程序Logo,从而能够透传出更多的品牌信息。
目前,小程序码的应用越来越来广泛,尤其是在移动支付和在线社交等领域。但是在许多场景下现有小程序码仍有一定的局限性,例如:小程序码的抗图像畸变的能力不足,小程序码被打印在一个平整的平面上。如果小程序码所在的平面发生了凸起或凹陷,例如二维码被打印在球体上,二维码的识别率会大幅下降。对于柱体、椎体等的曲面甚至织物等非刚体的表面,二维码的识别能力非常有限。另外,现有的小程序码中,任意位置较小块的污损就可能导致该小程序码无法被识别。
以下结合附图,详细说明本说明书各实施例提供的技术方案。
接下来,将针对说明书实施例提供的一种二维码生成方法结合附图进行具体说明:
实施例1
图1为本说明书实施例提供的一种二维码生成方法的流程示意图。从程序角度而言,流程的执行主体可以为搭载于应用服务器的程序或应用客户端。
如图1所示,该流程可以包括以下步骤:步骤110:获取待生成二维码图像的二维码编码。
二维码编码,可以表示的是用于生成二维码图像的编码,例如,可以是一串预设位 数的字符串,如二进制序列,三进制序列等。在本方案中,以二进制序列为例,二维码中承载的内容数据,经过信息转换后,可以得到一串二维码序列。
需要说明的是,这里的二维码可以指的是小程序码,小程序码可以表示依附于原有的应用程序中,用于某一功能的二维码。例如:即时通讯应用程序中的小程序码以及支付应用程序中的小程序码,小程序码在实际应用场景中,可以用于点餐、支付、购票、医疗挂号等诸多场景中。
在本说明书的描述中,二维码可以是指二维码编码或二维码图片,可以根据实际需要来设置,本申请对此不进行具体限定。另外,在本说明书实施例中,二维码信息,是指二维码编码中携带的具有实际含义的信息,例如,用户中心标识信息等。
步骤120:对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码。
容错编码(error resilient coding),可以表示在编码过程中加入一部分冗余信息来增强抗误码能力,力求以最少量的冗余来获得最大的增益,其抗误码性能是以牺牲编码效率为代价。
根据处理差错扩散的类型和方式的不同,容错编码技术主要有:插入同步标记(RM)、数据分割(DP)、可逆变长编码(RVLC)、参数集、帧内编码更新技术、分层编码(LC)技术、相关子数据流传输的多描述编码(MDC)等。
二维码的容错率可以指生成的二维码就算被遮挡了一部分,或者有一部分没有完全显示出来时,用户都能扫描成功,这个被遮挡部分在全部的比值,就可以被理解为一个容错率。
容错编码具有多个容错级别,也可以被理解为容错编码具有多个等级的冗余度。例如:每个版本的容错编码分别对应L、M、Q、H这四种容错级别。其中,L级容错的小程序码,大约10%的字码可被修正;M级容错的小程序码,大约15%的字码可被修正;Q级容错的小程序码,大约25%的字码可被修正;H级容错的小程序码,大约35%的字码可被修正。例如H级容错的小程序码,大约35%的字码可被修正。这意味着在最理想情况下,当这个小程序码35%的面积被遮挡/损坏,扫码引擎还是能识别出这个小程序码承载的信息。
但是,需要说明的是,以上述35%的H等级为例,35%被破坏的面积,不能是定位图案和功能性数据,必须是纯编码区,而且错误的区域还要分布得均匀,才能识别出整个二维码。
在本方案中,容错率被预先设定,一旦小程序码的版本、纠错级别确定了,其对应的纠错码就可以是固定的,在整个过程中,无需再加入额外的容错信息,从而保证编码区对应的数据均匀。从而无论小程序码中哪部分被遮挡,只要不遮挡定位点位且遮挡面积小于或等于35%,则该小程序码仍能被识别出来。并且,在解码阶段也可以通过对应的规则消除纠错码,得到相应的内容信息。
本方案中,通过使用固定容错率的编码算法进行容错,使生成的小程序码数据分布均匀,各个部位的数据容错一致。使用固定容错的容错编码可以保证了小程序码的容错能力,使生成的小程序码具有抗污损,抗扭曲,抗反光等能力。
步骤130:确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧。
生成区域可以表示用于生成二维码的区域。
数据信息位可以表示的是用于表示承载内容信息的小程序码中的点位。具体地,数据信息位中可以存储有商品信息或其他内容信息,扫描设备通过扫描小程序码可以获取数据信息位中存储的内容信息。
二维码的生成区域可以指的是二维码的轮廓区域,比如:需要生成一个直径为6厘米的二维码时,二维码的轮廓区域为一个直径为6厘米的圆形区域。
码元形状可以指的是二维码图像中用于承载内容信息的码块的形状,例如:圆点、方块、矩形以及圆弧等等。在本说明书实施例中,码元形状可以包括圆点、圆弧。
二维码编码中,每个编码位的数值对应了小程序码中的码元形状,例如:以二维码编码为二进制序列为例,二进制序列的“1”表示码元形状为黑色圆点,二进制中的“0”表示为白色圆点(此时默认背景颜色为白色),如果二进制序列中连续出现“1”,则构成黑色圆弧。
步骤140:根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息。
第一位置信息可以表示的是每个数据信息位在生成区域中对应的位置。
预设排列规则可以表示预先设定的对于二维码编码的排序规则,例如:预设排列规则中可以设定二维码编码对应的二维码图像中的起始码元点位,还可以设定二维码编码中的每一个编码位对应的二维码图像中的码元点位,从而基于二维码编码,按照预设排列规则,可以确定每个数据信息位具体在生成区域中的位置。
步骤150:确定所述生成区域中各个定位点位的第二位置信息。
第二位置信息可以表示每个定位点位在生成区域中对应的位置。
定位点位可以表示定位二维码的点位,一般情况下,定位点位包括四个,其中包括方向定位点位,方向定位点位可以标记二维码的方向。方向定位点位可以设置在二维码图像中的右下角,其他的定位点位可以分别设置在二维码图像的生成区域中的左上角位置、左下角位置以及右上角位置。
以圆形二维码为例,右下角的方向定位点位确定了该圆形二维码的方向之后,就可以进一步确定圆形二维码的其他三个定位点位的所在位置,从而确定各个定位点位的位置信息。
步骤160:基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
需要说明的是,各定位点位的位置信息以及有效信息位的位置信息可以用坐标进行表示,也可以用矩阵的形式进行表示。用矩阵形式进行表示时,可以将二维码中的每个定位点位以及有效信息位对应转换成矩阵当中的每行每列中对应的元素。比如:将二维码中左上定位区的定位点位转换为矩阵中第一行第一列对应的元素。
一个二维码图像中,可以包括用于定位二维码的定位点位、用于承载内容信息的数据信息位,其中,各个定位点位的码元形状已知,因此,在确定各个定位点位的位置信息、各个数据信息位的位置信息以及各个数据信息位的码元形状之后,就可以生成相应的二维码图像。
应当理解,本说明书一个或多个实施例所述的方法其中部分步骤的顺序可以根据实际需要相互交换,或者其中的部分步骤也可以省略或删除。
图1中的方法,通过获取待生成二维码图像的二维码编码,采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;确定所述容错处理后的二维码 编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;再确定所述生成区域中各个定位点位的第二位置信息;然后基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。这一方案,圆点和圆弧的形状设计以及采用固定容错编码算法进行编码,能够生成抗畸变能力强、抗污能力强的二维码。
基于图1的方法,本说明书实施例还提供了该方法的一些具体实施方案,下面进行说明。
可选的,所述确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状,具体可以包括:对于所述容错处理后的二维码编码中的每个编码位,确定该编码位在所述容错处理后的二维码编码中的顺序;确定所述顺序在所述二维码生成区域中对应的数据信息位的位置;根据该编码位的值确定所述位置的数据信息位对应的码元形状。
需要说明的是,采用预先设定容错率的编码算法进行容错编码,可以理解为采用固定容错的编码算法将内容信息对应的数据转换为预设位数的字符串,例如:采用固定容错的编码算法将内容信息对应的数据转换为二进制序列。其中,内容信息可以表示的是二维码需要承载的信息。比如:商品信息、应用程序功能信息、平台信息、品牌信息等等。在将内容信息转换为二进制序列时,可以将内容信息对应的字符每三位分为一组,将每组数据转换为10位二进制数据,余下的一或两位转换成4或7位的二进制数据。
需要说明的是,一个二进制序列中的每个二进制位在二进制序列中都具有顺序。比如:一个二进制序列为010110101,从左至右开始看,二进制序列中的第一个二进制位为0,第二个二进制位为1,第三个二进制位为0……第九个二进制位为1。将二进制序列中的第一个二进制位对应二维码中数据信息位中的预设起始点位,将二进制序列中的第二个二进制位对应二维码中数据信息位中的第二个点位,依次类推,……,将二进制序列中的二进制位分别对应二维码中数据信息位中相应的位置。
假设用二进制中的“1”表示黑色圆点,此时,可以设置圆弧对应的圆点数量,例如:可以设置至少三个黑色圆点对应一段圆弧,即当二进制序列中存在连续三个“1”时,才会形成一段圆弧。
进一步地,还可以设置相邻圆点之间的距离,以及圆点与相邻圆弧之间的距离。还可以设置圆点以及圆弧的排列角度,这里的排列角度可以指的是极角坐标对应的角度值。
可选的,所述生成区域中还包括掩模信息;所述获取待生成二维码图像的二维码编码之前,还可以包括:根据所述掩模信息对所述二维码编码进行掩模处理,得到掩模处理后的二维码编码。
其中,掩码信息可以存储在除定位点位外的其他点位中,具体需要多少个码元存储掩模信息,可以根据生成的二维码的容量或尺寸来进行确定,一般情况下,一个码元中可以存储两种掩模。
需要说明的是,数据信息位所在的区域可以为数字区域,定位点位所在的区域可以为功能区域。掩模处理仅针对数据信息位所在的数字区域进行掩模,不对定位点位所在的功能区域产生影响。
因此,掩模的作用可以是让二维码中的圆点和圆弧分布均匀一些,从而可以提高二维码识别的准确度。而掩模的好坏是由掩码决定的。其中,掩码可以指根据特定规则将二维码区域内码元的值改变的一种策略。采用掩码的目的是调整二维码内各个码元的展 示。如果二维码内某个码元被掩模处理了,可以理解为:如果该码元在进行掩模处理之前是白色圆点,那么经过掩模处理之后可以变成黑色圆点。换句话说,掩码可以理解为将二维码中的码元的像素值进行修改。
需要说明的是,本说明书实施例中,采用预设设定的容错率的编码算法进行容错编码,可以保证生成的小程序码中的数据分布均匀,这里所说的数据可以包含需要承载的内容对应的数据以及码基本信息的元数据。
而掩模的作用是保证生成的小程序码中的码元形状或颜色看起来分布均匀。
上述实施例中生成的小程序码可以结合图2进行说明。
图2为本说明书实施例提供的小程序码结构示意图。如图2所示,小程序码图像的整体为圆环状,小程序码图像中可以包括由所述圆点240和所述圆弧250构成的圆环、中间区域220、第一定位点位210和方向定位点位230。
其中,可选的,每一圈圆环的圆环环宽相同。其中,圆环的环宽可以理解为圆弧250的宽度,也可以理解为圆点240的直径长度。在小程序码图像中,每个圆点240的直径长度与圆弧250的宽度相等。
可选的,所述中间区域220与所述圆环同圆心;所述中间区域220用于显示第一标识,第一标识可以是品牌的logo;相邻所述圆环之间具有相同间隔;所述中间区域220与相邻的码元形状构成的圆环之间的间隔与相邻所述圆环之间的间隔相同。如图1所示,背景颜色默认为白色,相邻圆环之间都留有空白间隔。这样的结构,即使小程序码被打印出来张贴在柱子上或打印出来的纸张自然卷曲时,“一圈黑一圈白”的设计,即使张贴时部分图像被压缩,也可以确定有圆点240和圆弧250组成的黑色圆环的下一圈为白色,两圈黑色圆环的中间一定有一圈白色,从而可以确定被压缩的部分。从而提升生成的小程序码的非线性畸变场景的识别能力。
需要说明的是,二维码图像的背景颜色以及二维码中的标识区域颜色可以根据实际应用场景进行设定。另外,上述步骤中所说的两种颜色可以表示的是二值化以后的两种颜色,而不是彩色意义下的两种颜色。初始生成的二维码具有多种颜色,经过二值化处理之后,仅具有两种颜色。
如图2中所示,数据区域可以是3圈由圆点240或圆弧250组成的圆环,用来承载数据。使用设定容错效率的容错算法进行容错编码,例如:使用整体容错率达到25%的容错编码,具体容错策略是(16,8),即有效数据16字节,最多支持8字节错误纠正,数据流总长32字节。右下角的方向定位点位230可以作为一种辅助定位点,参与码的定位与解码,还用于显示第二标识,进一步地,右下角的第二标识的显示面积可以小于中间区域中的第一标识的显示面积,两个LOGO区域中的内容可以根据需要填充自定义,如品牌,活动LOGO等。
可选的,将小程序码跟32种掩膜(又称「mask」,可依照一定的规则生成)进行异或运算,最终选取满足条件的作为最终的小程序码。
需要说明的是,在图2中,数据区域可选为3圈或4圈,最外环(第四圈)可以用来承载数据,也可以用来作为小程序码图像的修饰。
通过上述方法,生成的小程序码整体为圆环状,数据区域是圆点和圆弧构成的圆环。且相邻圆环中间都留有相同间隔的空白区域中,中间区域以及右下角区域作为logo显示区,采用固定容错进行编码,不需要再透传容错信息,使数据分布均匀。能够保证生成的二维码抗畸变能力强、抗污损能力强,且能透传更多的品牌信息。
对应于上述实施例,生成的二维码对应有解码的方法:
实施例2
图3为本说明书实施例提供的一种二维码解码方法的流程示意图。从程序角度而言,流程的执行主体可以为搭载于应用服务器的程序或应用客户端。实施例2中的解码过程与实施例1中的编码过程对应。
如图3所示,该流程可以包括以下步骤:步骤310:获取待识别二维码图像的图像信息。
需要说明的是,该步骤中提到的图像信息可以表示不受限于二维码载体限制的二维码本身的信息,比如:在电脑上画出来的二维码的信息。例如:二维码的尺寸信息、各个定位点位的位置信息、数据信息位的位置信息以及二维码中各个点位对应的码元形状、码元颜色等等。
步骤320:根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息。
步骤330:基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息。
由于从二维码的图像信息中可以确定各个定位点位的位置信息,已知中间预留的logo显示区,除了定位点位以及中间显示区域之外剩下的点位可以确定为数据信息位。
数据信息位中可以存储有内容信息。扫描设备通过扫描二维码可以获取数据信息位中存储的内容信息。
步骤340:基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧。
在确定了数据信息位在图像中的位置信息之后,就可以从图像信息中确定每个数据信息位对应的码元的形状。
步骤350:按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码。
预设排列规则可以是小程序码在生成的时候所用的排列规则,在解码时,只需要按照生成小程序二维码时用到的排列规则进行对应解析,就可以将每个数据信息位的码元形状解析为二维码编码。
步骤360:采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
实施例1中的编码算法与实施例2中的解码算法应该对应,假设,采用容错25%的容错算法对内容信息进行编码,得到二进制序列,那么,在解码时,也应该采用容错25%的容错算法对二进制序列进行解码。需要说明的是,容错算法的具体选择可以根据实际应用场景进行选择。
基于图3的方法,本说明书实施例还提供了该方法的一些具体实施方案,下面进行说明。
可选的,所述待识别二维码图像可以为圆环状;所述图像中包含第一定位点位和方向定位点位;所述图像的左上角位置、右上角位置以及左下角位置分布有第一定位点位;所述图像的右下角位置分布有方向定位点位。
具体地,待识别二维码图像中的小程序码结构可以参见实施例1中对于小程序码结构的描述。
可选的,所述根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息,具体可以包括:基于所述定位点位置信息,采用自适应采样算法,确定所述待识别二维码图像中的每个定位点位在所述图像中的位置信息以及每个数据信息位在所述图像中的位置信息。
本方案中,在解码时,采用自适应采样的算法确定采样点的位置,最终采样得到比特流,能够进一步提高非线性畸变场景的识别率。
其中,畸变是一些常见的非线性变换,如物料表面褶皱产生的变化,物料铺设在不平的表面,如圆柱体表面从而使码产生变化。现有的采样算法中,在进行采样时,对应的过程是:在进帧图像中找到4个定位点位,根据码上坐标系4个定位点位(预制)与图像坐标系的4个定位点位,计算出码上坐标系到图上坐标系的变换矩阵;然后基于变换矩阵和码上坐标系的数据点位(预制),计算出图上坐标系的采样位置,直接在对应点位采样得到0/1比特流,最后解码比特流得到原始数据。现有的采样方法,将基于采样位置采集到的第一个点直接作为最终的采样点进行采样,这样在非线性畸变场景下,由于非线性畸变场景下,小程序码的图像容易被压缩,部分图像被压缩或拉伸,导致小程序码图像中的部分码元形状发生变化,容易将错误的采样点作为最终的采样点采集到错误的比特流,例如:原本是圆弧,但是被压缩之后,采集到的为圆点,从而导致最终对小程序码识别错误。
基于这一缺陷,本说明书实施例在改进了小程序码的基础上,进一步改进了对于小程序码的解码方法中的采样方法,基于自适应采样,对误差进行纠正,从而得到正确的采样点位置,采样到准确率较高的比特流,从而提高对于小程序码的识别准确率。
具体地,所述基于所述定位点位置信息,采用自适应采样算法,确定每个数据信息位在所述图像中的位置信息,具体可以包括:基于所述定位点位置信息,确定所述待识别二维码图像中每个定位点位在图像坐标系中的第一位置信息;获取各定位点位在码上坐标系中的第二位置信息;基于所述第一位置信息以及所述第二位置信息,计算所述码上坐标系与所述图像坐标系之间的变换矩阵;获取各数据信息位在码上坐标系中的第三位置信息;基于所述变换矩阵以及所述第三位置信息,确定各数据信息位在所述图像坐标系中的初始采样点位置;基于所述自适应采样算法,对所述初始采样点位置进行修正,确定各数据信息位在所述图像坐标系中的最终采样点位置;基于所述最终采样点位置,在所述待识别图像中进行采样,得到每个数据信息位在所述图像中的位置信息。
需要说明的是,码上坐标系,也可以称作标准坐标系,可以表示以码的视角为基准的坐标系,不考虑任何变化,码的外接正方形左上角为原点,单个数据点为1单位的坐标系。图上坐标系可以表示以进帧图像视角为基准的坐标系,图像左上角为原点的坐标系,每个像素为1单位。
基于前面论述的小程序码的结构,可以确定小程序码中,圆弧与圆弧之间,圆弧与最外圈装饰之间,圆弧与内部LOGO2区域之间都留有空白。
畸变产生的误差具有以下2个特点:畸变是逐渐积累的,总有某个采样点是准的,然后慢慢偏移准确采样位置,畸变的误差具有传递性,一个采样点和该采样点周围的采样点,误差具有相似性。
在具体实现过程中,理想的采样点总是在数据点的中心位置,例如:如果是黑色圆点,那么采样点应该在黑色圆点的圆心位置,如果是圆弧,采样点应该在圆弧一半宽度且原理两侧半个单位或更远的位置。
本说明书实施例,基于上述采样思路,在对每个数据点位进行采集时,可以结合图4进行说明。
图4为本说明书实施例提供的二维码解码方法中自适应采样的流程示意图。
如图4所示,在采用自适应采样方法进行采样时,开始采样之后,可以先叠加历史误差;然后根据传统采样方法进行初始采样,初始采样得到初始采样结果。其中,初始采样结果中可以包括黑色采样结果1或白色采样结果0。
当初始采样值为1时,可以修正采样点到黑色圆点中心或到小圆弧一半宽度且离边缘半个单位的位置。
当初始采样值为0时,在直径方向上向两边各查找设定的距离,该设定距离可以基于实际应用场景进行调整,如果在移动了设定距离之后,找到了黑色块,则可以说明此处采样结果应该是黑色,将原本的白色采样点未知纠正到黑色采样点对应的理想采样位置,例如:移动到该黑色采样点对应的圆心。
基于历史误差进行误差纠正,纠正后在基于新的采样点进行重新采样。其中,误差纠正可以表示对初始采样的结果进行纠正,例如:初始采样结果是黑色圆点时,可以修正采样点到黑色圆点中心或到小圆弧一半宽度且离边缘半个单位的位置。
如果初始采样结果是白色,那么在直径方向上向两边各查找设定的距离,该设定距离可以基于实际应用场景进行调整,如果在移动了设定距离之后,找到了黑色块,那说明此处采样应该是黑色,将原本的白色采样点纠正到那黑色采样点的理想采样位置。如果在移动了设定距离之后,仍然是白色块,那可以确定初始采样点的位置不需要进行修正,所有采样结束。
基于上述过程,得到最终的采样点位置,基于最终采样点位置进行采样,得到比特流,最终解码得到相应的内容信息。
通过上述方法,基于圆环状的小程序码,采用自适应采样的方法进行解码,能够提高小程序码的识别准确率。
对于本说明书中的上述实施例,相对于现有的点射状的二维码、或其他圆形结构的二维码来说,能够实现以下技术效果:对于点射状的即时通讯程序中的小程序码,由于小程序码向外射线分布,在畸变场景中,尤其是弯曲场景中,识别率极低。而对于部分圆形结构的小程序码,由于数据分布不均匀,容错能力极低,随意遮挡任何部分就无法对小程序码进行识别。
本说明书实施例的方案,生成的小程序码整体为圆环状,数据区域是圆点和圆弧构成的圆环。且相邻圆环中间都留有相同间隔的空白区域中,中间区域以及右下角区域作为logo显示区,数据均匀分布,各个部位的数据容错一致。例如:使用25%容错的容错编码保证了码的容错能力。能够保证生成的二维码抗畸变能力强、抗污损能力强,且能透传更多的品牌信息。
另外,一些小程序码中,采用暗,高亮,中亮三种颜色的码元承载数据,在复杂的线下环境中(如:暗光,反光等场景),会极大降低小程序码的识别成功率。本方案中,二值图像的数据展示,在弱光/强光场景更高识别率。并且将小程序码的中间区域以及右下角的方向定位点区域都设置为显示logo的区域,丰富了用户可直接获取的信息内容。同时,预留了两个LOGO区域,能同时透出主品牌和服务类型、功能或活动(如红包,点餐等)信息。使用特定的设计外形有利于培养用户的扫码习惯。
基于同样的思路,本说明书实施例还提供了上述实施例1中的方法对应的装置。图5是本说明书实施例提供的一种二维码生成装置示意图。如图5所示,该装置可以包括:二维码编码获取模块510,用于获取待生成二维码图像的二维码编码;容错编码模块520,用于对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容 错处理后的二维码编码;码元形状确定模块530,用于确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧;第一位置信息确定模块540,用于根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;第二位置信息确定模块550,用于确定所述生成区域中各个定位点位的第二位置信息;二维码图像生成模块560,用于基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
基于图5的装置,本说明书实施例还提供了该装置的一些具体实施方案,下面进行说明。
可选的,所述码元形状确定模块530,具体可以用于:对于所述容错处理后的二维码编码中的每个编码位,确定该编码位在所述容错处理后的二维码编码中的顺序;确定所述顺序在所述二维码生成区域中对应的数据信息位的位置;根据该编码位的值确定所述位置的数据信息位对应的码元形状。
可选的,所述装置,还可以包括:掩模模块,用于根据所述掩模信息对所述二维码编码进行掩模处理,得到掩模处理后的二维码编码。
可选的,所述定位点位可以包括第一定位点位和第二定位点位;所述第一定位点位可以分别分布在所述生成区域的左上角位置、右上角位置以及左下角位置;所述第二定位点位可以分布在所述生成区域的右下角位置。
可选的,所述二维码图像中可以包括由所述圆点和所述圆弧构成的圆环;每一圈所述圆环的圆环环宽相同。
可选的,所述二维码图像中还可以包括中间区域,所述中间区域与所述圆环同圆心;所述中间区域可以用于显示第一标识;相邻所述圆环之间具有相同间隔;所述中间区域与相邻的码元形状构成的圆环之间的间隔与相邻所述圆环之间的间隔相同。
可选的,所述二维码图像中的码元可以采用两种颜色进行编码。
可选的,所述方向定位点位所对应的区域可以用于显示第二标识;所述第二标识的显示面积小于所述第一标识的显示面积。
基于同样的思路,本说明书实施例还提供了上述实施例2中的方法对应的装置。图6是本说明书实施例提供的一种二维码解码装置示意图。如图6所示,该装置可以包括:图像信息获取模块610,用于获取待识别二维码图像的图像信息;定位点位置信息确定模块620,用于根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息;数据信息位位置信息确定模块630,用于基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息;码元形状确定模块640,用于基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧;二维码编码生成模块650,用于按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码;解码模块660,用于采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
基于图6的装置,本说明书实施例还提供了该装置的一些具体实施方案,下面进行说明。
可选的,所述待识别二维码图像为圆环状;所述图像中可以包含第一定位点位和方向定位点位;所述图像的左上角位置、右上角位置以及左下角位置分布有第一定位点位;所述图像的右下角位置分布有方向定位点位。
可选的,所述数据信息位位置信息确定模块630,具体可以包括:数据信息位位置信息确定单元,用于基于所述定位点位置信息,采用自适应采样算法,确定所述待识别二维码图像中的每个定位点位在所述图像中的位置信息以及每个数据信息位在所述图像中的位置信息。
可选的,所述数据信息位位置信息确定单元,具体可以用于:基于所述定位点位置信息,确定所述待识别二维码图像中每个定位点位在图像坐标系中的第一位置信息;获取各定位点位在码上坐标系中的第二位置信息;基于所述第一位置信息以及所述第二位置信息,计算所述码上坐标系与所述图像坐标系之间的变换矩阵;获取各数据信息位在码上坐标系中的第三位置信息;基于所述变换矩阵以及所述第三位置信息,确定各数据信息位在所述图像坐标系中的初始采样点位置;基于所述自适应采样算法,对所述初始采样点位置进行修正,确定各数据信息位在所述图像坐标系中的最终采样点位置;基于所述最终采样点位置,在所述待识别图像中进行采样,得到每个数据信息位在所述图像中的位置信息。
基于同样的思路,本说明书实施例还提供了上述方法对应的设备。
图7是本说明书实施例提供的一种二维码生成、解码示意图。如图7所示,设备700可以包括:至少一个处理器710;以及,与所述至少一个处理器通信连接的存储器730;其中,所述存储器730存储有可被所述至少一个处理器710执行的指令720。
对应于实施例1,所述指令被所述至少一个处理器710执行,以使所述至少一个处理器710能够:获取待生成二维码图像的二维码编码;对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧;根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;确定所述生成区域中各个定位点位的第二位置信息;基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
对应于实施例2,所述指令被所述至少一个处理器710执行,以使所述至少一个处理器710能够:获取待识别二维码图像的图像信息;根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息;基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息;基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧;按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码;采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
基于同样的思路,本说明书实施例还提供了上述方法对应的计算机可读介质。计算机可读介质上存储有计算机可读指令。
对应于实施例1,所述计算机可读指令可被处理器执行以实现以下方法:获取待生成二维码图像的二维码编码;对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧;根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;确定所述生成区域中各个定位点位的第二位置信息;基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
对应于实施例2,所述计算机可读指令可被处理器执行以实现以下方法:获取待识别二维码图像的图像信息;根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息;基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息;基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧;按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码;采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于设备实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字符系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字符助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或 者这些设备中的任何设备的组合。
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字符多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带式磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。

Claims (22)

  1. 一种二维码生成方法,包括:
    获取待生成二维码图像的二维码编码;
    对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;
    确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧;
    根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;
    确定所述生成区域中各个定位点位的第二位置信息;
    基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
  2. 根据权利要求1所述的方法,所述确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状,具体包括:
    对于所述容错处理后的二维码编码中的每个编码位,确定该编码位在所述容错处理后的二维码编码中的顺序;
    确定所述顺序在所述二维码生成区域中对应的数据信息位的位置;
    根据该编码位的值确定所述位置的数据信息位对应的码元形状。
  3. 根据权利要求1所述的方法,所述生成区域中还包括掩模信息;所述获取待生成二维码图像的二维码编码之前,还包括:
    根据所述掩模信息对所述二维码编码进行掩模处理,得到掩模处理后的二维码编码。
  4. 根据权利要求1所述的方法,所述定位点位包括第一定位点位和第二定位点位;所述第一定位点位分别分布在所述生成区域的左上角位置、右上角位置以及左下角位置;所述第二定位点位分布在所述生成区域的右下角位置。
  5. 根据权利要求1所述的方法,所述二维码图像中包括由所述圆点和所述圆弧构成的圆环;每一圈所述圆环的圆环环宽相同。
  6. 根据权利要求5所述的方法,所述二维码图像中还包括中间区域,所述中间区域与所述圆环同圆心;所述中间区域用于显示第一标识;相邻所述圆环之间具有相同间隔;所述中间区域与相邻的码元形状构成的圆环之间的间隔与相邻所述圆环之间的间隔相同。
  7. 根据权利要求1所述的方法,所述二维码图像中的码元采用两种颜色进行编码。
  8. 根据权利要求4所述的方法,所述方向定位点位所对应的区域用于显示第二标识;所述第二标识的显示面积小于所述第一标识的显示面积。
  9. 一种二维码解码方法,包括:
    获取待识别二维码图像的图像信息;
    根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息;
    基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息;
    基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧;
    按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码;
    采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
  10. 根据权利要求9所述的方法,所述待识别二维码图像为圆环状;所述图像中包含第一定位点位和方向定位点位;所述图像的左上角位置、右上角位置以及左下角位 置分布有第一定位点位;所述图像的右下角位置分布有方向定位点位。
  11. 根据权利要求9所述的方法,所述基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息,具体包括:
    基于所述定位点位置信息,采用自适应采样算法,确定所述待识别二维码图像中的每个定位点位在所述图像中的位置信息以及每个数据信息位在所述图像中的位置信息。
  12. 根据权利要求11所述的方法,所述基于所述定位点位置信息,采用自适应采样算法,确定每个数据信息位在所述图像中的位置信息,具体包括:
    基于所述定位点位置信息,确定所述待识别二维码图像中每个定位点位在图像坐标系中的第一位置信息;
    获取各定位点位在码上坐标系中的第二位置信息;
    基于所述第一位置信息以及所述第二位置信息,计算所述码上坐标系与所述图像坐标系之间的变换矩阵;
    获取各数据信息位在码上坐标系中的第三位置信息;
    基于所述变换矩阵以及所述第三位置信息,确定各数据信息位在所述图像坐标系中的初始采样点位置;
    基于所述自适应采样算法,对所述初始采样点位置进行修正,确定各数据信息位在所述图像坐标系中的最终采样点位置;
    基于所述最终采样点位置,在所述待识别图像中进行采样,得到每个数据信息位在所述图像中的位置信息。
  13. 一种二维码生成装置,包括:
    二维码编码获取模块,用于获取待生成二维码图像的二维码编码;
    容错编码模块,用于对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;
    码元形状确定模块,用于确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧;
    第一位置信息确定模块,用于根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;
    第二位置信息确定模块,用于确定所述生成区域中各个定位点位的第二位置信息;
    二维码图像生成模块,用于基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
  14. 根据权利要求13所述的装置,所述码元形状确定模块,具体用于:
    对于所述容错处理后的二维码编码中的每个编码位,确定该编码位在所述容错处理后的二维码编码中的顺序;
    确定所述顺序在所述二维码生成区域中对应的数据信息位的位置;
    根据该编码位的值确定所述位置的数据信息位对应的码元形状。
  15. 根据权利要求13所述的装置,所述二维码图像中包括由所述圆点和所述圆弧构成的圆环;每一圈所述圆环的圆环环宽相同。
  16. 根据权利要求15所述的装置,所述二维码图像中还包括中间区域,所述中间区域与所述圆环同圆心;所述中间区域用于显示第一标识;相邻所述圆环之间具有相同间隔;所述中间区域与相邻的码元形状构成的圆环之间的间隔与相邻所述圆环之间的间隔相同。
  17. 一种二维码解码装置,包括:
    图像信息获取模块,用于获取待识别二维码图像的图像信息;
    定位点位置信息确定模块,用于根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息;
    数据信息位位置信息确定模块,用于基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息;
    码元形状确定模块,用于基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧;
    二维码编码生成模块,用于按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码;
    解码模块,用于采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
  18. 根据权利要求17所述的装置,所述数据信息位位置信息确定模块,具体包括:
    数据信息位位置信息确定单元,用于基于所述定位点位置信息,采用自适应采样算法,确定所述待识别二维码图像中的每个定位点位在所述图像中的位置信息以及每个数据信息位在所述图像中的位置信息。
  19. 根据权利要求18所述的装置,所述数据信息位位置信息确定单元,具体用于:
    基于所述定位点位置信息,确定所述待识别二维码图像中每个定位点位在图像坐标系中的第一位置信息;
    获取各定位点位在码上坐标系中的第二位置信息;
    基于所述第一位置信息以及所述第二位置信息,计算所述码上坐标系与所述图像坐标系之间的变换矩阵;
    获取各数据信息位在码上坐标系中的第三位置信息;
    基于所述变换矩阵以及所述第三位置信息,确定各数据信息位在所述图像坐标系中的初始采样点位置;
    基于所述自适应采样算法,对所述初始采样点位置进行修正,确定各数据信息位在所述图像坐标系中的最终采样点位置;
    基于所述最终采样点位置,在所述待识别图像中进行采样,得到每个数据信息位在所述图像中的位置信息。
  20. 一种二维码生成设备,包括:
    至少一个处理器;以及,
    与所述至少一个处理器通信连接的存储器;其中,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够:
    获取待生成二维码图像的二维码编码;
    对所述二维码编码采用预先设定容错率的编码算法进行容错编码,得到容错处理后的二维码编码;
    确定所述容错处理后的二维码编码的各个数据信息位在二维码图像的生成区域中对应的码元形状;所述码元形状包括圆点或圆弧;
    根据二维码编码预设排列规则,确定所述容错处理后的二维码编码的各个数据信息位在所述生成区域中对应的第一位置信息;
    确定所述生成区域中各个定位点位的第二位置信息;
    基于所述第一位置信息、每个数据信息位对应的码元形状以及每个定位点位的第二位置信息,生成二维码图像。
  21. 一种二维码解码设备,包括:
    至少一个处理器;以及,
    与所述至少一个处理器通信连接的存储器;其中,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够:
    获取待识别二维码图像的图像信息;
    根据所述待识别二维码图像的图像信息,确定所述待识别二维码图像中的每个定位点位在图像中的定位点位置信息;
    基于所述定位点位置信息,确定各个数据信息位在所述图像中的位置信息;
    基于所述各个数据信息位在所述图像中的位置信息,确定所述各个数据信息位对应的码元形状;所述码元形状包括圆点或圆弧;
    按照预设排列规则;根据每个所述数据信息位对应的码元形状生成二维码编码;
    采用预设的解码算法对所述二维码编码进行解码,得到所述数据信息位中储存的内容信息。
  22. 一种计算机可读介质,其上存储有计算机可读指令,所述计算机可读指令可被处理器执行以实现权利要求1至12中任一项所述的方法。
PCT/CN2022/081625 2021-03-23 2022-03-18 一种二维码生成、解码方法、装置及设备 WO2022199471A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110308114.2A CN112926715B (zh) 2021-03-23 2021-03-23 一种二维码生成、解码方法、装置及设备
CN202110308114.2 2021-03-23

Publications (1)

Publication Number Publication Date
WO2022199471A1 true WO2022199471A1 (zh) 2022-09-29

Family

ID=76175657

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/081625 WO2022199471A1 (zh) 2021-03-23 2022-03-18 一种二维码生成、解码方法、装置及设备

Country Status (2)

Country Link
CN (1) CN112926715B (zh)
WO (1) WO2022199471A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116796782A (zh) * 2023-05-04 2023-09-22 北京百度网讯科技有限公司 二维码的生成方法、识别方法、装置、设备及存储介质
CN117032085A (zh) * 2023-08-04 2023-11-10 安徽捷圆电子科技有限公司 Aoi机连线自动化控制方法、系统及其应用
CN117094349A (zh) * 2023-10-19 2023-11-21 中国物品编码中心 二维码图形的生成方法、装置、设备及介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114912475A (zh) * 2021-02-07 2022-08-16 华为技术有限公司 二维码识别方法及相关装置
CN112926715B (zh) * 2021-03-23 2024-02-02 支付宝(中国)网络技术有限公司 一种二维码生成、解码方法、装置及设备
CN113487001B (zh) * 2021-09-08 2021-12-24 飞狐信息技术(天津)有限公司 二维码生成方法及装置、二维码识别方法及装置

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104933387A (zh) * 2015-06-24 2015-09-23 上海快仓智能科技有限公司 一种基于二维码解码的快速定位识别的方法
US20150324946A1 (en) * 2014-05-09 2015-11-12 Graphiclead LLC System and method for embedding of a two dimensional code with an image
CN105975894A (zh) * 2016-05-11 2016-09-28 华中科技大学 一种基于自适应边缘检测和映射模型的一维码识别算法
CN106951812A (zh) * 2017-03-31 2017-07-14 腾讯科技(深圳)有限公司 识别二维码的方法、装置和终端
CN108764420A (zh) * 2018-04-24 2018-11-06 中国人民银行印制科学技术研究所 一种二维码及其编码、识别方法、具有防伪功能的产品
CN108960000A (zh) * 2018-07-17 2018-12-07 深圳市零点零科技有限公司 一种长条小型二维码识别方法
CN110288069A (zh) * 2019-06-26 2019-09-27 百度在线网络技术(北京)有限公司 二维码生成和解析的方法、装置、设备及可读存储介质
CN110969233A (zh) * 2018-09-30 2020-04-07 北京微播视界科技有限公司 二维码的生成方法、装置、硬件装置
CN111209991A (zh) * 2019-12-31 2020-05-29 徐波 一种环形码及其设计方法
CN112926715A (zh) * 2021-03-23 2021-06-08 支付宝(杭州)信息技术有限公司 一种二维码生成、解码方法、装置及设备
CN113487001A (zh) * 2021-09-08 2021-10-08 飞狐信息技术(天津)有限公司 二维码生成方法及装置、二维码识别方法及装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104851117B (zh) * 2014-02-13 2018-11-23 腾讯科技(深圳)有限公司 图像与二维码的融合方法和装置
CN108038529B (zh) * 2017-12-08 2020-10-09 北京中星仝创科技有限公司 一种带图像的圆形二维码生成及读取的方法
CN108776828B (zh) * 2018-06-07 2021-04-13 中国联合网络通信集团有限公司 二维码生成方法、二维码生成装置和二维码
CN112163655B (zh) * 2020-09-30 2021-05-07 上海麦广互娱文化传媒股份有限公司 一种动态隐式二维码及其生成和检测方法及设备
CN112215030B (zh) * 2020-10-28 2022-06-10 天津大学 一种基于柱面二维码的复原和识别方法

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150324946A1 (en) * 2014-05-09 2015-11-12 Graphiclead LLC System and method for embedding of a two dimensional code with an image
CN104933387A (zh) * 2015-06-24 2015-09-23 上海快仓智能科技有限公司 一种基于二维码解码的快速定位识别的方法
CN105975894A (zh) * 2016-05-11 2016-09-28 华中科技大学 一种基于自适应边缘检测和映射模型的一维码识别算法
CN106951812A (zh) * 2017-03-31 2017-07-14 腾讯科技(深圳)有限公司 识别二维码的方法、装置和终端
CN108764420A (zh) * 2018-04-24 2018-11-06 中国人民银行印制科学技术研究所 一种二维码及其编码、识别方法、具有防伪功能的产品
CN108960000A (zh) * 2018-07-17 2018-12-07 深圳市零点零科技有限公司 一种长条小型二维码识别方法
CN110969233A (zh) * 2018-09-30 2020-04-07 北京微播视界科技有限公司 二维码的生成方法、装置、硬件装置
CN110288069A (zh) * 2019-06-26 2019-09-27 百度在线网络技术(北京)有限公司 二维码生成和解析的方法、装置、设备及可读存储介质
CN111209991A (zh) * 2019-12-31 2020-05-29 徐波 一种环形码及其设计方法
CN112926715A (zh) * 2021-03-23 2021-06-08 支付宝(杭州)信息技术有限公司 一种二维码生成、解码方法、装置及设备
CN113487001A (zh) * 2021-09-08 2021-10-08 飞狐信息技术(天津)有限公司 二维码生成方法及装置、二维码识别方法及装置

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116796782A (zh) * 2023-05-04 2023-09-22 北京百度网讯科技有限公司 二维码的生成方法、识别方法、装置、设备及存储介质
CN117032085A (zh) * 2023-08-04 2023-11-10 安徽捷圆电子科技有限公司 Aoi机连线自动化控制方法、系统及其应用
CN117094349A (zh) * 2023-10-19 2023-11-21 中国物品编码中心 二维码图形的生成方法、装置、设备及介质
CN117094349B (zh) * 2023-10-19 2024-01-09 中国物品编码中心 二维码图形的生成方法、装置、设备及介质

Also Published As

Publication number Publication date
CN112926715A (zh) 2021-06-08
CN112926715B (zh) 2024-02-02

Similar Documents

Publication Publication Date Title
WO2022199471A1 (zh) 一种二维码生成、解码方法、装置及设备
JP6894005B2 (ja) 識別コードを生成および識別するための方法および装置
US9406010B2 (en) Producing, capturing and using visual identification tags for moving objects
CN103793735B (zh) 一种圆形二维条码及其编码解码方法
CN101430768B (zh) 一种二维条码的定位方法
CN102880850B (zh) 一种二维码批量扫描的方法及扫描设备
JP3953501B1 (ja) プログラム、情報記憶媒体、2次元コード生成システム、画像生成システム及び2次元コード
CN109285198A (zh) 一种环形编码标记点的编码及识别方法
CN107122816A (zh) 一种自定义寻像图形二维码及生成方法
CN106845593A (zh) 一种矩形固定点阵信息编解码方法
CN104992207A (zh) 一种手机二维条码编解码方法
CN105718980A (zh) 一种生成二维码图片的方法
CN106067054A (zh) 一种基于qr码的二维码
CN115511031A (zh) 一种扩容二维码、三维码解码方法、系统、设备和介质
CN111291846B (zh) 一种二维码生成、解码、识别方法、装置及设备
CN112926714B (zh) 融合qr码、条形码和光学字符的视觉三维码及其编码方法
CN105701529A (zh) 一种在二维码上实现彩色图片显示的方法
Wang et al. Camera readable 2d bar codes design and decoding for mobile phones
US20240185016A1 (en) Two-dimensional code generation and decoding methods, apparatuses, and devices
CN109635613B (zh) 一种用于球体表面的二维码生成方法、系统及装置
You et al. Multi-style migration QR code
CN108229625A (zh) 一种编码方法及装置
CN110866578B (zh) 一种二维纹理码及其编码和解码方法
Wang et al. Research on the Structure and Coding of a Novel Double Z Two-Dimensional Bar Code with Large Capacity
CN108229233A (zh) 一种解码方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22774132

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 18551997

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 11202306453T

Country of ref document: SG

122 Ep: pct application non-entry in european phase

Ref document number: 22774132

Country of ref document: EP

Kind code of ref document: A1