Dm code detection and identification method and device, computer device, and storage medium

CN116258155BActive Publication Date: 2026-09-22JIANGSU ZHONGKEGUANWEI AUTOMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211708872.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-29
Publication Date
2026-09-22
Estimated Expiration
2042-12-29

AI Technical Summary

Technical Problem

但是在工业环境下,存在背景杂乱、条码受损等复杂情况,上述方案很难保证DM码检测识别的准确性

Benefits of technology

[0058]本申请涉及一种DM码检测识别方法、装置、计算机设备、存储介质。方法包括:获取待处理图像;使用目标检测算法对待处理图像进行处理,得到粗定位个图像;使用像素累计方法对粗定位图像进行处理,得到细定位数据;根据细定位数据对粗定位图像进行仿射变换和网格划分处理,得到标准图像;根据标准图像进行解码,得到识别结果。通过两次定位过程,能够保证在工业复杂环境下DM码检测识别的准确率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116258155B_ABST
    Figure CN116258155B_ABST
Patent Text Reader

Abstract

The application relates to a DM code detection and recognition method and device, computer equipment and a storage medium. The method comprises the following steps: acquiring an image to be processed; processing the image to be processed by using a target detection algorithm to obtain a coarsely positioned image; processing the coarsely positioned image by using a pixel accumulation method to obtain fine positioning data; performing affine transformation and grid division processing on the coarsely positioned image according to the fine positioning data to obtain a standard image; and decoding the standard image to obtain a recognition result. The method can ensure the accuracy of DM code detection and recognition in an industrial complex environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a DM code detection and recognition method, apparatus, computer equipment, and storage medium. Background Technology

[0002] With the advent of the information age and the development of computer technology, the requirements for information density and information security are becoming increasingly stringent. QR codes, with their large information capacity and strong error correction capabilities, are facing broader application demands and more diverse usage scenarios. As a type of QR code, DM (Data Matrix) codes, with their high information density and strong error correction capabilities, are widely used in fields such as coding management, warehousing and logistics, and industrial manufacturing.

[0003] A typical DM code detection and recognition scheme includes: using Hough transform to detect the DM code localization pattern for DM code localization and recognition; using the YOLOv3-Tiny target detection model to quickly locate the ROI (Region of Interest) containing the DM code in the image to be detected; traversing the ROI cyclically according to a preset trajectory to accurately locate and recognize the DM code; constructing a multi-layer image pyramid sequence and searching for DM code localization edges in the pyramid image, accurately locating the DM code position based on the DM code localization edges, obtaining an accurate DM code image and recognizing it.

[0004] The above-described solution can meet the accuracy requirements for DM code detection and recognition in scenarios with simple backgrounds and neat barcodes, such as detecting and recognizing DM codes on printed materials. However, in industrial environments, where there are complex situations such as cluttered backgrounds and damaged barcodes, the above-described solution can hardly guarantee the accuracy of DM code detection and recognition. Summary of the Invention

[0005] Therefore, it is necessary to provide a DM code detection and recognition method, device, computer equipment, and computer-readable storage medium that can ensure the accuracy of detection and recognition under complex conditions such as complex backgrounds and damaged barcodes, in order to address the above-mentioned technical problems.

[0006] Firstly, this application provides a DM code detection and recognition method. The method includes:

[0007] Obtain the image to be processed;

[0008] The image to be processed is processed using an object detection algorithm to obtain a coarse localization image; the coarse localization image includes the DM code to be identified.

[0009] The coarse localization image is processed using a pixel accumulation method to obtain fine localization data;

[0010] A affine transformation and mesh generation are performed on the coarse positioning image based on the fine positioning data to obtain a standard image.

[0011] The recognition result is obtained by decoding the standard image.

[0012] In one embodiment, an object detection algorithm is used to process the image to be processed to obtain a coarse localization image, including:

[0013] The image to be processed is scaled and normalized to obtain a normalized image;

[0014] The normalized image was processed using the YoloV5-Nano target detection model to obtain a coarse localization image. The YoloV5-Nano target detection model includes three detection heads with downsampling factors of 8, 16, and 32.

[0015] In one embodiment, during the step of processing the image to be processed using a target detection algorithm, process category data is obtained; the process category data is used to indicate the process category for creating the DM code to be identified.

[0016] The coarse localization image is processed using a pixel accumulation method to obtain fine localization data, including:

[0017] When the process type is printing, the coarse positioning image is processed by Gaussian filtering to obtain the filtered image; the filtered image is then processed by local threshold binarization to obtain the coarse binarized image.

[0018] When the process category is dot-matrix forming, the coarse positioning image is stretched in grayscale to obtain the stretched image; the stretched image is then subjected to Gaussian filtering to obtain the filtered image; and the filtered image is then subjected to local threshold binarization to obtain the coarse binarized image.

[0019] The coarse binarized image is processed using a pixel accumulator to obtain fine localization data. The pixel accumulator is used to statistically analyze the pixel distribution in the corresponding direction to obtain the pixel block distribution pattern and edge transition position in that direction.

[0020] In one embodiment, the fine positioning data includes the four corner coordinates of the DM code to be identified; the four corner coordinates include the intersection coordinates of the three corner coordinates corresponding to the positioning edge and the clock edge.

