A color barcode, a method for identifying and decoding the barcode, and an electronic device.

Through the design and identification method of color barcodes, the brightness components and Y channel components of different standard colors are used to solve the problem of insufficient utilization of graphic color information and difficulty in identification under lighting conditions in traditional barcode technology, and achieve efficient color barcode identification. Barcode decoding.

CN118504599BActive Publication Date: 2024-09-17JIANGSU PEREGRINE MICROELECTRONICS CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410957794.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-17
Publication Date
2024-09-17
Estimated Expiration
2044-07-17

AI Technical Summary

Technical Problem

Traditional barcode technology is difficult to utilize graphic color information. The recognition and decoding process requires high accuracy in graphic segmentation, and recognition is difficult under special lighting conditions.

Method used

Using color bar identification codes, N rectangular single color blocks are sequentially aligned and spliced ​​along the width direction of the color block. The first T rectangular color blocks are used as verification color blocks, and the last (N-T) rectangular color blocks are used as encoding color blocks, using different standards. The brightness component of the color distinguishes the encoded value and is combined with the Y channel component for image preprocessing, positioning, segmentation and decoding.

Benefits of technology

It achieves the accurate extraction of complete coding information of color barcodes while using less computing resources, improves the efficiency and accuracy of identification and decoding, and overcomes the dependence on lighting conditions in traditional barcode technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118504599B
    Figure CN118504599B
Patent Text Reader

Abstract

The present invention discloses a color bar identification code, identification code identification and decoding method and electronic device. In combination with the Y channel component, a strip-shaped color bar identification code containing multiple standard colors is formed by aligning and splicing monochrome blocks of different standard colors, wherein different standard colors represent different information features. In the identification and decoding process, by judging the connected set characteristics and related characteristic conditions of the color graphics to be identified and its y component value, and through the steps of angle correction, verification decoding matching and color block attribute matching, the complete coding information of the color bar identification code can be accurately extracted from the color graphics to be identified on the basis of using less computing power resources and not performing absolutely accurate graphic segmentation, thereby realizing efficient decoding of the color bar identification code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a data representation structure and a data recognition method, and in particular to a color bar code and a recognition and decoding method thereof. Background Art

[0002] Computer image recognition has become an important research branch of computer vision technology and an important foundation for image retrieval. The local features of an image are the key to recognition, and they have unique advantages in providing more image details, providing a foundation for object semantic support, and recognizing objects under occlusion conditions.

[0003] As one of the automatic identification systems, barcode technology has matured. A barcode is a graphic identifier that arranges multiple black bars and spaces of varying widths according to certain coding rules to express a set of information. Compared with other identification technologies, barcode as a graphic recognition technology has many advantages, such as easy symbol production, simple scanning operation, fast information collection speed, and high data reliability.

[0004] However, the traditional barcode recognition technology only uses black and white as the reference colors for feature coding, which leaves a large gap in the use of graphic color coding information, severely limiting the expansion of barcode coding information capacity. At the same time, the development of multi-color barcode technology still faces many bottlenecks, such as difficulty in graphic segmentation and positioning, and large images due to lighting conditions. Summary of the invention

[0005] Purpose of the invention: In view of the above-mentioned prior art, a color barcode, a method for identifying and decoding the code, and an electronic device are proposed to solve the problems in traditional barcode technology that it is difficult to utilize graphic color information, the recognition and decoding process requires high accuracy of graphic segmentation, and it is difficult to identify under special lighting conditions.

[0006] Technical solution: A color bar identification code, including N rectangular single-color blocks aligned and spliced ​​in sequence along the width direction of the color blocks; wherein the first T rectangular color blocks are used as verification color blocks, each verification color block takes a different standard color and the brightness component is lower than the preset threshold value Th_Y1; the last (NT) rectangular color blocks are used as coding color blocks, in the coding color block sequence, the coding color blocks of each odd sequence take a color from j standard colors and the brightness component is higher than the preset threshold value Th_Y2, the coding color blocks of each even sequence take a color from o standard colors and the brightness component is lower than the preset threshold value Th_Y1, and there is no color overlap between the j standard colors and the o standard colors, Th_Y2>0.5>Th_Y1; the coding color blocks of different standard colors represent different coding values.

[0007] Furthermore, the value range of N is 20~30, the value range of T is 2~6, and let Z=T+j+o, the value range of Z is 10~20.

[0008] Furthermore, the RGB channel value of each standard color is selected from p equidistant fixed grayscale values.

