Color two-dimensional code recognition method and device, color two-dimensional code generation method and device, equipment and storage medium
Through the recognition method of color QR code, the color and position of cell color blocks are obtained, and the color blocks of cells are extracted and sorted, which solves the problem of low recognition efficiency due to high complexity of QR codes, and achieves the improvement of recognition efficiency.
Patent Information
- Application Number
- CN202411265387.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2025-01-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The increase in black and white blocks in existing QR codes leads to an increase in complexity, prolonging generation and identification time, and reducing identification efficiency.
By obtaining the color and position of cell color blocks in the color QR code image, extracting color block features, decoding characters and sorting them, the recognition of color QR codes is achieved.
It reduces the complexity of QR codes and improves recognition efficiency. Colored QR codes can carry more types of information, which effectively improves the recognition speed compared to traditional QR codes.
Smart Images

Figure CN119272784A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a color two-dimensional code recognition method, generation method, device, computer equipment and storage medium. Background Art
[0002] With the rapid development of science and technology, QR code technology has been widely used in multiple technical fields, such as AR recognition technology, smart payment technology and so on.
[0003] At present, with the extensive use of QR codes, more and more data needs to be stored in the QR codes, resulting in more and more black and white blocks in the QR codes, which greatly increases the complexity of the QR codes. As a result, longer encoding and decoding time is required when generating or identifying QR codes, reducing the recognition efficiency of QR codes. Summary of the invention
[0004] The embodiments of the present invention provide a color two-dimensional code recognition method, a generation method, an apparatus, a computer device and a storage medium to solve the technical problem of low efficiency in two-dimensional code recognition.
[0005] A color two-dimensional code recognition method, the method comprising: Get the color QR code image; Performing color block feature extraction on the color two-dimensional code image to obtain the color block color and color block position corresponding to each cell color block in the color two-dimensional code image; Based on the color of the color block, obtaining a decoding character corresponding to each of the cell color blocks; Based on the position of the color block, each of the decoded characters is sorted to obtain a recognition result.
[0006] In the above method, optionally, the color block feature extraction of the color two-dimensional code image to obtain the color block color and the color block position corresponding to each cell color block includes: By using an edge detection algorithm, the color two-dimensional code image is divided into color blocks to obtain the cell color blocks and the color block position corresponding to each cell color block; Color features are extracted for each cell color block to obtain the color block color corresponding to each cell color block.
[0007] In the above method, optionally, the color feature extraction of each cell color block is performed to obtain the color block color corresponding to each cell color block, including: Performing color mode conversion on each of the cell color blocks respectively, so as to convert the color mode of each of the cell color blocks from the CMYK mode to the RGB mode; Extracting color features of each cell color block converted by the color mode to obtain RGB color values; Based on the RGB color value, determine the color block color corresponding to each of the cell color blocks.
[0008] Optionally, the method further comprises dividing the color two-dimensional code image into color blocks by an edge detection algorithm to obtain the cell color blocks and the color block positions corresponding to each cell color block, including: Using an edge detection algorithm, identifying edge lines of color blocks in the color two-dimensional code image; Based on the color block edge lines, dividing the color two-dimensional code image into a plurality of initial color blocks; According to the color block shape and the color block side length of each of the initial color blocks, determining whether the initial color block contains a plurality of cell color blocks of the same color; If the initial color block contains a plurality of unit color blocks of the same color, dividing the initial color block into independent unit color blocks according to the side lengths of the color blocks; According to the positional relationship between each of the cell color blocks, the color block position of each of the cell color blocks in the color two-dimensional code image is determined.
[0009] In the above method, optionally, the color block position includes color block coordinates; The step of sorting each of the decoded characters based on the color block position to obtain a recognition result includes: According to the size of the horizontal coordinate value in each of the color block coordinates, the decoded characters corresponding to the color block coordinates are divided into character columns, and each character column is sorted; According to the size of the ordinate value in each color block coordinate, the decoded characters in each character column are sorted in turn to obtain a recognition result.
[0010] A method for generating a color two-dimensional code, the method comprising: Randomly generate string data containing a preset number of encoded characters; Determine the color of the color block corresponding to each of the coded characters; According to the sequence of each coded character in the string data, determine the color block position of each coded character in the color two-dimensional code; A cell color block is generated at the corresponding color block position according to the color of the color block to obtain a color two-dimensional code.
[0011] A color two-dimensional code recognition device, comprising: An image acquisition unit acquires a color QR code image; A feature extraction unit, used to extract color block features from the color two-dimensional code image to obtain the color block color and color block position corresponding to each cell color block in the color two-dimensional code image; A character acquisition unit, used for obtaining a decoding character corresponding to each cell color block based on the color of the color block; The character sorting unit is used to sort each of the decoded characters based on the position of the color block to obtain a recognition result.
[0012] In the above method, optionally, the feature extraction unit is used to: Performing color mode conversion on each of the cell color blocks respectively, so as to convert the color mode of each of the cell color blocks from the CMYK mode to the RGB mode; Extracting the color value of each cell color block converted by the color mode to obtain the RGB color value; Based on the RGB color value, determine the color block color corresponding to each of the cell color blocks.
[0013] 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 color two-dimensional code recognition method as described in any one of the above items when executing the computer program.
[0014] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the color two-dimensional code recognition method as described in any one of the above items is implemented.
[0015] The above-mentioned color two-dimensional code recognition method, generation method, device, computer equipment and storage medium obtain the color block color and color block position of each cell color block in the color two-dimensional code image to obtain the decoding character corresponding to each cell color block according to the color block color, and then sort each decoding character based on the color block position to obtain the recognition result. It can be seen that the cell color blocks in the color two-dimensional code image in the present invention can carry more types of information according to the different colors. Compared with the traditional two-dimensional code containing only black and white cell color blocks, the complexity of the two-dimensional code can be effectively reduced, and then when the color two-dimensional code is recognized, the purpose of improving the recognition efficiency of the two-dimensional code is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] 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.
[0017] Figure 1 This is a flow chart for implementing a color two-dimensional code recognition method disclosed in an embodiment of the present invention; Figure 2 It is a partial implementation flow chart of a color two-dimensional code recognition method disclosed in an embodiment of the present invention; Figure 3 It is a partial implementation flow chart of a color two-dimensional code recognition method disclosed in an embodiment of the present invention; Figure 4 It is a partial implementation flow chart of a color two-dimensional code recognition method disclosed in an embodiment of the present invention; Figure 5 It is a partial implementation flow chart of a color two-dimensional code recognition method disclosed in an embodiment of the present invention; Figure 6 It is a partial implementation flow chart of a method for generating a color two-dimensional code disclosed in an embodiment of the present invention; Figure 7 It is a structural schematic diagram of a color two-dimensional code recognition device disclosed in an embodiment of the present invention; Figure 8 It is a structural schematic diagram of a color two-dimensional code generating device disclosed in an embodiment of the present invention; Fig. 9 It is a structural schematic diagram of a computer device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0018] 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.
[0019] The present invention discloses a color two-dimensional code recognition method, generation method, device, computer equipment and storage medium, by obtaining the color block color and color block position of each cell color block in a color two-dimensional code image, to obtain the decoding character corresponding to each cell color block according to the color block color, and then sort each decoding character based on the color block position to obtain a recognition result. It can be seen that the cell color blocks in the color two-dimensional code image in the present invention can carry more types of information according to the different colors, and compared with the two-dimensional code containing only black and white cell color blocks, the complexity of the two-dimensional code can be effectively reduced, thereby achieving the purpose of improving the recognition efficiency of the two-dimensional code.
[0020] It should be understood that each color block in the color two-dimensional code in this embodiment can carry different types of information according to the different colors assigned. For example, when the cell color block can be assigned any color of red, green, and blue, a cell can carry three different types of information. When the cell color block can be assigned any color of red, green, blue, black, and white, a cell can carry five different types of information. By analogy, the more types of colors that can be assigned to the cell color block, the more types of information that the cell color block can carry. In traditional two-dimensional codes, a cell color block can only carry two types of information. Therefore, using a color two-dimensional code can effectively reduce the complexity of the two-dimensional code.
[0021] like Figure 1 As shown, this embodiment discloses a flowchart of a method for realizing color two-dimensional code recognition, which uses an electronic device with image recognition function, such as a mobile phone, a tablet computer, a laptop computer, an AR device, and a server. The method in this embodiment may specifically include the following steps: S101: Acquire a color two-dimensional code image.
[0022] The color QR code may be a square QR code or a bar QR code composed of a preset number of cell blocks of different colors. The shape of the color QR code is not specifically limited in this embodiment.
[0023] Specifically, in this embodiment, the color two-dimensional code image can be obtained by installing a camera or connecting an electronic device with a camera, such as a mobile phone or a tablet computer. The color two-dimensional code is dynamically scanned by the camera of the electronic device to obtain the color two-dimensional code image.
[0024] For example, take a mobile phone as an example. Open the QR code recognition software that matches the color QR code in the mobile phone, use the scanning function in the recognition software, aim the camera of the mobile phone at the paper color QR code, or the color QR code dynamically updated on other electronic devices for dynamic recognition, and obtain the required color QR code. Based on this, the color QR code image can be obtained.
[0025] S102: Extracting color block features from the color two-dimensional code image to obtain the color block color and color block position corresponding to each cell color block in the color two-dimensional code image.
[0026] The color block edge lines between different cell color blocks in the color two-dimensional code image are identified, and then the color two-dimensional code image is divided into different cell color blocks according to the color block edge lines. The color block position corresponding to each cell color block is determined according to the color block edge lines, and color extraction is performed on each cell color block respectively to obtain the color block color corresponding to each cell color block.
[0027] Furthermore, in this embodiment, the color block color and the color block position corresponding to each cell color block in the color two-dimensional code image can be obtained by the following steps: Figure 2 As shown: S201: Divide the color two-dimensional code image into color blocks by using an edge detection algorithm to obtain cell color blocks and the color block position corresponding to each cell color block.
[0028] Through the edge detection algorithm, the color block edge line of each cell color block in the color two-dimensional code image is determined, and then the color two-dimensional code image is divided according to the color block edge line to obtain the cell color blocks. The positional relationship between different cell color blocks is determined according to the color block edge line to obtain the color block position corresponding to each cell color block.
[0029] Specifically, in this embodiment, the edge detection algorithm can be used to determine whether the pixel value in the color two-dimensional code image has a sudden change, so as to determine the edge line of the color block. For example, when the first-order derivative is calculated at the position of the color block edge line, an extreme value will appear, and when the second-order derivative is calculated at the position of the color block edge line, the second-order derivative is 0, and then the current position can be determined to be the color block edge line. By analogy, all the color block edge lines in the color two-dimensional code image are calculated, and then the color block is divided into color blocks according to the color block edge lines to obtain unit color blocks, and the position of each unit color block in the color two-dimensional code image is determined according to the color block edge lines.
[0030] S202: Extract color features of each cell color block respectively to obtain the color block color corresponding to each cell color block.
[0031] The color features of each cell color block are extracted by a feature extraction algorithm to obtain the color block color corresponding to each cell color block.
[0032] Specifically, in this embodiment, the color feature of each cell color block can be extracted through the following steps: Figure 3 As shown: S301: Performing color mode conversion on each cell color block respectively, so as to convert the color mode of each cell color block from the CMYK mode to the RGB mode.
[0033] It should be understood that CMYK, also known as printing color mode, is a color mode that relies on reflection and can only be seen under external light sources. Therefore, the image seen on the printed matter is expressed in the CMYK mode. For example, the color QR code on paper uses the CMYK mode. Therefore, when the color QR code image obtained comes from the color QR code on paper, the color mode of the cell color block needs to be converted from the CMYK mode to the RGB mode.
[0034] Specifically, in this embodiment, the color mode of each cell color block can be converted by using an existing image processing tool with a color mode conversion function, so as to convert the color mode of each cell color block from the CMYK mode to the RGB mode.
[0035] It should be noted that in this embodiment, not only can the color mode of the cell color blocks be converted after the cell color blocks are divided, but the color of the color QR code image can also be directly converted when the color QR code image is obtained. The technical solutions formed by swapping the color mode conversion steps are within the protection scope of the present invention.
[0036] S302: Extract color features of each cell color block after color mode conversion to obtain RGB color value.
[0037] Specifically, in this embodiment, RGB color values can be extracted from the cell color blocks through a color feature extraction algorithm, such as based on a color histogram, a color moment, etc. The specific method for extracting RGB color values from the cell color blocks is not limited in this embodiment.
[0038] S303: Determine the color block color corresponding to each cell color block based on the RGB color value.
[0039] Based on the RGB color value, query the RGB color value table to determine the color corresponding to the current RGB color value, that is, the color block color corresponding to the cell color block. Similarly, query the color block color corresponding to each cell color block. The RGB color value table includes RGB color values and corresponding colors, such as {255, 0, 0} corresponds to red, {0, 255, 0} corresponds to green, and {0, 0, 255} corresponds to blue, thereby constructing the RGB color value table.
[0040] In summary, in this embodiment, by converting the color mode of the cell color block, the problem of inaccurate extracted RGB values caused by directly extracting color features of the cell color blocks in the acquired color QR code image when the color QR code is a paper QR code is avoided, which is beneficial to improving the accuracy of color QR code recognition.
[0041] S103: Based on the color of the color block, obtain the decoding character corresponding to each cell color block.
[0042] The decoded characters include but are not limited to numbers, letters, and symbols.
[0043] It should be understood that, based on actual needs, each cell color block is assigned a certain number of color block colors. For example, when a cell can be assigned any one of red, green, and blue color blocks, the types of decoded characters include at least three different numbers, letters, or symbols, such as 1, 2, 3, a, b, c, etc., where red corresponds to 1, green corresponds to 2, and blue corresponds to 3, and so on. When the number of color block colors that can be assigned to a cell increases, the number of block characters can be increased accordingly.
[0044] Specifically, in this embodiment, a mapping relationship table between color block colors and decoded characters may be suggested in advance. When the color block color is acquired, the mapping relationship table is queried to obtain the decoded character corresponding to the cell color block.
[0045] S104: Sort each decoded character based on the color block position to obtain a recognition result.
[0046] According to the position of the color block, the front-to-back position relationship and the up-down position relationship of each cell color block are determined, and then the arrangement order of the decoded characters corresponding to each cell color block is determined according to the front-to-back position relationship and the up-down position relationship of each cell color block, and the characters are arranged according to the arrangement order to obtain the recognition result. In other words, the recognition result is the string obtained by sorting each decoded character according to the arrangement order.
[0047] Furthermore, in this embodiment, after obtaining the recognition result, the recognition result can be sent to the background server corresponding to the color QR code, so that the background server matches the corresponding target data according to the recognition result, and returns the target data to the device that recognizes the color QR code. The target data includes but is not limited to text, voice, video, image, three-dimensional graphics, etc., which are not limited in this embodiment.
[0048] For example, taking a mobile phone as an example, the user opens the scanning software corresponding to the color QR code in the mobile phone, grants the scanning software permission to use the mobile phone camera, and then recognizes the color QR code through the mobile phone camera to obtain the recognition result, and then sends the recognition result to the background server through the mobile phone, so that the background server matches the corresponding target data according to the recognition result, and returns the target data to the mobile phone for the user to browse.
[0049] For example, taking AR glasses as an example, when a user wears AR glasses, the AR glasses are used to identify the color QR code to obtain a recognition result, and then the recognition result is sent to the background server through the AR glasses through the Internet, so that the background server matches the corresponding target data according to the recognition result, and returns the target data to the AR glasses, and then displays the target data at the color QR code position in the field of view of the AR glasses, such as a stereoscopic image.
[0050] In summary, the present invention discloses a color two-dimensional code recognition method, which obtains the color block color and color block position of each cell color block in a color two-dimensional code image, obtains the decoding character corresponding to each cell color block according to the color block color, and then sorts each decoding character based on the color block position to obtain a recognition result. It can be seen that the cell color blocks in the color two-dimensional code image in the present invention can carry more types of information according to the different colors, and can effectively reduce the complexity of the two-dimensional code compared to the two-dimensional code containing only black and white cell color blocks, thereby achieving the purpose of improving the efficiency of two-dimensional code recognition.
[0051] based on Figure 2 In the specific implementation, step S201 can be implemented by the following steps: Figure 4 As shown: S401: Using an edge detection algorithm, identifying edge lines of color blocks in a color two-dimensional code image.
[0052] Specifically, in this embodiment, the edge detection algorithm can be used to determine whether the pixel value in the color two-dimensional code image has a sudden change, so as to determine the edge line of the color block. For example, when the first-order derivative is calculated at the position of the color block edge line, an extreme value will appear, and when the second-order derivative is calculated at the position of the color block edge line, the second-order derivative is 0, and then the current position can be determined to be the color block edge line. By analogy, all the color block edge lines in the color two-dimensional code image are calculated, and then the color block is divided into color blocks according to the color block edge lines to obtain unit color blocks, and the position of each unit color block in the color two-dimensional code image is determined according to the color block edge lines.
[0053] S402: Divide the color two-dimensional code image into a plurality of initial color blocks based on the color block edge lines.
[0054] It should be understood that when there are multiple adjacent cell color blocks of the same color in the color two-dimensional code image in this embodiment, it may not be possible to accurately divide each cell color block by only dividing the color two-dimensional code image based on the color block edge line. For example, when two or more adjacent cell color blocks are cell color blocks of the same color, only a color block containing multiple cell color blocks, i.e., an initial color block, can be obtained by dividing the color block edge line. Therefore, each initial color block needs to be recognized again to divide the color block containing multiple cell color blocks into multiple independent cell color blocks.
[0055] Specifically, in this embodiment, the color two-dimensional code image can be divided into a plurality of initial color blocks by using an image division tool, such as Labelme, etc., and the type of the image division tool is not limited in this embodiment.
[0056] S403: judging whether the initial color block contains a plurality of cell color blocks of the same color according to the color block shape and the color block side length of each initial color block.
[0057] When the initial color block contains multiple cell color blocks with the same color, the initial color block is divided into independent cell color blocks according to the shape and side length of the initial color block; when the initial color block does not contain multiple cell color blocks with the same color, the current initial color block is determined to be a cell color block.
[0058] It should be understood that independent cell color blocks are usually square. When the color block shape of the initial color block is a rectangle or an irregular shape, it can be determined that the initial color block contains multiple cell color blocks of the same color. When the color block shape of the initial color block is a square, it is determined whether the color block side length of the initial color block is the preset side length. If the side length of the initial color block is not the preset side length, and the preset side length is greater than the initial side length, it is determined that the initial color block contains multiple cell color blocks of the same color.
[0059] S404: If there are multiple unit cell color blocks with the same color in the initial color block, divide the initial color block into independent unit cell color blocks according to the side lengths of the color blocks.
[0060] According to the ratio between the preset side length of the cell color block and the side length of the color block, a corresponding number of split points are marked on each side of the initial color block, and the initial color block is divided into independent cell color blocks according to the split points. For example, the split points in the horizontal direction are connected with the split points in the vertical direction to obtain a split line, and the original color block is split according to the split line to divide the initial color block into independent cell color blocks.
[0061] S405: Determine the color block position of each cell color block in the color two-dimensional code image according to the positional relationship between each cell color block.
[0062] The positional relationship between each cell color block includes left-right relationship and up-down relationship. According to the left-right relationship and up-down relationship between each cell color block, the unique color block position of each cell color block in the color two-dimensional code image is determined.
[0063] Specifically, the color block position in this embodiment includes but is not limited to being represented by numbers, characters or coordinates. For example, taking numbers as an example, according to the up-and-down relationship of each cell color block, all cell color blocks are divided into color block columns, and according to the left-and-right relationship of each cell color block, the left-and-right relationship of the color block column is determined, and the color block position of the first cell color block at the top in the leftmost color block column is recorded as "1", and the color block position of the second cell color block at the top in the leftmost color block column is recorded as "2", and so on, to obtain the color block position of each cell color block.
[0064] For another example, taking coordinates as an example, a plane rectangular coordinate system is established based on the color two-dimensional code image, and each cell color block is a coordinate point in the color two-dimensional code image. According to the up-down relationship of each cell color block, all cell color blocks are divided into color block columns, and according to the left-right relationship of each cell color block, the left-right relationship of the color block column is determined. The color block position of the first cell color block at the bottom of the leftmost color block column is recorded as "(1,1)", and the color block position of the second cell color block at the bottom of the leftmost color block column is recorded as "(1,2)", and so on, to obtain the color block position of each cell color block.
[0065] To summarize, in this embodiment, the color two-dimensional code image is divided into multiple initial color blocks through an edge detection algorithm, and then whether the initial color block contains multiple cell color blocks is judged according to the color block shape and color block side length of the initial color block, and the initial color block is divided twice, thereby avoiding the problem of insufficient recognition of the cell color blocks in the color two-dimensional code image, which is beneficial to improving the recognition accuracy and recognition efficiency of the color two-dimensional code image.
[0066] based on Figure 1 In the specific implementation, step S104 can be implemented by the following steps: Figure 5 As shown: S501: Divide the decoded characters corresponding to the color block coordinates into character columns according to the size of the horizontal coordinate value in each color block coordinate, and sort each character column.
[0067] The decoded characters with the same horizontal coordinates in the color block coordinates are divided into the same character column, and then each character column is sorted according to the size of the vertical coordinates of the color block coordinates corresponding to the decoded characters in each character column.
[0068] For example, a plane rectangular coordinate system is established based on the color QR code image, and the decoded characters corresponding to all color block coordinates with a horizontal coordinate of 1 are divided into the first character column, and the decoded characters corresponding to all color block coordinates with a horizontal coordinate of 2 are divided into the second character column, and so on. It is possible to divide the decoded characters corresponding to the color block coordinates into character columns and sort each character column.
[0069] S502: Sort the decoded characters in each character column in turn according to the size of the ordinate value in each color block coordinate to obtain a recognition result.
[0070] According to the size of the ordinate in the color block coordinates, the decoded characters in each character column are sorted respectively to obtain the column string corresponding to each character column. Then, according to the size of the ordinate value in each color block coordinate, the order of each character column is determined, and then each column string is spliced to obtain the complete string data, that is, the recognition result.
[0071] For example, the horizontal coordinate of the decoded character in the first character column is smaller than the horizontal coordinate of the decoded character in the second character column, and smaller than the horizontal coordinate of the decoded character in the third character column. The decoded characters in the first character column are sorted as 321 according to the size of the vertical coordinate, the decoded characters in the second character column are sorted as 123 according to the size of the vertical coordinate, and the decoded characters in the third character column are sorted as 231 according to the size of the vertical coordinate. Then, according to the size of the vertical coordinate value in each color block coordinate, the order of each character column is determined, and then each column character string is spliced to obtain the character string data 321123231, that is, the recognition result.
[0072] It should be understood that the above method is only one way to sort the decoded characters in this embodiment. You can also divide the character lines first, and then sort them according to the character lines to obtain the recognition results, etc. The decoding character sorting method is not limited in this embodiment. In addition, if the position of each cell color block in the color two-dimensional code image is represented by a specific independent number in the present invention, then the recognition result can be obtained by directly sorting according to the size of the number.
[0073] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0074] like Figure 6 FIG. 1 is a flowchart of a method for generating a color two-dimensional code disclosed in an embodiment of the present invention. The method is applicable to electronic devices with data processing capabilities, such as mobile phones, tablet computers, notebook computers, and servers. The method in this embodiment may specifically include the following steps: S601: Randomly generate character string data containing a preset number of coded characters.
[0075] The coded characters include but are not limited to any one or more of numbers, letters and symbols. It should be understood that the string data containing the preset number of coded characters is the data that the color QR code needs to carry, and the color QR code is generated according to the string data.
[0076] For example, take the example of a string data containing 16-bit coded characters, where the 16-bit coded characters can all be random combinations of numbers, such as 1231231231231231, or the 16-bit coded characters can all be random combinations of letters, such as abcabcabcabcabca, or the first 8 bits of the 16-bit coded characters are random combinations of numbers, and the last 8 bits are random combinations of letters, such as 12312312abcabcab. The specific encoding form of the string data is not limited in this embodiment.
[0077] It should be noted that the number of random numbers, letters and symbols that can be used for each coded character is fixed. For example, when there are only three colors available in a cell color block, there are only three optional coded characters, such as three numbers 123 or 456.
[0078] S602: Determine the color of the color block corresponding to each coded character.
[0079] Specifically, in this embodiment, a mapping relationship table between color block colors and coded characters may be suggested in advance, and the color mapping relationship table may be queried according to the coded characters to obtain the color block color corresponding to the coded characters.
[0080] For example, taking the coded characters 123 as an example, 1 may correspond to red, 2 may correspond to green, and 3 may correspond to blue, thereby establishing a mapping relationship table between 123 and red, green, and blue.
[0081] S603: Determine the color block position of each coded character in the color two-dimensional code according to the sequence of each coded character in the string data.
[0082] The order of each coded character in the string data corresponds to the color block position in the color QR code. A position mapping relationship table is established between the order of the coded characters in the string data and the color block position in the color QR code. According to the order of each coded character in the string data, the position mapping relationship table is queried to determine the color block position of each coded character in the color QR code.
[0083] For example, taking the string data of 123123123 as an example, the coordinate position is used to represent the color block in the color two-dimensional code, and a mapping relationship between the order of the coded characters and the coordinate position is established. The first coded character 1 corresponds to the coordinate position (1,3), the second coded character 2 corresponds to the coordinate position (2,3), the third coded character 3 corresponds to the coordinate position (3,3), the fourth coded character 1 corresponds to the coordinate position (1,2), the fifth coded character 2 corresponds to the coordinate position (2,2), the sixth coded character 3 corresponds to the coordinate position (3,2), the seventh coded character 1 corresponds to the coordinate position (1,1), the eighth coded character 2 corresponds to the coordinate position (2,1), and the ninth coded character 3 corresponds to the coordinate position (3,1). Based on this, a mapping relationship table between the order of the coded characters in the string data and the color block positions in the color two-dimensional code is established, and the color block position of each coded character in the color two-dimensional code can be determined.
[0084] It should be understood that the above-mentioned mapping relationship between the sequence of coded characters and the coordinate positions is only a form of expression in this embodiment, and does not constitute a specific limitation on the mapping relationship between the sequence of coded characters and the coordinate positions.
[0085] S604: Generate a cell color block at a corresponding color block position according to the color of the color block to obtain a color two-dimensional code.
[0086] The color block color corresponding to each coded character is respectively used to generate a cell color block of the specified color at the corresponding color block position.
[0087] For example, taking the string data of 123123123, the corresponding color block colors are red, green, blue, red, green, blue, and the corresponding color block positions are (1,3), (2,3), (3,3), (1,2), (2,2), (3,2), (1,1), (2,1), (3,1) as an example, a red cell color block is generated at position (1,3), a green cell color block is generated at position (2,3), a blue cell color block is generated at position (3,3), a red cell color block is generated at position (1,2), a green cell color block is generated at position (2,2), a blue cell color block is generated at position (3,2), a red cell color block is generated at position (1,1), a green cell color block is generated at position (2,1), and a blue cell color block is generated at position (3,1), and finally a color QR code is generated.
[0088] It should be noted that if a color QR code is displayed through an electronic device, it can be displayed in RGB mode. If a color QR code needs to be printed, the color QR code needs to be converted to CMYK mode before printing.
[0089] In summary, the present invention discloses a color two-dimensional code generation method, by determining the color block color corresponding to each coded character in the randomly generated string data, and according to the sequence of each coded character in the string data, determining the color block position corresponding to each coded character, and finally generating a color two-dimensional code according to the color block color and the color block position. It can be seen that the cell color blocks in the color two-dimensional code image of the present invention can carry more types of information according to the different colors, and compared with the two-dimensional code containing only black and white cell color blocks, the complexity of the two-dimensional code can be effectively reduced, thereby achieving the purpose of improving the recognition efficiency of the two-dimensional code.
[0090] like Figure 7 As shown, it is a schematic diagram of the structure of a color two-dimensional code recognition device disclosed in an embodiment of the present invention. The device is suitable for electronic devices with data processing capabilities, such as mobile phones, tablet computers, laptops, and servers.
[0091] Specifically, the color two-dimensional code recognition device in this embodiment may include the following units: The image acquisition unit 701 acquires a color two-dimensional code image; The feature extraction unit 702 is used to extract the color block features of the color two-dimensional code image to obtain the color block color and color block position corresponding to each cell color block in the color two-dimensional code image; The character acquisition unit 703 is used to obtain the decoding character corresponding to each cell color block based on the color of the color block; The character sorting unit 704 is used to sort each decoded character based on the color block position to obtain a recognition result.
[0092] In summary, the present invention discloses a color two-dimensional code recognition device, which obtains the color block color and color block position of each cell color block in a color two-dimensional code image, obtains the decoding character corresponding to each cell color block according to the color block color, and then sorts each decoding character based on the color block position to obtain a recognition result. It can be seen that the cell color blocks in the color two-dimensional code image in the present invention can carry more types of information according to the different colors. Compared with the two-dimensional code containing only black and white cell color blocks, the complexity of the two-dimensional code can be effectively reduced, thereby achieving the purpose of improving the recognition efficiency of the two-dimensional code.
[0093] In one implementation, the feature extraction unit 702 is used to: Performing color mode conversion on each cell color block respectively, so as to convert the color mode of each cell color block from CMYK mode to RGB mode; Extract the color value of each cell color block after color mode conversion to obtain the RGB color value; Based on the RGB color value, determine the color block color corresponding to each cell color block.
[0094] In one implementation, the feature extraction unit 702 is used to: Performing color mode conversion on each cell color block respectively, so as to convert the color mode of each cell color block from CMYK mode to RGB mode; The color features of each cell color block after color mode conversion are extracted to obtain the RGB color value; Based on the RGB color value, determine the color block color corresponding to each cell color block.
[0095] In one implementation, the feature extraction unit 702 is used to: By using edge detection algorithm, the edge line of the color block in the color two-dimensional code image is identified; Based on the edge lines of the color blocks, the color two-dimensional code image is divided into a plurality of initial color blocks; According to the shape and side length of each initial color block, determine whether the initial color block contains multiple cell color blocks with the same color; If the initial color block contains multiple cell color blocks with the same color, the initial color block is divided into independent cell color blocks according to the side length of the color block; According to the positional relationship between each cell color block, the color block position of each cell color block in the color two-dimensional code image is determined.
[0096] In one implementation, the color block position includes the color block coordinates; the character sorting unit 704 is used to: According to the size of the horizontal coordinate value in each color block coordinate, the decoded characters corresponding to the color block coordinate are divided into character columns, and each character column is sorted; According to the size of the ordinate value in each color block coordinate, the decoded characters in each character column are sorted in turn to obtain the recognition result.
[0097] For the specific definition of the color two-dimensional code recognition device, please refer to the relevant definition of the color two-dimensional code recognition method in the above text, which will not be repeated here. Each module in the above-mentioned color two-dimensional code recognition device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0098] like Figure 8 As shown, it is a structural schematic diagram of a color two-dimensional code generating device disclosed in an embodiment of the present invention. The device is suitable for electronic devices with data processing capabilities, such as mobile phones, tablet computers, laptop computers, and servers.
[0099] Specifically, the color two-dimensional code recognition device in this embodiment may include the following units: The data generating unit 801 is used to randomly generate a character string data including a preset number of coded characters; A color block color determination unit 802 is used to determine the color block color corresponding to each coded character; The color block position determination unit 803 is used to determine the color block position of each coded character in the color two-dimensional code according to the sequence of each coded character in the string data; The two-dimensional code generating unit 804 is used to generate a cell color block at a corresponding color block position according to the color of the color block to obtain a color two-dimensional code.
[0100] In summary, the present invention discloses a color two-dimensional code generating device, which determines the color of the color block corresponding to each coded character in the randomly generated string data, and determines the color block position corresponding to each coded character according to the sequence of each coded character in the string data, and finally generates a color two-dimensional code according to the color block color and the color block position. It can be seen that the cell color blocks in the color two-dimensional code image in the present invention can carry more types of information according to the different colors. Compared with the two-dimensional code containing only black and white cell color blocks, the complexity of the two-dimensional code can be effectively reduced, thereby achieving the purpose of improving the recognition efficiency of the two-dimensional code.
[0101] In one implementation, the present application embodiment discloses a computer device, which may be a server, and its internal structure diagram may be as shown in FIG. Fig. 9 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a color two-dimensional code recognition method is implemented.
[0102] 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, wherein the processor implements the following steps when executing the computer program: Get the color QR code image; Performing color block feature extraction on the color two-dimensional code image to obtain the color block color and color block position corresponding to each cell color block in the color two-dimensional code image; Based on the color of the color block, get the decoding character corresponding to each cell color block; Based on the color block position, each decoded character is sorted to obtain the recognition result.
[0103] In one implementation, the present application discloses a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor in a computer device, the computer device can perform the steps of any embodiment of a color two-dimensional code recognition method disclosed in the present invention. The computer-readable storage medium can be non-volatile or volatile.
[0104] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: Get the color QR code image; Performing color block feature extraction on the color two-dimensional code image to obtain the color block color and color block position corresponding to each cell color block in the color two-dimensional code image; Based on the color of the color block, get the decoding character corresponding to each cell color block; Based on the color block position, each decoded character is sorted to obtain the recognition result.
[0105] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0106] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0107] 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 color two-dimensional code recognition method, characterized in that: The method comprises: Get the color QR code image; Performing color block feature extraction on the color two-dimensional code image to obtain the color block color and color block position corresponding to each cell color block in the color two-dimensional code image; Based on the color of the color block, obtaining a decoding character corresponding to each of the cell color blocks; Based on the position of the color block, each of the decoded characters is sorted to obtain a recognition result.
2. The color two-dimensional code recognition method according to claim 1, characterized in that: The color block feature extraction of the color two-dimensional code image to obtain the color block color and the color block position corresponding to each cell color block includes: By using an edge detection algorithm, the color two-dimensional code image is divided into color blocks to obtain the cell color blocks and the color block position corresponding to each cell color block; Color features are extracted for each cell color block to obtain the color block color corresponding to each cell color block.
3. The color two-dimensional code recognition method according to claim 2, characterized in that: The color feature extraction is performed on each of the cell color blocks to obtain the color block color corresponding to each of the cell color blocks, including: Performing color mode conversion on each of the cell color blocks respectively, so as to convert the color mode of each of the cell color blocks from the CMYK mode to the RGB mode; Extracting color features of each cell color block converted by the color mode to obtain RGB color values; Based on the RGB color value, determine the color block color corresponding to each of the cell color blocks.
4. The color two-dimensional code recognition method according to claim 2, characterized in that: The color block division of the color two-dimensional code image by an edge detection algorithm to obtain the cell color blocks and the color block position corresponding to each cell color block includes: Using an edge detection algorithm, identifying edge lines of color blocks in the color two-dimensional code image; Based on the color block edge lines, dividing the color two-dimensional code image into a plurality of initial color blocks; According to the color block shape and the color block side length of each of the initial color blocks, determining whether the initial color block contains a plurality of cell color blocks of the same color; If the initial color block contains a plurality of unit color blocks of the same color, dividing the initial color block into independent unit color blocks according to the side lengths of the color blocks; According to the positional relationship between each of the cell color blocks, the color block position of each of the cell color blocks in the color two-dimensional code image is determined.
5. The color two-dimensional code recognition method according to claim 1, characterized in that: The color block position includes color block coordinates; The step of sorting each of the decoded characters based on the color block position to obtain a recognition result includes: According to the size of the horizontal coordinate value in each of the color block coordinates, the decoded characters corresponding to the color block coordinates are divided into character columns, and each character column is sorted; According to the size of the ordinate value in each color block coordinate, the decoded characters in each character column are sorted in turn to obtain a recognition result.
6. A method for generating a color two-dimensional code, characterized in that: The method comprises: Randomly generate string data containing a preset number of encoded characters; Determine the color of the color block corresponding to each of the coded characters; According to the sequence of each coded character in the string data, determine the color block position of each coded character in the color two-dimensional code; A cell color block is generated at the corresponding color block position according to the color of the color block to obtain a color two-dimensional code.
7. A color two-dimensional code recognition device, characterized in that: include: An image acquisition unit acquires a color two-dimensional code image; A feature extraction unit, used to extract color block features from the color two-dimensional code image to obtain the color block color and color block position corresponding to each cell color block in the color two-dimensional code image; A character acquisition unit, used for obtaining a decoding character corresponding to each cell color block based on the color of the color block; The character sorting unit is used to sort each of the decoded characters based on the position of the color block to obtain a recognition result.
8. The color two-dimensional code recognition device according to claim 7, characterized in that: The feature extraction unit is used for: Performing color mode conversion on each of the cell color blocks respectively, so as to convert the color mode of each of the cell color blocks from the CMYK mode to the RGB mode; Extracting the color value of each cell color block converted by the color mode to obtain the RGB color value; Based on the RGB color value, determine the color block color corresponding to each of the cell color blocks.
9. 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 color two-dimensional code recognition method as described in any one of claims 1 to 5 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the color two-dimensional code recognition method as described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method and system for generating color code as well as method and system for analyzing color code
CN102147873A
Encoding method and decoding method for color two-dimensional code
CN104268615A
Color two-dimension code recognition method and recognition device
CN104778440A
Method of encoding / decoding color QR code
CN104899630A
Information transmission system, method and apparatus
CN107169540A