[0021] The coarse binarized image is processed using a pixel accumulator to obtain fine localization data, including:

[0022] Use a pixel accumulator to statistically analyze the texture features of the coarse binarized image;

[0023] Based on texture features, the localized edges and their corresponding three angular coordinates are determined through edge tracking and constraint conditions.

[0024] The module width is determined based on the statistical characteristics calculated by the pixel accumulator on the positioning edge;

[0025] Based on the three angular coordinates corresponding to the positioning edge and the module width, the clock edge and the corresponding intersection coordinates are obtained.

[0026] In one embodiment, an affine transformation and mesh generation process are performed on the coarse positioning image based on the fine positioning data to obtain a standard image, including:

[0027] Based on the four corner coordinates of the DM code to be identified, an affine transformation is performed on the coarse positioning image to obtain the corrected image;

[0028] The corrected image is preprocessed to obtain a fine binarized image;

[0029] The finely binarized image is divided into grids to obtain a standard image.

[0030] In one embodiment, the finely binarized image is subjected to grid division processing to obtain a standard image, including:

[0031] Use a pixel accumulator to statistically analyze the texture features of a finely binarized image;

[0032] Based on the texture features of the fine binarized image, the positioning edges are redefined;

[0033] Based on the statistical results of the pixel accumulator on the clock edge, the clock edge and the module boundary point are redefined.

[0034] Starting from the module boundary point, trace the gradient edges to form grid lines;

[0035] The standard image is obtained by dividing the image into finer binary segments based on the grid lines.

[0036] In one embodiment, the fine positioning data includes the dimension of the DM code to be identified; the dimension of the DM code to be identified is determined based on the statistical features obtained from the pixel accumulator on the clock edge and the module width;

[0037] Decoding is performed on the standard image to obtain the recognition results, including:

[0038] Determine the decoding parameters based on the dimension of the DM code to be identified;

[0039] Based on the decoding parameters, the standard image is decoded to obtain the recognition result.

[0040] Secondly, this application also provides a DM code detection and recognition device. The device includes:

[0041] The acquisition module is used to acquire the image to be processed;

[0042] The coarse localization module is used to process the image to be processed using an object detection algorithm to obtain a coarse localization image; the coarse localization image includes the DM code to be identified.

[0043] The fine localization module is used to process the coarse localization image using a pixel accumulation method to obtain fine localization data;

[0044] The correction module is used to perform affine transformation and mesh division processing on the coarse positioning image based on the fine positioning data to obtain a standard image;

[0045] The recognition module is used to decode the standard image to obtain the recognition result.

[0046] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0047] Obtain the image to be processed;

[0048] The image to be processed is processed using an object detection algorithm to obtain a coarse localization image; the coarse localization image includes the DM code to be identified.

[0049] The coarse localization image is processed using a pixel accumulation method to obtain fine localization data;

[0050] A affine transformation and mesh generation are performed on the coarse positioning image based on the fine positioning data to obtain a standard image.

[0051] The recognition result is obtained by decoding the standard image.

[0052] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0053] Obtain the image to be processed;

[0054] The image to be processed is processed using an object detection algorithm to obtain a coarse localization image; the coarse localization image includes the DM code to be identified.

[0055] The coarse localization image is processed using a pixel accumulation method to obtain fine localization data;

[0056] A affine transformation and mesh generation are performed on the coarse positioning image based on the fine positioning data to obtain a standard image.

[0057] The recognition result is obtained by decoding the standard image.

[0058] This application relates to a DM code detection and recognition method, apparatus, computer equipment, and storage medium. The method includes: acquiring an image to be processed; processing the image to be processed using a target detection algorithm to obtain a coarse localization image; processing the coarse localization image using a pixel accumulation method to obtain fine localization data; performing affine transformation and mesh division processing on the coarse localization image based on the fine localization data to obtain a standard image; and decoding based on the standard image to obtain the recognition result. Through these two localization processes, the accuracy of DM code detection and recognition can be guaranteed even in complex industrial environments. Attached Figure Description

[0059] Figure 1 This is a schematic diagram of an exemplary structure of a DM code in one embodiment;

[0060] Figure 2 This is a flowchart illustrating a DM code detection and recognition method in one embodiment;

[0061] Figure 3 This is a flowchart illustrating the process of using an object detection algorithm to process an image to obtain a coarse localization image in one embodiment.

[0062] Figure 4 This is an exemplary schematic diagram of the image to be processed in one embodiment;

[0063] Figure 5 This is an exemplary schematic diagram of a coarse positioning image in one embodiment;

[0064] Figure 6 This is a schematic diagram illustrating the process of using a pixel accumulation method to process a coarse localization image to obtain fine localization data in one embodiment.

[0065] Figure 7 This is a schematic diagram of the process of processing a coarse binarized image based on a pixel accumulator to obtain fine localization data in one embodiment;

[0066] Figure 8 This is an exemplary schematic diagram of the four corners of the DM code to be identified in one embodiment;

[0067] Figure 9 This is a flowchart illustrating the process of performing affine transformation and mesh division on a coarse positioning image based on fine positioning data to obtain a standard image in one embodiment.