[0009] Furthermore, for T verification color blocks, the RGB channel value of the color of one of the verification color blocks is {0,0,0}; one of the RGB channels of the color of the remaining verification color blocks has a channel value of 0, and the values ​​of the other two channels are equal; for the verification color block with a channel value of {0,0,0}, its representation verification code is “---”; for the remaining verification color blocks, the channel representation verification code of the channel value of 0 is “-”, and the channel representation verification code of the channel value of 1 is “+”.

[0010] A method for identifying and decoding a color barcode, comprising:

[0011] Step 1: preprocessing the RGB mode image to be identified containing the color barcode;

[0012] Step 2: By determining the Y channel connected set characteristics of the image to be identified, the barcode is located and the image is segmented;

[0013] Step 3: Determine the characteristic conditions of the sub-images containing the candidate barcode obtained in step 2 one by one, and finally locate and extract the barcode decoding area;

[0014] Step 4: Perform a decoding operation on the bar code decoding area to obtain a decoding value of the color bar code.

[0015] Furthermore, the step 2 comprises:

[0016] Step 2.1: Extract the Y channel component of each pixel in the image to be identified in the RGB mode, and retain the y component value after conversion to 2 decimal places, and then perform normalization processing to form a Y channel image;

[0017] Step 2.2: Extract all 8-connected sets with similar number of pixels in the Y channel image;

[0018] Step 2.3: Aggregate the 8-connected sets with similar numbers of pixels and adjacency to form a new connected set, and each 8-connected set in the new connected set is called an original connected set; when the number of original connected sets contained in the new connected set is [N, N+ΔN], the new connected set is considered to be a candidate barcode, and according to the pixel coordinates of the new connected set, the Y channel image is segmented and the image to be identified after preprocessing in step 1 is segmented synchronously according to the corresponding relationship of the pixel coordinates, and the Y channel sub-image containing the candidate barcode and the RGB mode sub-image are obtained respectively.

[0019] Furthermore, the step 3 comprises:

[0020] Step 3.1: Convolve the first Y channel sub-image containing the candidate barcode in 8 gradient directions to form 8 feature sub-graphs, calculate the average pixel value of each feature sub-graph, and record the gradient directions corresponding to the two feature sub-graphs with the highest average pixel values ​​as α1 and α2 respectively. If α1 and α2 are orthogonal, it is determined that the candidate barcode meets the first feature condition. Otherwise, the first feature condition is determined for the next Y channel sub-image containing the candidate barcode; rotate the Y channel sub-image that meets the first feature condition and its corresponding RGB mode sub-image by an angle of α1;

[0021] Step 3.2: According to the original connected set boundary in the candidate barcode obtained in step 2.3, the RGB mode sub-image after the rotation processing in step 3.1 is divided into pixel blocks, and then the pixel blocks that meet any of the following two conditions are extracted from the divided pixel blocks as candidate verification color blocks; wherein condition ①: one of the RGB channels of the pixel corresponding to the pixel block has a channel value less than the threshold value th1, and the other two channel values ​​are greater than or equal to 2*th1, and the absolute value of the difference between the two channel values ​​is less than the threshold value th2; condition ②: the three RGB channel values ​​of the pixel corresponding to the pixel block are all less than the threshold value th1; verification decoding is performed on the obtained candidate verification color blocks, and the channel value of the pixel less than the threshold value th1 is decoded as "-", and the channel value of the pixel greater than or equal to the threshold value th1 is decoded as "+", so as to form a verification decoding string; if the verification decoding string contains the complete verification code string defined by the color barcode, it is determined that the candidate barcode satisfies the second characteristic condition, and the candidate verification color blocks corresponding to the verification decoding string are used as the verification area; otherwise, return to step 3.1 to perform the first characteristic condition judgment on the next Y channel sub-image containing the candidate barcode;

[0022] Step 3.3: For the Y channel sub-image corresponding to the candidate barcode that meets the second characteristic condition, threshold processing is performed on the original connected set in the Y channel sub-image. If the pixel value of the original connected set is less than 0.5, the attribute tag of the original connected set is mapped to 0; if the pixel value of the original connected set is greater than or equal to 0.5, the attribute tag of the original connected set is mapped to 1; in the Y channel sub-image, the attribute tag value string of the (NT) original connected sets connected to the verification area is obtained. If the attribute tag value string is consistent with the color barcode standard definition, If the color block attribute tag value string matches bit by bit, it is determined that the candidate barcode meets the third characteristic condition, and the boundary where the (NT) original connected sets in the candidate barcode are located is the boundary where the barcode decoding area for final decoding is located; otherwise, return to step 3.1 to perform the first characteristic condition judgment on the next Y channel sub-image containing the candidate barcode; extract the barcode decoding area from the RGB mode sub-image corresponding to the Y channel sub-image, and divide the barcode decoding area into (NT) decoding color blocks according to the boundary of the original connected set.

