Dynamic two-dimensional code generating and decoding method

By dividing data files into blocks to generate dynamic QR codes and combining them with error correction technology, the shortcomings of static QR codes in terms of data capacity, security, and decoding flexibility are solved, achieving an efficient and dynamic visual experience and flexible decoding.

CN121638293APending Publication Date: 2026-03-10FUJIAN NEWLAND AUTO ID TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-27
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing static QR codes are insufficient in terms of data capacity, security, visual experience, and decoding flexibility, and cannot meet the needs of complex application scenarios.

Method used

By segmenting data files and generating dynamic QR codes, and then playing static QR codes using video frame rates, combined with error correction technology and segmentation methods, dynamic visual effects and efficient decoding are achieved.

Benefits of technology

It breaks through the physical capacity limit of a single QR code, improves data carrying capacity, enhances visual appeal and decoding success rate, and increases tolerance to environmental interference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121638293A_ABST
    Figure CN121638293A_ABST
Patent Text Reader

Abstract

The invention relates to a dynamic two-dimensional code generating and decoding method, and the method comprises the steps: a code generating process: obtaining a to-be-generated video template of a dynamic two-dimensional code, and carrying out the frame extraction of the to-be-generated video template, and obtaining a plurality of image frames; performing binarization processing on each image frame to obtain a plurality of code areas, and recording the position and shape of each code area; the method comprises the following steps: partitioning a data file to be coded based on a partitioning method, and adding block header information in front of each data block; coding the block header information of the current data block and the corresponding block data according to a coding mode corresponding to the blocking method, and generating a static two-dimensional code with the same shape as the code area; pasting all the static two-dimensional codes back to the code area and playing the static two-dimensional codes at a preset frame rate to obtain dynamic two-dimensional codes; in the decoding process, a decoding device is used for scanning the dynamic two-dimensional code, the current static two-dimensional code is collected and decoded, and if decoding succeeds, the current decoded static two-dimensional code is stored; and the decoding process is iterated until a complete data file is spliced, and decoding is ended.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of dynamic two-dimensional code, and mainly relates to a dynamic two-dimensional code generation and decoding method. BACKGROUND

[0002] At present, most two-dimensional codes are in the form of a picture (not a video), that is, static two-dimensional codes. The current mainstream technology is developed around "static single code" or "static multi-code splicing". Although some technologies try to optimize the shape of two-dimensional codes or increase the display dimension, they all do not break through the essence of "static picture", resulting in difficult-to-solve problems in the four core dimensions of capacity bearing, security, visual experience and decoding flexibility, and cannot meet the needs of increasingly complex application scenarios.

[0003] Based on the current development status of bar code technology, the existing two-dimensional code related technologies can be divided into four categories; standard static two-dimensional code: a limited amount of data (such as a website, text) is encoded into a picture containing a specific black and white square pattern; variable shape two-dimensional code: artistic design is performed on the positioning pattern, format information, etc. of the two-dimensional code during the encoding process, or the internal modules of the code picture are allowed to present different shapes (such as circles, triangles), thereby generating two-dimensional codes with special appearances (such as circular, logo embedded shape); structure addition mode using two-dimensional code: when the data volume is too large for a two-dimensional code to accommodate, the data can be divided into multiple parts, and a series of two-dimensional codes that are structurally related to each other are generated.

[0004] However, the above existing technologies all have the following key problems; 1. When the amount of data to be encoded is large, the static two-dimensional code either fails to be generated due to exceeding the capacity limit, or a "large" two-dimensional code with very dense modules is generated; when this high-density two-dimensional code is displayed on a screen with limited size (such as a mobile phone), the code scanning device may fail to decode due to the inability to clearly distinguish each module; among them, the standard static two-dimensional code and the variable shape two-dimensional code are limited by the physical information density of a single picture; the structure addition mode using two-dimensional code divides the data into blocks, but requires continuous scanning of multiple independent two-dimensional codes with fixed shapes, resulting in a discontinuous user experience; 2. The appearance of the static two-dimensional code is fixed and rigid, and cannot provide a dynamic and rich visual experience; 3. The static two-dimensional code exists in the form of a picture, which can be easily copied and spread through screenshot, photographing, etc.; 4. The decoding flexibility is poor, there is no code omission fault tolerance mechanism, and the decoding efficiency is low, among which the structure addition mode using two-dimensional code requires "scanning all codes", and if one code is missed, the complete data cannot be spliced, and the decoding directly fails.