[0068] Figure 10 This is an exemplary schematic diagram of the corrected image in one embodiment;

[0069] Figure 11 This is a schematic diagram illustrating the process of dividing a finely binarized image into a grid to obtain a standard image in one embodiment.

[0070] Figure 12This is an exemplary schematic diagram of grid lines defined in one embodiment;

[0071] Figure 13 This is a structural block diagram of a DM code detection and recognition device in one embodiment;

[0072] Figure 14 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0073] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0074] like Figure 1 The diagram shows an exemplary structure of a DM code. The DM code includes two orthogonal positioning edges (solid lines) and two orthogonal clock edges (dashed lines). The area enclosed by the positioning edges and clock edges is the data area and the silence area; the data area is composed of modules of roughly the same size. The DM code stores information through an arrangement of modules of varying depths, encoding data in binary code, which can be directly read by a computer. The L-shaped positioning edges and L-shaped clock edges together form the positioning pattern of the DM code. The positioning pattern is the same for DM codes within the same version, but the data area varies depending on the data being expressed.

[0075] In one embodiment, such as Figure 2 As shown, a DM code detection and recognition method is provided, which can be applied to various barcode scanners, personal computers, laptops, tablets, smartphones, IoT devices, and portable wearable devices. The DM code detection and recognition method includes the following steps:

[0076] Step 202: Obtain the image to be processed. For example, the image to be processed may be an image containing the DM code to be recognized, obtained by the image acquisition system in the barcode scanner.

[0077] Step 204: Use an object detection algorithm to process the image to be processed to obtain a coarse localization image; the coarse localization image includes the DM code to be identified.

[0078] Step 206: Process the coarse localization image using the pixel accumulation method to obtain fine localization data.

[0079] Step 208: Perform affine transformation and mesh division on the coarse positioning image based on the fine positioning data to obtain the standard image.

[0080] Step 210: Decode the standard image to obtain the recognition result.

[0081] In the above-mentioned DM code detection and recognition method, a target detection model is used to coarsely locate the DM code to obtain a coarsely located image. Then, the pixel accumulation method is used to accurately locate and recognize the DM code. Through two positioning processes, the accuracy of DM code detection and recognition in complex industrial environments is guaranteed.

[0082] In one embodiment, such as Figure 3 As shown, step 204 of the DM code detection and recognition method uses a target detection algorithm to process the image to be processed, obtaining a coarse localization image, including:

[0083] Step 302: Scale and normalize the image to be processed to obtain a normalized image.

[0084] The image to be processed, acquired by the image acquisition system, is scaled to a size of (320, 320), and then normalized. For example, the normalization process can be described by the following formula:

[0085]

[0086] Where mean_ = [0.485, 0.456, 0.406] is the mean of the three channels of the scaled image, and std_value = [0.229, 0.224, 0.225] is the variance of the three channels of the scaled image.

[0087] Step 304: The normalized image is processed using the YoloV5-Nano target detection model to obtain a coarse localization image; wherein, the YoloV5-Nano target detection model includes three detection heads with downsampling factors of 8, 16, and 32.

[0088] The detection of the region containing the DM code to be identified was performed by the YoloV5-Nano object detection model. The Yolo object detection model is a convolutional neural network capable of predicting the positions and categories of multiple bounding boxes simultaneously, primarily used for end-to-end object detection and recognition. YoloV5-Nano is the Nano version of the deep learning-based YoloV5 object detection model.

[0089] For example, if the image to be processed includes a DM code to be identified, the YoloV5-Nano object detection model outputs the position of the detection box corresponding to the DM code to be identified; based on the position of the detection box, a coarse localization image is obtained.

[0090] If the YOLOV5-Nano object detection model does not output the location of the detection box, it can be assumed that the image to be processed does not contain the DM code to be identified, and the current detection and recognition process ends. The prompt message "No DM code found" can be output.

[0091] The scale of the DM code to be identified in the image is unstable. During the detection and identification process, the YoloV5-Nano target detection model uses three detection heads with downsampling factors of 8, 16, and 32, which correspond to the small, medium, and large scale of the DM code to be identified, respectively.

[0092] like Figure 4 The image shown is an example schematic diagram of the image to be processed. Figure 5 The image shown is an example schematic diagram of a coarse localization image obtained using the detection and recognition method of this embodiment.

[0093] In one embodiment, in the DM code detection and recognition method, during the step of processing the image to be processed using a target detection algorithm model, process category data is obtained; the process category data is used to indicate the process category of the DM code to be recognized.

[0094] like Figure 6 As shown, the DM code detection and recognition method includes the following steps: processing the coarse localization image using a pixel accumulation method to obtain fine localization data.

[0095] Step 602: When the process type is printing, the coarse positioning image is subjected to Gaussian filtering to obtain the filtered image; the filtered image is subjected to local threshold binarization to obtain the coarse binarized image.

[0096] Step 604: When the process category is dot-matrix forming, the coarse positioning image is stretched in grayscale to obtain the stretched image; the stretched image is processed by Gaussian filtering to obtain the filtered image; the filtered image is processed by local threshold binarization to obtain the coarse binarized image.