[0023] Furthermore, the steps include: for each decoding color block in the bar identification code decoding area, respectively calculating the average value of each RGB channel value of all pixels in each decoding color block to form a decoding color vector of each decoding color block, and then performing Euclidean distance calculation on each code color vector located in the odd sequence and the three-dimensional vector of each color in the j standard colors, and performing Euclidean distance calculation on each code color vector located in the even sequence and the three-dimensional vector of each color in the o standard colors, respectively taking the standard color corresponding to the minimum distance value as the color of each decoding color block, and the encoding value corresponding to each standard color is the decoding value of each decoding color block.

[0024] Furthermore, in the step 3.3, in the Y channel sub-image, the original connected set is scanned to the right starting from the coordinates of the center point of the verification area, and its attribute tag value is recorded starting from the first scanned original connected set that is not in the verification area, and the scanning stops when the (NT)th original connected set is scanned, thereby obtaining an attribute tag value string with (NT) bits containing only 0 and 1.

[0025] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for identifying and decoding a color barcode is realized.

[0026] Beneficial effects: A color bar identification code of the present invention combines the Y channel component and forms a strip-shaped bar identification code containing multiple standard colors by aligning and splicing monochrome blocks of different standard colors, wherein different standard colors represent different information features.

[0027] During the recognition and decoding process, by judging the connected set characteristics and related feature conditions of the color graphic to be identified and its y-component value, and going through the steps of angle correction, verification decoding matching, and color block attribute matching, the complete coding information of the color bar identification code can be accurately extracted from the color graphic to be identified while utilizing fewer computing resources and without absolutely accurate graphic segmentation, thereby achieving efficient decoding of the color bar identification code. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 An example of a color bar identification code defined for the present invention;

[0029] Figure 2 The figure is a schematic diagram of the recognition and decoding process of the color bar code of the present invention;

[0030] Figure 3 A schematic diagram for comparing candidate barcodes provided by an embodiment of the present invention;

[0031] Figure 4 A schematic diagram of the gradient direction and related convolution kernels for feature condition determination provided by an embodiment of the present invention;

[0032] Figure 5 A schematic diagram of a verification decoding and matching method for feature condition determination provided by an embodiment of the present invention;

[0033] Figure 6 A schematic diagram of a pixel value matching method after scanning an original connected set for feature condition determination provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The present invention will be further explained below in conjunction with the accompanying drawings.

[0035] A color barcode identification code comprises a barcode carrier. The color barcode identification code is made on the carrier. The making method includes but is not limited to printing, spraying and printing.

[0036] Standard definition and encoding method of barcode:

[0037] Define a color barcode (hereinafter referred to as barcode), which is a color block with a size of W * H N rectangular blocks i The color blocks are aligned and spliced ​​in sequence along the width W direction to form a rectangular bar code containing multiple standard colors, where each rectangular color block i The color of the block is denoted as c(block i), i∈[1,N]. In this bar identification code, the first T rectangular color blocks are used as verification color blocks. Each color block takes a different standard color and contains a lower brightness component, which is used to locate and verify the bar identification code. In this bar identification code, the last (NT) rectangular color blocks are used as coding color blocks. Among the coding color blocks, the first coding color block is marked as sequence 1. The coding color blocks of each odd sequence take a color from j standard colors and contain a higher brightness component. The coding color blocks of each even sequence take a color from o standard colors and contain a lower brightness component. There is no color overlap between the j standard colors and the o standard colors. In the coding color blocks, different standard colors represent different coding values. When (NT) is an even number, the total coding capacity is j. (N-T) / 2 *o (N-T) / 2 , when (NT) is an odd number, the total coding capacity is j ((N-T-1) / 2)+1 *o (N-T-1) / 2 In the present invention, N∈[20,30] is preferred, and when the aspect ratio of the single rectangular color block is 1:8, a better barcode segmentation and recognition effect can be achieved. Furthermore, W=3mm is preferred.