[0005] Therefore, there is an urgent need for a dynamic two-dimensional code generation and decoding method. SUMMARY

[0006] To address the problems existing in the prior art, this invention proposes a dynamic QR code generation and decoding method.

[0007] The technical solution of the present invention is as follows: On the one hand, this invention proposes a method for generating and decoding dynamic QR codes, the method comprising a code generation process and a decoding process: Code generation process: Obtain the dynamic QR code video template to be generated, and extract multiple image frames from it; perform binarization on each image frame to obtain several code areas, and record the position and shape of each code area; The data file to be encoded is divided into blocks based on the block-based method, and block header information is added before each data block. The block header information and the corresponding block data of the current data block are encoded according to the encoding method corresponding to the block-based method to generate a static QR code with the same shape as the code area. Paste all static QR codes back into the code area and play them at a preset frame rate to obtain dynamic QR codes; Decoding process: Use a decoding device to scan the dynamic QR code, collect the current static QR code for decoding, and if the decoding is successful, save the current decoded static QR code. The decoding process is iterated until a complete data file is assembled, at which point the decoding ends.

[0008] Preferably, each image frame is binarized to distinguish the foreground and background regions. Select the region in the foreground area whose connected region is larger than the preset code range as the code area, and record the position and shape of the code area.

[0009] Preferably, the block header information includes the block index, total number of blocks, and file ID; The segmentation methods include single segmentation, irregular segmentation, and regular segmentation.

[0010] Preferably, the rule segmentation is carried out in the following steps: Based on the size of the data file in bytes and the preset byte size of each block Calculate the number of blocks ; If the first If the size of a block is less than the preset size, it will be padded. Generated based on error correction algorithm The total number of blocks is expanded by each error correction block, meaning that the total number of blocks in the header information of the current data block is the sum of the data blocks and the error correction blocks.

[0011] Preferably, the block header information and corresponding block data of the current data block are encoded according to the encoding method corresponding to a single block. The specific steps are as follows: The preset code generation program generates a preliminary two-dimensional code for encoding the current data block for each code area, and records the size parameters of the preliminary two-dimensional codes; The maximum value in the size parameters of all the preliminary two-dimensional codes is selected as the uniform size parameter; Based on the uniform size parameter, a plurality of static two-dimensional codes are regenerated.

[0012] Preferably, the block header information and the corresponding block data of the current data block are encoded according to the encoding mode corresponding to irregular block division, and the specific steps are as follows: The preset code generation program encodes the data file based on the initial size parameter to obtain an initial block number; The size of the initial block number and the number of code areas is determined, if the initial block number is less than the number of code areas, the initial size parameter is reduced by a preset step, otherwise, the initial size parameter is increased by a preset step, until the block number is equal to the number of code areas, and the current size parameter is taken as the uniform size parameter; Based on the uniform size parameter, a plurality of static two-dimensional codes are regenerated.

[0013] Preferably, the block header information and the corresponding block data of the current data block are encoded according to the encoding mode corresponding to regular block division, and the specific steps are as follows: The preset code generation program generates a plurality of test two-dimensional codes with fixed size for each code area, and records the size parameters of the test two-dimensional codes; The maximum value in the size parameters of all the test two-dimensional codes is selected as the uniform size parameter.

[0014] Preferably, the current collected static two-dimensional code is decoded, and the specific steps are as follows: If the decoding is successful, it is determined whether the current static two-dimensional code has been decoded, if yes, the current static two-dimensional code is discarded; Otherwise, it is determined whether the file id of the current static two-dimensional code is the same as that in the list, if yes, the current static two-dimensional code is recorded in the list, otherwise, the current list is emptied and the current static two-dimensional code is recorded in the list; It is further determined whether a preset splicing threshold is reached, if yes, the static two-dimensional codes in the current list are spliced, and the list is emptied, and the decoding process is ended; otherwise, the collection is performed again; If the decoding fails, the collection is performed again.