[0097] Step 606: Process the coarse binarized image based on the pixel accumulator to obtain fine localization data. The pixel accumulator is used to statistically analyze the pixel distribution in a corresponding direction to obtain the pixel block distribution pattern and edge transition positions in that direction; the pixel accumulator can be considered an image feature extractor.

[0098] The coarse localization image is processed so that its pixel values ​​are only 0 and 255. The coarse localization image is binarized.

[0099] For printed DM codes, since their edges are smooth and linear and have high contrast, Gaussian filtering is used to smooth the image to remove noise interference while retaining edge pixels for easy positioning. Then, local threshold binarization is used to reduce the influence of uneven illumination and divide the pixel values ​​into 0 and 255, resulting in a coarse binarized image.

[0100] For DM codes formed by dot matrix, since they have many gradient directions and are more susceptible to illumination, the contrast is first improved by grayscale stretching, then the image is blurred by Gaussian filtering to fuse the intermittent dots into lines for easy positioning, and finally the image is transformed into a coarse binarized image with pixel values ​​of only 0 and 255 by local threshold binarization.

[0101] In the above-mentioned DM code detection and recognition method, by distinguishing different DM code process categories, it can effectively be compatible with different DM code production processes and working scenarios. At the same time, the coarse positioning image is binarized to reduce the impact of uneven lighting on the detection and recognition process.

[0102] In one embodiment, the fine positioning data is the coordinates of the four corners of the DM code to be identified; the four corner coordinates include the coordinates of the intersection of the three corner coordinates corresponding to the positioning edge and the clock edge.

[0103] like Figure 7 The diagram shows the process of using the pixel accumulation method to process the coarse binarized image and obtain fine localization data in this DM code detection and recognition method, including:

[0104] Step 702: Use a pixel accumulator to count the texture features of the coarse binarized image.

[0105] Step 704: Based on the texture features, determine the positioning edge and its corresponding three angular coordinates through edge tracking and constraint conditions.

[0106] The texture features of the entire image are statistically analyzed using horizontal and vertical pixel accumulators. Edge pixels with a certain linewidth are tracked, and the area of ​​connected components is calculated using pixel accumulators to further calculate the average linewidth. Possible positioning edges are then selected using an average linewidth constraint formula.

[0107] The connected region area refers to the area of ​​a pixel block with a certain width, obtained by searching for the starting points of the pixel block with a certain width using a pixel accumulator. If the starting points of multiple consecutive rows (or columns) are adjacent, they are considered connected. The accumulated width of the pixel block containing these starting points is the connected region area. Dividing the connected region area by the number of consecutive adjacent starting points found and then multiplying by the corresponding coefficient yields the average line width.

[0108] The constraint formula for the average line width is: S <kl 2 In the context of edge tracking, S is the area formed by the cumulative line width of the tracking points, l is the length of the line formed by the tracking points, and k is the threshold of the constraint formula.

[0109] Since the two positioning edges in the coarse positioning image are approximately orthogonal, when the coarse positioning image is not rotated, the average line width is at least twice the module width. Therefore, S = (l^2) / 4 should be the minimum value that the upper limit threshold for line width determination can take. If we assume that the positioning edges are made into a completely black square, then half the area of ​​this square, S = (l^2) / 2, should be the maximum value that the upper limit threshold for line width determination can take. Further considering the angles of the positioning edges relative to the horizontal and vertical pixel accumulators caused by image rotation and distortion, but also considering that standard relaxation will increase interfering lines, the upper limit threshold k for line width determination should be selected in [1 / 4, 1 / 2].

[0110] Given that the edge of the positioning point is a solid color, the area outside the positioning point is a solid color different from the positioning line, and the area inside the positioning line has rich gradients at the edge of the data region, the pixel accumulator can be moved in the direction of the positioning point to count gradient features and filter the positioning points.

[0111] For example, the pixel accumulator is rotated to the suspected positioning edges selected by the average linewidth constraint formula, and the texture features at that location are statistically analyzed. Since positioning edges are a uniform color, suspected positioning edges should mostly consist of continuous connected regions of the same color with few edges; otherwise, they are not positioning edges. Next, the pixel accumulator is shifted outward. Since the area outside the positioning edge is a uniform color different from the positioning edge, cases where most are continuous connected regions of a solid color with few edges should be selected for the next matching step. For candidate positioning edges that meet the conditions, the pixel accumulator on it is shifted inward by the previously estimated distance of one to two average linewidths to check if it belongs to the data area. Since the edges of the data area are rich and the colors are interlaced, only those that meet the statistical characteristic of frequent color changes can be retained. Only those that meet the above three selection conditions can be retained as positioning edges.

[0112] Since the positioning edges of the DM code are orthogonal and intersect, we can select pairs of positioning edges to determine the three angular coordinates of the DM code.

[0113] Step 706: Determine the module width based on the statistical features obtained from the pixel accumulator on the positioning edge.

[0114] The statistical features obtained from the pixel accumulator on the positioning edge, for example, the area of ​​the connected region divided by the length of the line segment on the positioning edge, yields the average line width on the positioning edge, which is then used to determine the module width.

[0115] Step 708: Based on the three angular coordinates corresponding to the positioning edge and the module width, obtain the clock edge and the corresponding intersection coordinates.

