Pattern coding method and device, pattern decoding method and device, medium and equipment
By generating a coding matrix with different colors in the item pattern and adjusting the color increment, the problem of insufficient concealment of item identification information is solved, and anti-trash identification without relying on professional equipment is achieved.
Patent Information
- Application Number
- CN202510535769.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art, the item identification information is insufficiently concealed in the anti-cross-cross-up scenario and relies on professional equipment to identify it, which is prone to tampering or forged, affecting the anti-cross-up effect.
By obtaining the original pattern and identification information of the target item, a first encoding matrix with different binary logical states is generated, and the target area is determined in the original pattern for color increment adjustment to form the target pattern, so that the sub-regions corresponding to the encoding elements are different in colors, achieving concealment and does not rely on professional equipment recognition.
It provides untampered identification information, ensures the concealment and accurate extraction of identification information, supports the anti-cross-off verification process, and reduces the identification needs of relying on professional equipment.
Smart Images

Figure CN120449914A_ABST
Abstract
Description
Technical Field
[0001] The present specification relates to the field of computer technology, and more specifically, to a pattern encoding method, pattern decoding method, apparatus, medium, and device in the field of computer technology. Background Art
[0002] Channelling refers to the unauthorized transfer of goods from designated sales areas to other areas for sale. This behavior not only disrupts market order but also harms the interests of brands. In the context of channelling, item identification information is particularly important. Its main role is to track the distribution path of items through identification information, thereby effectively identifying and curbing channelling. However, item identification information is usually recorded on the packaging pattern. Relevant personnel may make the identification information invalid or difficult to identify by means of smearing, covering, or replacing the packaging. Therefore, there is an urgent need to improve the concealment of item identification information. Summary of the Invention
[0003] This specification provides a pattern encoding method, a pattern decoding method, an apparatus, a medium, and a device, which can improve the concealment of identification information and does not rely on professional equipment for identification.
[0004] In a first aspect, a pattern coding method is provided, comprising:
[0005] Obtain the original pattern and identification information corresponding to the target object;
[0006] Encrypting and generating a first coding matrix according to the identification information, the first coding matrix including first coding elements and second coding elements with different binary logic states;
[0007] Determining a first target area corresponding to a first coding matrix in the original pattern;
[0008] The target pattern is obtained by performing color incremental adjustment on the first target area. The target pattern includes a second target area corresponding to the first target area. The sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the second target area have different colors.
[0009] In a second aspect, a pattern decoding method is provided, comprising:
[0010] Acquire a captured image of the target object, the captured image including a target pattern, the target pattern including a second target area corresponding to a first coding matrix, the first coding matrix including first coding elements and second coding elements having different binary logic states, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area having different colors;
[0011] performing binarization processing on the captured image to obtain a binarized image, determining a third target area corresponding to the second target area from the binarized image, wherein the grayscale values of the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the third target area are different;
[0012] Acquire a first coding matrix according to the third target area;
[0013] The first coding matrix is decrypted to obtain identification information corresponding to the target object.
[0014] In a third aspect, a pattern coding device is provided, comprising:
[0015] An acquisition unit, configured to acquire the original pattern and identification information corresponding to the target object;
[0016] A generating unit, configured to generate a first coding matrix based on the encrypted identification information, wherein the first coding matrix includes a first coding element and a second coding element having different binary logic states;
[0017] a determining unit, configured to determine a first target area corresponding to a first coding matrix in the original pattern;
[0018] The adjustment unit is used to perform color incremental adjustment on the first target area to obtain a target pattern, where the target pattern includes a second target area corresponding to the first target area, and the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the second target area have different colors.
[0019] In a fourth aspect, a pattern decoding device is provided, comprising:
[0020] a first acquisition unit, configured to acquire a captured image of a target object, the captured image including a target pattern, the target pattern including a second target area corresponding to a first coding matrix, the first coding matrix including first coding elements and second coding elements having different binary logic states, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area having different colors;
[0021] a processing unit, configured to perform binarization processing on the captured image to obtain a binarized image, and determine, from the binarized image, a third target area corresponding to the second target area, wherein a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the third target area have different grayscale values;
[0022] A second acquiring unit, configured to acquire a first coding matrix according to a third target area;
[0023] The decryption unit is used to decrypt the first coding matrix to obtain identification information corresponding to the target object.
[0024] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code is executed, the above method is implemented.
[0025] In a sixth aspect, an electronic device is provided, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the above method.
[0026] In a seventh aspect, a computer program product is provided, which stores at least one instruction, and when the at least one instruction is executed by a processor, the steps of the above method are implemented.
[0027] In the embodiments of this specification, firstly, the original pattern and identification information corresponding to the target object are obtained; secondly, a first coding matrix is generated by encrypting the identification information; thirdly, a first target area corresponding to the first coding matrix is determined within the original pattern, and the color of the first target area is incrementally adjusted to obtain the target pattern, so that the subareas corresponding to the first coding element and the subareas corresponding to the second coding element in the second target area have different colors. The encryption process renders the first coding matrix tamper-proof and difficult to crack. The difference between the second target area and the surrounding area after the color incremental adjustment is minimal, providing sufficient concealment and eliminating the need for specialized equipment for identification. This effectively addresses the problem of insufficient concealment of identification information or reliance on specialized equipment in related technologies.
[0028] On the one hand, by obtaining a captured image of the target item, a reliable input is provided for subsequent processing. Secondly, the target pattern in the captured image includes a second target area corresponding to the first coding matrix, and the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the second target area have different colors. This color difference provides a basic feature for decoding. Thirdly, the captured image is binarized to obtain a binary image, and a third target area corresponding to the second target area is determined from the binary image. The grayscale values of the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the third target area are different. Finally, the first coding matrix is obtained based on the third target area, and the first coding matrix is decrypted to obtain the identification information corresponding to the target item, thereby restoring the identification information. In this way, the accurate extraction of the first coding matrix is ensured, and the identification information is restored through the decryption process, providing reliable data for the subsequent anti-channeling verification process. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 This is a schematic diagram of a scenario for preventing counterfeiting provided by an embodiment of this specification;
[0030] Figure 2This is a flow chart of a pattern coding method provided in an embodiment of this specification;
[0031] Figure 3 This is an example schematic diagram of a first coding matrix provided in an embodiment of this specification;
[0032] Figure 4 This is an example schematic diagram of converting an original pattern into a target pattern provided in an embodiment of this specification;
[0033] Figure 5 This is an example schematic diagram of a sub-region corresponding to a coding element provided in an embodiment of this specification;
[0034] Figure 6 This is an example schematic diagram of a tracing pattern provided in an embodiment of this specification;
[0035] Figure 7 This is a flowchart of a color increment adjustment provided by an embodiment of this specification;
[0036] Figure 8 This is a flowchart of a color increment adjustment provided by an embodiment of this specification;
[0037] Figure 9 This is a schematic diagram of a process for encrypting and generating a first coding matrix provided by an embodiment of this specification;
[0038] Figure 10 This is a flowchart of a redundant coding process provided by an embodiment of this specification;
[0039] Figure 11 This is an example schematic diagram of a positioning coding matrix provided in an embodiment of this specification;
[0040] Figure 12 This is a flow chart of a pattern decoding method provided in an embodiment of this specification;
[0041] Figure 13 This is a schematic diagram of a binary processing flow provided by an embodiment of this specification;
[0042] Figure 14 This is a schematic diagram of a process for determining a third target area provided in an embodiment of this specification;
[0043] Figure 15 This is a schematic diagram of a process for decrypting and obtaining identification information provided by an embodiment of this specification;
[0044] Figure 16 is a structural diagram of a pattern coding device provided in an embodiment of this specification;
[0045] Figure 17is a structural diagram of a pattern decoding device provided in an embodiment of this specification;
[0046] Figure 18 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0047] The following will clearly and thoroughly describe the technical solutions in this specification with reference to the accompanying drawings. In the description of the embodiments of this specification, unless otherwise specified, " / " means or. For example, A / B can mean A or B. "And / or" in the text is only a description of the association relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of this specification, "multiple" means two or more than two.
[0048] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.
[0049] Channelling refers to the unauthorized transfer of goods from designated sales areas to other areas for sale. This behavior not only disrupts market order but also harms the interests of brands. In the context of channelling, item identification information is particularly important. Its main role is to track the distribution path of items through identification information, thereby effectively identifying and curbing channelling. However, item identification information is usually recorded on the packaging pattern. Relevant personnel may make the identification information invalid or difficult to identify by means of smearing, covering, or replacing the packaging. Therefore, there is an urgent need to improve the concealment of item identification information.
[0050] Item identification information refers to information uniquely associated with an item, used to identify and track the item's identity and distribution path. This identification information can be unique, meaning each item corresponds to a specific piece of identification information, such as a unique serial number for each product. Alternatively, it can be shared across a category or batch of items, such as the batch number of a single batch of products. For example, identification information can include the item's unique ID, production date, production batch, and sales region, allowing for tracking its entire distribution process from production to sales.
[0051] See Figure 1 , Figure 1This is a schematic diagram of a scenario for preventing counterfeiting provided by an embodiment of this specification. In which, the user end and the server end acquire and analyze identification information through a communication connection. The user end can be a smart phone, tablet computer or other portable device, and the server end can be a server of the brand / related service platform, or a cloud platform. There is an area containing identification information in the packaging pattern of the target item, and this identification information may be encrypted or unencrypted. The user end takes a picture of the target item and obtains a corresponding captured image, which contains identification information. The user end uploads the captured image to the server end, which receives and analyzes the captured image to extract the identification information of the target item. The server end can use the identification information to perform various operations, such as verifying the authenticity of the item, tracking the circulation path of the item, identifying counterfeiting, etc.
[0052] One related technology uses explicit QR codes to record item identification information. While QR codes offer advantages in terms of large information capacity and ease of generation and scanning, they also have disadvantages in that they are highly visible and easily detectable and tampered with. For example, individuals can smudge or cover the QR code, rendering it ineffective or illegible, thereby evading brand tracking. Furthermore, the conspicuousness of QR codes makes them susceptible to counterfeiting, further reducing their effectiveness in preventing counterfeiting.
[0053] Another related technology uses digital watermarks to record item identification information. Digital watermarking embeds information into images. Its advantage lies in its concealment, making it difficult to detect with the naked eye. However, its disadvantage lies in its direct display, making it susceptible to extraction and manipulation by professionals. For example, individuals can use image processing techniques to extract the identifying information from a digital watermark and then tamper with or forge it, thereby evading the brand's tracking.
[0054] Another related technology uses micron-scale code dots to record item identification information. Micron-scale code dots are extremely small carriers of identification information. Their advantage is that they are invisible to the human eye, making them somewhat concealed. However, their disadvantage is that they require specialized equipment to read, increasing complexity and cost. Furthermore, the reading accuracy of micron-scale code dots is affected by environmental factors such as lighting and packaging materials, further reducing their reliability in practical applications.
[0055] In summary, the above-mentioned related technologies all have certain problems in the anti-channelling scenario, such as the QR code is too conspicuous, the digital watermark has limited concealment, and the micron-level code points require professional equipment. To address the above problems, this application proposes a pattern encoding method and a pattern decoding method based on color invisibility.
[0056] The pattern encoding method first obtains the original pattern and identification information corresponding to the target object; secondly, encrypts the identification information to generate a first encoding matrix; thirdly, determines the first target area corresponding to the first encoding matrix in the original pattern, and performs color increment adjustment on the first target area to obtain the target pattern, so that the sub-area corresponding to the first encoding element and the sub-area corresponding to the second encoding element in the second target area have different colors. The encryption process makes the first encoding matrix tamper-proof and difficult to crack. The difference between the second target area and the surrounding area after the color increment adjustment is small, providing sufficient concealment and not relying on professional equipment for identification. Thus, through the combination of the above steps, a pattern encoding method is provided that is both concealed and independent of professional equipment for identification, effectively solving the problem of insufficient concealment of identification information or dependence on professional equipment for identification in related technologies.
[0057] Among them, the pattern decoding method first obtains a captured image of the target item, providing a reliable input for subsequent processing; secondly, the target pattern in the captured image includes a second target area corresponding to the first coding matrix, and the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the second target area are different in color. This color difference provides a basic feature for decoding; thirdly, the captured image is binarized to obtain a binary image, and a third target area corresponding to the second target area is determined from the binary image. The grayscale values of the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the third target area are different; finally, the first coding matrix is obtained based on the third target area, and the first coding matrix is decrypted to obtain the identification information corresponding to the target item, thereby realizing the restoration of the identification information. In this way, through the combination of the above steps, the accurate extraction of the first coding matrix is ensured, and the identification information is restored through the decryption process, providing reliable data for the subsequent anti-channeling verification process.
[0058] based on Figure 1 The following scenario will be combined with Figure 2 - Figure 15 , the pattern encoding method and pattern decoding method provided in the embodiments of this specification are introduced in detail.
[0059] See Figure 2 , is a flow chart of a pattern coding method provided in the embodiment of this specification. Figure 2 As shown, the method of the embodiment of this specification may include the following steps S102 to S108.
[0060] S102: Obtain the original pattern and identification information corresponding to the target object.
[0061] Specifically, the target item involved in this embodiment can be any item, such as food, medicine, or electronic products. The original pattern corresponding to the target item refers to the pattern that has not been encoded, and the identification information corresponding to the target item refers to information uniquely associated with the target item and is primarily used to uniquely identify the product. For example, the identification information corresponding to the target item may include the target product's unique ID, or additional information such as the target product's production date, production batch, and sales region.
[0062] Regarding the process of obtaining the original pattern and identification information corresponding to the target item, in some possible implementations, the original pattern and identification information corresponding to the target item are pre-stored. In this case, the original pattern and identification information corresponding to the target item can be directly obtained by querying a pre-stored database or file. In some possible implementations, the original pattern can be obtained by scanning the packaging of the target item, and the identification information can be obtained by reading a database or label of the target item. In some possible implementations, the original pattern and identification information corresponding to the target item can be received as input by a user.
[0063] S104: Generate a first coding matrix based on the encrypted identification information. The first coding matrix includes first coding elements and second coding elements with different binary logic states.
[0064] Specifically, the first encoding matrix involved in this embodiment refers to a matrix structure formed by arranging multiple encoding elements according to a specific rule, and is used to carry encrypted identification information. The first encoding matrix includes first encoding elements and second encoding elements with different binary logical states. The different binary logical states mean that the first encoding element and the second encoding element represent different binary logical states, for example, the first encoding element represents a binary logical state of "0" and the second encoding element represents a binary logical state of "1", or the first encoding element represents a binary logical state of "1" and the second encoding element represents a binary logical state of "0".
[0065] To facilitate understanding of the first encoding matrix involved in this embodiment, please refer to Figure 3 , is a schematic diagram of an example of a first encoding matrix provided in an embodiment of this specification. The first encoding matrix is a matrix composed of binary codes "0" and "1", and each element in the matrix represents a coding element. The arrangement order and position of the coding elements are determined according to the encryption rules. The first coding element represents the binary logic state "1", and the second coding element represents the binary logic state "0". It should be noted that the size of the first encoding matrix can be adjusted according to actual needs, for example, it can be a matrix of 13×13, 8×8, 16×16, or other sizes.
[0066] Regarding the process of generating the first encoding matrix based on encrypted identification information, in some possible implementations, the identification information may be encrypted using a preset key to generate encrypted data, and the first encoding matrix may be generated based on the encrypted data. In some possible implementations, the identification information may be encrypted without a key to generate encrypted data, and the first encoding matrix may be generated based on the encrypted data. In some possible implementations, other encryption methods, such as a hash algorithm, a symmetric encryption algorithm, or an asymmetric encryption algorithm, may be used to encrypt the identification information to generate encrypted data, and the first encoding matrix may be generated based on the encrypted data.
[0067] S106: Determine a first target area corresponding to the first coding matrix in the original pattern.
[0068] Specifically, the first target area involved in this embodiment refers to the area in the original pattern used to carry the first coding matrix. The size and shape of this area match the first coding matrix to ensure that the first coding matrix can be completely embedded therein. The relationship between the first coding matrix and the first target area is that the size of the first coding matrix determines the division method of the first target area. For example, if the first coding matrix is a 13×13 matrix, the first target area needs to be able to be equally divided into 13×13 grids, each grid corresponding to a coding element in the first coding matrix, ensuring that each coding element in the first coding matrix can be accurately mapped to the corresponding sub-area in the first target area.
[0069] Regarding the process of determining the first target area corresponding to the first coding matrix in the original pattern, in some possible implementations, a rectangular area can be selected in the original pattern as the first target area according to preset rules, and the size of the rectangular area is proportional to the size of the first coding matrix. For example, if the first coding matrix is a 13×13 matrix, the first target area can be a 13×13 mm rectangular area, and the specific size can be adjusted according to actual needs. In some possible implementations, an image processing algorithm can be used to automatically identify a suitable area in the original pattern as the first target area. The characteristics of the area include uniform color, simple texture, etc., to ensure that subsequent color increment adjustments can proceed smoothly. In some possible implementations, a user can manually select an area in the original pattern as the first target area. The user can use the interactive interface to select an area in the original pattern. The size and shape of the area are set by the user according to the size and shape of the first coding matrix.
[0070] S108 , incrementally adjust the color of the first target area to obtain a target pattern, where the target pattern includes a second target area corresponding to the first target area, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area have different colors.
[0071] Specifically, the color increment referred to in this embodiment refers to the numerical value used to adjust the color values of each sub-region within the first target region. This numerical value can be positive, negative, or zero, and is used to change the color attributes of the sub-region, such as brightness, hue, or saturation. It should be noted that the adjustment range of the color increment is generally small to ensure that the visual difference between the second target region and the original pattern is not obvious, thereby enhancing concealment.
[0072] The target pattern refers to a pattern that has been adjusted by color increments, which retains the overall visual effect of the original pattern while embedding the information of the first coding matrix in the second target area. The target pattern includes a second target area corresponding to the first target area, which refers to the area in the target pattern formed after the first target area has been adjusted by color increments. The size and shape of the second target area are consistent with the first target area, but the color attributes have changed. The relationship between the first target area and the second target area is: the first target area is the area before the color increment adjustment, and the second target area is the area after the color increment adjustment. The two correspond in spatial position but have different color attributes. The sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the second target area have different colors, which means that in the second target area, the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element have different color attributes, such as different brightness, hue or saturation. This difference provides basic features for the subsequent decoding process.
[0073] Regarding the process of incrementally adjusting the color of the first target area to obtain the target pattern, in some possible implementations, a first color increment corresponding to the first coding element and a second color increment corresponding to the second coding element may be obtained, where the first color increment and the second color increment are different; a color incremental adjustment is performed on the sub-area corresponding to the first coding element in the first target area based on the first color increment, and a color incremental adjustment is performed on the sub-area corresponding to the second coding element in the first target area based on the second color increment, to obtain the target pattern. In some possible implementations, a third color increment corresponding to the target coding element may be obtained, where the target coding element is one of the first coding element and the second coding element; and a color incremental adjustment is performed on the sub-area corresponding to the target coding element in the first target area based on the third color increment, to obtain the target pattern.
[0074] It should be noted that the aforementioned color increment adjustment can be performed in the RGB color space, the YUV color space, or other color spaces, without limitation. The target pattern involved in this embodiment can be applied to the packaging of the target item through various methods such as spraying, pasting, and printing, and can be expressed in the form of text, graphics, symbols, or a combination thereof, without limitation.
[0075] To understand this embodiment, please refer to Figure 4 - Figure 5 .
[0076] like Figure 4 The figure below is an example schematic diagram of converting an original pattern into a target pattern according to an embodiment of this specification. The first target region in the original pattern is a rectangular area. After processing through the relevant steps, a target pattern is obtained. The target pattern includes a second target region of the same size as the first target region. Each subregion in the second target region exhibits color differences after color increment adjustment.
[0077] like Figure 5 The figure below is a schematic diagram of an example of sub-regions corresponding to coding elements provided in an embodiment of this specification. The sub-region corresponding to the first coding element is a darker region, while the sub-region corresponding to the second coding element is a lighter region, thereby reflecting the difference in color between the sub-region corresponding to the first coding element and the sub-region corresponding to the second coding element in the second target area.
[0078] In this embodiment, the original pattern and identification information corresponding to the target object are first obtained. Secondly, a first coding matrix is generated by encrypting the identification information. Thirdly, a first target area corresponding to the first coding matrix is determined within the original pattern. The target pattern is then obtained by incrementally adjusting the color of the first target area, so that the subareas corresponding to the first coding element and the subareas corresponding to the second coding element in the second target area have different colors. The encryption process renders the first coding matrix tamper-proof and difficult to crack. The difference between the second target area and the surrounding area after the incremental color adjustment is minimal, providing sufficient concealment and eliminating the need for specialized equipment for identification. Thus, through the combination of the above steps, a pattern encoding method is provided that is both concealed and independent of specialized equipment for identification, effectively resolving the issues of insufficient concealment of identification information or reliance on specialized equipment in related technologies.
[0079] In one embodiment, the target pattern includes a two-dimensional code area, and the two-dimensional code area and the second target area do not overlap with each other.
[0080] Specifically, the QR code area may carry an explicit QR code, which is used to guide the user to take a photo.
[0081] For example, see Figure 6, which is an example schematic diagram of a traceability pattern provided in an embodiment of this specification. The QR code area can carry a traceability QR code. The traceability QR code refers to a QR code that is uniquely associated with the target item and contains traceability information of the target item, such as production information, circulation information, sales information, etc. The user terminal can be a smart phone, tablet computer or other portable device. The user can operate the user terminal to take a picture of the target item to obtain a captured image, and the captured image contains the target pattern. The user terminal uploads the captured image to the server terminal, so that the server terminal uses the traceability QR code to parse the traceability information of the target item, and feeds back the traceability information to the user terminal for the user to view the traceability details of the target item.
[0082] At the same time, the captured image also contains a second target area of the target pattern. The server can use the content in the second target area to restore the identification information corresponding to the target product and use this identification information to implement anti-channelling verification. It should be noted that the above-mentioned traceability QR code can also be replaced with an anti-counterfeiting verification QR code or other QR code used to guide users to take pictures, without limitation.
[0083] It's understandable that ordinary users generally don't care about counterfeiting, but they do care about item traceability. This embodiment, by providing a QR code area within the target pattern and including a traceability QR code within the QR code area, allows ordinary users to proactively provide information for counterfeiting verification. Specifically, out of concern for item traceability, ordinary users will proactively operate the user terminal to photograph the target item and upload the captured image to the server. While parsing the traceability QR code, the server can also obtain the second target area within the captured image, thereby restoring the identification information corresponding to the target item and implementing counterfeiting verification. Thus, by combining the traceability QR code with the second target area, this embodiment not only meets the ordinary user's need for item traceability, but also provides the necessary information source for counterfeiting verification, achieving proactive and covert counterfeiting verification. Furthermore, since the QR code area and the second target area do not overlap, interference from the QR code area on the second target area is avoided, ensuring the integrity and recognizability of the first encoding matrix in the second target area, further improving the accuracy and reliability of counterfeiting verification. At the same time, the introduction of traceability QR codes has also enhanced the practicality of target patterns, enabling them to not only carry identification information but also provide traceability functions, further enhancing the application value of target patterns.
[0084] See Figure 7 , provides a flow chart of color increment adjustment for the embodiment of this specification. Figure 7 As shown, the method of the embodiment of this specification may include the following steps S202 to S204, and steps S202 to S204 may be used as Figure 2 The detailed steps of step S108 in the embodiment shown are as follows.
[0085] S202, obtaining a first color increment corresponding to a first coding element and a second color increment corresponding to a second coding element, wherein the first color increment and the second color increment are different;
[0086] S204 , performing color increment adjustment on the subregion corresponding to the first coding element in the first target region according to the first color increment, and performing color increment adjustment on the subregion corresponding to the second coding element in the first target region according to the second color increment, to obtain a target pattern.
[0087] Specifically, the first color increment and the second color increment in this embodiment are values for adjusting the color of the subregions corresponding to the first and second coding elements, respectively. The first color increment and the second color increment are distinct, meaning that there is a difference in their values to ensure that the subregions corresponding to the first and second coding elements can be distinguished in terms of color attributes.
[0088] Regarding the process of obtaining the first color increment corresponding to the first coding element and the second color increment corresponding to the second coding element, in some possible implementations, the first color increment and the second color increment can be directly specified according to preset rules. For example, the preset rules may stipulate that each color component of the sub-region corresponding to the first coding element in the RGB color space is increased by 5 units, and each color component of the sub-region corresponding to the second coding element in the RGB color space is decreased by 5 units. In some possible implementations, the first color increment and the second color increment can be generated based on the identification information of the target object. In some possible implementations, the first color increment and the second color increment can be obtained through user input, for example, the user can enter specific values of the first color increment and the second color increment through an interactive interface.
[0089] It should be noted that the color increment adjustment of the subregion corresponding to the first coding element in the first target region according to the first color increment is performed by adding the first color increment to the original color value of the subregion corresponding to the first coding element, wherein the original color value of the subregion corresponding to the first coding element may be the original color value of each pixel in the subregion, taken as the average, mode, or other method to select a representative color, or the original color value of each pixel in the first target region is taken as the average, mode, or other method to select a representative color. Similarly, the color increment adjustment of the subregion corresponding to the second coding element in the first target region according to the second color increment is performed by adding the second color increment to the original color value of the subregion corresponding to the second coding element, wherein the original color value of the subregion corresponding to the second coding element may be the original color value of each pixel in the subregion, taken as the average, mode, or other method to select a representative color, or the original color value of each pixel in the first target region is taken as the average, mode, or other method to select a representative color.
[0090] Regarding the process of performing color incremental adjustment on the sub-region corresponding to the first coding element in the first target area according to the first color increment, and performing color incremental adjustment on the sub-region corresponding to the second coding element in the first target area according to the second color increment, in some possible implementations, the color of the sub-region in the first target area can be adjusted by an image processing algorithm. For example, the color incremental adjustment can be achieved by adjusting the RGB value, YUV value or other color space value of the sub-region. In some possible implementations, the color of the sub-region in the first target area can be adjusted by calling an image processing library or software. For example, the color adjustment function in the OpenCV library can be called to perform color incremental adjustment on the sub-region.
[0091] For example, for the RGB color space, the color increment adjustment can be achieved by the following formula:
[0092] For the sub-region corresponding to the first coding element, its RGB value is adjusted to:
[0093] R'=R+ΔR1
[0094] G'=G+ΔG1
[0095] B'=B+ΔB1
[0096] Wherein, R, G, B are the original RGB values of the sub-region corresponding to the first coding element, ΔR1, ΔG1, ΔB1 are the first color increments, and |ΔR1|, |ΔG1|, |ΔB1|≤10.
[0097] For the sub-region corresponding to the second coding element, its RGB value is adjusted to:
[0098] R'=R+ΔR2
[0099] G'=G+ΔG2
[0100] B'=B+ΔB2
[0101] Wherein, ΔR2, ΔG2, and ΔB2 are second color increments, and |ΔR2|, |ΔG2|, and |ΔB2| are ≤10.
[0102] Through the above adjustment, it is ensured that the sub-regions corresponding to the first coding element and the second coding element have obvious color differences in the RGB color space, and the adjustment amplitude is controlled within 10 units to avoid excessive visual impact on the original pattern.
[0103] For example, for the YUV color space, the color increment adjustment can be achieved by the following formula:
[0104] For the sub-region corresponding to the first coding element, its YUV value is adjusted to:
[0105] Y'=Y+ΔY1
[0106] U'=U+ΔU1
[0107] V'=V+ΔV1
[0108] Wherein, Y, U, V are the original YUV values of the sub-region, ΔY1, ΔU1, ΔV1 are the first color increments, and |ΔY1|, |ΔU1|, |ΔV1|≤10.
[0109] For the sub-region corresponding to the second coding element, its YUV value is adjusted to:
[0110] Y'=Y+ΔY2
[0111] U'=U+ΔU2
[0112] V'=V+ΔV2
[0113] Wherein, ΔY2, ΔU2, and ΔV2 are second color increments, and |ΔY2|, |ΔU2|, and |ΔV2|≤10.
[0114] Through the above adjustment, it is ensured that the sub-regions corresponding to the first coding element and the second coding element have obvious color differences in the YUV color space, and the adjustment amplitude is controlled within 10 units to avoid excessive visual impact on the original pattern.
[0115] In this embodiment, a first color increment corresponding to the first coding element and a second color increment corresponding to the second coding element are firstly obtained to ensure that there is a difference in the values of the two. Then, the color increment of the sub-region corresponding to the first coding element in the first target area is adjusted according to the first color increment, and the color increment of the sub-region corresponding to the second coding element in the first target area is adjusted according to the second color increment, so that the sub-region corresponding to the first coding element and the sub-region corresponding to the second coding element in the second target area have different colors. The amplitude of the color increment adjustment is generally small to ensure that the visual difference between the second target area and the original pattern is not obvious, thereby enhancing the concealment.
[0116] See Figure 8 , provides a flow chart of color increment adjustment for the embodiment of this specification. Figure 8 As shown, the method of the embodiment of this specification may include the following steps S302 to S304, and steps S302 to S304 may be used as Figure 2 The detailed steps of step S108 in the embodiment shown are as follows.
[0117] S302, obtaining a third color increment corresponding to a target coding element, where the target coding element is one of the first coding element and the second coding element;
[0118] S304 , performing color increment adjustment on the sub-region corresponding to the target coding element in the first target region according to the third color increment to obtain a target pattern.
[0119] Specifically, the target coding element in this embodiment is one of the first coding element and the second coding element, and the third color increment is a value for adjusting the color of the subregion corresponding to the target coding element. The value of the third color increment can be a positive number, a negative number, or zero, and is used to change the color attributes of the subregion, such as brightness, hue, or saturation.
[0120] Regarding the process of obtaining the third color increment corresponding to the target code element, in some possible implementations, the third color increment can be directly specified according to preset rules. For example, the preset rules may specify that each color component of the subregion corresponding to the target code element in the RGB color space is increased or decreased by 5 units. In some possible implementations, the third color increment can be generated based on the identification information of the target object. In some possible implementations, the third color increment can be obtained through user input, for example, the user can enter a specific value for the third color increment through an interactive interface.
[0121] It should be noted that the color increment adjustment of the sub-area corresponding to the target coding element in the first target area according to the third color increment is to add the third color increment on the basis of the original color value of the sub-area corresponding to the target coding element, wherein the original color value of the sub-area corresponding to the target coding element can be the original color value of each pixel in the sub-area, adding and averaging, taking the mode or other methods to select a representative color value, or the original color value of each pixel in the first target area, adding and averaging, taking the mode or other methods to select a representative color.
[0122] Regarding the process of performing color incremental adjustment on the sub-region corresponding to the target coding element in the first target region according to the third color increment, in some possible implementations, the color of the sub-region in the first target region can be adjusted by an image processing algorithm. For example, the color incremental adjustment can be achieved by adjusting the RGB value, YUV value, or other color space value of the sub-region. In some possible implementations, the color of the sub-region in the first target region can be adjusted by calling an image processing library or software. For example, the color adjustment function in the OpenCV library can be called to perform color incremental adjustment on the sub-region.
[0123] For example, for the RGB color space, the color increment adjustment can be achieved by the following formula:
[0124] For the sub-region corresponding to the target coding element, its RGB value is adjusted to:
[0125] R'=R+ΔR3
[0126] G'=G+ΔG3
[0127] B'=B+ΔB3
[0128] Wherein, R, G, B are the original RGB values of the sub-region corresponding to the target coding element, ΔR3, ΔG3, ΔB3 are the third color increments, and |ΔR3|, |ΔG3|, ΔB3|≤10.
[0129] For example, for the YUV color space, the color increment adjustment can be achieved by the following formula:
[0130] For the sub-region corresponding to the target coding element, its YUV value is adjusted to:
[0131] Y'=Y+ΔY3
[0132] U'=U+ΔU3
[0133] V'=V+ΔV3
[0134] Wherein, Y, U, V are the original YUV values of the sub-region, ΔY3, ΔU3, ΔV3 are the third color increments, and |ΔY3|, |ΔU3|, |ΔV3|≤10.
[0135] Through the above adjustment, it is ensured that the sub-region corresponding to the target coding element has obvious color changes in the RGB or YUV color space, and the adjustment amplitude is controlled within 10 units to avoid excessive visual impact on the original pattern.
[0136] In this embodiment, the third color increment corresponding to the target coding element is first obtained to ensure that the color attributes of the sub-region are adjusted. Secondly, the color increment of the sub-region corresponding to the target coding element in the first target region is adjusted based on the third color increment, so that the sub-region corresponding to the target coding element in the second target region has a different color from the unadjusted sub-region. By adjusting the color increment only for the sub-region corresponding to the target coding element, rather than adjusting the sub-regions corresponding to the first and second coding elements simultaneously, the visual impact on the original pattern can be further reduced, thereby improving concealment.
[0137] See Figure 9 , provides a schematic diagram of a process for encrypting and generating a first coding matrix in the embodiment of this specification. Figure 9 As shown, the method of the embodiment of this specification may include the following steps S402 to S406, and steps S402 to S406 may be used as Figure 2 The detailed steps of step S104 in the embodiment are shown.
[0138] S402, generating initial data according to the identification information;
[0139] S404, encrypting the initial data according to a preset key to obtain encrypted data;
[0140] S406: Generate a first encoding matrix according to the encrypted data.
[0141] Specifically, the initial data referred to in this embodiment refers to raw data generated based on identification information and used for subsequent encryption processing. The generation of the initial data may include formatting, encoding, or other preprocessing of the identification information to ensure its suitability for encryption. Encrypted data refers to data processed by an encryption algorithm, ensuring immutability and confidentiality.
[0142] Regarding the process of generating initial data based on identification information, in some possible implementations, the initial data can be generated by formatting the identification information. For example, the identification information can be converted into a string or binary data in a specific format. In some possible implementations, the initial data can be generated by encoding the identification information. For example, the identification information can be converted into the initial data using Base64 encoding, ASCII encoding, or other encoding methods. In some possible implementations, the initial data can be generated by hashing the identification information. For example, the identification information can be hashed using MD5, SHA-1, or other hash algorithms to generate the initial data.
[0143] Regarding the process of encrypting the initial data according to a preset key to obtain encrypted data, in some possible implementations, the initial data may be encrypted using a symmetric encryption algorithm. For example, AES, DES, or another symmetric encryption algorithm may be used in combination with a preset key to encrypt the initial data to generate encrypted data. In some possible implementations, the initial data may be encrypted using an asymmetric encryption algorithm. For example, RSA, ECC, or another asymmetric encryption algorithm may be used in combination with a preset key to encrypt the initial data to generate encrypted data. In some possible implementations, the initial data may be encrypted using a hybrid encryption method. For example, a symmetric encryption algorithm and an asymmetric encryption algorithm may be combined to encrypt the initial data to generate encrypted data.
[0144] Regarding the process of generating the first encoding matrix based on the encrypted data, in some possible implementations, the first encoding matrix can be generated by converting the encrypted data into binary data. For example, each byte of the encrypted data can be converted into 8-bit binary data and arranged according to specific rules to generate the first encoding matrix. In some possible implementations, the first encoding matrix can be generated by performing redundant encoding on the encrypted data. For example, the encrypted data can be encoded using a Hamming code, a Reed-Solomon (RS) code, or other redundant encoding method to generate the first encoding matrix. In some possible implementations, the first encoding matrix can be generated by performing a matrix transformation on the encrypted data. For example, the encrypted data can be processed using matrix multiplication, matrix transposition, or other matrix transformation methods to generate the first encoding matrix.
[0145] Exemplarily, the encryption process can be expressed as the following relationship:
[0146] Cencoded=AES(Iinput,Kkey)
[0147] Where, Cencoded refers to the encrypted data, Iinput refers to the initial data, Kkey refers to the preset key, and AES() refers to the AES encryption algorithm function.
[0148] In this embodiment, initial data is first generated based on the identification information, providing a foundation for subsequent encryption processing. Second, the initial data is encrypted using a preset key to generate encrypted data, ensuring data immutability and confidentiality. Finally, a first encoding matrix is generated based on the encrypted data, providing a carrier for embedding the identification information. The encryption process renders the first encoding matrix immutable and difficult to crack, providing a reliable data foundation for subsequent anti-channelling verification.
[0149] In one embodiment, Figure 9 Step S402 of the embodiment shown is further refined and may include the following steps:
[0150] Obtain random identification information corresponding to the target item;
[0151] Generate initial data based on the identification information, random identification information and a preset key.
[0152] Specifically, the random identification information referred to in this embodiment refers to randomly generated data associated with the target object, used to enhance the complexity and security of the initial data. The random identification information can be a random number, random string, or other randomly generated data, and can be generated based on a timestamp, hardware information, or other random source. The initial data refers to the raw data generated from the identification information, random identification information, and a preset key, and is used for subsequent encryption processing.
[0153] Regarding the process of obtaining random identification information corresponding to the target item, in some possible implementations, the random identification information can be generated using a random number generator. For example, a pseudo-random number generator or a true random number generator can be used to generate the random identification information. In some possible implementations, the random identification information can be generated using hardware information. For example, the random identification information can be generated based on the hardware serial number, MAC address, or other hardware information of the target item. In some possible implementations, the random identification information can be generated using a timestamp. For example, the random identification information can be generated based on the current timestamp to ensure its uniqueness and randomness.
[0154] Regarding the process of generating initial data based on the identification information, random identification information, and preset key, in some possible implementations, the initial data can be generated by concatenating the identification information, random identification information, and preset key. For example, the identification information, random identification information, and preset key can be concatenated in a specific order into a string or binary data to generate the initial data. In some possible implementations, the initial data can be generated by hashing the identification information, random identification information, and preset key. For example, the identification information, random identification information, and preset key can be hashed using MD5, SHA-1, or other hash algorithms to generate the initial data. In some possible implementations, the initial data can be generated by encrypting the identification information, random identification information, and preset key. For example, the identification information, random identification information, and preset key can be encrypted using AES, DES, or other encryption algorithms to generate the initial data. In some possible implementations, the initial data can be generated by taking a weighted sum of the identification information, random identification information, and preset key. For example, weights can be assigned to the identification information, random identification information, and preset key, and a weighted sum of the three can be performed based on the weights to generate the initial data. The weight value can be a fixed value or a dynamic value. The fixed value can be determined based on a preset rule, and the dynamic value can be determined based on the attributes, timestamp or other dynamic factors of the target item.
[0155] For example, the process of generating initial data can be expressed as the following relationship:
[0156] Iinput=f(Iproduct,Kkey,Irandom)
[0157] Where Iinput refers to the initial data, f() refers to the function that generates the initial data, Iproduct refers to the identification information of the target product, Kkey refers to the preset key, and Irandom refers to the random identification information.
[0158] In this embodiment, the random identification information corresponding to the target object is first obtained to provide additional randomness and complexity for the generation of the initial data. Secondly, the initial data is generated based on the identification information, the random identification information, and a preset key, ensuring the uniqueness and security of the initial data. The introduction of the random identification information enhances the initial data's resistance to cracking, while the use of the preset key further enhances data security, providing a reliable foundation for subsequent encryption processing.
[0159] See Figure 10 , provides a flowchart of redundant coding processing for the embodiment of this specification. Figure 10As shown, the method of the embodiment of this specification may include the following steps S502 to S506, and steps S502 to S506 may be used as Figure 9 The detailed steps of step S406 in the embodiment are shown.
[0160] S502, generating a second encoding matrix according to the encrypted data;
[0161] S504, performing redundant coding processing on the second coding matrix to obtain a third coding matrix;
[0162] S506: Extract the third coding matrix based on the preset first size to obtain the first coding matrix.
[0163] Specifically, the second coding matrix involved in this embodiment refers to a coding matrix generated based on encrypted data and used for subsequent redundant coding processing. The third coding matrix refers to a coding matrix obtained by performing redundant coding processing on the second coding matrix, and has error correction and interference resistance. The first coding matrix refers to the final coding matrix obtained by extracting the third coding matrix based on a preset first size, and is used to embed into the target pattern.
[0164] Regarding the process of generating the second encoding matrix based on the encrypted data, in some possible implementations, the second encoding matrix can be generated by converting the encrypted data into binary data. For example, each byte of the encrypted data can be converted into 8-bit binary data and arranged according to a specific rule to generate the second encoding matrix. In some possible implementations, the second encoding matrix can be generated by performing a matrix transformation on the encrypted data. For example, the encrypted data can be processed using matrix multiplication, matrix transposition, or other matrix transformation methods to generate the second encoding matrix. In some possible implementations, the second encoding matrix can be generated by performing block processing on the encrypted data. For example, the encrypted data can be divided into multiple data blocks, and each data block can be converted into a matrix form to generate the second encoding matrix.
[0165] Regarding the process of redundantly encoding the second coding matrix to obtain the third coding matrix, in some possible implementations, the second coding matrix can be redundantly encoded using a Hamming code. For example, a third coding matrix with error correction capabilities can be generated by adding check bits to the second coding matrix. In some possible implementations, the second coding matrix can be redundantly encoded using an RS code. For example, redundant data can be added to the second coding matrix to generate a third coding matrix with interference resistance. In some possible implementations, the second coding matrix can be redundantly encoded using a convolutional code. For example, a third coding matrix with error correction capabilities can be generated by performing a convolution operation on the second coding matrix.
[0166] Regarding the process of extracting the third coding matrix based on a preset first size to obtain the first coding matrix, in some possible implementations, the first coding matrix can be generated by cropping the third coding matrix. For example, a sub-matrix that meets the size requirements can be cropped from the third coding matrix according to the preset first size to serve as the first coding matrix. In some possible implementations, the first coding matrix can be generated by compressing the third coding matrix. For example, the third coding matrix can be compressed according to the preset first size to generate the first coding matrix that meets the size requirements. Exemplarily, the above-mentioned preset first size can be 13×13, and the size of the third coding matrix may vary depending on the specific application scenario and coding requirements, for example, it can be 16×8, 15×15, 20×20, or 25×25, etc., and this is not limited.
[0167] For example, generating the second encoding matrix according to the encrypted data can be expressed as the following relationship:
[0168] Mencode=reshape(Cencoded, 16, 8)
[0169] In the formula, Mencode refers to the second encoding matrix, Cencoded refers to the encrypted data, 16 and 8 are the specified sizes, and reshape() is the generating function. As you can see, the size of the second encoding matrix is 16×8.
[0170] The second coding matrix is subjected to redundant coding, and the third coding matrix obtained can be expressed as the following relationship:
[0171] Mrs=rs(Mencode,k,n)
[0172] Where Mrs refers to the third coding matrix, Mencode refers to the second coding matrix, k is the data dimension before redundant coding processing, n is the data dimension after redundant coding processing, and rs() is the redundant coding processing function.
[0173] The third encoding matrix is extracted based on the preset first size, and the first encoding matrix obtained can be expressed as the following relationship:
[0174] Munit=extract(Mrs, 13, 13)
[0175] In the formula, Mrs refers to the third encoding matrix, 13 and 13 are the preset first sizes, Munit refers to the first encoding matrix, and extract() refers to the extraction function. It can be seen that the size of the first encoding matrix is 13×13.
[0176] In this embodiment, a second coding matrix is first generated based on the encrypted data, providing a foundation for redundant coding. Secondly, redundant coding is performed on the second coding matrix to generate a third coding matrix, enhancing the coding matrix's error correction and anti-interference capabilities. Finally, the third coding matrix is extracted based on a preset first size to obtain the first coding matrix, ensuring that the coding matrix size meets the requirements. The redundant coding process gives the first coding matrix stronger anti-interference and error correction capabilities, providing a reliable data foundation for subsequent anti-channelling verification.
[0177] In one embodiment, Figure 10 Step S506 of the embodiment shown is further refined and may include the following steps:
[0178] Extracting the third encoding matrix based on the preset first size to obtain a fourth encoding matrix;
[0179] Obtaining a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size, where the preset second size and the preset third size are different from each other and are both smaller than the preset first size;
[0180] The first positioning coding matrix and the second positioning coding matrix are embedded in the fourth coding matrix to obtain a first coding matrix. The first positioning coding matrix and the second positioning coding matrix are diagonally distributed in the first coding matrix.
[0181] Specifically, the fourth coding matrix involved in this embodiment refers to the coding matrix obtained by extracting the third coding matrix based on the preset first size, and its size is consistent with the preset first size. The first positioning coding matrix and the second positioning coding matrix refer to coding matrices with a preset second size and a preset third size, respectively, and are used to provide positioning information in the fourth coding matrix to facilitate the subsequent decoding process. The preset second size and the preset third size are different from each other and are both smaller than the preset first size to ensure that the first positioning coding matrix and the second positioning coding matrix can be embedded in the fourth coding matrix without affecting the main information of the fourth coding matrix. Exemplarily, the above-mentioned preset first size can be 13×13, the preset second size can be 5×5, and the preset third size can be 3×3.
[0182] The first coding matrix refers to the final coding matrix obtained after embedding the first positioning coding matrix and the second positioning coding matrix in the fourth coding matrix. Its size is consistent with the preset first size, and the first positioning coding matrix and the second positioning coding matrix are diagonally distributed in the first coding matrix to facilitate rapid positioning in the subsequent decoding process.
[0183] Regarding the process of extracting the third coding matrix based on a preset first size to obtain the fourth coding matrix, in some possible implementations, the fourth coding matrix can be generated by cropping the third coding matrix. For example, a sub-matrix meeting the size requirement can be cropped from the third coding matrix based on the preset first size to serve as the fourth coding matrix. In some possible implementations, the fourth coding matrix can be generated by compressing the third coding matrix. For example, the third coding matrix can be compressed based on the preset first size to generate the fourth coding matrix meeting the size requirement.
[0184] Regarding the process of obtaining a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size, in some possible implementations, the first positioning coding matrix and the second positioning coding matrix can be generated according to a preset rule. For example, the preset rule can specify that the first positioning coding matrix and the second positioning coding matrix are each composed of a specific binary code to ensure their uniqueness and identifiability.
[0185] Regarding the process of embedding the first positioning coding matrix and the second positioning coding matrix into the fourth coding matrix to obtain the first coding matrix, in some possible implementations, the first positioning coding matrix and the second positioning coding matrix can be embedded into the fourth coding matrix through matrix replacement. For example, elements at specific positions in the fourth coding matrix can be replaced with elements of the first positioning coding matrix and the second positioning coding matrix to generate the first coding matrix.
[0186] In this embodiment, the fourth coding matrix is first extracted from the third coding matrix based on a preset first size, ensuring that the coding matrix size meets the requirements. Secondly, a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size are obtained, providing positioning information for the fourth coding matrix. Finally, the first positioning coding matrix and the second positioning coding matrix are embedded in the fourth coding matrix to obtain the first coding matrix, ensuring that the first coding matrix contains clear positioning information. The first and second positioning coding matrices are diagonally distributed within the first coding matrix, facilitating rapid positioning during the subsequent decoding process, thereby improving decoding efficiency and accuracy.
[0187] In one embodiment, the step of "obtaining a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size" in the above embodiment is further refined to include the following steps:
[0188] Obtaining a third positioning coding matrix of a preset second size and a fourth positioning coding matrix of a preset third size;
[0189] Obtain first description information and second description information of the target item;
[0190] Adding the preset first positioning information to the fixed coding area of the third positioning coding matrix, and adding the first description information to the non-fixed coding area of the third positioning coding matrix, to obtain a first positioning coding matrix of a preset second size;
[0191] The preset second positioning information is added to the fixed coding area of the fourth positioning coding matrix, and the second description information is added to the non-fixed coding area of the fourth positioning coding matrix to obtain a second positioning coding matrix of a preset third size.
[0192] Specifically, the third and fourth positioning coding matrices involved in this embodiment refer to initial coding matrices having a preset second size and a preset third size, respectively, and are used for the subsequent addition of positioning information. The first and second description information of the target item refer to descriptive information associated with the target item. The preset first positioning information and the preset second positioning information respectively refer to fixed information used to identify the positioning coding matrix, such as a specific binary code or symbol, to ensure its uniqueness and identifiability. The fixed coding area refers to the area in the positioning coding matrix used to carry the preset positioning information, and the non-fixed coding area refers to the area in the positioning coding matrix used to carry the descriptive information.
[0193] Regarding the process of obtaining a third positioning coding matrix of a preset second size and a fourth positioning coding matrix of a preset third size, in some possible implementations, the third positioning coding matrix and the fourth positioning coding matrix can be generated according to preset rules. For example, the preset rules may specify that the third positioning coding matrix and the fourth positioning coding matrix are each composed of a specific binary code. In some possible implementations, the third positioning coding matrix and the fourth positioning coding matrix can be generated randomly. For example, a random number generator can be used to generate the third positioning coding matrix and the fourth positioning coding matrix.
[0194] Regarding the process of obtaining the first and second description information of the target item, in some possible implementations, the first and second description information can be obtained by querying a database of the target item. For example, the first description information can be the production date of the target item, and the second description information can be the production batch of the target item. In some possible implementations, the first and second description information can be obtained through user input. For example, the user can enter the specific content of the first and second description information through an interactive interface.
[0195] Regarding the process of adding the preset first positioning information to the fixed coding region of the third positioning coding matrix and adding the first description information to the non-fixed coding region of the third positioning coding matrix to obtain the first positioning coding matrix of the preset second size, in some possible implementations, the preset first positioning information can be added to the fixed coding region of the third positioning coding matrix through matrix replacement. For example, elements of the fixed coding region of the third positioning coding matrix can be replaced with elements of the preset first positioning information.
[0196] Regarding the process of adding the preset second positioning information to the fixed coding region of the fourth positioning coding matrix and adding the second description information to the non-fixed coding region of the fourth positioning coding matrix to obtain the second positioning coding matrix of the preset third size, in some possible implementations, the preset second positioning information can be added to the fixed coding region of the fourth positioning coding matrix through matrix replacement. For example, elements of the fixed coding region of the fourth positioning coding matrix can be replaced with elements of the preset second positioning information.
[0197] To understand this embodiment, please refer to Figure 11 , which is an example schematic diagram of a positioning coding matrix provided in an embodiment of this specification. The preset second size is 5×5, and the area corresponding to the first positioning coding matrix is distributed in the upper left corner of the second target area. It is divided diagonally into a fixed coding area and a non-fixed coding area. The fixed coding area is used to carry the preset first positioning information, and the non-fixed coding area is used to carry the first description information. The preset third size is 3×3, and the area corresponding to the second positioning coding matrix is distributed in the lower right corner of the second target area. It is divided diagonally into a fixed coding area and a non-fixed coding area. The fixed coding area is used to carry the preset second positioning information, and the non-fixed coding area is used to carry the second description information.
[0198] In this embodiment, a third positioning coding matrix of a preset second size and a fourth positioning coding matrix of a preset third size are first obtained to provide a basis for adding positioning information. Secondly, first and second description information of the target object are obtained to provide additional descriptive information for the positioning coding matrix. Finally, the preset first positioning information is added to the fixed coding region of the third positioning coding matrix, and the first description information is added to the non-fixed coding region of the third positioning coding matrix to obtain the first positioning coding matrix of the preset second size. The preset second positioning information is added to the fixed coding region of the fourth positioning coding matrix, and the second description information is added to the non-fixed coding region of the fourth positioning coding matrix to obtain the second positioning coding matrix of the preset third size. The preset positioning information in the fixed coding region ensures the uniqueness and identifiability of the positioning coding matrix, while the description information in the non-fixed coding region enhances the complexity and security of the positioning coding matrix, providing a reliable foundation for the subsequent decoding process.
[0199] See Figure 12 , is a flow chart of a pattern decoding method provided in the embodiment of this specification. Figure 12 As shown, the method of the embodiment of this specification may include the following steps S602 to S608.
[0200] S602, obtaining a captured image of the target object, where the captured image includes a target pattern, the target pattern includes a second target area corresponding to a first coding matrix, the first coding matrix includes first coding elements and second coding elements with different binary logic states, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area have different colors.
[0201] Specifically, the captured image of the target object referred to in this embodiment refers to an image obtained by photographing the target object via a user terminal, which may be a smartphone, tablet computer, or other portable device. Definitions of related terms such as target pattern, first coding matrix, second target area, binary logic state, first coding element, and second coding element are provided in the embodiment of the pattern coding method described above and are not further described here.
[0202] Regarding the process of obtaining a photographic image of a target object, in some possible implementations, the photographic image of the target object can be obtained by receiving a photographic image uploaded by a user. For example, a user can upload the photographic image to a server through an interactive interface, and the server receives and stores the photographic image. In some possible implementations, the photographic image of the target object can be obtained by querying a pre-stored database or file. For example, a pre-stored database or file can be queried to obtain the photographic image of the target object.
[0203] S604: Binarize the captured image to obtain a binarized image, and determine a third target area corresponding to the second target area from the binarized image, wherein the grayscale values of the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the third target area are different.
[0204] Specifically, the binarization processing involved in this embodiment refers to converting the captured image into an image containing only two grayscale values. The binarized image refers to the image after binarization processing, such as black (grayscale value is 0) and white (grayscale value is 255), so as to facilitate subsequent image processing and analysis. The third target area refers to the area corresponding to the second target area in the binary image. The size and shape of the third target area are consistent with the second target area, but the grayscale value attribute has changed. The grayscale values of the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the third target area are different from each other, which means that in the third target area, the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element have differences in grayscale value attributes, such as black and white. This difference provides basic features for the subsequent decoding process.
[0205] Regarding the process of binarizing the captured image to obtain a binary image, in some possible implementations, a pre-trained semantic segmentation model can be called to binarize the pre-processed image to obtain a binary image. In some possible implementations, the captured image can be binarized using an image processing algorithm. For example, a threshold segmentation algorithm can be used to binarize the captured image to generate a binary image. In some possible implementations, the captured image can be binarized by calling an image processing library or software. For example, a binarization processing function in the OpenCV library can be called to binarize the captured image to generate a binary image.
[0206] Regarding the process of determining the third target area corresponding to the second target area from the binary image, in some possible implementations, the third target area corresponding to the second target area can be determined from the binary image using a positioning coding matrix. In some possible implementations, the third target area corresponding to the second target area can be automatically identified in the binary image by an image processing algorithm. For example, an edge detection algorithm or a region growing algorithm can be used to identify the third target area in the binary image. In some possible implementations, a user can manually select an area in the binary image as the third target area. For example, a user can use an interactive interface to select an area in the binary image, and the size and shape of the area are set by the user according to the size and shape of the second target area.
[0207] S606: Acquire a first coding matrix according to the third target area.
[0208] Specifically, regarding the process of obtaining the first coding matrix based on the third target area, in some possible implementations, multiple coding elements can be determined based on pixel grayscale value statistics, and the first coding matrix can be determined based on the multiple coding elements. In some possible implementations, the first coding matrix can be extracted from the third target area using an image processing algorithm. For example, a matrix extraction algorithm can be used to extract the first coding matrix from the third target area. In some possible implementations, the first coding matrix can be extracted from the third target area by calling an image processing library or software. For example, a matrix extraction function in the OpenCV library can be called to extract the first coding matrix from the third target area.
[0209] S608: Decrypt the first coding matrix to obtain identification information corresponding to the target object.
[0210] Specifically, regarding the process of decrypting the first coding matrix to obtain identification information corresponding to the target item, in some possible implementations, the first coding matrix can be decrypted using a symmetric decryption algorithm. For example, AES, DES, or other symmetric decryption algorithms can be used in conjunction with a preset key to decrypt the first coding matrix to obtain identification information corresponding to the target item. In some possible implementations, the first coding matrix can be decrypted using an asymmetric decryption algorithm. For example, RSA, ECC, or other asymmetric decryption algorithms can be used in conjunction with a preset key to decrypt the first coding matrix to obtain identification information corresponding to the target item. In some possible implementations, the first coding matrix can be decrypted using a hybrid decryption method. For example, a symmetric decryption algorithm and an asymmetric decryption algorithm can be combined to decrypt the first coding matrix to obtain identification information corresponding to the target item.
[0211] In this embodiment, a captured image of the target item is obtained and binarized, a third target area corresponding to the second target area is determined from the binarized image, a first coding matrix is obtained based on the third target area, and finally the first coding matrix is decrypted to obtain the identification information corresponding to the target item. It can be understood that the target pattern is adjusted by color increments and encrypted, so that the identification information has a high degree of concealment in the target pattern and is not easily detected or tampered with by the naked eye. At the same time, the accuracy and efficiency of the decoding process are ensured by binarization and matrix extraction. In addition, this embodiment does not rely on professional equipment. It only requires an ordinary shooting device as the user end to complete the shooting, and the server end completes the decoding, which reduces the cost and complexity of use. Through the combination of the above steps, the problem of insufficient concealment of identification information or dependence on professional equipment in the related art is effectively solved, providing reliable data support for anti-channeling verification.
[0212] See Figure 13, provides a schematic diagram of the binary processing process for the embodiment of this specification. Figure 13 As shown, the method of the embodiment of this specification may include the following steps S702 to S704, and steps S702 to S704 may be used as Figure 12 This is a refinement of the step S604 of “binarizing the captured image to obtain a binarized image”.
[0213] S702, preprocessing the captured image to obtain a preprocessed image;
[0214] S704: Call a pre-trained semantic segmentation model to perform binarization on the pre-processed image to obtain a binarized image.
[0215] Specifically, the preprocessing involved in this embodiment refers to a series of processing operations on the captured image to improve the image quality and facilitate subsequent binarization processing. The preprocessed image refers to an image that has been preprocessed, and its quality is better than the original captured image, such as denoising, grayscale, size adjustment, etc. The semantic segmentation model refers to a model obtained through machine learning training, which is used to classify the image at the pixel level to achieve binarization processing. The binary image refers to an image obtained after processing by the semantic segmentation model, and its pixel values only contain two grayscale values, such as black (grayscale value is 0) and white (grayscale value is 255), so as to facilitate subsequent image processing and analysis. It can be understood that since the sub-region corresponding to the first coding element and the sub-region corresponding to the second coding element in the target pattern are different in color, this color difference provides a clear classification basis for the semantic segmentation model, so that the semantic segmentation model can accurately identify and distinguish different coding elements in the target pattern, thereby generating a high-quality binary image.
[0216] Regarding the process of preprocessing the captured image to obtain a preprocessed image, in some possible implementations, the captured image can be denoised using an image processing algorithm. For example, Gaussian filtering, median filtering, or other denoising algorithms can be used to denoise the captured image to remove noise interference in the image. In some possible implementations, the captured image can be converted into a grayscale image using an image processing algorithm. For example, a weighted average method or other grayscale algorithm can be used to convert the captured image into a grayscale image to simplify the image processing process. In some possible implementations, the captured image can be resized using an image processing algorithm. For example, bilinear interpolation, bicubic interpolation, or other interpolation algorithms can be used to resize the captured image to ensure that its size meets the requirements of subsequent processing.
[0217] Regarding the process of binarizing a pre-processed image using a pre-trained semantic segmentation model to generate a binary image, some possible implementations can process the pre-processed image by loading a pre-trained semantic segmentation model. For example, a deep learning-based semantic segmentation model, such as U-Net, DeepLab, or other semantic segmentation models, can be loaded to perform pixel-level classification on the pre-processed image to generate a binary image.
[0218] Regarding the training process of the semantic segmentation model, in some possible implementations, it can be achieved through the following steps: first, collect a large amount of image data containing target patterns and annotate each image, and the annotation content includes the location and category information of the target pattern; second, divide the annotated image data into training set, validation set and test set for model training, validation and testing; third, select a suitable semantic segmentation model architecture, such as U-Net, DeepLab or other model architectures, and initialize the model parameters; then, use the training set to train the model, and optimize the model parameters through the backpropagation algorithm to minimize the loss function; finally, use the validation set and test set to verify and test the trained model, evaluate the performance of the model, and optimize the model based on the evaluation results.
[0219] For example, the binarization process can be expressed as the following relationship:
[0220] Ibinary=binarize(Iresized)
[0221] Where Ibinary refers to the binary image, Iresized refers to the preprocessed image, and binarize() refers to the binarization processing function of the semantic segmentation model.
[0222] In this embodiment, the captured image is first preprocessed to improve image quality and facilitate subsequent binarization. Secondly, a pre-trained semantic segmentation model is used to binarize the preprocessed image, generating a binary image that provides a reliable foundation for the subsequent decoding process. The semantic segmentation model ensures the accuracy and efficiency of the binarization process through pixel-level classification. Furthermore, deep learning enhances the model's generalization and robustness, providing reliable data support for the subsequent anti-counterfeiting verification process.
[0223] In one embodiment, Figure 13 Step S702 of the embodiment shown is further refined and may include the following steps:
[0224] Performing denoising on the captured image to obtain a denoised image;
[0225] Convert the denoised image to a grayscale image;
[0226] The grayscale image is resized according to a preset fourth size to obtain a preprocessed image.
[0227] Specifically, the denoising process involved in this embodiment refers to the removal of noise interference in the captured image through an image processing algorithm to improve the image quality. A denoised image refers to an image that has undergone denoising processing, in which the noise interference is significantly reduced and the image details are clearer. A grayscale image refers to an image that is converted into an image containing only grayscale information, in which the grayscale value of each pixel represents the brightness information of the pixel. The preset fourth size refers to a pre-set image size, which is used to ensure that the image size meets the requirements of subsequent processing. A preprocessed image refers to an image that has undergone denoising processing, grayscale processing, and size adjustment, and its quality is better than the original captured image, which is convenient for subsequent binarization processing.
[0228] Regarding the process of denoising the captured image to obtain a denoised image, in some possible implementations, the captured image can be denoised using an image processing algorithm. For example, a Gaussian filter algorithm can be used to denoise the captured image, and a weighted average of each pixel in the image is performed through a convolution operation to remove noise interference in the image. In some possible implementations, a median filter algorithm can be used to denoise the captured image, and the salt and pepper noise in the image is removed by replacing the current pixel value with the median of the pixel neighborhood. In some possible implementations, other denoising algorithms, such as bilateral filtering, non-local mean filtering, etc., can be used to denoise the captured image to improve image quality.
[0229] Regarding the process of converting the denoised image into a grayscale image, in some possible implementations, the denoised image can be converted into a grayscale image using an image processing algorithm. For example, a weighted average method can be used to convert the denoised image into a grayscale image, multiplying the red, green, and blue channels of a color image by different weight coefficients and then summing the values to obtain a grayscale value. In some possible implementations, other grayscale conversion algorithms, such as a maximum method or an average method, can be used to convert the denoised image into a grayscale image. It is understood that converting the image into a grayscale image can reduce the complexity of subsequent image processing.
[0230] Regarding the process of resizing the grayscale image according to the preset fourth size to obtain the preprocessed image, in some possible implementations, the grayscale image can be resized using an image processing algorithm. For example, a bilinear interpolation algorithm can be used to resize the grayscale image, and the grayscale value of the target pixel is obtained by calculating the position of the target pixel in the original image and taking a weighted average of the grayscale values of the four pixels around it. In some possible implementations, a bicubic interpolation algorithm can be used to resize the grayscale image, and the grayscale value of the target pixel is obtained by calculating the position of the target pixel in the original image and taking a weighted average of the grayscale values of the sixteen pixels around it. In some possible implementations, other interpolation algorithms, such as nearest neighbor interpolation, Lanczos interpolation, etc., can be used to resize the grayscale image to ensure that its size meets the requirements of subsequent processing.
[0231] For example, the grayscale image is resized according to the preset fourth size, and the obtained preprocessed image can be expressed as the following relationship:
[0232] Iresized=resize(Iimage,w,h)
[0233] Where Iimage refers to the grayscale image, Iresized refers to the preprocessed image, w is the specified width, h is the specified height, w and h together define the preset fourth size, and resize() refers to the resizing function.
[0234] In this embodiment, the captured image is first denoised to remove noise interference and improve image quality. Secondly, the denoised image is converted to a grayscale image to simplify the image processing process. Finally, the grayscale image is resized according to a preset fourth dimension to ensure that the image size meets the requirements of subsequent processing. Through these steps, a preprocessed image is obtained, providing high-quality input data for the subsequent binarization process, thereby improving the accuracy and efficiency of the binarization process.
[0235] See Figure 14 , provides a flow chart of determining the third target area in the embodiment of this specification. Figure 14 As shown, the method of the embodiment of this specification may include the following steps S802 to S806, and steps S802 to S806 may be used as Figure 12 This is a refinement of the step S604 of “determining a third target area corresponding to the second target area from the binarized image”.
[0236] S802: Obtain a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size;
[0237] S804, determining a first mask area from the binarized image according to the structural information corresponding to the first coding matrix, the first positioning coding matrix, and the second positioning coding matrix;
[0238] S806: Determine a third target area corresponding to the second target area based on the first mask area.
[0239] Specifically, the first positioning coding matrix and the second positioning coding matrix involved in this embodiment refer to coding matrices with a preset second size and a preset third size, respectively, which are used to provide positioning information in the binary image to facilitate the determination of the third target area. The preset second size and the preset third size are different from each other and are both smaller than the preset first size, so as to ensure that the first positioning coding matrix and the second positioning coding matrix can be embedded in the first coding matrix without affecting the main information of the first coding matrix. The structural information corresponding to the first coding matrix refers to information such as the size, shape and arrangement rules of the coding elements of the first coding matrix, which is used to guide the process of extracting the first coding matrix from the binary image. The first mask area refers to the area determined in the binary image according to the first positioning coding matrix and the second positioning coding matrix, which is used to further extract the third target area. The third target area refers to the area corresponding to the second target area in the binary image, and its size and shape are consistent with the second target area, but the grayscale value attribute has changed.
[0240] Regarding the process of obtaining a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size, in some possible implementations, the first positioning coding matrix and the second positioning coding matrix can be generated according to preset rules. For example, the preset rules may specify that the first positioning coding matrix and the second positioning coding matrix are each composed of specific binary codes to ensure their uniqueness and identifiability. In some possible implementations, the first positioning coding matrix and the second positioning coding matrix can be obtained by querying a pre-stored database or file. For example, the specific contents of the first positioning coding matrix and the second positioning coding matrix can be obtained by querying a pre-stored database or file.
[0241] Regarding the process of determining the first mask region from the binarized image based on the structural information corresponding to the first coding matrix, the first positioning coding matrix, and the second positioning coding matrix, in some possible implementations, the positions of the first positioning coding matrix and the second positioning coding matrix can be identified in the binarized image using an image processing algorithm. For example, a template matching algorithm can be used to search for regions in the binarized image that match the first positioning coding matrix and the second positioning coding matrix, and their positions can be determined. In some possible implementations, the positions of the first positioning coding matrix and the second positioning coding matrix can be identified in the binarized image by calling an image processing library or software. For example, a template matching function in the OpenCV library can be used to search for regions in the binarized image that match the first positioning coding matrix and the second positioning coding matrix, and their positions can be determined. In some possible implementations, the first mask region can be determined based on the structural information corresponding to the first coding matrix, combined with the positions of the first positioning coding matrix and the second positioning coding matrix. For example, a region in the binarized image can be selected as the first mask region based on the size and shape of the first coding matrix, combined with the positions of the first positioning coding matrix and the second positioning coding matrix.
[0242] Regarding the process of determining the third target area corresponding to the second target area based on the first mask area, in some possible implementations, the third target area can be extracted from the first mask area by an image processing algorithm. For example, an edge detection algorithm or a region growing algorithm can be used to identify the third target area in the first mask area. In some possible implementations, the third target area can be extracted from the first mask area by calling an image processing library or software. For example, the edge detection function or region growing function in the OpenCV library can be called to identify the third target area in the first mask area. In some possible implementations, a user can manually select an area in the first mask area as the third target area. For example, the user can use an interactive interface to select an area in the first mask area, and the size and shape of the area are set by the user according to the size and shape of the second target area.
[0243] For example, the process of determining the first mask area can be expressed as the following relationship:
[0244] maskunit=detect_mask(Ibinary,Munit,Ppattern)
[0245] Wherein, maskunit refers to the first mask area, Ibinary refers to the binary image, Munit refers to the structural information corresponding to the first coding matrix, Ppattern refers to the first positioning coding matrix and the second positioning coding matrix, and detect_mask() refers to the processing function for determining the first mask area.
[0246] In this embodiment, positioning information is first provided for determining the third target region by obtaining a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size. Secondly, a first mask region is determined from the binarized image based on the structural information corresponding to the first coding matrix, the first positioning coding matrix, and the second positioning coding matrix, providing a basis for extracting the third target region. Finally, based on the first mask region, the third target region corresponding to the second target region is determined, ensuring the accuracy and completeness of the third target region. The use of the first and second positioning coding matrices enhances positioning accuracy, while the determination of the first mask region further narrows the search range, improving the efficiency of extracting the third target region and providing a reliable foundation for the subsequent decoding process.
[0247] In one embodiment, Figure 14 Step S806 of the embodiment shown is further refined and may include the following steps:
[0248] Performing perspective transformation correction on the first mask area to obtain a second mask area;
[0249] The second mask area is determined as a third target area corresponding to the second target area.
[0250] Specifically, the perspective transformation correction involved in this embodiment refers to performing a geometric transformation on the first mask area through an image processing algorithm to correct image distortion caused by shooting angle or perspective distortion, thereby obtaining a second mask area. The second mask area refers to the area after perspective transformation correction, and its shape and size more closely match the second target area, facilitating subsequent decoding processing.
[0251] Regarding the process of performing perspective transformation correction on the first mask area to obtain the second mask area, in some possible implementations, the first mask area can be perspective transformed and corrected by an image processing algorithm. For example, the first mask area can be geometrically transformed using a perspective transformation algorithm, and the second mask area can be generated by calculating the coordinates of the four corner points of the first mask area and mapping them to the target coordinates. In some possible implementations, the first mask area can be perspective transformed and corrected by calling an image processing library or software. For example, the perspective transformation function in the OpenCV library can be called to perform geometric transformation on the first mask area to generate the second mask area. In some possible implementations, the first mask area can be perspective transformed and corrected by the user manually inputting the corner point coordinates and target coordinates of the first mask area. For example, the user can input the corner point coordinates and target coordinates of the first mask area through an interactive interface to generate the second mask area.
[0252] Regarding the process of determining the second mask area as the third target area corresponding to the second target area, in some possible implementations, the third target area can be extracted from the second mask area by an image processing algorithm. For example, an edge detection algorithm or a region growing algorithm can be used to identify the third target area in the second mask area. In some possible implementations, the third target area can be extracted from the second mask area by calling an image processing library or software. For example, an edge detection function or a region growing function in the OpenCV library can be called to identify the third target area in the second mask area. In some possible implementations, a user can manually select an area in the second mask area as the third target area. For example, the user can use an interactive interface to select an area in the second mask area, and the size and shape of the area are set by the user according to the size and shape of the second target area.
[0253] In this embodiment, a second mask area is first obtained by performing perspective transformation correction on the first mask area. This corrects image distortion caused by shooting angle or perspective distortion, ensuring that the shape and size of the second mask area more closely match the second target area. Secondly, the second mask area is determined as a third target area corresponding to the second target area, ensuring the accuracy and completeness of the third target area. The perspective transformation correction improves the extraction accuracy of the third target area, and the use of the second mask area further optimizes the shape and size of the third target area, providing a reliable foundation for the subsequent decoding process.
[0254] In one embodiment, Figure 12 Step S606 of the embodiment shown is further refined and may include the following steps:
[0255] Dividing the third target area into a plurality of grid areas according to the structural information corresponding to the first coding matrix;
[0256] Performing pixel grayscale value statistics on each of the plurality of grid areas to obtain pixel grayscale value statistics results for each grid area;
[0257] Determine the coding element corresponding to each grid area according to the pixel grayscale value statistics of each grid area, where the coding element corresponding to the grid area is the first coding element or the second coding element;
[0258] A first coding matrix is determined according to the coding elements corresponding to each grid area.
[0259] The grid area involved in this embodiment refers to a plurality of sub-areas into which the third target area is divided according to the structural information corresponding to the first coding matrix, and each grid area corresponds to a coding element in the first coding matrix. Pixel grayscale value statistics refers to the calculation and analysis of the pixel grayscale values in each grid area to determine the grayscale characteristics of the grid area. A coding element refers to a basic unit in the first coding matrix, whose value is the first coding element or the second coding element, representing different binary information respectively. The first coding matrix refers to a matrix composed of multiple coding elements, which is used to store and transmit specific information.
[0260] Regarding the process of dividing the third target area into multiple grid areas according to the structural information corresponding to the first coding matrix, in some possible implementations, the third target area can be divided into multiple grid areas by an image processing algorithm. For example, the third target area can be divided into multiple grid areas according to a preset grid size based on the size and shape of the first coding matrix, and the size and shape of each grid area correspond one-to-one to the coding elements in the first coding matrix. In some possible implementations, the third target area can be divided into multiple grid areas by calling an image processing library or software. For example, the image segmentation function in the OpenCV library can be called to divide the third target area into multiple grid areas according to a preset grid size. In some possible implementations, the third target area can be divided into multiple grid areas by manually setting the grid size by the user. For example, the user can set the grid size through an interactive interface to divide the third target area into multiple grid areas.
[0261] Regarding the process of performing pixel grayscale value statistics on each grid area in a plurality of grid areas and obtaining the pixel grayscale value statistics results of each grid area, in some possible implementations, the number of pixels with a grayscale value of 0 and the number of pixels with a grayscale value of 255 in each grid area can be counted as the pixel grayscale value statistics results of the grid area. For example, a loop structure can be used to traverse all pixels in each grid area, determine whether the grayscale value of each pixel is 0 or 255, and count them respectively. In some possible implementations, pixel grayscale value statistics can be performed on each grid area by calling an image processing library or software. For example, the statistical function in the OpenCV library can be called to calculate the average value, median or mode of the grayscale values of all pixels in each grid area as the pixel grayscale value statistics results of the grid area.
[0262] Regarding the process of determining the coding element corresponding to each grid area based on the pixel grayscale value statistics of each grid area, in some possible implementations, the coding element corresponding to the grid area where the number of pixels with a grayscale value of 0 is greater than the number of pixels with a grayscale value of 255 can be determined as the first coding element, and the coding element corresponding to the grid area where the number of pixels with a grayscale value of 0 is less than or equal to the number of pixels with a grayscale value of 255 can be determined as the second coding element. Regarding the use of the average, median, or mode as the pixel grayscale value statistics, in some possible implementations, the average, median, or mode of the grayscale values of all pixels in each grid area can be calculated as the pixel grayscale value statistics of that grid area. For example, if the average grayscale value of the pixels in the grid area is greater than a preset grayscale threshold, the coding element corresponding to that grid area is determined as the first coding element; otherwise, it is determined as the second coding element. Similarly, classification can be performed based on the statistical results of the median or mode to determine the coding element corresponding to the grid area.
[0263] Regarding the process of determining the first coding matrix based on the coding elements corresponding to each grid area, in some possible implementations, the first coding matrix can be generated by arranging the coding elements corresponding to each grid area according to their positions in the third target area. For example, the coding elements corresponding to each grid area can be arranged in the order of rows and columns in the third target area to generate the first coding matrix. In some possible implementations, the coding elements corresponding to each grid area can be arranged to generate the first coding matrix by calling an image processing library or software. For example, the matrix generation function in the OpenCV library can be called to arrange the coding elements corresponding to each grid area to generate the first coding matrix. In some possible implementations, the first coding matrix can be generated by the user manually arranging the coding elements corresponding to each grid area. For example, the user can arrange the coding elements corresponding to each grid area through an interactive interface to generate the first coding matrix.
[0264] For example, assuming that the structural information corresponding to the first coding matrix indicates that the size of the first coding matrix is 13×13 and the size of the third target area is M×N, the third target area is divided into 13×13 grid areas based on the structural information corresponding to the first coding matrix, with each grid area having a size of (M / 13)×(N / 13). Pixel grayscale values are counted for each grid area, and the number of pixels with a grayscale value of 0 (C0(i,j)) and the number of pixels with a grayscale value of 255 (C255(i,j)) are calculated, where i and j represent the row and column indices of the grid area, respectively. According to a preset classification rule, if C0(i,j)>C255(i,j), the coding element corresponding to the grid area is determined to be the first coding element; if C0(i,j)≤C255(i,j), the coding element corresponding to the grid area is determined to be the second coding element. Finally, the coding elements corresponding to each grid area are arranged according to their position in the third target area to generate a 13×13 first coding matrix.
[0265] In this embodiment, the third target area is first divided into multiple grid areas based on the structural information corresponding to the first coding matrix, providing a basis for subsequent pixel grayscale value statistics and coding element determination. Secondly, pixel grayscale value statistics are performed on each of the multiple grid areas to obtain pixel grayscale value statistics for each grid area, providing a basis for determining the coding elements corresponding to each grid area. Thirdly, the coding elements corresponding to each grid area are determined based on the pixel grayscale value statistics for each grid area, ensuring the accuracy of the coding elements. Finally, the first coding matrix is determined based on the coding elements corresponding to each grid area, completing the conversion from the third target area to the first coding matrix. The division of the grid areas improves the extraction accuracy of the first coding matrix, and the pixel grayscale value statistics and coding element determination further optimize the generation process of the first coding matrix, providing a reliable foundation for the subsequent decoding process.
[0266] See Figure 15 , provides a schematic diagram of a process for decrypting and obtaining identification information in the embodiment of this specification. Figure 15 As shown, the method of the embodiment of this specification may include the following steps S902 to S906, and steps S902 to S906 may be used as Figure 12 The detailed steps of step S608 of the embodiment are shown.
[0267] S902, obtaining encrypted data from the first encoding matrix;
[0268] S904, decrypting the encrypted data according to the preset key to obtain initial data;
[0269] S906: Obtain identification information corresponding to the target item from the initial data.
[0270] Specifically, regarding the process of obtaining encrypted data from the first coding matrix, in some possible implementations, the encrypted data can be extracted from the first coding matrix using an image processing algorithm. For example, the encrypted data can be extracted from the first coding matrix according to preset extraction rules based on the size and shape of the first coding matrix. In some possible implementations, the encrypted data can be extracted from the first coding matrix by calling an image processing library or software. For example, the matrix extraction function in the OpenCV library can be called to extract the encrypted data from the first coding matrix. In some possible implementations, the encrypted data can be extracted from the first coding matrix by manually setting extraction rules. For example, the user can set extraction rules through an interactive interface to extract the encrypted data from the first coding matrix.
[0271] Regarding the process of decrypting encrypted data using a preset key to obtain initial data, in some possible implementations, a symmetric decryption algorithm can be used to decrypt the encrypted data. For example, AES, DES, or another symmetric decryption algorithm can be used in combination with a preset key to decrypt the encrypted data to obtain initial data. In some possible implementations, an asymmetric decryption algorithm can be used to decrypt the encrypted data. For example, RSA, ECC, or another asymmetric decryption algorithm can be used in combination with a preset key to decrypt the encrypted data to obtain initial data. In some possible implementations, a hybrid decryption method can be used to decrypt the encrypted data. For example, a symmetric decryption algorithm and an asymmetric decryption algorithm can be combined to decrypt the encrypted data to obtain initial data.
[0272] Regarding the process of obtaining identification information corresponding to the target item from the initial data, in some possible implementations, the identification information corresponding to the target item can be obtained by parsing the initial data. For example, the initial data can be parsed according to preset parsing rules to extract the identification information corresponding to the target item. In some possible implementations, the initial data can be parsed by calling a data processing library or software. For example, a parsing function in the data processing library can be called to parse the initial data and extract the identification information corresponding to the target item. In some possible implementations, the initial data can be parsed by a user manually setting parsing rules. For example, a user can set parsing rules through an interactive interface to parse the initial data and extract the identification information corresponding to the target item.
[0273] Exemplarily, the process of decryption and obtaining identification information can be expressed as the following relationship:
[0274] Iproduct=AES_decrypt(Mrs,Kkey)
[0275] Where Iproduct refers to the identification information corresponding to the target item, Kkey refers to the preset key, Mrs refers to the encrypted data, and AES_decrypt() refers to the AES decryption algorithm function.
[0276] In this embodiment, encrypted data is first obtained from the first encoding matrix, providing the basis for subsequent decryption. Second, the encrypted data is decrypted using a preset key to obtain initial data, ensuring data integrity and accuracy. Finally, the identification information corresponding to the target item is obtained from the initial data, completing the conversion from the first encoding matrix to the identification information corresponding to the target item. The acquisition and decryption of encrypted data ensures data immutability and confidentiality, while the analysis of the initial data further optimizes the identification information extraction process, providing reliable data support for the subsequent anti-channelling verification process.
[0277] In one embodiment, Figure 15 Step S902 of the illustrated embodiment may be further refined to include the following steps:
[0278] Perform redundant decoding on the first coding matrix to obtain encrypted data
[0279] Specifically, the redundant decoding process involved in this embodiment refers to the process of extracting encrypted data by decoding the first encoding matrix and removing redundant information. The purpose of the redundant decoding process is to restore the original encrypted data and ensure its integrity and accuracy. The encrypted data refers to the data obtained through the redundant decoding process and is used for subsequent decryption.
[0280] Regarding the process of performing redundant decoding on the first coding matrix to obtain encrypted data, in some possible implementations, a Hamming code can be used to perform redundant decoding on the first coding matrix. For example, the original encrypted data can be restored by removing the check bits in the first coding matrix. In some possible implementations, a Reed-Solomon code can be used to perform redundant decoding on the first coding matrix. For example, the original encrypted data can be restored by removing the redundant data in the first coding matrix. In some possible implementations, a convolutional code can be used to perform redundant decoding on the first coding matrix. For example, the original encrypted data can be restored by performing an inverse operation of a convolution operation on the first coding matrix.
[0281] Regarding the redundant decoding processing of Hamming codes, in some possible implementations, this can be achieved through the following steps: first, according to the coding rules of the Hamming code, determine the position of the check bits in the first coding matrix; second, use the check bits to correct errors in the data in the first coding matrix and remove erroneous data; finally, remove the check bits and restore the original encrypted data. Regarding the redundant decoding processing of Reed-Solomon codes, in some possible implementations, this can be achieved through the following steps: first, according to the coding rules of the Reed-Solomon code, determine the position of the redundant data in the first coding matrix; second, use the redundant data to correct errors in the data in the first coding matrix and remove erroneous data; finally, remove the redundant data and restore the original encrypted data. Regarding the redundant decoding processing of convolutional codes, in some possible implementations, this can be achieved through the following steps: first, according to the coding rules of the convolutional code, determine the convolution operation parameters in the first coding matrix; second, use the inverse operation of the convolution operation to decode the data in the first coding matrix and remove redundant information; finally, restore the original encrypted data.
[0282] Regarding the specific implementation of redundant decoding processing, in some possible implementations, redundant decoding processing can be performed on the first coding matrix using an image processing algorithm. For example, a decoding algorithm for a Hamming code, a Reed-Solomon code, or a convolutional code can be used to perform redundant decoding processing on the first coding matrix to restore the original encrypted data. In some possible implementations, redundant decoding processing can be performed on the first coding matrix by calling an image processing library or software. For example, a decoding function in the OpenCV library can be called to perform redundant decoding processing on the first coding matrix to restore the original encrypted data. In some possible implementations, redundant decoding processing can be performed on the first coding matrix by manually setting decoding rules by the user. For example, the user can set decoding rules through an interactive interface to perform redundant decoding processing on the first coding matrix to restore the original encrypted data.
[0283] Exemplarily, the redundant decoding process can be expressed as the following relationship:
[0284] Mrs = rs_decode (Munit)
[0285] Wherein, Munit refers to the first coding matrix, Mrs refers to the encrypted data, and rs_decode() refers to the redundant decoding processing function.
[0286] In this embodiment, redundant decoding is first performed on the first encoding matrix to remove redundant information and restore the original encrypted data, ensuring data integrity and accuracy. This redundant decoding process removes check bits, redundant data, or redundant information from convolution operations to restore the original encrypted data, providing a reliable foundation for subsequent decryption. The use of redundant decoding further enhances the data's anti-interference and error correction capabilities, providing reliable data support for subsequent anti-counterfeiting verification.
[0287] The following will be combined Figure 16 , the pattern coding device provided in the embodiment of this specification is introduced in detail. It should be noted that, Figure 16 The pattern encoding device 1 is used to execute the present invention Figure 2 - Figure 15 For the convenience of explanation, only the part related to the embodiment of this specification is shown. For the specific technical details not disclosed, please refer to this specification. Figure 2 - Figure 15 The embodiment shown in FIG. 1 , wherein the pattern coding device 1 specifically comprises:
[0288] An acquisition unit 11 is used to acquire the original pattern and identification information corresponding to the target object;
[0289] A generating unit 12 is configured to generate a first coding matrix based on the encrypted identification information, where the first coding matrix includes a first coding element and a second coding element having different binary logic states;
[0290] a determining unit 13, configured to determine a first target area corresponding to a first coding matrix in the original pattern;
[0291] The adjustment unit 14 is configured to perform color incremental adjustment on the first target area to obtain a target pattern, wherein the target pattern includes a second target area corresponding to the first target area, and the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the second target area have different colors.
[0292] Optionally, the adjustment unit 14 is further used to: obtain a first color increment corresponding to the first coding element, and a second color increment corresponding to the second coding element, the first color increment and the second color increment are different from each other; perform a color increment adjustment on the sub-area corresponding to the first coding element in the first target area according to the first color increment, and perform a color increment adjustment on the sub-area corresponding to the second coding element in the first target area according to the second color increment, to obtain a target pattern.
[0293] Optionally, the adjustment unit 14 is further used to: obtain a third color increment corresponding to the target coding element, where the target coding element is one of the first coding element and the second coding element; and perform a color increment adjustment on the sub-area corresponding to the target coding element in the first target area according to the third color increment to obtain a target pattern.
[0294] Optionally, the generating unit 12 is further configured to: generate initial data according to the identification information; encrypt the initial data according to a preset key to obtain encrypted data; and generate a first coding matrix according to the encrypted data.
[0295] Optionally, the generating unit 12 is further configured to: obtain random identification information corresponding to the target item; and generate initial data according to the identification information, the random identification information, and a preset key.
[0296] Optionally, the generating unit 12 is further configured to: generate a second coding matrix according to the encrypted data; perform redundant coding processing on the second coding matrix to obtain a third coding matrix; and extract the third coding matrix based on a preset first size to obtain the first coding matrix.
[0297] Optionally, the generation unit 12 is further configured to: extract the third coding matrix based on a preset first size to obtain a fourth coding matrix; obtain a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size, where the preset second size and the preset third size are different from each other and are both smaller than the preset first size; and embed the first positioning coding matrix and the second positioning coding matrix into the fourth coding matrix to obtain a first coding matrix, where the first positioning coding matrix and the second positioning coding matrix are diagonally distributed in the first coding matrix.
[0298] Optionally, the generation unit 12 is further used to: obtain a third positioning coding matrix of a preset second size, and a fourth positioning coding matrix of a preset third size; obtain first description information and second description information of the target item; add the preset first positioning information to the fixed coding area of the third positioning coding matrix, and add the first description information to the non-fixed coding area of the third positioning coding matrix, to obtain the first positioning coding matrix of the preset second size; add the preset second positioning information to the fixed coding area of the fourth positioning coding matrix, and add the second description information to the non-fixed coding area of the fourth positioning coding matrix, to obtain the second positioning coding matrix of the preset third size.
[0299] The effects that can be achieved by this embodiment can be found in the relevant embodiments of the above-mentioned pattern coding method, which will not be described in detail here.
[0300] The following will be combined Figure 17 , the pattern decoding device provided in the embodiment of this specification is introduced in detail. It should be noted that, Figure 17 The pattern decoding device 2 is used to execute the present invention Figure 2 - Figure 15 For the convenience of explanation, only the part related to the embodiment of this specification is shown. For the specific technical details not disclosed, please refer to this specification. Figure 2 - Figure 15 The embodiment shown in FIG. 1 , wherein the pattern decoding device 2 specifically includes:
[0301] A first acquisition unit 21 is configured to acquire a captured image of a target object, the captured image including a target pattern, the target pattern including a second target area corresponding to a first coding matrix, the first coding matrix including first coding elements and second coding elements having different binary logic states, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area having different colors;
[0302] A processing unit 22 is configured to perform binarization processing on the captured image to obtain a binarized image, and determine a third target area corresponding to the second target area from the binarized image, wherein the grayscale values of the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the third target area are different;
[0303] A second acquiring unit 23 is configured to acquire a first coding matrix according to a third target area;
[0304] The decryption unit 24 is configured to decrypt the first coding matrix to obtain identification information corresponding to the target object.
[0305] Optionally, the processing unit 22 is further configured to: pre-process the captured image to obtain a pre-processed image; and call a pre-trained semantic segmentation model to perform binarization on the pre-processed image to obtain a binarized image.
[0306] Optionally, the processing unit 22 is further configured to: perform denoising on the captured image to obtain a denoised image; convert the denoised image into a grayscale image; and resize the grayscale image according to a preset fourth size to obtain a preprocessed image.
[0307] Optionally, the processing unit 22 is further used to: obtain a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size; determine a first mask area from the binarized image according to the structural information corresponding to the first coding matrix, the first positioning coding matrix, and the second positioning coding matrix; and determine a third target area corresponding to the second target area based on the first mask area.
[0308] Optionally, the processing unit 22 is further configured to: perform perspective transformation correction on the first mask area to obtain a second mask area; and determine the second mask area as a third target area corresponding to the second target area.
[0309] Optionally, the second acquisition unit 23 is further used to: divide the third target area into multiple grid areas according to the structural information corresponding to the first coding matrix; perform pixel grayscale value statistics on each grid area in the multiple grid areas to obtain pixel grayscale value statistics results of each grid area; determine the coding elements corresponding to each grid area according to the pixel grayscale value statistics results of each grid area, and the coding elements corresponding to the grid areas are the first coding elements or the second coding elements; and determine the first coding matrix according to the coding elements corresponding to each grid area.
[0310] Optionally, the decryption unit 24 is further configured to: obtain encrypted data from the first coding matrix; decrypt the encrypted data according to a preset key to obtain initial data; and obtain identification information corresponding to the target object from the initial data.
[0311] Optionally, the decryption unit 24 is further configured to perform redundant decoding processing on the first coding matrix to obtain encrypted data.
[0312] The effects that can be achieved by this embodiment can be found in the relevant embodiments of the above-mentioned pattern decoding method, which will not be described in detail here.
[0313] See Figure 18 , is a schematic diagram of the structure of an electronic device provided in the embodiment of this specification. Figure 18 As shown, the electronic device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, an input / output interface 1003, a memory 1005, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between these components. The network interface 1004 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As Figure 18 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, an input and output interface module, and an application program.
[0314] exist Figure 18 In the electronic device 1000 shown, the input / output interface 1003 is mainly used to provide an input interface for the user and obtain data input by the user.
[0315] In one embodiment, the processor 1001 may be configured to call an application stored in the memory 1005 and specifically perform the following operations:
[0316] Obtain the original pattern and identification information corresponding to the target object;
[0317] Encrypting and generating a first coding matrix according to the identification information, the first coding matrix including first coding elements and second coding elements with different binary logic states;
[0318] Determining a first target area corresponding to a first coding matrix in the original pattern;
[0319] The target pattern is obtained by performing color incremental adjustment on the first target area. The target pattern includes a second target area corresponding to the first target area. The sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the second target area have different colors.
[0320] Optionally, when performing a color incremental adjustment on the first target area to obtain a target pattern, the processor 1001 specifically performs the following operations: obtaining a first color increment corresponding to the first coding element, and a second color increment corresponding to the second coding element, the first color increment and the second color increment being different from each other; performing a color incremental adjustment on the sub-area corresponding to the first coding element in the first target area according to the first color increment, and performing a color incremental adjustment on the sub-area corresponding to the second coding element in the first target area according to the second color increment to obtain the target pattern.
[0321] Optionally, when performing a color incremental adjustment on the first target area to obtain a target pattern, the processor 1001 specifically performs the following operations: obtaining a third color increment corresponding to the target coding element, where the target coding element is one of the first coding element and the second coding element; performing a color incremental adjustment on the sub-area corresponding to the target coding element in the first target area according to the third color increment to obtain the target pattern.
[0322] Optionally, when executing encryption to generate the first coding matrix according to the identification information, the processor 1001 specifically performs the following operations: generating initial data according to the identification information; encrypting the initial data according to a preset key to obtain encrypted data; and generating the first coding matrix according to the encrypted data.
[0323] Optionally, when executing the process of generating initial data according to the identification information, the processor 1001 specifically performs the following operations: obtaining random identification information corresponding to the target item; and generating initial data according to the identification information, the random identification information and a preset key.
[0324] Optionally, when executing the generation of the first coding matrix based on the encrypted data, the processor 1001 specifically performs the following operations: generating a second coding matrix based on the encrypted data; performing redundant coding processing on the second coding matrix to obtain a third coding matrix; and extracting the third coding matrix based on a preset first size to obtain the first coding matrix.
[0325] Optionally, when the processor 1001 extracts the third coding matrix based on the preset size to obtain the first coding matrix, it specifically performs the following operations: extracts the third coding matrix based on the preset first size to obtain a fourth coding matrix; obtains a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size, where the preset second size and the preset third size are different from each other and are both smaller than the preset first size; embeds the first positioning coding matrix and the second positioning coding matrix into the fourth coding matrix to obtain the first coding matrix, where the first positioning coding matrix and the second positioning coding matrix are diagonally distributed in the first coding matrix.
[0326] Optionally, when executing the acquisition of the first positioning coding matrix of the preset second size and the second positioning coding matrix of the preset third size, the processor 1001 specifically performs the following operations: acquiring the third positioning coding matrix of the preset second size and the fourth positioning coding matrix of the preset third size; acquiring the first description information and the second description information of the target item; adding the preset first positioning information to the fixed coding area of the third positioning coding matrix, and adding the first description information to the non-fixed coding area of the third positioning coding matrix, to obtain the first positioning coding matrix of the preset second size; adding the preset second positioning information to the fixed coding area of the fourth positioning coding matrix, and adding the second description information to the non-fixed coding area of the fourth positioning coding matrix, to obtain the second positioning coding matrix of the preset third size.
[0327] In one embodiment, the processor 1001 may be configured to call an application stored in the memory 1005 and specifically perform the following operations:
[0328] Acquire a captured image of the target object, the captured image including a target pattern, the target pattern including a second target area corresponding to a first coding matrix, the first coding matrix including first coding elements and second coding elements having different binary logic states, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area having different colors;
[0329] performing binarization processing on the captured image to obtain a binarized image, determining a third target area corresponding to the second target area from the binarized image, wherein the grayscale values of the sub-area corresponding to the first coding element and the sub-area corresponding to the second coding element in the third target area are different;
[0330] Acquire a first coding matrix according to the third target area;
[0331] The first coding matrix is decrypted to obtain identification information corresponding to the target object.
[0332] Optionally, when the processor 1001 performs binarization processing on the captured image to obtain a binarized image, it specifically performs the following operations: preprocessing the captured image to obtain a preprocessed image; calling a pre-trained semantic segmentation model to binarize the preprocessed image to obtain a binarized image.
[0333] Optionally, when the processor 1001 performs preprocessing on the captured image to obtain a preprocessed image, it specifically performs the following operations: denoising the captured image to obtain a denoised image; converting the denoised image into a grayscale image; and resizing the grayscale image according to a preset fourth size to obtain a preprocessed image.
[0334] Optionally, when the processor 1001 determines the third target area corresponding to the second target area from the binarized image, it specifically performs the following operations: obtaining a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size; determining a first mask area from the binarized image according to the structural information corresponding to the first coding matrix, the first positioning coding matrix, and the second positioning coding matrix; and determining the third target area corresponding to the second target area based on the first mask area.
[0335] Optionally, when the processor 1001 determines the third target area corresponding to the second target area based on the first mask area, it specifically performs the following operations: performing perspective transformation correction on the first mask area to obtain the second mask area; and determining the second mask area as the third target area corresponding to the second target area.
[0336] Optionally, when executing to obtain the first coding matrix based on the third target area, the processor 1001 specifically performs the following operations: dividing the third target area into multiple grid areas according to the structural information corresponding to the first coding matrix; performing pixel grayscale value statistics on each grid area in the multiple grid areas to obtain pixel grayscale value statistics results of each grid area; determining the coding elements corresponding to each grid area according to the pixel grayscale value statistics results of each grid area, the coding elements corresponding to the grid area being the first coding elements or the second coding elements; and determining the first coding matrix according to the coding elements corresponding to each grid area.
[0337] Optionally, when the processor 1001 decrypts the first coding matrix to obtain identification information corresponding to the target item, it specifically performs the following operations: obtaining encrypted data from the first coding matrix; decrypting the encrypted data according to a preset key to obtain initial data; and obtaining identification information corresponding to the target item from the initial data.
[0338] Optionally, when executing the process of acquiring encrypted data from the first coding matrix, the processor 1001 specifically performs the following operations: performing redundant decoding processing on the first coding matrix to obtain encrypted data.
[0339] The effects that can be achieved by this embodiment can be found in the relevant embodiments of the above-mentioned pattern encoding method and pattern decoding method, which will not be described in detail here.
[0340] The embodiment of this specification also provides a computer storage medium, which is a computer readable storage medium that stores computer program code. When the computer program code is executed, the above Figure 2 - Figure 15 The pattern encoding method and pattern decoding method of the embodiment shown, the specific execution process can be found in Figure 2 - Figure 15 The detailed description of the illustrated embodiment will not be repeated here.
[0341] The embodiment of this specification also provides a computer program product, which stores at least one instruction, and when the at least one instruction is executed by a processor, the above Figure 2 - Figure 15 The pattern encoding method and pattern decoding method of the embodiment shown, the specific execution process can be found in Figure 2 - Figure 15 The detailed description of the illustrated embodiment will not be repeated here.
[0342] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware through a computer program. The program can be stored in a computer-readable storage medium, and when executed, the program can include the processes in the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0343] The above disclosure is only a preferred embodiment of this specification, and certainly cannot be used to limit the scope of rights of this specification. Therefore, equivalent changes made according to the claims of this specification are still within the scope covered by this specification.
Claims
1. A pattern coding method, comprising: Obtain the original pattern and identification information corresponding to the target object; Encrypting and generating a first coding matrix according to the identification information, the first coding matrix including first coding elements and second coding elements with different binary logic states; Determining a first target area corresponding to the first encoding matrix in the original pattern; A target pattern is obtained by performing color incremental adjustment on the first target area, wherein the target pattern includes a second target area corresponding to the first target area, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area have different colors.
2. The method according to claim 1, wherein the step of performing color incremental adjustment on the first target area to obtain the target pattern comprises: Obtaining a first color increment corresponding to the first coding element and a second color increment corresponding to the second coding element, wherein the first color increment and the second color increment are different from each other; A target pattern is obtained by performing a color increment adjustment on a subregion corresponding to the first coding element in the first target region according to the first color increment, and performing a color increment adjustment on a subregion corresponding to the second coding element in the first target region according to the second color increment.
3. The method according to claim 1, wherein the step of performing color incremental adjustment on the first target area to obtain the target pattern comprises: Obtaining a third color increment corresponding to a target coding element, where the target coding element is one of the first coding element and the second coding element; According to the third color increment, a color increment adjustment is performed on the sub-region corresponding to the target coding element in the first target region to obtain a target pattern.
4. The method according to claim 1, wherein encrypting and generating a first coding matrix based on the identification information comprises: generating initial data according to the identification information; Encrypting the initial data according to a preset key to obtain encrypted data; A first encoding matrix is generated according to the encrypted data.
5. The method according to claim 4, wherein generating initial data according to the identification information comprises: Obtaining random identification information corresponding to the target object; Initial data is generated according to the identification information, the random identification information and a preset key.
6. The method according to claim 4, wherein generating a first encoding matrix according to the encrypted data comprises: generating a second encoding matrix according to the encrypted data; performing redundant coding processing on the second coding matrix to obtain a third coding matrix; The third encoding matrix is extracted based on a preset first size to obtain a first encoding matrix.
7. The method according to claim 6, wherein extracting the third encoding matrix based on a preset size to obtain the first encoding matrix comprises: Extracting the third encoding matrix based on a preset first size to obtain a fourth encoding matrix; Obtaining a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size, wherein the preset second size and the preset third size are different from each other and are both smaller than the preset first size; The first positioning coding matrix and the second positioning coding matrix are embedded in the fourth coding matrix to obtain a first coding matrix, where the first positioning coding matrix and the second positioning coding matrix are diagonally distributed in the first coding matrix.
8. The method according to claim 7, wherein obtaining the first positioning coding matrix of the preset second size and the second positioning coding matrix of the preset third size comprises: Obtaining a third positioning coding matrix of a preset second size and a fourth positioning coding matrix of a preset third size; Obtaining first description information and second description information of the target item; Adding the preset first positioning information to the fixed coding area of the third positioning coding matrix, and adding the first description information to the non-fixed coding area of the third positioning coding matrix, to obtain a first positioning coding matrix of a preset second size; The preset second positioning information is added to the fixed coding area of the fourth positioning coding matrix, and the second description information is added to the non-fixed coding area of the fourth positioning coding matrix to obtain a second positioning coding matrix of a preset third size.
9. A pattern decoding method, comprising: Acquiring a captured image of a target object, the captured image including a target pattern, the target pattern including a second target area corresponding to a first coding matrix, the first coding matrix including first coding elements and second coding elements having different binary logic states, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area having different colors; performing binarization processing on the captured image to obtain a binarized image, and determining a third target region corresponding to the second target region from the binarized image, wherein a subregion corresponding to the first coding element and a subregion corresponding to the second coding element in the third target region have different grayscale values; Acquire the first coding matrix according to the third target area; The first coding matrix is decrypted to obtain identification information corresponding to the target object.
10. The method according to claim 9, wherein the binarization processing of the captured image to obtain a binarized image comprises: Preprocessing the captured image to obtain a preprocessed image; A pre-trained semantic segmentation model is called to perform binarization processing on the pre-processed image to obtain a binarized image.
11. The method according to claim 10, wherein preprocessing the captured image to obtain a preprocessed image comprises: performing denoising processing on the captured image to obtain a denoised image; Converting the denoised image into a grayscale image; The grayscale image is resized according to a preset fourth size to obtain a preprocessed image.
12. The method according to claim 9, wherein determining a third target area corresponding to the second target area from the binarized image comprises: Obtaining a first positioning coding matrix of a preset second size and a second positioning coding matrix of a preset third size; determining a first mask area from the binarized image according to the structural information corresponding to the first coding matrix, the first positioning coding matrix, and the second positioning coding matrix; Based on the first mask area, a third target area corresponding to the second target area is determined.
13. The method according to claim 12, wherein determining a third target area corresponding to the second target area based on the first mask area comprises: Performing perspective transformation correction on the first mask area to obtain a second mask area; The second mask area is determined as a third target area corresponding to the second target area.
14. The method according to claim 9, wherein obtaining the first encoding matrix according to the third target area comprises: Dividing the third target area into a plurality of grid areas according to the structural information corresponding to the first encoding matrix; Performing pixel grayscale value statistics on each of the plurality of grid areas to obtain pixel grayscale value statistics results for each of the grid areas; Determining, based on pixel grayscale value statistics of each grid area, a coding element corresponding to each grid area, where the coding element corresponding to the grid area is the first coding element or the second coding element; The first coding matrix is determined according to the coding elements corresponding to each of the grid areas.
15. The method according to claim 9, wherein decrypting the first coding matrix to obtain identification information corresponding to the target object comprises: Obtaining encrypted data from the first encoding matrix; Decrypting the encrypted data according to a preset key to obtain initial data; Acquire identification information corresponding to the target item from the initial data.
16. The method according to claim 15, wherein obtaining encrypted data from the first encoding matrix comprises: Redundant decoding is performed on the first encoding matrix to obtain encrypted data.
17. A pattern coding device comprising: An acquisition unit, configured to acquire the original pattern and identification information corresponding to the target object; A generating unit, configured to generate a first coding matrix by encryption according to the identification information, wherein the first coding matrix includes a first coding element and a second coding element having different binary logic states; a determining unit, configured to determine, in the original pattern, a first target area corresponding to the first encoding matrix; an adjustment unit, configured to perform incremental color adjustment on the first target area to obtain a target pattern, wherein the target pattern includes a second target area corresponding to the first target area, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area have different colors.
18. A pattern decoding device, comprising: a first acquisition unit, configured to acquire a captured image of a target object, the captured image including a target pattern, the target pattern including a second target area corresponding to a first coding matrix, the first coding matrix including first coding elements and second coding elements having different binary logic states, and a sub-area corresponding to the first coding element and a sub-area corresponding to the second coding element in the second target area having different colors; a processing unit, configured to perform binarization processing on the captured image to obtain a binarized image, and determine, from the binarized image, a third target region corresponding to the second target region, wherein a subregion corresponding to the first coding element and a subregion corresponding to the second coding element in the third target region have different grayscale values; a second acquiring unit, configured to acquire the first coding matrix according to the third target area; A decryption unit is used to decrypt the first coding matrix to obtain identification information corresponding to the target object.
19. A computer-readable storage medium storing computer program code, wherein when the computer program code is executed, the method according to any one of claims 1 to 16 is implemented.
20. An electronic device, comprising: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the method according to any one of claims 1 to 16.
21. A computer program product, wherein the computer program product stores at least one instruction, and when the at least one instruction is executed by a processor, the steps of the method according to any one of claims 1 to 16 are implemented.