[0015] On the other hand, the present application also provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method as described in the present application when executing the program.

[0016] In still another aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method as described in the present application.

[0017] The present application has the following beneficial effects: 1. The present application provides a dynamic two-dimensional code generation and decoding method, which pastes the two-dimensional code generated by encoding back to the code area to form a video, breaks through the static form of a single two-dimensional code, realizes dynamic visual effect, changes the two-dimensional code from a boring static picture to a continuous video with dynamic effect, improves visual attraction, and enhances the novelty and interest of user experience. 2. The present application provides a dynamic two-dimensional code generation and decoding method, which splits a single large file into multiple data blocks through data file block encoding technology, and uses multiple two-dimensional codes to carry respectively, thereby bypassing the upper limit of the physical capacity of a single two-dimensional code, and improving the data carrying capacity. 3. The present application provides a dynamic two-dimensional code generation and decoding method, which uses error correction technology to allow the original data to be recovered completely even if all two-dimensional codes are not scanned, improves the success rate and efficiency of decoding, and enhances the tolerance to incomplete scanning, which can cope with common disturbances in real environment such as light changes, occlusion, and jitter. BRIEF DESCRIPTION OF DRAWINGS

[0018] Figure 1 is a specific flowchart of the embodiment of the present application; Figure 2 is a decoding process flowchart of the embodiment of the present application; Figure 3 is a code area schematic diagram of the embodiment of the present application; Figure 4 is a dynamic two-dimensional code schematic diagram generated by the single block method of the embodiment of the present application; Figure 5 is a dynamic two-dimensional code schematic diagram generated by the irregular block method of the embodiment of the present application; Figure 6 is a dynamic two-dimensional code schematic diagram generated by the regular block method of the embodiment of the present application. DETAILED DESCRIPTION

[0019] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0020] It should be understood that the step numbers used herein are only for the convenience of description, and are not intended to limit the execution sequence of the steps.

[0021] It should be understood that the terms used in the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the present application and the appended claims, "a", "an", and "the" in singular form are intended to include plural forms unless the context clearly indicates otherwise.

[0022] The terms "comprise" and "include" indicate the presence of the described features, integers, steps, operations, elements, and / or components, but do not exclude one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0023] The term "and / or" means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.