[0116] Based on the rectangular shape of the DM code, the coordinates of the fourth corner of the DM code to be identified are deduced, which is the intersection point of the clock edges. It is known that the two ends of the clock edge have different colors, and the width of the color block is approximately the average line width (i.e., the estimated module width). The entire clock edge has many overlapping edges, and the area outside the clock edge is a solid color. The pixel accumulator is moved to the suspected clock edge position, and the pixel accumulator is rotated to analyze the texture features at that location. Using the module width as a constraint, edges that satisfy the conditions of frequent color block changes, different color blocks at both ends of the line segment, and a unified color block connected region after outward translation are considered clock edges. The intersection point of two clock edges that meet the above conditions is the fourth corner point of the DM code to be identified, and the coordinates of the intersection point corresponding to the clock edge are obtained. This achieves precise localization of the DM code to be identified. Figure 8 As shown, these are the coordinates of the four corners of the DM code to be identified in this embodiment. Points A, B, and C are the three corners corresponding to the positioning edge, and point D is the coordinate of the intersection point corresponding to the clock edge.

[0117] like Figure 9 As shown, in one embodiment, the DM code detection and recognition method performs affine transformation and grid division processing on the coarse positioning image based on the fine positioning data to obtain a standard image, including:

[0118] Step 902: Based on the four corner coordinates of the DM code to be identified, perform an affine transformation on the coarse positioning image to obtain the corrected image.

[0119] The coarse localization image is corrected by performing affine transformations on the four corners of the DM code to be identified. The affine transformation matrix can be obtained by the following formula:

[0120]

[0121] Where (x, y) are the coordinates of a point in the image before the affine transformation, (x′, y′) are the coordinates of the corresponding point after the affine transformation, ω is a coefficient, and the 3×3 matrix is ​​the affine transformation matrix H. After obtaining the affine transformation matrix H, an inverse affine transformation can be performed on the distorted image to finally obtain the image after affine transformation correction, such as... Figure 10 As shown.

[0122] Step 904: Preprocess the corrected image to obtain a fine binarized image.

[0123] The preprocessing process includes: first, improving the contrast of the corrected image by grayscale stretching; then, smoothing the image by Gaussian filtering to remove noise interference; and finally, reducing the influence of uneven illumination by local threshold binarization to obtain a fine binarized image.

[0124] Step 906: Perform grid division processing on the fine binarized image to obtain a standard image.

[0125] In one embodiment, such as Figure 11 As shown, the finely binarized image is divided into grids to obtain a standard image, including:

[0126] Step 1102: Use a pixel accumulator to statistically analyze the texture features of the fine binarized image.

[0127] Step 1104: Based on the texture features of the fine binarized image, redetermine the positioning edges.

[0128] Step 1106: Based on the statistical results of the pixel accumulator on the clock edge, redetermine the clock edge and the module boundary point.

[0129] Step 1108: Starting from the module boundary point, trace the gradient edge to form a grid line.

[0130] Step 1110: Divide the image into finer binarized segments according to the grid lines to obtain a standard image.

[0131] In this embodiment, the positioning edges are detected by statistical histograms using horizontal and vertical pixel accumulators, and the positioning edges of the DM code to be identified are repositioned. Then, the clock edge is repositioned based on the pixel accumulator at the clock edge, and the module boundary point is determined. Finally, the tracking gradient edge is triggered from the module boundary point to form grid lines. Figure 12 The image shown is a schematic diagram illustrating an example of the grid lines determined in this embodiment. A standard image is obtained by refining the binary image based on the grid lines.

[0132] For fine binarized images, the clock edge and positioning edge are repositioned to reduce the number of cases where they are not adjusted due to dirt or distortion, thereby improving the accuracy of grid line division.

[0133] In one embodiment, the fine positioning data includes the dimension of the DM code to be identified; the dimension of the DM code to be identified is determined based on the statistical characteristics obtained from the pixel accumulator on the clock edge and the module width.

[0134] Based on the pixel features statistically analyzed by the pixel accumulator on the clock edge and the estimated module width, and taking into account factors such as distortion, lossless, and noise that may lead to module classification or merging, the estimated DM code bit length is scored, and dimension detection is performed in the horizontal and vertical directions respectively.

[0135] In a standard DM code, the clock edge should consist of two colors alternating at equal widths, and the total number of color blocks is the dimension of the DM code. Therefore, the dimension of the DM code to be identified can be calculated by statistically analyzing the distribution of color blocks on the clock edge.

[0136] For example, the pixel accumulator is moved to the clock edge to perform texture feature statistics, and line-by-line detection is performed by translating from the outside in. Using the average line width estimated above as a constraint, thresholds are set for widths that are too small, moderate, or too large. The width of each color block is checked sequentially. If all color blocks have moderate widths, the highest score is awarded, indicating that a dimension has been detected in that direction. The pixel accumulator is then stopped, ending the dimension detection in that direction. If a color block is too large, it is directly split and points are deducted. The detected dimension results and scores are recorded, and the pixel accumulator continues to be translated to detect dimensions. If any color block is too small, the sum of the widths of the current color block and the three color blocks to its left and right is calculated, along with the sum of the widths of the current color block and the two color blocks to its right. Various scenarios are analyzed and considered. If the result completely violates the dimension distribution pattern, the current detection is terminated, and the pixel accumulator continues to be translated. Otherwise, the color blocks are merged and points are deducted. The dimension detection results and scores are recorded, and the pixel accumulator continues to be translated.