[0038] Specifically, the T standard colors of the verification color block and the (j+o) standard colors of the coding color block together form a standard color set CS, and the total number of elements in the set is Z = T + j + o. For higher-performance image sensors or image signal processing (ISP) systems, Z can take a higher value to increase the encoding information capacity of the barcode, preferably Z∈[10,20]. Each element CS in CS i is a three-dimensional vector, that is, the RGB channel value corresponding to the standard color, denoted as CS i ={ r(CS i ), g(CS i ), b(CS i )}. The RGB channel value of each element in CS is selected from p fixed grayscale values ​​with equal intervals (or approximately equal intervals). For example, for an 8-bit color image, when p is 4, the channel value of each standard color in the barcode is selected from the grayscale value set {0, 85, 170, 255}. In the coded color block, the three-dimensional vectors of the odd-numbered sequence of related colors form a vector element subset CSJ, and the elements in the subset CSJ i ={ r(CSJ i ), g(CSJ i ), b(CSJ i )}; The three-dimensional vectors of even sequence related colors form a vector element subset CSO, and the elements in the subset CSO i ={ r(CSO i ), g(CSO i ), b(CSO iIn the present invention, preferably p∈[2,5] can achieve better graphics processing effects, wherein the more standard color elements CS contains, the higher the value of p needs to be.

[0039] Further, extract each CS i The Y channel component of the image is converted into a Y channel component, and the Y channel component is normalized. For an 8-bit color image, the Y channel component of each standard color is calculated as follows: y=(0.299r+0.587g+0.114b)\255. The Y channel component represents the brightness value of the image, and the converted y component value retains 2 decimal places. Among them, for the verification color block, y∈[0.00,0.30]; for the odd sequence of the coded color block, y∈[0.70,1.00]; for the even sequence of the coded color block, y∈[0.00,0.30]. The present invention sets the attribute of the standard color with a y component value lower than 0.50 as dark, and the attribute of the standard color with a y component value higher than or equal to 0.50 as bright. Therefore, in a bar code, the attributes of the first T rectangular color blocks are dark, and the attributes of the remaining rectangular color blocks are arranged in intervals of light and dark, and each dark attribute rectangular color block is marked as 0, and each bright attribute color block is marked as 1.

[0040] For T verification color blocks, the RGB channel value of one of the color blocks is {0,0,0}; one of the RGB channels of the color of the remaining color blocks has a channel value of 0, and the values ​​of the other two channels are equal. For the verification color block with a channel value of {0,0,0}, it is encoded as a three-digit verification code of "---"; for the remaining verification color blocks, the channel value of 0 is encoded as "-", and the channel value of 1 is encoded as "+".

[0041] Table 1 is a standard color set of this embodiment, with a total of 15 color elements. The channel value of each standard color is one of the four arithmetic values ​​{0, 85, 170, 255}. The first four colors CS1~CS4 in the standard color set are used to verify the color of the color block (dark attribute), and the corresponding verification code values ​​are: ---, ++-, +-+, -++. A total of 4 colors CS5~CS8 are used to encode the color of the even sequence (dark attribute) in the color block, and the corresponding code values ​​are CO(CS i )∈{1,2, 3,4};CS9~CS 15 A total of 7 colors are used to encode the color of the odd sequence (bright attribute) in the color block, corresponding to the encoding value CO(CS i )∈{1,2,3,4,5,6,7}. If N is an odd number and T is 4, the encoding information capacity of this standard color set is: 7 (N-5) / 2+1 *4 (N-5) / 2 .

[0042] Table 1 A standard color set

[0043]

[0044] Figure 1 This is an example of a barcode defined in Table 1 in this embodiment, and the number of rectangular color blocks contained is N=21. Among them, the colors of the verification color blocks block1~block4 correspond to the standard colors CS1, CS2, CS3, and CS4 respectively, and their y component values ​​correspond to 0.00, 0.30, 0.14, and 0.23 respectively, all of which belong to dark attribute color blocks in the range of [0.00,0.30]. The verification code string formed is: ---++-+-+-++. The fifth rectangular color block corresponds to the first coded color block, and the y component value of the color blocks in the odd sequence of the coded color blocks satisfies [0.70,1.00], that is, the bright attribute color block with an attribute mark value of 1; the y component value of the color blocks in the even sequence of the coded color blocks satisfies [0.00,0.30], that is, the dark attribute color block with an attribute mark value of 0. Figure 1 In the figure, the 16-bit coded value string represented by the 16 coded color blocks is: 61734274512213645.

[0045] The specific steps of the above color bar code recognition and decoding method are as follows:

[0046] Step 1: Preprocess the RGB image to be identified containing the color barcode.

[0047] Step 1.1: The image to be identified containing the color barcode is acquired by a camera device, and the image size is assumed to be Q*A pixels.

[0048] Step 1.2: Perform a low-intensity Gaussian filter on the three channels of the image to be identified to reduce the interference of image noise on image segmentation and positioning. Among them, the low-intensity Gaussian filter refers to convolution processing of the image channel value with a Gaussian filter kernel with a small standard deviation. In this embodiment, a 3*3 Gaussian filter kernel with a small standard deviation is: [0.075, 0.124, 0.075; 0.124, 0.204, 0.124; 0.075, 0.124, 0.075].

[0049] Step 1.3: Perform histogram equalization processing on the channel values ​​of the image to be identified after Gaussian filtering to reduce the interference of image shadows or highlights on image segmentation and positioning.

[0050] Step 2: By determining the connected set characteristics of the Y channel of the image to be identified, the barcode is located and the image is segmented.

[0051] Step 2.1: Extract the Y channel component of each pixel in the RGB mode image to be identified f(x,y), retain 2 decimal places after the conversion, and then perform normalization to form a Y channel image g(x,y), where x, y are pixel coordinate values, x∈[1,Q], y∈[1,A].

[0052] Step 2.2: Extract all 8-connected sets with similar numbers of pixels in the Y channel image. In particular, because the decimal places of the y component values ​​are truncated, it is equivalent to quantizing the Y channel component values ​​of each pixel. Then, pixels with slight differences in the original y component values ​​also have the same values ​​after quantization, that is, the quantization process may have an 8-connected relationship. When the difference in the number of pixels between two 8-connected sets is less than the preset pix_dif, the two connected sets are considered to have similar numbers of pixels. For a group of 8-connected sets with similar numbers of pixels, calculate the average number of pixels pix_ave of these 8-connected sets. Preferably, when the pix_dif value is taken as 0.5%~3% of the total number of image pixels, a better connected set segmentation efficiency can be achieved.

[0053] Step 2.3: When there are more than pix_ave*k pixels in the 8-connected set A within the 8-neighborhood range of any pixel in the 8-connected set B, the 8-connected set A and the 8-connected set B are considered to have an adjacency relationship. The 8-connected sets with similar numbers of pixels and adjacency are aggregated to form a new connected set, and each 8-connected set in the new connected set is called an original connected set. When the number of original connected sets contained in the new connected set is [N, N+ΔN], the new connected set is considered to be a candidate barcode. According to the pixel coordinates of the new connected set, the Y channel image g(x,y) is segmented and the image to be identified after preprocessing in step 1 is segmented synchronously according to the corresponding relationship of the pixel coordinates, and the Y channel sub-image and RGB mode sub-image containing the candidate barcode are obtained respectively. If there is no new connected set that meets the conditions of the candidate barcode, it is determined that there is no color barcode in the image to be identified.

[0054] Preferably, when ΔN∈[5,10], k∈[5%,10%], the segmentation efficiency and accuracy can be better balanced. If the number of rectangular color blocks of the defined color bar code is N=21, when ΔN is set to 10, such as Figure 3 As shown, if the new connected set 1 contains 26 original connected sets, whose number is in the interval [21,31], then the new connected set 1 is a candidate barcode identification code; while the new connected set 2 contains only 8 original connected sets, whose number is not in the interval [21,31], then the new connected set 2 is not a candidate barcode identification code.

[0055] Step 3: Determine the characteristic conditions of the sub-images containing the candidate barcodes one by one, and finally locate and extract the barcode decoding area.

[0056] Step 3.1: If Figure 4 As shown, the first Y channel sub-image containing the candidate barcode is convolved with convolution kernels that focus on 8 gradient directions (0°, 45°, 90°, 135°, 180°, -135°, -90°, -45°), and each convolution kernel forms 8 feature sub-graphs after convolution of the candidate barcode. The average pixel value of each feature sub-graph (i.e., the average value of the y channel) is calculated, and the gradient directions corresponding to the two feature sub-graphs with the highest average pixel values ​​are recorded as α1 and α2 respectively. If α1 and α2 have an orthogonal relationship, i.e., the absolute value of the difference between α1 and α2 is 90°, then it is determined that the candidate barcode meets the first feature condition for barcode determination, otherwise, the first feature condition determination is performed on the next Y channel sub-image containing the candidate barcode. The Y channel sub-image that meets the first feature condition and its corresponding RGB mode sub-image are rotated by an angle of α1 to achieve normalization of the rotation characteristics of the image, i.e., the first angle correction is used to ensure that the method of the present invention can process barcodes with different rotation angles.

[0057] Step 3.2: Combined with the original connected set boundary in the candidate barcode obtained in step 2.3, the RGB mode sub-image corresponding to the Y channel sub-image that meets the first characteristic condition after the rotation processing in step 3.1 is divided into pixel blocks, and then pixel blocks that meet any of the following two conditions are extracted from the divided pixel blocks as candidate verification color blocks; Condition ①: One of the RGB channels of the pixel corresponding to the pixel block has a value less than the threshold th1, and the other two channel values ​​are greater than or equal to 2*th1 and the absolute value of the difference between the two channel values ​​is less than the threshold th2; Condition ②: The three RGB channel values ​​of the pixel corresponding to the pixel block are all less than the threshold th1.

[0058] Verify and decode the obtained candidate verification color blocks, decode the channel values ​​of pixels less than the threshold th1 as "-", and decode the channel values ​​of pixels greater than or equal to the threshold th1 as "+". If at least T color blocks among the candidate verification color blocks are continuously adjacent, then verify and decode twice from the positive order and the reverse order to form two groups of verification decoding strings. Among them, the continuous adjacency of multiple color blocks means that each color block can be aggregated into a continuous pixel block as a whole, and any color block has an adjacency relationship with the remaining one or two non-adjacent color blocks. Positive order verification decoding refers to scanning from the leftmost candidate verification color block to the right; reverse order verification decoding refers to scanning from the rightmost candidate verification color block to the left. If one of the verification decoding strings contains a complete verification encoding string defined by the standard, the verification decoding string is matched with the verification encoding string, and the candidate bar identification code is determined to meet the second characteristic condition of the bar identification code, and the several candidate verification color blocks corresponding to the verification decoding string are used as the verification area; otherwise, return to step 3.1 to perform the first characteristic condition judgment on the next Y channel sub-image containing the candidate bar identification code. Among them, for those that match the verification code string after reverse verification decoding, the Y channel sub-image and its corresponding RGB mode sub-image are rotated 180° to achieve the second angle correction.

[0059] In this embodiment, Figure 5 As shown, the candidate verification color block contains 6 colored pixel blocks that are continuously adjacent from left to right. Set th1=th2=10, then pixel block 2 meets condition ② that the values ​​of the three RGB channels are all less than 10, and pixel blocks 1, 3, 4, 5, and 6 meet condition ① that one of the RGB channel values ​​in the pixels of the pixel block is less than 10, and the values ​​of the other two channels are greater than or equal to 20 and the absolute value of their difference is less than 10. These 6 pixel blocks are verified and decoded in positive order from left to right, and the resulting 18-bit verification decoding string, where the 4th to 15th bits are consistent with a set of standard defined complete verification coding strings, is considered that the 2nd to 4th candidate verification color blocks corresponding to the 4th to 15th bits in the verification decoding string are the verification area.

[0060] Step 3.3: For the Y channel sub-image corresponding to the candidate barcode that meets the second characteristic condition, calculate the average value of all pixel coordinates (i.e., the average value of the y channel) for the corresponding verification area, and the pixel point corresponding to the average value is the center point of the verification area. Perform threshold processing on the original connected set in the Y channel sub-image. If the pixel value (y channel value) of the original connected set is less than 0.5, the attribute mark of the original connected set is mapped to 0; if the pixel value of the original connected set is greater than or equal to 0.5, the attribute mark of the original connected set is mapped to 1. In the Y channel sub-image, scan the original connected set from the coordinates of the center point of the verification area to the right, and record its attribute mark value from the first scanned original connected set that is not in the verification area, and stop when the (NT)th original connected set is scanned, thereby obtaining an attribute mark value string with (NT) bits containing only 0 and 1. Figure 6 As shown, the direction line scan_line with the center point of the verification area as the left endpoint represents the scanning path of the original connected set. If the attribute tag value string matches the color block attribute tag value string defined by the standard bit by bit, it is determined that the candidate bar identification code meets the third characteristic condition of the bar identification code, and the boundary where the (NT) original connected sets scanned in the candidate bar identification code are located is the boundary where the bar identification code decoding area that can be finally decoded is located; otherwise, return to step 3.1 to perform the first characteristic condition judgment on the next Y channel sub-image containing the candidate bar identification code. Preferably, the number of verification color blocks T∈[2,4,6] defined by the standard can obtain a more stable rectangular center to ensure that the connected set scanning path can completely pass through the actual encoding color block area. According to the boundary where the bar identification code decoding area that can be finally decoded is located, the bar identification code decoding area is extracted from the RGB mode sub-image corresponding to the Y channel sub-image that meets the third characteristic condition, and according to the boundary of the original connected set, the bar identification code decoding area is divided into (NT) decoding color blocks, recorded as d_block. i , i∈[1, NT], the color vector value of each decoded color block is d_c(d_block i ), i is the color block sequence identifier increasing from left to right.

[0061] In this embodiment, the number of verification color blocks of the bar code defined by the standard is T=4, and the number of encoding color blocks is N=17. The candidate bar code contains a total of 26 original connected sets S1~S26, of which S5~S8 are the verification area. The first decoded color block scanned from the center point of the verification area to the right that is not in the verification area is S9, and the y component value of its pixel is 0.78, and its attribute mark value is recorded as 1. Then, the original connected sets S9~S26 are scanned in turn in the same attribute mark value statistical method, and a total of 17 attribute mark value strings with 0 and 1 intervals are obtained, which are compared with Figure 2If the defined encoding color block attribute mark string matches bit by bit, the area where the decoding color blocks S9 to S26 are located is considered to be the boundary of the bar identification code decoding area that can be finally decoded.

[0062] Step 4: Decode the barcode decoding area.

[0063] For each decoded color block, calculate the average value of each RGB channel value of all pixels in it to form a decoded color block d_block i The decoded color vector c(d_block i )={r(d_block i ), g(d_block i ), b(d_block i )}, and then calculate the Euclidean distance between each code color vector in the odd sequence and each element in the vector element subset CSJ of the standard color set CS one by one, and the calculation formula is:

[0064]

[0065] The Euclidean distance between each code color vector in the even sequence and each element in the vector element subset CSO of the standard color set CS is calculated one by one. The calculation formula is:

[0066]

[0067] Take the CSJ with the smallest distance value i or CSO i As each decoded color block d_block i The standard color, the encoding value corresponding to the standard color is the decoding color block d_block i The decoded value of .

[0068] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for encoding a color barcode, characterized in that: It includes N rectangular single-color blocks that are aligned and spliced ​​in sequence along the width direction of the color blocks; the first T rectangular color blocks are used as verification color blocks, each verification color block takes a different standard color and the brightness component is lower than the preset threshold Th_Y1; the last (NT) rectangular color blocks are used as coding color blocks, in the coding color block sequence, the coding color blocks of each odd sequence take a color from j standard colors and the brightness component is higher than the preset threshold Th_Y2, the coding color blocks of each even sequence take a color from o standard colors and the brightness component is lower than the preset threshold Th_Y1, and there is no color overlap between the j standard colors and the o standard colors, Th_Y2>0.5>Th_Y1; the coding color blocks of different standard colors represent different coding values.

2. The method for encoding a color barcode according to claim 1, characterized in that: The value range of N is 20~30, the value range of T is 2~6, and let Z=T+j+o, the value range of Z is 10~20.

3. The method for encoding a color barcode according to claim 1, characterized in that: The RGB channel value of each standard color is selected from p equally spaced fixed grayscale values.

4. The method for encoding a color barcode according to claim 3, characterized in that: For T verification color blocks, the RGB channel value of the color of one verification color block is {0,0,0}; one of the RGB channels of the color of the remaining verification color blocks has a channel value of 0, and the values ​​of the other two channels are equal; for the verification color block with a channel value of {0,0,0}, its representation verification code is "---"; for the remaining verification color blocks, the channel representation verification code of the channel value of 0 is "-", and the channel representation verification code of the channel value of 1 is "+".

5. The method for identifying and decoding a color barcode according to any one of claims 1 to 4, characterized in that: include: Step 1: preprocessing the RGB mode image to be identified containing the color bar code; Step 2: By determining the Y channel connectivity characteristics of the image to be identified, the barcode is located and the image is segmented; Step 3: Determine the characteristic conditions of the sub-images containing the candidate barcode obtained in step 2 one by one, and finally locate and extract the barcode decoding area; Step 4: Perform a decoding operation on the bar code decoding area to obtain a decoding value of the color bar code.

6. The method for identifying and decoding a color barcode according to claim 5, characterized in that: The step 2 comprises: Step 2.1: Extract the Y channel component of each pixel in the image to be identified in the RGB mode, and retain the y component value after conversion to 2 decimal places, and then perform normalization processing to form a Y channel image; Step 2.2: Extract all 8-connected sets with similar number of pixels in the Y channel image; Step 2.3: Aggregate the 8-connected sets with similar numbers of pixels and adjacency to form a new connected set, and each 8-connected set in the new connected set is called an original connected set; when the number of original connected sets contained in the new connected set is [N, N+ΔN], ΔN∈[5,10], the new connected set is considered to be a candidate barcode, and according to the pixel coordinates of the new connected set, the Y channel image is segmented and the image to be identified after preprocessing in step 1 is segmented synchronously according to the corresponding relationship of the pixel coordinates, and the Y channel sub-image containing the candidate barcode and the RGB mode sub-image are obtained respectively.

7. The method for identifying and decoding a color barcode according to claim 6, characterized in that: The step 3 comprises: Step 3.1: Convolve the first Y channel sub-image containing the candidate barcode in 8 gradient directions to form 8 feature sub-graphs, calculate the average pixel value of each feature sub-graph, and record the gradient directions corresponding to the two feature sub-graphs with the highest average pixel values ​​as α1 and α2 respectively. If α1 and α2 are orthogonal, it is determined that the candidate barcode meets the first feature condition. Otherwise, the first feature condition is determined for the next Y channel sub-image containing the candidate barcode; rotate the Y channel sub-image that meets the first feature condition and its corresponding RGB mode sub-image by an angle of α1; Step 3.2: According to the original connected set boundary in the candidate barcode obtained in step 2.3, the RGB mode sub-image after the rotation processing in step 3.1 is divided into pixel blocks, and then the pixel blocks that meet any of the following two conditions are extracted from the divided pixel blocks as candidate verification color blocks; wherein condition ①: one of the RGB channels of the pixel corresponding to the pixel block has a channel value less than the threshold value th1, and the other two channel values ​​are greater than or equal to 2*th1, and the absolute value of the difference between the two channel values ​​is less than the threshold value th2; condition ②: the three RGB channel values ​​of the pixel corresponding to the pixel block are all less than the threshold value th1; verification decoding is performed on the obtained candidate verification color blocks, and the channel value of the pixel less than the threshold value th1 is decoded as "-", and the channel value of the pixel greater than or equal to the threshold value th1 is decoded as "+", so as to form a verification decoding string; if the verification decoding string contains the complete verification code string defined by the color barcode, it is determined that the candidate barcode satisfies the second characteristic condition, and the candidate verification color blocks corresponding to the verification decoding string are used as the verification area; otherwise, return to step 3.1 to perform the first characteristic condition judgment on the next Y channel sub-image containing the candidate barcode; Step 3.3: For the Y channel sub-image corresponding to the candidate barcode that meets the second characteristic condition, threshold processing is performed on the original connected set in the Y channel sub-image. If the pixel value of the original connected set is less than 0.5, the attribute tag of the original connected set is mapped to 0; if the pixel value of the original connected set is greater than or equal to 0.5, the attribute tag of the original connected set is mapped to 1; in the Y channel sub-image, the attribute tag value string of the (NT) original connected sets connected to the verification area is obtained. If the attribute tag value string is consistent with the color barcode standard definition, If the color block attribute tag value string matches bit by bit, it is determined that the candidate barcode meets the third characteristic condition, and the boundary where the (NT) original connected sets in the candidate barcode are located is the boundary where the barcode decoding area for final decoding is located; otherwise, return to step 3.1 to perform the first characteristic condition judgment on the next Y channel sub-image containing the candidate barcode; extract the barcode decoding area from the RGB mode sub-image corresponding to the Y channel sub-image, and divide the barcode decoding area into (NT) decoding color blocks according to the boundary of the original connected set.

8. The method for identifying and decoding a color barcode according to claim 6 or 7, characterized in that: The steps include: for each decoding color block in the bar identification code decoding area, respectively calculating the average value of each RGB channel value of all pixels in each decoding color block to form a decoding color vector of each decoding color block, and then performing Euclidean distance calculation on each code color vector located in an odd sequence and a three-dimensional vector of each color in the j standard colors, and performing Euclidean distance calculation on each code color vector located in an even sequence and a three-dimensional vector of each color in the o standard colors, respectively taking the standard color corresponding to the minimum distance value as the color of each decoding color block, and the encoding value corresponding to each standard color is the decoding value of each decoding color block.

9. The method for recognizing and decoding a color barcode according to claim 7, characterized in that: In the step 3.3, in the Y channel sub-image, the original connected set is scanned to the right starting from the coordinates of the center point of the verification area, and its attribute tag value is recorded starting from the first scanned original connected set that is not in the verification area, and the scanning stops when the (NT)th original connected set is scanned, thereby obtaining an attribute tag value string with (NT) bits containing only 0 and 1.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for recognizing and decoding the color barcode described in any one of claims 5-9 is implemented.