[0024] Embodiment one: Referring to Figure 1 The present application provides a dynamic two-dimensional code generation and decoding method, which comprises a code generation process and a decoding process: Code generation process: S1, obtain a dynamic two-dimensional code video template to be generated, and frame it to obtain a plurality of image frames; Each image frame is subjected to binaryzation processing to distinguish the foreground region and the background region therein; The regions in the foreground region with a connected region greater than a preset code range are taken as code regions, a plurality of code regions are obtained, and the positions and shapes of the code regions are recorded; S2, the data file to be encoded is divided into blocks based on a block division method, and a block header information is added before each data block; the block header information includes block index, total block number and file id, wherein the block header information is realized by using the structure addition function of the two-dimensional code; The data file to be encoded includes text files, picture files, table files, etc. S21, the block division method includes single block division, irregular block division and regular block division; S221, single block division refers to that the entire data file is divided into one block, i.e. no splitting is performed; for this case, generally the data file is small, and the user focuses on the dynamic feature rather than encoding a large amount of data; At this time, the encoding data of each two-dimensional code generated is the same, only the appearance of each two-dimensional code is different, and any two-dimensional code in the dynamic two-dimensional code can be successfully decoded when decoding; S222, irregular refers to the entire data file is split into several blocks of different sizes; for this case, mainly in order to correspond to the area of the code area of each picture of the video template, the area of the code area is relatively large, the data is relatively large, the area of the code area is relatively small, the data is relatively small; When generating the code, the data is filled into the two-dimensional code in turn, and after filling one two-dimensional code, the remaining data is filled into the subsequent two-dimensional code until all the data is filled; In this case, the actual number of pictures of the animation video is the same as the number of blocks; when decoding, all two-dimensional codes in the dynamic two-dimensional code need to be scanned to decode S223, regular block refers to the entire data file is split into several blocks of the same size; for this case, it may be due to some special consideration, the data file must be split into several blocks of the same size, such as when the number of pictures of the video template is different from the number of blocks of the data file, because each block of data is the same size, any block of data can be encoded into any picture of the video template, at this time, each block of data in the cyclic block sequence can be encoded into each picture in the cyclic picture sequence of the video template, without considering whether the number of blocks is the same as the number of pictures; When decoding, only part of the two-dimensional code in the dynamic two-dimensional code needs to be scanned to decode; The specific steps of the regular block are: Based on the byte size of the data file And the preset byte size of each block , calculate the number of blocks ; If the byte size of the first block is less than the preset byte size, it is filled; Based on the error correction algorithm (such as Reed-Solomon code, fountain code) Generate a number of error correction blocks to expand the total number of blocks, that is, the total number of blocks in the header information of the data block is the sum of the data block and the error correction block; Among them, the role of the error correction block is that the dynamic two-dimensional code is played in a loop, the decoding device may start scanning at any time, and some frames may be missed due to shaking, blocking, light changes and other reasons; The introduction of error correction blocks can not require scanning all static two-dimensional codes, as long as a sufficient number of blocks are collected, the decoding can be successful; In addition, when the number of blocks is greater than the number of code areas, some blocks will share the same shape; if the decoding is missed at the time when the shape appears, two blocks will be lost at the same time, and the introduction of error correction blocks can tolerate the loss of multiple blocks; S22, encode the block header information and corresponding block data of the current data block according to the encoding mode corresponding to the block splitting method, to generate a static two-dimensional code with the same shape as the code area; When generating the code, the size consistency of each static two-dimensional code in the dynamic two-dimensional code must be maintained, so as not to break the continuity of the animation; therefore, the size parameter input during code generation for each block of data must be the same, and the size parameter is the magnification multiple of the code area shape; the larger the size parameter, the larger the code area, and thus more data can be stored; S221, encode the block header information and corresponding block data of the current data block according to the encoding mode corresponding to the single block splitting, since the total number of blocks is 1, regardless of the size of the data file, it is always encoded into one two-dimensional code, the specific steps are as follows: Use the preset code generation program to generate a preliminary two-dimensional code for each code area, which encodes the current data block, and record the size parameters of each preliminary two-dimensional code; Select the maximum value of the size parameters of all preliminary two-dimensional codes, and set it as the unified size parameter; Based on the unified size parameter, generate a plurality of static two-dimensional codes; S222, encode the block header information and corresponding block data of the current data block according to the encoding mode corresponding to the irregular block splitting, wherein the size parameter is specified by the user in a trial manner, and the size parameter directly affects the value of the block number: the larger the size parameter, the smaller the block number; the smaller the size parameter, the larger the block number, the specific steps are as follows: The preset code generation program encodes the data file based on the initial size parameter to obtain the initial block number; Determine the size of the initial block number and the number of code areas, if the initial block number is less than the number of code areas, decrease the initial size parameter by a preset step, otherwise, increase the initial size parameter by a preset step, until the block number is equal to the number of code areas, and the current size parameter is used as the unified size parameter; Based on the unified size parameter, generate a plurality of static two-dimensional codes; S223, encode the block header information and corresponding block data of the current data block according to the encoding mode corresponding to the regular block splitting; wherein the size of each block is the same, and the size of the data in each code is the same, the specific steps are as follows: Use the preset code generation program to generate a plurality of test two-dimensional codes with fixed size for each code area, and record the size parameters of each test two-dimensional code; wherein the preset code generation program only starts the byte encoding mode and closes all other encoding modes; Select the maximum value of the size parameters of all test two-dimensional codes as the unified size parameter; S3, paste all the static two-dimensional codes back to the code area and play them at a preset frame rate to obtain a dynamic two-dimensional code; When the static two-dimensional code is pasted back to the code area, the foreground area in the static two-dimensional code can be selected to be transparent, and the background area can be selected to be the background color of the image frame, so that the dynamic code can basically maintain the color tone in the original animation video; The frame rate refers to the number of static two-dimensional codes in the dynamic two-dimensional code displayed per second. The value of the frame rate is related to the speed of the decoding algorithm and the speed of screen refresh. The faster the decoding speed and the faster the screen refresh, the larger the frame rate. In general, the frame rate can be appropriately selected as 10-30; When the regular block is adopted, the number of blocks can be greater than the number of code areas. In this case, the block sequence and the code area sequence are circularly pasted back. The decoding process is S4, please refer to Figure 3 The decoding device is used to scan the dynamic two-dimensional code, collect the current static two-dimensional code, and decode the current static two-dimensional code. Specifically, If the decoding is successful, it is judged whether the current static two-dimensional code has been decoded. If yes, the current static two-dimensional code is discarded. Otherwise, it is judged whether the file id of the current static two-dimensional code is the same as that in the list. If yes, the current static two-dimensional code is recorded in the list. Otherwise, the current list is emptied, and then the current static two-dimensional code is recorded in the list. It is further judged whether the preset splicing threshold is reached. If yes, the static two-dimensional codes in the current list are spliced, the list is emptied, and the decoding process is ended. Otherwise, the collection is re-performed. If the decoding fails, the collection is re-performed. The list is a block list, the length of the list is the total number of blocks, the list index is the block index, and the elements in the list are the contents of each block (including the block header and the block data). At the beginning, the list is empty. When a static code is read, the total number of blocks in the block header information of the code is obtained, a list with a length of the total number of blocks is generated, and each element in the list is empty at this time. Then, the data (including the block header and the block data) of the static code just read is placed in the list element corresponding to the index. The file id is used to identify a file. The file ids in the block header information of all blocks of a file are the same. If the file id in the block header information of a certain static code is different from the file id of the block saved in the list, it is indicated that the static code is from another dynamic code generated by another file, and it is indicated that another dynamic code is being read. Therefore, the content of the previous dynamic code in the list needs to be emptied first. It is judged whether the file id of the current static two-dimensional code is the same as that in the list. The same means that the current static two-dimensional code and the block data stored in the list come from the same file (i.e., the same dynamic code), so the current static two-dimensional code can be added to the list for subsequent splicing of the complete file. S5, the decoding device has different processing modes for different block methods. If it is single partition, the decoding device does not need to make any modification for dynamic code; in decoding, any static 2D code can be successfully decoded as long as it is scanned; If it is irregular partition, the decoding device should start the buffer mode to prevent the decoded data from being outputted, and when a 2D code in a picture is successfully decoded, no feedback is given to the user, and the decoding continues until the splicing is completed and the decoding is ended; in decoding, all static 2D codes in the dynamic code need to be scanned to be successfully decoded; however, the scanning order can be arbitrary, thus, the static 2D code missed in the previous loop can be scanned in the next loop; If it is regular partition and the missing scanning is allowed, the decoding device needs to increase the corresponding missing scanning module; in decoding, any 9 static 2D codes (without check) or any 10 static 2D codes (with check) of the 18 static 2D codes in the dynamic 2D code can be successfully decoded without scanning all the static 2D codes; S6, iteratively decoding until the complete data file is spliced, and the decoding is ended; In a specific embodiment, the obtained 15 code regions are as shown in Figure 3 The process of generating the dynamic 2D code by using the single partition method after the data file is partitioned is as follows: The data file is a text file with a size of 1169 bytes, the block header information is total block number = 1, block index = 1, and file id = 1246; The preset code generation program encodes 15 static 2D codes with the same shape as the code region by using the automatic size parameter, and the specific size parameter is: 0.541667, 0.540416, 0.529941, 0.533138, 0.526559, 0.540331, 0.536471, 0.536471, 0.529363, 0.531469, 0.530124, 0.530233, 0.530233, 0.544186, 0.538979; the maximum size parameter 0.544186 is taken as the uniform size parameter; Referring to Figure 4 , the 15 static 2D codes with the same shape as the code region are re-encoded based on the uniform size parameter, and are pasted back to the 15 code regions and played at the preset frame rate to obtain the dynamic 2D code; In decoding, any code can be successfully decoded as long as it is scanned; In another specific embodiment, the obtained 15 code regions are as shown in Figure 3 The process of generating the dynamic 2D code by using the irregular partition method after the data file is partitioned is as follows: The data file is a picture file with a size of 8434 bytes; the size parameter is taken as 0.5 to encode, and the initial number of blocks is 12<15; the size parameter is reduced to re-encode until the number of blocks is exactly 15, at which time the size parameter is taken as 0.46 as the unified size parameter; Please refer to Figure 5 , based on the unified size parameter, 15 static two-dimensional codes with the same shape as the code area are re-encoded, and are pasted back to the 15 code areas and played at a preset frame rate to obtain a dynamic two-dimensional code; In another specific embodiment, the 15 code areas obtained are as shown in Figure 3 The process of generating a dynamic two-dimensional code by using a regular block method to block the data file is as follows: The data file is a picture file with a size of 8434 bytes; the fixed block size is 1000 bytes; The preset code generation program uses an automatic size parameter to encode 15 static two-dimensional codes with the same shape as the code area and a byte size of 1000, and the specific size parameters are: 0.500000, 0.500000, 0.499320, 0.492265, 0.495430, 0.486363, 0.494118, 0.494118, 0.489300, 0.476636, 0.489469, 0.485623, 0.502326, 0.497741, 0.500715; the maximum value 0.500715 is taken as the unified size parameter; When each block is taken as 1000 bytes, the data file is split into 9 data blocks, and the last block is padded to also be 1000 bytes; 9 error correction blocks are added, and the 9 data blocks plus the 9 error correction blocks have a total of 18 blocks; Please refer to Figure 6 , based on the unified size parameter, 18 static two-dimensional codes with the same shape as the code area are re-encoded, and are pasted back to the 15 code areas and played at a preset frame rate; Since the number of blocks is not equal to the number of code areas, the block sequence and the code area sequence are cyclically pasted back, where the block sequence is b1, b2, b3,..., b18, b1, b2, b3,..., b18,..., and the code area sequence is s1, s2, s3,..., s15, s1, s2, s3,..., s15,...; Therefore, the pasting order is b1 pasted on s1, b2 pasted on s2,..., b16 pasted on s1,..., b18 pasted on s3, until a dynamic two-dimensional code is obtained; Among them, for decoding, 18 static codes are needed to be a complete dynamic two-dimensional code; for animation, 15 code area shapes are needed to be a complete animation; If the continuity of the animation loop is not concerned, 18 static codes can be considered to constitute a dynamic two-dimensional code; if the continuity of the animation is concerned, the least common multiple 90 is needed, at this time 90 static codes constitute a dynamic two-dimensional code; if it can be played infinitely, it can be considered that this infinitely long animation video is a dynamic two-dimensional code.