[0137] If the dimension with the highest score exists, then that dimension is used as the dimension for this direction. Otherwise, first exclude dimensions with too low scores, then calculate the weighted sum of the occurrence frequency and score of the remaining dimension detection results, and take the dimension detection result with the highest score among the maximum values ​​as the dimension for this direction.

[0138] In this embodiment, decoding based on a standard image to obtain a recognition result includes: determining decoding parameters based on the dimension of the DM code to be recognized; and decoding the standard image based on the decoding parameters to obtain the recognition result. The DM code is decoded according to the Reed-Solomon (RS) encoding rule.

[0139] In this embodiment, the dimensional features of the DM code to be identified are determined by the statistical features and module width obtained by the pixel accumulator on the clock edge. This can effectively accommodate different manufacturing processes and working conditions, improve the accuracy of dimensional detection, and thus ensure the accuracy of decoding.

[0140] In one embodiment, the DM code detection and recognition method includes the following steps:

[0141] (1) Coarse positioning of DM code, specifically including:

[0142] Coarse image preprocessing: The image to be processed is scaled to a fixed size and normalized to obtain a normalized image.

[0143] Location and classification using object detection algorithms: The Nano version of the deep learning object detection algorithm YOLOv5 is used to detect the region where the DM code to be identified is located, and the manufacturing process and code character contrast are classified.

[0144] (2) Image preprocessing and DM code localization, specifically including:

[0145] DM code image preprocessing includes grayscale stretching, smoothing filtering, and binarization to obtain a coarse binarized image.

[0146] DM code fine localization includes edge detection, virtual edge intersection correction, module width, and dimension estimation. Based on the coarsely binarized image obtained from DM code image preprocessing, the texture features of the entire image are statistically analyzed using horizontal and vertical pixel accumulators. Edge tracking and constraint condition determination are used to detect and locate edges to determine the three angular coordinates of the DM code to be identified. The module width is estimated based on the statistical features calculated by the pixel accumulator on the located edges, and clock edges are detected to achieve fine localization of the DM code to be identified. The dimension of the DM code to be identified is estimated based on the statistical features of the pixel accumulator on the virtual edges and the estimated module width.

[0147] (3) Affine transformation and DM code recognition, specifically including:

[0148] Affine transformation: By performing an affine transformation on the four corner coordinates of the DM code to be identified, the coarse positioning image is corrected to a standard shape, resulting in a corrected image.

[0149] Fine image preprocessing includes grayscale stretching, smoothing filtering, and binarization to obtain a fine binarized image.

[0150] Mesh generation includes secondary edge localization, clock edge detection, and gradient tracking. Based on the fine binarized image obtained from the aforementioned fine image preprocessing, edges are detected using histograms calculated from horizontal and vertical pixel accumulators. Clock lines and module boundary points are located using pixel accumulators at clock edges. Gradient edges are tracked from the module boundary points to form mesh generation symbols. Finally, decoding is performed according to the RS encoding rules of the DM code.

[0151] The DM code detection and recognition method provided in the above embodiments can accurately detect, locate, and recognize the DM code to be recognized in complex scenes with uneven lighting, rich textures, and large deviations in image acquisition angles; it can effectively recognize DM codes that are damaged, blurred, folded, or otherwise damaged; it is effectively compatible with various DM code manufacturing processes and different working scenarios; it improves the accuracy of detection and recognition and ensures high real-time performance.

[0152] In one embodiment, in the DM code detection and recognition method, if there are multiple DM codes to be recognized in the image to be recognized, then processing the image using a target detection algorithm will output multiple detection boxes; or, if there is only one DM code to be recognized in the image to be recognized, but processing the image using a target detection algorithm results in false detections, multiple detection boxes will be output; each detection box corresponds to a coarse localization region. Subsequent detection and recognition processes are then performed sequentially on each coarse localization region.

[0153] Determine if there are any unprocessed detection boxes. If so, crop the corresponding image region based on the detection box and perform coarse localization. If no matching localization edges are found during coarse localization, it means that the detection box does not contain the DM code to be identified. The subsequent detection and recognition process ends for this detection box, and the next detection box is read for coarse localization. If no matching localization edges are found in the coarse localization regions corresponding to all detection boxes, the current detection and recognition process ends for the image to be processed, and the message "No DM code found" can be output.

[0154] If multiple detection frames identify matching edges, resulting in multiple fine-grained localization data, the subsequent detection and recognition process is executed sequentially based on each fine-grained localization data. If decoding fails during the fine-grained localization and decoding process based on the current fine-grained localization data, the detection and recognition process is executed based on the next fine-grained localization data.

[0155] If the current fine localization data completes the subsequent detection and recognition process, decoding is successful, and the decoding result is output. Simultaneously, the detection and recognition process continues based on the next fine localization data. If all fine localization data fails to complete the subsequent detection and recognition process, the current detection and recognition process for the image to be processed ends, and the message "No DM code found" can be output.

