Grid code generation and identification method, computer equipment and storage medium
By using grid code generation and recognition methods in the grid code generation and recognition system, using high-definition macro camera and cloud verification, the problem of insufficient response speed of the existing system is solved, and efficient grid code verification and The hidden audit tools enhance the anti-counterfeiting and anti-cross-official capabilities of goods.
Patent Information
- Application Number
- CN202411569051.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-02-18
AI Technical Summary
The existing grid code verification and identification systems are insufficient in response to a large number of verification requests, making it difficult to meet the rapidly growing verification needs.
A grid code generation and identification method is proposed. By converting anti-counterfeiting information into a fill code, and filling preset start code, fill code and random code into the two-dimensional matrix, a layout diagram containing the grid code is formed. This method uses a high-definition macro camera to obtain layout diagrams, analyze them through terminal devices and send them to the cloud for verification, and supports the acquisition of GPS positioning information to determine whether the product has stolen goods.
It improves the verification and identification speed of grid code, supports efficient processing of a large number of verification requests, enhances the ability to prevent counterfeiting and anti-cross-trashing of goods, and provides hidden audit tools, suitable for cross-trashing management application scenarios.
Smart Images

Figure CN119477345A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a grid code generation and recognition method, a computer device and a storage medium. Background Art
[0002] With the continuous development of industries such as commodity retail, commodity anti-counterfeiting and anti-channelling have become more and more important. At the same time, new information embedding methods are increasingly used in various fields. Among them, the grid information code, as a special code rule, has the characteristics of simple information layout and high parsing effectiveness. In practical applications (such as solutions based on ZL202111217583.X), by parsing the data of the grid, it is finally converted into numerical values or information that can be identified by consumers or market auditors, which solves the problem of commodity anti-counterfeiting and anti-channelling. However, with the geometric growth of the number of verifications, the verification response speed has become more and more important, and the existing solutions need to be improved and optimized. To this end, it is urgent to introduce an efficient verification and identification terminal and identification method. Summary of the invention
[0003] To overcome the deficiencies of the prior art, embodiments of the present invention provide a grid code generation and recognition method, a computer device, and a storage medium.
[0004] A grid code generation method, comprising:
[0005] Converting the anti-counterfeiting information corresponding to the product information into a filling code of a first preset number of digits;
[0006] A two-dimensional matrix of a preset size is set, and the four corners of the two-dimensional matrix are used as positioning angles; a reserved area is defined between each two adjacent positioning angles, and four reserved areas are obtained;
[0007] Taking any one of the reserved areas as the starting mark area and filling in a preset starting code;
[0008] Filling the filling code into the two-dimensional matrix from the position where the preset start code is located, and then filling the blank area of the two-dimensional matrix except the four reserved areas and the filling code with random codes;
[0009] The check information corresponding to the filling code and the length of the random code are filled into the three reserved areas outside the starting mark area to obtain a layout diagram containing a grid code.
[0010] A grid code recognition method is used to recognize a layout diagram containing a grid code obtained by the above-mentioned grid code generation method, and comprises:
[0011] Acquire the layout diagram through a terminal device, and determine the four reserved areas according to the four positioning angles of the layout diagram;
[0012] Parsing whether the four reserved areas contain the preset start code, if the preset start code is not parsed, the recognition fails;
[0013] If the preset start code is obtained by parsing, then the padding code is parsed after the preset start code to see if it is included. If the padding code is not parsed, the recognition fails.
[0014] If the padding code is obtained by parsing, the verification information corresponding to the padding code and the length of the random code are extracted from the three reserved areas outside the start mark area, and the padding code, the verification information and the length of the random code are sent to the cloud for verification;
[0015] The verification result is sent back to the terminal device.
[0016] A grid code recognition terminal device is used in the above-mentioned grid code recognition method and includes: a high-definition macro camera, a network communication module, and a satellite positioning module; wherein:
[0017] The high-definition macro camera is used to obtain the layout diagram; the network communication module is used to communicate remotely with the cloud; and the satellite positioning module is used to obtain the current longitude and latitude information of the grid code recognition terminal device.
[0018] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned grid code generation method when executing the computer program; or the processor implements the steps of the above-mentioned grid code recognition method when executing the computer program.
[0019] A computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the above-mentioned grid code generation method; or, when executed by a processor, implements the steps of the above-mentioned grid code recognition method.
[0020] The above-mentioned grid code generation and identification method, computer equipment and storage medium propose an optimized grid code generation method, which uses a layout diagram containing a grid code as an information carrier, corresponds to the product one by one, and plays the role of one object and one code, which is convenient for merchants and consumers to identify the authenticity of the product, the legality of sales, and the validity of traceability. At the same time, the grid code recognition method can be applied to an embedded DSP image processing device that supports a high-definition macro camera, locates the effective point in the layout diagram, reversely calculates the bit encoding corresponding to the grid through the relative position of the grid space, and then obtains the unique code value through reverse byte parsing, correctness verification and decompression, and then sends the code value to the cloud server to obtain the corresponding product information, traceability information, and the validity and legality of the verification code value; and supports obtaining the current GPS satellite positioning information, sending the information to the cloud server, and combining the pre-set sales area of the code value to determine whether the product has a cross-selling behavior. In addition, the terminal device with grid code recognition, as a special audit tool, makes the audit method concealed, which is very suitable for the application scenario of cross-selling management. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0022] Figure 1 is a layout diagram containing a grid code in one embodiment of the present invention;
[0023] Figure 2 It is a schematic diagram of marking a layout diagram containing a grid code in one embodiment of the present invention. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] A grid code generation method is provided, which specifically comprises the following steps:
[0026] S1, converting the anti-counterfeiting information corresponding to the commodity information into a filling code of a first preset number of digits.
[0027] The anti-counterfeiting information is used to correspond to the commodity information; the length of the filling code, that is, the preset number of digits, can be flexibly set, preferably a 16-digit hexadecimal number.
[0028] S2, setting a two-dimensional matrix of a preset size, with the four corners of the two-dimensional matrix as positioning angles; a reserved area is defined between every two adjacent positioning angles, and four reserved areas are obtained.
[0029] Wherein, the size of the two-dimensional matrix corresponds to the number of rows and columns of the matrix. The four corners of the matrix are four vertices, or the corners can also be 2X2 or 3X3 submatrices. The positioning angle is used to limit the reserved area for filling in information, and the row or column between each adjacent two positioning angles is the reserved area. It can be understood that when the corners are 2X2 or 3X3 matrices, the corresponding reserved area is a rectangular area of the same width or length.
[0030] S3, taking any reserved area as the start mark area and filling in a preset start code.
[0031] The start mark area can be flexibly selected, which further increases the difficulty of cracking. The length and specific value of the preset start code can be predefined, for example, 0101010101, but not limited to this.
[0032] S4, filling the filling code into the two-dimensional matrix from the position after the preset start code, and then filling the blank area of the two-dimensional matrix except the four reserved areas and the filling code with random codes.
[0033] After selecting a reserved area as the start mark area, a filling code is filled after the start code. It can be understood that when the length of the filling code exceeds the start mark area, it can be filled in other rows or columns in the two-dimensional matrix in sequence until it is filled. The random code is randomly generated and used to fill the blank area in the two-dimensional matrix except the four reserved areas and the filling code.
[0034] S5, filling the check information corresponding to the filling code and the length of the random code into the three reserved areas outside the start mark area to obtain a layout diagram including the grid code.
[0035] The check information corresponding to the filling code is used to ensure that the data bits of the filling code are correct. At the same time, the length of the random code can also be used as one of the check information. The check information and the length of the random code are flexibly filled into the three reserved areas outside the start mark area to increase the difficulty of cracking. Finally, the layout diagram containing the grid code is obtained as follows Figure 1 As shown, Figure 1 The location of the hidden information in Figure 2 shown.
[0036] Furthermore, the generation process of the filling code includes the following steps:
[0037] S11, first use a symmetric encryption algorithm to encrypt and verify the anti-counterfeiting information, and then perform MD5 operation on the encryption verification result to obtain an MD5 summary.
[0038] S12, performing a modulo operation of a preset byte length on the MD5 digest, and merging the modulo result into the bytecode of the encryption verification result.
[0039] S13, compressing the combined bytecode to obtain a filling code with a first preset number of bits.
[0040] Specifically, in one implementation, a character string data with a limited total length is first encrypted and verified using a symmetric encryption algorithm, and in the symmetric encryption, different secret keys are used for encryption and decryption for different client entities; the encryption verification result after symmetric encryption is assumed to be 22245678987543; an MD5 operation is performed on it to obtain a result value of the MD5 summary, and the modulo of the 5-bit byte length is obtained, and the converted number is 78894; the data after the two are combined is: 2224567898754378894; the combined bytecode is compressed in hexadecimal and converted into a filling code: 1edf40b7b7fdec8e.
[0041] When filling, first generate a square with the corresponding side length according to the bit length converted from hexadecimal to ensure that the number of grids is sufficient to fill the data, then generate 4 corner positioning angles, and then select one side as the starting side, fill in 0101010101 as the starting mark, and the data content starts from the starting side and fills in the compressed bits; after completing the data filling, fill the blank area with random bits, and then fill the bit length into the left side of the starting side, take the modulus of the bit with the binary value of the customer number, use the result information as the check code, and fill the check code information into the right side of the starting side; the side opposite the starting side is filled randomly.
[0042] A grid code recognition method is provided, which is used to recognize a layout diagram containing a grid code obtained by the above grid code generation method, and comprises the steps of:
[0043] S6, obtaining a layout diagram through a terminal device, and determining four reserved areas according to four positioning angles of the layout diagram.
[0044] S7, analyzing whether the four reserved areas contain a preset start code. If the preset start code is not analyzed, the recognition fails.
[0045] S8, if the preset start code is obtained through parsing, then parse whether a filling code is included after the preset start code. If the filling code is not parsed, the recognition fails.
[0046] S9, if the padding code is obtained through parsing, the verification information and the length of the random code corresponding to the padding code are extracted from the three reserved areas outside the start mark area, and the padding code, the verification information and the length of the random code are sent to the cloud for verification.
[0047] S10, the verification result is sent back to the terminal device.
[0048] It can be understood that which of the four reserved areas is the start mark area, the specific value of the preset start code, the calculation process of the filling code, the verification information and the length of the random code are all determined at the beginning of the design of the recognition program. Steps S6-S10 are the inverse operation process based on the grid code generation method. Here, only one example is given for illustration. The process of recognition in the terminal device or APP includes:
[0049] ① Align the acquisition device (or the viewfinder of the APP) with the location of the dot print matrix code (the four corners of the preview screen are aligned with the four corners of the grid code), and the image acquisition is automatically triggered;
[0050] ②Process the read pictures. Processing process:
[0051] A. Image preprocessing, binarization, and noise removal;
[0052] B. Preliminary acquisition of feature points through wavelet transformation, removal of noise and interference points;
[0053] C. Image edge detection and contour extraction, filtering out contour points that meet the requirements (the print photo may be blurred, and the square is no longer a complete square shape);
[0054] D. Position the processed data and decode it for the next step;
[0055] ③ Reversely parse the point data in the order of generation. Calculate the four positioning points, obtain the special starting position value, and calculate the proportional segmentation relative position according to the starting position; then compare the relative distance between the feature points to obtain the corresponding bit value, binarize it into binary bits, intercept the effective bit length through the length value of the left side of the starting bit, and verify the correctness of the bit through the right side check bit;
[0056] ④ Reversely parse the digits into byte data, perform verification, and decrypt them into valid data after successful verification;
[0057] ⑤ Mix the valid data with timestamp and encryption, which is used for transmission security;
[0058] ⑥ Obtain the current GPS positioning information and transmit the encrypted data and GPS data to the cloud via the TCP network;
[0059] ⑦ The cloud collects data and verifies its legitimacy, decrypts data, extracts valid data and compares it with the database, reads the accurate data of the code value, related product data, batch data, preset sales data, etc. and transmits it back to the identifier; at the same time, the cloud uploads the recorded information to the blockchain for permanent storage, and stores the blockchain records in the cloud database.
[0060] ⑧The identification device or APP provides the result information to relevant personnel for inspection.
[0061] Furthermore, in step S9, when the filling code, the verification information and the length of the random code are sent to the cloud for verification, it also includes:
[0062] S91, the latitude and longitude information of the terminal device is sent to the cloud, and the latitude and longitude information is stored in the blockchain. That is, the latitude and longitude information is used to determine the current verification positioning information, and the latitude and longitude of the information and the unique code (obtained by the inverse operation of the filling code, verification information and the length of the random code) are sent to the cloud for verification and recording, and the recorded information is stored in the blockchain to avoid tampering.
[0063] A grid code recognition terminal device is provided, and includes: a high-definition macro camera, a network communication module, and a satellite positioning module; wherein the high-definition macro camera is used to obtain a layout map; the network communication module is used to communicate remotely with the cloud; the satellite positioning module, such as GPS, Beidou satellite positioning, etc., is used to obtain the current longitude and latitude information of the grid code recognition terminal device.
[0064] Specifically, the grid code recognition terminal device can be based on a smart phone, computer or other smart hardware device. Its software APP program and hardware support image acquisition through an embedded macro camera, image processing through an embedded image processor DSP, and the removal of noise information. It can locate the effective points of the grid, reversely calculate the bit encoding corresponding to the grid through the relative position of the grid space, and then obtain the unique code value through reverse byte parsing, correctness verification and decompression, and send the code value to the cloud server to obtain the corresponding product information, traceability information, and verify the validity and legality of the code value; the device supports obtaining the current positioning information, sending the information to the cloud server, and combining the pre-set sales area of the code value to determine whether the product has any channel flooding.
[0065] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the grid code generation and recognition method in the above embodiment are implemented. To avoid repetition, they are not described here.
[0066] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the grid code generation and recognition method in the above method embodiment is implemented. To avoid repetition, it is not described here.
[0067] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A grid code generation method, characterized in that: include: Converting the anti-counterfeiting information corresponding to the product information into a filling code of a first preset number of digits; Setting a two-dimensional matrix of a preset size, with the four corners of the two-dimensional matrix as positioning angles; A reserved area is defined between each two adjacent positioning angles, so that four reserved areas are obtained; Taking any one of the reserved areas as the start mark area and filling in a preset start code; Filling the filling code into the two-dimensional matrix from the position where the preset start code is located, and then filling the blank area of the two-dimensional matrix except the four reserved areas and the filling code with random codes; The check information corresponding to the filling code and the length of the random code are filled into the three reserved areas outside the start mark area to obtain a layout diagram containing a grid code.
2. The grid code generation method according to claim 1, characterized in that: The step of converting the anti-counterfeiting information corresponding to the commodity information into a filling code of a first preset number of digits includes: First, the anti-counterfeiting information is encrypted and verified using a symmetric encryption algorithm, and then an MD5 operation is performed on the encryption verification result to obtain an MD5 digest; Performing a modulo operation of a preset byte length on the MD5 digest, and merging the result after the modulo operation into the bytecode of the encryption verification result; The combined bytecodes are compressed to obtain a filling code having the first preset number of bits.
3. The grid code generation method according to claim 1, characterized in that: The first preset number of bits is 16 bits.
4. The grid code generation method according to claim 2, characterized in that: The preset byte length is 5 bytes.
5. A grid code recognition method, characterized in that: The grid code recognition method is used to recognize a layout diagram containing a grid code obtained by the grid code generation method according to any one of claims 1 to 4, and comprises: Acquire the layout diagram through a terminal device, and determine the four reserved areas according to the four positioning angles of the layout diagram; Parsing whether the four reserved areas contain the preset start code, if the preset start code is not parsed, the recognition fails; If the preset start code is obtained by parsing, then the preset start code is parsed to see whether the padding code is included, and if the padding code is not parsed, the recognition fails; If the padding code is obtained by parsing, the verification information corresponding to the padding code and the length of the random code are extracted from the three reserved areas outside the start mark area, and the padding code, the verification information and the length of the random code are sent to the cloud for verification; The verification result is sent back to the terminal device.
6. The grid code recognition method according to claim 5, characterized in that: When the filling code, the verification information and the length of the random code are sent to the cloud for verification, it also includes: The latitude and longitude information of the terminal device is sent to the cloud, and the latitude and longitude information is stored in the blockchain.
7. A grid code recognition terminal device, characterized in that: The grid code recognition terminal device is applied in the grid code recognition method as claimed in claim 6, and comprises: a high-definition macro camera, a network communication module, and a satellite positioning module; wherein, The high-definition macro camera is used to obtain the layout diagram; the network communication module is used to communicate remotely with the cloud; and the satellite positioning module is used to obtain the current longitude and latitude information of the grid code recognition terminal device.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the grid code generation method according to any one of claims 1 to 4 are implemented; or, when the processor executes the computer program, the steps of the grid code recognition method according to any one of claims 5 to 6 are implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the grid code generation method according to any one of claims 1 to 4 are implemented; or, when the computer program is executed by a processor, the steps of the grid code recognition method according to any one of claims 5 to 6 are implemented.
Citation Information
Patent Citations
A method, system, device and medium for generating and verifying anti-counterfeiting dot matrix
CN113988244B