[0025] Embodiment two: The embodiment provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the dynamic two-dimensional code generation and decoding method according to any one of the embodiment one when executing the program.

[0026] Embodiment three: The embodiment provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement the dynamic two-dimensional code generation and decoding method according to any one of the embodiment one.

[0027] In the embodiments of the present application, "at least one" refers to one or more, and "multiple" refers to two or more. The "and / or" describes the association relationship of the associated objects, which means that there can be three kinds of relationships, for example, A and / or B, which can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Wherein A, B can be singular or plural. The character " / " generally represents that the front and rear associated objects are in an "or" relationship. "At least one of the following" and the like means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b and c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, wherein a, b, c can be single or multiple.

[0028] Those of ordinary skill in the art can realize that the units and algorithm steps described in the embodiments disclosed herein can be realized by electronic hardware, computer software and a combination of electronic hardware and computer software. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0029] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working process of the system, device and unit described above can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.

[0030] In several embodiments provided in the present application, any function, if realized in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application or the parts of the technical solutions that essentially contribute to the prior art or the parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0031] The above description is only some embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation, or direct or indirect application in other related technical fields, is also included in the patent protection scope of the present application.

Claims

1. A dynamic two-dimensional code generation and decoding method, characterized in that, The method comprises a code generation process and a decoding process: The code generation process: obtaining a dynamic two-dimensional code video template to be generated, and frame extraction is performed on the dynamic two-dimensional code video template to obtain a plurality of image frames; Binaryzation is performed on each image frame to obtain a plurality of code regions, and the positions and shapes of the code regions are recorded; The data file to be encoded is divided into blocks based on a block division method, and block header information is added in front of each data block; the block header information and the corresponding block data of the current data block are encoded in a corresponding encoding mode of the block division method to generate static two-dimensional codes with the same shape as the code regions; All the static two-dimensional codes are pasted back to the code regions and played at a preset frame rate to obtain a dynamic two-dimensional code; The decoding process: a decoding device is used to scan the dynamic two-dimensional code, and the current static two-dimensional code is collected for decoding; if the decoding is successful, the current decoded static two-dimensional code is saved; Iterative decoding is performed until the complete data file is spliced, and the decoding is ended.