[0156] This embodiment improves the detection and recognition accuracy when multiple codes exist in the image by sequentially performing fine positioning and decoding on multiple detection boxes output during the coarse positioning process.

[0157] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0158] Based on the same inventive concept, this application also provides a DM code detection and recognition device for implementing the DM code detection and recognition method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more DM code detection and recognition device embodiments provided below can be found in the limitations of the DM code detection and recognition method described above, and will not be repeated here.

[0159] In one embodiment, such as Figure 13 As shown, a DM code detection and recognition device is provided, including: an acquisition module 1302, a coarse positioning module 1304, a fine positioning module 1306, a correction module 1308, and a recognition module 1310, wherein:

[0160] The acquisition module 1302 is used to acquire the image to be processed.

[0161] The coarse localization module 1304 is used to process the image to be processed using a target detection algorithm to obtain a coarse localization image; the coarse localization image includes the DM code to be identified.

[0162] The fine positioning module 1306 is used to process the coarse positioning image using a pixel accumulation method to obtain fine positioning data.

[0163] The correction module 1308 is used to perform affine transformation and mesh division processing on the coarse positioning image based on the fine positioning data to obtain a standard image.

[0164] The recognition module 1310 is used to decode the standard image to obtain the recognition result.

[0165] In one embodiment, the coarse localization module 1304 uses a target detection algorithm to process the image to be processed to obtain a coarse localization image, including: scaling and normalizing the image to be processed to obtain a normalized image; and using a YoloV5-Nano target detection model to process the normalized image to obtain a coarse localization image; the YoloV5-Nano target detection model includes three detection heads with downsampling factors of 8, 16, and 32.

[0166] In one embodiment, during the execution of processing the image to be processed using the target detection algorithm, the coarse positioning module 1304 obtains process category data; the process category data is used to indicate the process category for making the DM code to be identified.

[0167] The fine positioning module 1306 processes the coarse positioning image using a pixel accumulation method to obtain fine positioning data. This includes: when the process type is printing, performing Gaussian filtering on the coarse positioning image to obtain a filtered image; performing local threshold binarization on the filtered image to obtain a coarse binarized image; when the process type is dot-matrix forming, performing grayscale stretching on the coarse positioning image to obtain a stretched image; performing Gaussian filtering on the stretched image to obtain a filtered image; performing local threshold binarization on the filtered image to obtain a coarse binarized image; and processing the coarse binarized image based on a pixel accumulator to obtain fine positioning data. The pixel accumulator is used to statistically analyze the pixel distribution in the corresponding direction to obtain the pixel block distribution pattern and edge transition positions in that direction.

[0168] In one embodiment, the fine positioning data includes the coordinates of the four corners of the DM code to be identified; the four corner coordinates include the coordinates of the intersection of the three corner coordinates corresponding to the positioning edge and the clock edge.

[0169] The fine positioning module 1306 processes the coarse binarized image based on a pixel accumulator to obtain fine positioning data, including: using a pixel accumulator to statistically analyze the texture features of the coarse binarized image; determining the positioning edge and its corresponding three angular coordinates based on the texture features, through edge tracking and constraint conditions; determining the module width based on the statistical features calculated by the pixel accumulator on the positioning edge; and obtaining the clock edge and its corresponding intersection coordinates based on the three angular coordinates of the positioning edge and the module width.

[0170] In one embodiment, the correction module 1308 performs affine transformation and grid division processing on the coarse positioning image based on the fine positioning data to obtain a standard image, including: performing affine transformation on the coarse positioning image based on the four corner coordinates of the DM code to be identified to obtain a corrected image; preprocessing the corrected image to obtain a fine binarized image; and performing grid division processing on the fine binarized image to obtain a standard image.

[0171] In one embodiment, the correction module 1308 performs grid division processing on the fine binarized image to obtain a standard image, including: using a pixel accumulator to statistically analyze the texture features of the fine binarized image; redetermining the positioning edges based on the texture features of the fine binarized image; redetermining the clock edge and determining the module boundary point based on the statistical results of the pixel accumulator on the clock edge; tracing gradient edges from the module boundary point to form a grid; and dividing the fine binarized image according to the grid to obtain the standard image.

[0172] In one embodiment, the fine positioning data includes the dimension of the DM code to be identified; the dimension of the DM code to be identified is determined based on the statistical features obtained from the pixel accumulator on the clock edge and the module width. The identification module 1310 decodes the standard image to obtain the identification result, including: determining the decoding parameters based on the dimension of the DM code to be identified; and decoding the standard image based on the decoding parameters to obtain the identification result.

[0173] Each module in the aforementioned DM code detection and recognition device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0174] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 14As shown, the computer device includes a processor, memory, input / output interfaces, and a communication interface. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a DM code detection and recognition method. The computer device may include a display unit. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The computer device may include input devices. Input devices can be a touch layer covering the display screen, buttons, trackballs, or touchpads on the computer device casing, or external keyboards, touchpads, or mice.

[0175] Those skilled in the art will understand that Figure 14 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0176] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0177] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.