2. The dynamic two-dimensional code generation and decoding method according to claim 1, characterized in that, Binaryzation is performed on each image frame to distinguish the foreground region and the background region in the image frame; The code region is obtained by taking the region with a connected region greater than a preset code range in the foreground region, and the position and shape of the code region are recorded.

3. The dynamic two-dimensional code generation and decoding method according to claim 1, characterized in that, The block header information comprises a block index, a total block number and a file id; The block division method comprises single block division, irregular block division and regular block division.

4. The dynamic two-dimensional code generation and decoding method according to claim 3, characterized in that, The regular block division comprises the following steps: based on the size of the data file in bytes and a preset size of each chunk in bytes , calculate the number of chunks ; If the byte size of the first block is less than the preset byte size, padding is performed thereon; Generating based on error correction algorithm The total block number expansion is performed based on the error correction block, that is, the total block number in the block header information of the current data block is the sum of the data block and the error correction block.

5. The dynamic two-dimensional code generation and decoding method according to claim 3, wherein, The block header information and the corresponding block data of the current data block are encoded in a corresponding encoding mode of the single block division, and the specific steps are as follows: A preset code generation program is used to generate a preliminary two-dimensional code for encoding the current data block for each code region, and the size parameters of the preliminary two-dimensional codes are recorded; The maximum value in the size parameters of all the preliminary two-dimensional codes is selected as a unified size parameter; Based on the unified size parameter, a plurality of static two-dimensional codes are regenerated.

6. The dynamic two-dimensional code generation and decoding method according to claim 3, wherein, The block header information and the corresponding block data of the current data block are encoded in a corresponding encoding mode of the irregular block division, and the specific steps are as follows: A preset code generation program is used to encode the data file based on the initial size parameter to obtain an initial block number; The size of the initial block number and the number of code regions is judged; if the initial block number is less than the number of code regions, the initial size parameter is reduced by a preset step, otherwise, the initial size parameter is increased by a preset step until the block number is equal to the number of code regions, and the current size parameter is taken as a unified size parameter; Based on the unified size parameter, a plurality of static two-dimensional codes are regenerated.

7. The dynamic two-dimensional code generation and decoding method according to claim 4, wherein, The block header information and the corresponding block data of the current data block are encoded in a corresponding encoding mode of the regular block division, and the specific steps are as follows: A preset code generation program is used to generate a plurality of test two-dimensional codes with a fixed size for each code region, and the size parameters of the test two-dimensional codes are recorded; The maximum value in the size parameters of all the test two-dimensional codes is selected as a unified size parameter.

8. The dynamic two-dimensional code generation and decoding method according to claim 3, wherein, The current collected static two-dimensional code is decoded, and the specific steps are as follows: If the decoding is successful, it is judged whether the current static two-dimensional code has been decoded; if yes, the current static two-dimensional code is discarded; Otherwise, it is judged whether the file id of the current static two-dimensional code is the same as that in the list; if yes, the current static two-dimensional code is recorded in the list, otherwise, the current list is emptied, and then the current static two-dimensional code is recorded in the list; Further determine whether the preset splicing threshold is reached, if yes, splice the static two-dimensional code in the current list, empty the list, and end the decoding process; Otherwise, re-acquire; If the decoding fails, re-acquire.

9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the method of any one of claims 1 to 8 when executing the program.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method of any one of claims 1 to 8.