[0178] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0179] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0180] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0181] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0182] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A DM code detection and recognition method, characterized in that, The method includes: Obtain the image to be processed; The image to be processed is processed using a target detection algorithm to obtain a coarse localization image and process category data; the coarse localization image includes a DM code to be identified; the process category data is used to indicate the process category in which the DM code to be identified is produced. Based on process category data, the coarse positioning image is processed using a pixel accumulation method to obtain fine positioning data; the fine positioning data includes: the four corner coordinates of the DM code to be identified; the four corner coordinates include the intersection coordinates of the three corner coordinates corresponding to the positioning edge and the clock edge. A affine transformation and mesh division are performed on the coarse positioning image based on the four corner coordinates to obtain a standard image; The recognition result is obtained by decoding the standard image. Specifically, based on process category data, the coarse positioning image is processed using a pixel accumulation method to obtain fine positioning data, including: When the process type is printing, the coarse positioning image is subjected to Gaussian filtering to obtain a filtered image; the filtered image is then subjected to local threshold binarization to obtain a coarse binarized image. When the process category is dot-matrix forming, the coarse positioning image is stretched in grayscale to obtain a stretched image; the stretched image is then subjected to Gaussian filtering to obtain a filtered image; and the filtered image is then subjected to local threshold binarization to obtain a coarse binarized image. The coarse binarized image is processed using a pixel accumulator to obtain fine positioning data; the pixel accumulator is used to statistically analyze the pixel distribution in the corresponding direction to obtain the pixel block distribution pattern and edge transition position in that direction.

2. The method according to claim 1, characterized in that, The process of using a target detection algorithm to process the image to obtain a coarse localization image includes: The image to be processed is scaled and normalized to obtain a normalized image; The normalized image is processed using the YoloV5-Nano target detection model to obtain the coarse localization image; the YoloV5-Nano target detection model includes three detection heads with downsampling factors of 8, 16, and 32.

3. The method according to claim 1, characterized in that, The process of processing the coarse binarized image based on the pixel accumulator to obtain fine localization data includes: The texture features of the coarse binarized image are statistically analyzed using a pixel accumulator. Based on the texture features, the positioning edges and their corresponding three angular coordinates are determined through edge tracking and constraint conditions. The module width is determined based on the statistical features calculated by the pixel accumulator on the positioning edge; Based on the three angular coordinates corresponding to the positioning edge and the module width, the clock edge and the corresponding intersection coordinates are obtained.

4. The method according to claim 3, characterized in that, The standard image is obtained by performing affine transformation and meshing on the coarse positioning image based on the four corner coordinates, including: Based on the four corner coordinates of the DM code to be identified, an affine transformation is performed on the coarse positioning image to obtain the corrected image; The corrected image is preprocessed to obtain a fine binarized image; The finely binarized image is then divided into grids to obtain a standard image.

5. The method according to claim 4, characterized in that, The step of performing grid division processing on the finely binarized image to obtain a standard image includes: The pixel accumulator is used to statistically analyze the texture features of the fine binarized image; Based on the texture features of the fine binarized image, the positioning edges are redefined; Based on the statistical results of the pixel accumulator on the clock edge, the clock edge and the module boundary point are redefined. Starting from the module boundary point, trace the gradient edge to form a grid line; The standard image is obtained by dividing the fine binary image according to the grid lines.

6. The method according to claim 3, characterized in that, The fine positioning data includes the dimension of the DM code to be identified; the dimension of the DM code to be identified is determined based on the statistical characteristics obtained from the pixel accumulator on the clock edge and the module width; The step of decoding the standard image to obtain the recognition result includes: Determine the decoding parameters based on the dimension of the DM code to be identified; The standard image is decoded according to the decoding parameters to obtain the recognition result.

7. A DM code detection and recognition device, characterized in that, The device includes: The acquisition module is used to acquire the image to be processed; A coarse localization module is used to process the image to be processed using a target detection algorithm to obtain a coarse localization image and process category data; the coarse localization image includes a DM code to be identified; the process category data is used to indicate the process category in which the DM code to be identified is produced; The fine positioning module is used to process the coarse positioning image based on process category data using a pixel accumulation method to obtain fine positioning data; the fine positioning data includes: the four corner coordinates of the DM code to be identified; the four corner coordinates include the intersection coordinates of the three corner coordinates corresponding to the positioning edge and the clock edge. The correction module is used to perform affine transformation and mesh division processing on the coarse positioning image based on the four corner coordinates to obtain a standard image; The recognition module is used to decode the standard image to obtain the recognition result; The fine positioning module is used to perform Gaussian filtering on the coarse positioning image to obtain a filtered image when the process type is printing; to perform local threshold binarization on the filtered image to obtain a coarse binarized image; to perform grayscale stretching on the coarse positioning image to obtain a stretched image when the process type is dot-matrix forming; to perform Gaussian filtering on the stretched image to obtain a filtered image; to perform local threshold binarization on the filtered image to obtain a coarse binarized image; and to process the coarse binarized image based on a pixel accumulator to obtain fine positioning data; the pixel accumulator is used to statistically analyze the pixel distribution in the corresponding direction to obtain the pixel block distribution pattern and edge transition position in that direction.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • DM code locating and identification method and system

    CN106485255A

  • Positioning method and positioning system for QR code position detection graph

    CN114861696A