A DM code positioning and recognition method based on deep learning combined with pixel-level detection

By combining deep learning with pixel-level detection, and utilizing coarse localization models and semantic segmentation techniques, candidate corner point combinations of DM codes are extracted, solving the accuracy problem of DM code localization and recognition in complex backgrounds and achieving efficient DM code recognition.

CN118133858BActive Publication Date: 2024-10-18WAYZIM TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410312252.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-19
Publication Date
2024-10-18
Estimated Expiration
2044-03-19

AI Technical Summary

Technical Problem

Traditional QR code recognition methods struggle to accurately locate and recognize DataMatrix QR codes in complex backgrounds, impacting recognition accuracy.

Method used

A method combining deep learning and pixel-level detection is adopted. The DM code region is extracted through a coarse localization model. Combined with semantic segmentation and pixel-by-pixel traversal, candidate corner point combinations are extracted. L-shaped candidate localization markers are obtained by fitting vertical and horizontal straight lines. Pose calibration and mesh division are performed to finally identify the DM code.

Benefits of technology

It improves the accuracy and success rate of DM code positioning and recognition, while ensuring recognition speed and adapting to recognition needs in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118133858B_ABST
    Figure CN118133858B_ABST
Patent Text Reader

Abstract

The present application discloses a DM code positioning and recognition method combining deep learning with pixel-level detection, which relates to the technical field of DM code recognition. The method first uses a coarse positioning model to extract a DM code coarse positioning image from the original image to be detected, and then extracts a number of candidate corner point combinations based on the DM code coarse positioning image by pixel-by-pixel traversal and semantic segmentation methods, and finally sequentially traverses all the candidate corner point combinations to perform pixel-by-pixel analysis and processing on the DM code coarse positioning image for positioning and recognition. The method uses a pixel-by-pixel traversal method and a deep learning method to extract candidate corner point combinations respectively. The two methods complement each other, and can ensure the recognition speed on the basis of improving the accuracy and success rate of DM code positioning and recognition, and has a good recognition effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of DM code recognition, and in particular to a DM code positioning and recognition method combining deep learning with pixel-level detection. Background Art

[0002] Due to its high information density and high confidentiality, the QR code has an irreplaceable position in product traceability and identity recognition, and is widely used in daily life and industrial production. DataMatrix QR code, referred to as DM code, is a branch of QR code. DM code has a small area, high information storage density, large encoding capacity, and strong error correction ability. It is more used in industrial production and logistics.

[0003] However, the background in industrial production and logistics environments is usually complex, which places higher requirements on the positioning and recognition of DM codes. Traditional two-dimensional code recognition methods such as morphological methods and Hough line detection have poor results in positioning and detecting DM codes, affecting the recognition accuracy of DM codes. Summary of the invention

[0004] In response to the above problems and technical requirements, this application proposes a DM code positioning and recognition method combining deep learning with pixel-level detection. The technical solution of this application is as follows:

[0005] A DM code positioning and recognition method combining deep learning with pixel-level detection, the DM code positioning and recognition method comprising:

[0006] The image of the DM code area is extracted from the original image to be detected using a coarse positioning model to obtain a DM code coarse positioning image. The coarse positioning model is obtained based on the training of the target detection network.

[0007] After completing the binary preprocessing of the DM code coarse positioning image, it is traversed pixel by pixel, and a number of candidate corner point combinations are extracted based on the pixel value changes of the traversed pixels. Each candidate corner point combination includes the candidate coordinates of each positioning corner point of the DM code;

[0008] The semantic segmentation model is used to perform semantic segmentation on the DM code rough positioning image to obtain the DM code outline, and several candidate corner point combinations are obtained based on the vertex coordinates of the minimum circumscribed oblique rectangle of the DM code outline;

[0009] All candidate corner point combinations are traversed in sequence. For each candidate corner point combination traversed, the DM code coarse positioning image is parsed pixel by pixel based on the candidate coordinates of each positioning corner point contained in the candidate corner point combination to obtain the corresponding candidate standard DM code image. When the candidate standard DM code image is decoded successfully, the positioning and identification of the DM code is completed. When the candidate standard DM code image is decoded unsuccessfully, continue to traverse the next candidate corner point combination.

[0010] A further technical solution is to extract several candidate corner point combinations based on the pixel value changes of the traversed pixels, including:

[0011] The pixels in the DM code coarse positioning image are traversed row by row along the row direction and the horizontal separation points in each row of pixels are extracted. The horizontal separation points with row direction coordinates in the same interval in each pixel row are fitted with the least square method to obtain a vertical straight line, and several vertical straight lines are fitted in total; wherein the horizontal separation points are black pixels adjacent to white pixels in the same row;

[0012] The pixels in the DM code coarse positioning image are traversed column by column along the column direction and the longitudinal separation points in each column of pixels are extracted. The longitudinal separation points with the same column direction coordinates in each pixel column are fitted with the least square method to obtain a horizontal straight line, and several horizontal straight lines are fitted in total; wherein the longitudinal separation points are black pixels adjacent to the white pixels in the same column;

[0013] A plurality of L-shaped candidate positioning marks are obtained based on the obtained plurality of longitudinal straight lines and the plurality of transverse straight lines, and a corresponding candidate corner point combination is extracted according to each candidate positioning mark.

[0014] A further technical solution is to obtain a plurality of L-shaped candidate positioning marks based on the obtained plurality of longitudinal straight lines and the obtained plurality of transverse straight lines, including:

[0015] For each longitudinal straight line obtained by fitting, when the proportion of white pixels in each of the several parallel scanning columns of the DM code coarse positioning image on one side of the longitudinal straight line reaches a first threshold, and the proportion of black pixels in each of the several parallel scanning columns of the DM code coarse positioning image on the other side of the longitudinal straight line reaches a second threshold, the longitudinal straight line is determined to be a candidate longitudinal boundary line, otherwise the longitudinal straight line is filtered out;

[0016] For each horizontal straight line obtained by fitting, when the proportion of white pixels in each of the several parallel scanning lines of the DM code coarse positioning image on one side of the horizontal straight line reaches a third threshold, and the proportion of black pixels in each of the several parallel scanning lines of the DM code coarse positioning image on the other side of the horizontal straight line reaches a fourth threshold, the horizontal straight line is determined to be a candidate horizontal boundary line, otherwise the horizontal straight line is filtered out;

[0017] A plurality of L-shaped candidate positioning marks are obtained based on the retained plurality of longitudinal candidate boundary lines and the plurality of transverse candidate boundary lines.

[0018] A further technical solution is to obtain a plurality of L-shaped candidate positioning marks based on the retained plurality of longitudinal candidate boundary lines and a plurality of transverse candidate boundary lines, including:

[0019] A plurality of boundary line combinations are obtained by screening the plurality of longitudinal candidate boundary lines and the plurality of transverse candidate boundary lines, each boundary line combination includes a longitudinal candidate boundary line and a transverse candidate boundary line, and an angle between the longitudinal candidate boundary line and the transverse candidate boundary line in the same boundary line combination is within an angle range of 90°±θ, where θ is an error angle;

[0020] For each boundary line combination, a longitudinal boundary line segment is extracted based on the pixel values ​​of the pixel points on the longitudinal candidate boundary lines in the boundary line combination of the DM code coarse positioning image, and a transverse boundary line segment is extracted based on the pixel values ​​of the pixel points on the transverse candidate boundary lines in the boundary line combination of the DM code coarse positioning image, to obtain an L-shaped candidate positioning mark composed of the longitudinal boundary line segment and the transverse boundary line segment.

[0021] A further technical solution is that the extracted longitudinal boundary line segments and transverse boundary line segments include:

[0022] Connect the black pixels located on the candidate longitudinal boundary line in the DM code rough positioning image and whose pixel distance does not exceed the distance threshold into a line segment, and use the continuous line segment formed by the black pixels on the candidate longitudinal boundary line as the longitudinal boundary segment;

[0023] The black pixels located on the horizontal boundary line segment in the DM code coarse positioning image and whose pixel distance does not exceed the distance threshold are connected into a line segment, and the continuous line segment formed by the black pixels on the horizontal boundary line segment is used as the horizontal boundary line segment.

[0024] A further technical solution is that, based on each candidate corner point combination, a corresponding candidate standard DM code image is obtained, including:

[0025] Perform affine transformation on the DM code coarse positioning image according to the candidate coordinates of the four positioning corner points in the candidate corner point combination to obtain the posture calibrated image;

[0026] After completing the binary preprocessing of the posture calibrated image, traverse it pixel by pixel, extract the L-shaped positioning mark composed of the longitudinal positioning line segment and the transverse positioning line segment based on the change of the pixel value of the traversed pixel point, and extract the image of the posture calibrated image after completing the binary preprocessing that is located in the rectangular area composed of the positioning mark as the target segmentation image;

[0027] Determine the code element width based on the longitudinal positioning line segment and the transverse positioning line segment, and divide the target partition image into grids according to the code element width to obtain a plurality of grids;

[0028] All pixels in a grid where the number of black pixels is greater than the number of white pixels are set as black pixels, and all pixels in a grid where the number of white pixels is greater than the number of black pixels are set as white pixels to obtain a candidate standard DM code image.

[0029] A further technical solution is that determining the code element width and performing grid division according to the code element width includes:

[0030] Starting from the longitudinal positioning line segment, sequentially detect each pixel column adjacent to the longitudinal positioning line segment in the direction toward the other end of the transverse positioning line segment. When the proportion of black pixels in the detected pixel column reaches a second threshold, determine that the currently detected pixel column is a valid positioning column and continue to detect the next pixel column along the detection direction. Otherwise, terminate the detection and use the total number of the longitudinal positioning line segment and all valid positioning columns as the first code element width.

[0031] Starting from the horizontal positioning line segment, sequentially detect each pixel row adjacent to the horizontal positioning line segment in the direction toward the other end of the vertical positioning line segment, and when the proportion of black pixels in the detected pixel row reaches a fourth threshold, determine that the currently detected pixel row is a valid positioning row and continue to detect the next pixel row along the detection direction, otherwise, terminate the detection and use the total number of the horizontal positioning line segment and all valid positioning rows as the second code element width;

[0032] The target divided image is divided into a plurality of columns along the row direction according to the first code element width, and the target divided image is divided into a plurality of rows along the column direction according to the second code element width, thereby completing the grid division.

[0033] A further technical solution is that for any image to be processed among the DM code coarse positioning image and the image after attitude calibration, the image to be processed is subjected to binarization preprocessing, which includes:

[0034] The grayscale histogram of the pixel points in the central area of ​​the image to be processed is calculated, and histogram equalization is performed; the image to be processed after histogram equalization is divided into several local areas after USM sharpening, and adaptive binarization processing is performed on each local area according to the pixel values ​​of the pixel points in each local area.

[0035] A further technical solution is to obtain several candidate corner point combinations based on the coordinates of the minimum oblique rectangle of the outline of the DM code, including:

[0036] The coordinates of the four vertices of the minimum oblique rectangle circumscribing the outline of the DM code are arranged in a staggered manner in a clockwise order to obtain four candidate corner point combinations.

[0037] A further technical solution is that all candidate corner point combinations obtained by traversing in sequence include:

[0038] The traversal is performed in the order of first traversing each candidate corner point combination obtained by pixel-by-pixel traversal, and then traversing each candidate corner point combination obtained by the semantic segmentation model.

[0039] The beneficial technical effects of this application are:

[0040] The present application discloses a DM code positioning and recognition method combining deep learning with pixel-level detection. The method first performs rough positioning through a target detection algorithm to extract a rough positioning image of the DM code, and then uses a pixel-by-pixel traversal method and a deep learning method to respectively extract candidate corner point combinations, and then performs DM code recognition based on the candidate corner point combinations obtained by the two methods. The DM code can be positioned efficiently and accurately by identifying the corner point coordinates, and the combination of the pixel-by-pixel traversal method and the deep learning method can allow the candidate corner point combinations extracted by the two methods to complement each other, thereby ensuring the recognition speed on the basis of improving the accuracy and success rate of DM code positioning and recognition, and having a good recognition effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 This is the standard structure diagram of DM code.

[0042] Figure 2 This is a method flow chart of a DM code positioning and identification method according to an embodiment of the present application.

[0043] Figure 3 The flowchart of a method for extracting candidate corner point combinations by traversing pixel by pixel in an embodiment.

[0044] Figure 4 The figure is a schematic diagram of respectively extracting horizontal separation points and vertical separation points from a local image in an example.

[0045] Figure 5 The flowchart of a method for obtaining a candidate standard DM code image based on candidate corner point combination analysis in one embodiment. DETAILED DESCRIPTION

[0046] The specific implementation of the present application is further described below in conjunction with the accompanying drawings.

[0047] This application discloses a DM code positioning and recognition method combining deep learning with pixel-level detection. The method of this application is based on the standard format of DM code. The standard format of DM code is as follows: Figure 1 As shown in FIG. 1 , the DM code includes a data area, a search area, and a blank area. The data area of ​​the DM code is as follows: Figure 1 As shown in (a), the data area is composed of a number of rectangular code blocks of the same size in a two-dimensional grid form. The horizontal side length of all code blocks in the data area is a, and the vertical side length is b. The black and white code blocks in the data area are randomly distributed.

[0048] Finding border areas Figure 1 As shown in (b), the edge search area is located around the data area, and the edge search area includes a positioning mark. The positioning mark is an L-shaped structure composed of a longitudinal positioning edge 1 and a transverse positioning edge 2. The transverse side length of the longitudinal positioning edge 1 is also a, and the longitudinal side length covers the longitudinal range of the entire data area. The longitudinal side length of the transverse positioning edge 2 is b, and the transverse side length covers the transverse range of the entire data area. Therefore, the longitudinal positioning edge 1 is equivalent to a column composed of several code element blocks, and the transverse positioning edge 2 is equivalent to a row composed of several code element blocks, and all code element blocks in the longitudinal positioning edge 1 and the transverse positioning edge 2 are black code element blocks.

[0049] The edge search area also includes a clock mark, which is an L-shaped structure composed of a longitudinal clock edge 3 and a transverse clock edge 4. The longitudinal positioning edge 1 and the longitudinal clock edge 3 constitute the two transverse boundaries of the data area, and the transverse positioning edge 2 and the transverse clock edge 4 constitute the two longitudinal boundaries of the data area. The transverse side length of the longitudinal clock edge 3 is also a, and the longitudinal side length covers the longitudinal range of the entire data area. The longitudinal side length of the transverse clock edge 4 is b, and the transverse side length covers the transverse range of the entire data area. Therefore, the longitudinal clock edge 3 is equivalent to a column composed of a number of code element blocks, and the transverse clock edge 4 is equivalent to a row composed of a number of code element blocks. The black code element blocks and the white code element blocks in the longitudinal clock edge 3 are arranged alternately, and the number of black code element blocks and the white code element blocks are the same. The black code element blocks and the white code element blocks in the transverse clock edge 4 are arranged alternately, and the number of black code element blocks and the white code element blocks are the same.

[0050] The sum of the number of black symbol blocks and white symbol blocks on the horizontal clock edge 4 is the horizontal dimension of the DM code, and the sum of the number of black symbol blocks and white symbol blocks on the vertical clock edge 3 is the vertical dimension of the DM code. Based on the above standard structure of the DM code, when the data area includes M rows and N columns of symbol blocks, the vertical dimension of the DM code is M+2 and the horizontal dimension is N+2. The vertical dimension and horizontal dimension of most DM codes are the same, but some DM codes have different vertical dimensions and horizontal dimensions.

[0051] Blank area such as Figure 1 As shown in (c) in the figure, the blank area is located around the periphery of the edge-seeking area. The blank area covers an area with a horizontal interval d1 and a vertical interval d2 from the edge-seeking area. The intervals d1 and d2 are both custom known parameters, which are generally fixed default values ​​in the industry.

[0052] The standard form of a complete DM code consisting of a data area, a search area and a blank area is as follows: Figure 1 The four vertices of the edge-finding area of ​​the DM code are used as the four positioning corners of the DM code. Generally, the intersection vertex of the horizontal positioning edge 2 and the vertical clock edge 3 is used as the positioning corner A, and the other positioning corners are determined in the clockwise direction, such as Figure 1As shown in (d), the intersection vertex of the two positioning edges is the positioning corner point B, the intersection vertex of the longitudinal positioning edge 1 and the transverse clock edge 4 is the positioning corner point C, and the intersection vertex of the two clock edges is the positioning corner point D.

[0053] Based on DM code Figure 1 The DM code positioning and identification method includes the following steps, please refer to Figure 2 The flowchart shown:

[0054] Step 1: Use a coarse positioning model to extract an image of the area where the DM code is located from the original image to be detected to obtain a DM code coarse positioning image.

[0055] The coarse positioning model is pre-trained based on the target detection network, and the coarse positioning model extracts the DM code coarse positioning image from the original image to be detected by the target detection method. In one embodiment, the coarse positioning model is pre-trained based on the picodata model.

[0056] In one embodiment, extracting a DM code coarse positioning image using a coarse positioning model includes:

[0057] Input the original image to be detected into the coarse positioning model for target detection, and you can get several detection frames and the confidence score of each detection frame. Keep several detection frames whose confidence scores reach the score threshold, and delete other detection frames whose confidence scores do not reach the score threshold. The score threshold is customized according to actual needs.

[0058] The non-maximum suppression method is used to further screen the retained detection frames, including: first determine the detection frame with the highest confidence score, then traverse the other detection frames in turn, and calculate the overlapping area between the image in the traversed detection frame and the image in the detection frame with the highest confidence score. When the overlapping area reaches the overlapping area threshold, the traversed detection frame is deleted, otherwise the traversed detection frame is retained. The overlapping area threshold is customized according to actual needs.

[0059] After traversing all detection frames, the screening is completed, and the image in each remaining detection frame is the extracted DM code coarse positioning image.

[0060] This step requires the use of a coarse positioning model, so before using the coarse positioning model, a method for training the coarse positioning model is also included. In one embodiment, training the coarse positioning model includes the following process: first, a sample image containing a DM code is collected, and then the area where the DM code is located in the sample image is marked to construct a training data set. Then, the training data set is used to perform model training based on the target detection network to obtain the required coarse positioning model. In a use case, the training batch is 64, that is, 64 images are loaded into the memory at one time, and a back propagation is performed after the 64 forward propagations are completed. A stochastic gradient descent algorithm with momentum is used, the momentum is set to 0.9, the initial learning rate is set to 0.4, and the total iteration epoch is 300.

[0061] Step 2: After completing the binary preprocessing of the DM code coarse positioning image, perform pixel-by-pixel traversal, and extract several candidate corner point combinations based on the pixel value changes of the traversed pixels. Each extracted candidate corner point combination includes the candidate coordinates of each positioning corner point of the DM code.

[0062] In one embodiment, the binarization preprocessing of the DM code coarse positioning image includes: calculating the grayscale histogram of the pixel points in the central area of ​​the image to be processed, and performing histogram equalization, where the range of the central area is pre-defined. Then, the DM code coarse positioning image after the histogram equalization is divided into a plurality of local areas after USM sharpening, and adaptive binarization processing is performed on each local area according to the pixel values ​​of the pixel points in each local area.

[0063] Step 3, use the semantic segmentation model to perform semantic segmentation on the DM code rough positioning image to extract the DM code contour, then convert the DM code contour into a binary image, and find the minimum circumscribed oblique rectangle of the DM code contour in the binary image. Finally, based on the vertex coordinates of the minimum circumscribed oblique rectangle of the DM code contour, several candidate corner point combinations are obtained, and the meaning of the candidate corner point combination finally extracted is the same as that of step 2.

[0064] like Figure 1 As shown in the figure, the DM code has a regular shape, so the semantic segmentation effect is very good, so this step uses a pre-trained semantic segmentation model to extract the contour of the DM code. Therefore, before using the semantic segmentation model, the step of pre-training the semantic segmentation model is also included, including: constructing a coarse positioning sample image, annotating the closed-loop contour of the DM code in the coarse positioning sample image at the pixel level to construct a training data set, and then training the model based on the paddleseg model. The training batch is set to 64, the total iteration batch is set to 80,000, and the stochastic gradient descent algorithm with momentum is used. The momentum is set to 0.9 and the initial learning rate is set to 0.005.

[0065] In step 2, the four positioning corner points can be directly and accurately located during the pixel-by-pixel traversal process, thereby determining the candidate coordinates of the four positioning corner points. In step 3, after extracting the minimum circumscribed oblique rectangle of the outline of the DM code, only the four vertex coordinates of the minimum circumscribed oblique rectangle can be obtained, but it cannot be determined which positioning corner point of the DM code each of the four vertex coordinates corresponds to. However, the circumferential arrangement order of the four vertex coordinates of the minimum circumscribed oblique rectangle is fixed. Therefore, if the four vertex coordinates of the minimum circumscribed oblique rectangle are arranged in a staggered manner in a clockwise order, there must be an accurate correspondence between the vertex coordinates in a candidate corner point combination and the positioning corner point.

[0066] For example, the four vertex coordinates of the minimum circumscribed oblique rectangle of the extracted DM code outline are (x1, y1), (x2, y2), (x3, y3), and (x4, y4) in the clockwise direction. Then the vertex coordinate (x1, y1) may correspond to Figure 1 Any one of the positioning corner points A, B, C, and D in the image. However, once the vertex coordinates (x1, y1) are fixed to correspond to the positioning corner point A, it can be determined that (x2, y2) corresponds to the positioning corner point B, (x3, y3) corresponds to the positioning corner point C, and (x4, y4) corresponds to the positioning corner point D, which constitutes a candidate corner point combination. Through staggered arrangement, the vertex coordinates (x1, y1) can also correspond to the positioning corner point B, and it can be determined that (x2, y2) corresponds to the positioning corner point C, (x3, y3) corresponds to the positioning corner point D, and (x4, y4) corresponds to the positioning corner point A, which constitutes another candidate corner point combination. Correspondingly, another two candidate corner point combinations can be obtained, thereby obtaining all four candidate corner point combinations. Among these four candidate corner point combinations, there must be one candidate corner point combination in which the corresponding relationship is accurate, which will be screened and determined through subsequent methods.

[0067] It should be noted that, during actual execution, there is no specific order in which step 2 and step 3 are executed, and they can generally be executed simultaneously.

[0068] Step 4, all candidate corner point combinations obtained are traversed in sequence, where all candidate corner point combinations include the candidate corner point combinations determined by pixel-by-pixel traversal in step 2 and the candidate corner point combinations determined by the semantic segmentation model in step 3. For each candidate corner point combination traversed, the DM code coarse positioning image is parsed pixel by pixel based on the candidate coordinates of each positioning corner point contained in the candidate corner point combination to obtain the corresponding candidate standard DM code image.

[0069] After obtaining the corresponding candidate standard DM code image according to a candidate corner point combination, the candidate standard DM code image is decoded according to a predetermined decoding method. When the candidate standard DM code image is decoded successfully, it means that the identified candidate standard DM code image is accurate, and the positioning and identification of the DM code is determined to be completed. When the candidate standard DM code image is decoded unsuccessfully, it means that the candidate standard DM code image obtained at this time is inaccurate, and the next candidate corner point combination is traversed.

[0070] This method extracts candidate corner point combinations through two methods, step 2 and step 3, and increases the recognition success rate. Especially in the case of poor image quality, step 2 may not be able to extract candidate corner point combinations or the extracted candidate corner point combinations are very inaccurate through the pixel-by-pixel traversal method. If the DM code rough positioning image is only based on the candidate corner point combinations obtained by pixel-by-pixel traversal, the recognition accuracy and success rate will be low. The semantic segmentation model can accurately locate the DM code contour and obtain the candidate corner point combination, so the combination of the two parts of the candidate corner point combination can improve the recognition accuracy and success rate.

[0071] When traversing all candidate corner point combinations, this step can traverse each candidate corner point combination in a random order. However, as mentioned above, among the four candidate corner point combinations obtained in step 3, only one candidate corner point combination is accurate, and the other three candidate corner point combinations are inaccurate. If all candidate corner point combinations are mixed together and randomly traversed, the wrong candidate corner point combination among the four candidate corner point combinations obtained in step 3 will affect the algorithm time consumption. Therefore, in another embodiment, the traversal order adopted is: first traverse each candidate corner point combination obtained by pixel-by-pixel traversal in step 2 in turn, and after traversing each candidate corner point combination obtained by pixel-by-pixel traversal, traverse each candidate corner point combination obtained by the semantic segmentation model in step 3 in turn. Perform random traversal when traversing each candidate corner point combination obtained in step 2, and perform random traversal when traversing each candidate corner point combination obtained in step 3.

[0072] Based on this traversal order, there is a certain probability that recognition can be completed during the process of traversing each candidate corner point combination obtained in step 2, and only when recognition cannot be achieved, the candidate corner point combinations obtained in step 3 are traversed for supplementary recognition, thereby improving recognition efficiency and reducing recognition time on the basis of improving recognition accuracy and success rate. When this traversal order is adopted, step 2 can also be executed first, and then each candidate corner point combination obtained in step 2 is traversed. When recognition is successful, step 3 is no longer executed. When recognition is still not successful after traversal, step 3 is executed again to obtain each candidate corner point combination and then traverse. The specific step execution order can be customized as needed.

[0073] In one embodiment, the above step 2 extracts a plurality of candidate corner point combinations based on the pixel value changes of the traversed pixels, and includes the following steps. Figure 3 Flowchart:

[0074] Step 310, traverse the pixels in the DM code coarse positioning image row by row along the row direction and extract the horizontal separation points in each row of pixels. The horizontal separation points are black pixels adjacent to white pixels in the same row. For example, Figure 4 In the example, assuming that the local image of the DM code coarse positioning image is shown in (a), the horizontal separation points obtained by traversing the local image (a) row by row are represented by red shadows as shown in (b).

[0075] Then, the least squares fitting is performed on the horizontal separation points of the row direction coordinates in the same interval range in each pixel row to obtain a vertical straight line. The interval range division of the row direction coordinates is set according to actual needs. After this operation, several vertical straight lines are obtained by fitting, and each vertical straight line is basically along the vertical direction. However, due to the actual image deviation, it is generally difficult to ensure that the vertical straight line is completely vertical.

[0076] Step 320, traverse the pixels in the DM code coarse positioning image column by column along the column direction and extract the vertical separation points in each column of pixels. The vertical separation points are black pixels adjacent to white pixels in the same column. Figure 4 In the example, the vertical separation points extracted by traversing the local image (a) row by row are represented by green shadows as shown in (c).

[0077] Similarly, a least squares fitting is performed on the longitudinal separation points in each pixel column whose column coordinates are in the same interval to obtain a horizontal straight line, and a total of several horizontal straight lines are obtained by fitting. Similarly, the interval range divisions of the column coordinates are set according to actual needs.

[0078] Likewise, there is no specific execution order for step 310 and step 320, and they can generally be executed synchronously.

[0079] Step 330: obtain a plurality of L-shaped candidate positioning marks based on the obtained plurality of longitudinal straight lines and the obtained plurality of transverse straight lines, and extract a corresponding candidate corner point combination according to each candidate positioning mark.

[0080] (1) The vertical and horizontal lines obtained in step 310 and step 320 cover the entire DM code area, and the number is often large. In order to reduce the amount of calculation and improve the detection efficiency, the vertical and horizontal lines obtained are first screened. Since the ultimate goal is to obtain a candidate corner point combination, it is actually necessary to detect the outer circle boundary of the edge-seeking area of ​​the DM code, and the outer circle boundary can be determined based on the positioning mark, so the focus is on detecting the outer circle boundary of the positioning mark. Figure 1 It can be seen that the outer circle boundary of the positioning mark has the following characteristics: one side of the outer circle boundary of the longitudinal positioning edge 1 ( Figure 1 In the blank area, the pixels are white in theory. However, since the pixel size is much smaller than the size of a single symbol block in the DM code, the other side of the outer circle boundary of the longitudinal positioning edge 1 ( Figure 1 The right side in the middle is located in the code element block on the longitudinal positioning edge 1, so theoretically all pixels are black. The horizontal positioning edge 2 also has this feature. One side of the outer circle boundary of the horizontal positioning edge 2 ( Figure 1 The lower side is in the blank area, so theoretically all of them are white pixels. The other side of the outer circle boundary of the horizontal positioning edge 2 ( Figure 1 The upper side in the middle) is located in the code element block on the horizontal positioning edge 2, so theoretically they are all black pixels.

[0081] The pixels on both sides of the outer circle boundary of the two positioning edges to be found must meet the above characteristics, so based on this feature, other vertical and horizontal lines that do not meet the above requirements are first filtered out:

[0082] For each longitudinal straight line obtained by fitting, when the proportion of white pixels in each of the several parallel scanning columns of the DM code coarse positioning image on one side of the longitudinal straight line reaches the first threshold, and the proportion of black pixels in each of the several parallel scanning columns of the DM code coarse positioning image on the other side of the longitudinal straight line reaches the second threshold, the longitudinal straight line is determined to be a longitudinal candidate boundary line, otherwise the longitudinal straight line is filtered out. The parallel scanning columns of each longitudinal straight line are parallel to the longitudinal straight line, and the number of parallel scanning columns detected is configured as required, but does not exceed the number of pixel columns included in the horizontal interval d1 between the blank area coverage and the edge search area, nor does it exceed the number of pixel columns covered by a single code element block width. The first threshold and the second threshold can be set by default, mainly considering that errors may cause the blank area to not be completely white pixels and the positioning edge to not be completely black pixels. When a certain proportion is reached, it can be considered that the requirements are basically met.

[0083] Similarly, for each horizontal straight line obtained by fitting, when the proportion of white pixels in each of the several parallel scanning lines on one side of the horizontal straight line of the DM code coarse positioning image reaches the third threshold, and the proportion of black pixels in each of the several parallel scanning lines on the other side of the horizontal straight line of the DM code coarse positioning image reaches the fourth threshold, the horizontal straight line is determined to be a candidate horizontal boundary line, otherwise the horizontal straight line is filtered out. Similarly, the parallel scanning lines of each horizontal straight line are parallel to the horizontal straight line, and the number of parallel scanning lines detected is configured as needed, but does not exceed the number of pixel columns included in the longitudinal interval d2 between the blank area coverage and the edge-seeking area, nor does it exceed the number of pixel columns covered by a single code element block width. The third threshold and the fourth threshold can be set by default, in order to reduce the impact of acquisition errors.

[0084] (2) Then, several L-shaped candidate positioning marks can be obtained based on the retained several longitudinal candidate boundary lines and several transverse candidate boundary lines. After the above processing, the retained longitudinal candidate boundary lines and transverse candidate boundary lines basically meet the characteristics of the outer circle boundary. However, as mentioned above, the two positioning edges do not exist independently, but together constitute the positioning mark, and the positioning mark in the structure of the standard DM code is L-shaped, and the angle between the two positioning edges is 90°. Based on this feature, several boundary line combinations are first obtained based on the screening of several longitudinal candidate boundary lines and several transverse candidate boundary lines. Each boundary line combination includes a longitudinal candidate boundary line and a transverse candidate boundary line, and the angle between the longitudinal candidate boundary line and the transverse candidate boundary line in the same boundary line combination is within the angle range of 90°±θ, where θ is the error angle, which can be customized.

[0085] For each boundary line combination, the longitudinal boundary line segment is extracted based on the pixel values ​​of the pixel points on the longitudinal candidate boundary line in the boundary line combination of the DM code rough positioning image, and the transverse boundary line segment is extracted based on the pixel values ​​of the pixel points on the transverse candidate boundary line in the boundary line combination of the DM code rough positioning image, and the L-shaped candidate positioning mark composed of the longitudinal boundary line segment and the transverse boundary line segment is obtained. Including:

[0086] The black pixels on the candidate vertical boundary line in the DM code rough positioning image and whose pixel distance does not exceed the distance threshold are connected into line segments, and the continuous line segments formed by the black pixels on the candidate vertical boundary line are used as the vertical boundary segments. The black pixels on the horizontal boundary line segment in the DM code rough positioning image and whose pixel distance does not exceed the distance threshold are connected into line segments, and the continuous line segments formed by the black pixels on the horizontal boundary line segment are used as the horizontal boundary line segment.

[0087] The longitudinal boundary line segment and the transverse boundary line segment constitute an L-shaped candidate positioning mark. Due to the existence of errors, the candidate positioning mark extracted in this step is not necessarily strictly L-shaped, that is, the angle between the longitudinal boundary line segment and the transverse boundary line segment is not necessarily a perfect 90° angle. After determining the candidate positioning mark, the pixel coordinates of each end point position of the candidate positioning mark can be used as the candidate coordinates of the corresponding positioning corner points A, B, and C, and then the candidate coordinates of the positioning corner point D can be calculated accordingly based on the coordinate relationship of the rectangular structure, and a candidate corner point combination is obtained. Depending on the actual image situation, the candidate corner point combinations extracted in this step may be 0, 1, or more.

[0088] In one embodiment, the above step 4 performs pixel-by-pixel analysis on the DM code coarse positioning image based on the candidate coordinates of each positioning corner point included in the candidate corner point combination to obtain the corresponding candidate standard DM code image, which includes the following steps. Figure 5 Flowchart:

[0089] Step 510, based on the characteristic of the standard DM code being a rectangular structure, an affine transformation is performed on the DM code coarse positioning image according to the candidate coordinates of the four positioning corner points in the candidate corner point combination to obtain a posture calibrated image.

[0090] Step 520, after completing the binarization preprocessing of the posture calibrated image, perform a pixel-by-pixel traversal, extract the L-shaped positioning mark composed of the longitudinal positioning line segment and the transverse positioning line segment based on the change of the pixel value of the traversed pixel point, and extract the image of the posture calibrated image after completing the binarization preprocessing that is located in the rectangular area composed of the positioning mark as the target segmentation image.

[0091] The method for preprocessing the attitude calibrated image by binarization is the same as the method for preprocessing the DM code coarse positioning image by binarization in step 2, including: calculating the grayscale histogram of the pixel points in the central area of ​​the attitude calibrated image, and performing histogram equalization, where the range of the central area is predefined. Then, the attitude calibrated image after histogram equalization is divided into several local areas after USM sharpening, and adaptive binarization is performed on each local area according to the pixel values ​​of the pixel points in each local area.

[0092] The posture calibrated image after the binarization preprocessing is traversed pixel by pixel. The method for traversing to obtain the longitudinal positioning line segment is the same as the method for traversing to obtain the longitudinal boundary line segment in step 2. The method for traversing to obtain the transverse positioning line segment is the same as the method for traversing to obtain the transverse boundary line segment in step 2. This embodiment will not be repeated.

[0093] As mentioned above, the L-shaped positioning mark can mark the area where the data area and the edge-finding area are located in the DM code, so the extracted target partition image is theoretically an image of the area where the data area and the edge-finding area are located.

[0094] Step 530, determining the code element width based on the longitudinal positioning line segment and the transverse positioning line segment.

[0095] The symbol width includes the horizontal side length a and the vertical side length b of a single symbol block, such as Figure 1 As shown, for a standard DM code, the horizontal side length a of a single symbol block is equal to the width of the vertical positioning edge 1, and the vertical side length b of a single symbol block is equal to the width of the horizontal positioning edge 2. Therefore, by detecting the width of the vertical positioning edge 1 and the width of the horizontal positioning edge 2, the symbol width can be determined.

[0096] As described above, theoretically, the two positioning edges are all black pixels, so based on this feature, we can detect which pixel rows and columns are inside the two positioning edges, including:

[0097] Starting from the longitudinal positioning line segment, each pixel column adjacent to the longitudinal positioning line segment is detected in sequence along the direction toward the other end of the transverse positioning line segment. When the proportion of black pixels in the detected pixel column reaches the second threshold, it is determined that the currently detected pixel column is a valid positioning column, and a valid positioning column means that the pixel column is located inside the longitudinal positioning edge 1. Then continue to detect the next pixel column along the detection direction. When the proportion of black pixels in the detected pixel column does not reach the second threshold, the detection is terminated, and the total number of columns of the previously detected longitudinal positioning line segment and all valid positioning columns is used as the first code element width. The meaning of the second threshold here is as introduced above, and it is a threshold set to avoid detection errors.

[0098] Similarly, starting from the horizontal positioning line segment, each pixel row adjacent to the horizontal positioning line segment is detected in sequence along the direction toward the other end of the vertical positioning line segment. When the proportion of black pixels in the detected pixel row reaches the fourth threshold, it is determined that the currently detected pixel row is a valid positioning row, which means that the pixel row is located inside the horizontal positioning edge 2. Then continue to detect the next pixel row along the detection direction. When the proportion of black pixels in the detected pixel row does not reach the fourth threshold, the detection is terminated, and the total number of rows of the previously detected horizontal positioning line segment and all valid positioning rows is used as the second code element width.

[0099] In general, it can be assumed that the widths of the symbols in two directions of a single symbol block are equal, so only the first symbol width or only the second symbol width can be detected. However, considering that the symbol widths may be different in some cases, and in the actual industrial environment, affected by industrial carving, photography, etc., even if the symbol widths in two directions are equal, there may be errors in the image. Therefore, in order to ensure the recognition accuracy, this step detects the first symbol width and the second symbol width from two directions respectively.

[0100] Step 540, grid-dividing the target segmented image according to the code element width to obtain a plurality of grids. Figure 1 As introduced in the part, the data area and the edge-seeking area of ​​the DM code can be considered to be composed of an arrangement and combination of code blocks of equal specifications. Therefore, after determining the code width of the code block, the target division image that has been determined can be divided into several grids according to the code width. Each grid corresponds to a code block, including: dividing the target division image into several columns along the row direction according to the first code width, and dividing the target division image into several rows along the column direction according to the second code width, thereby completing the grid division.

[0101] Step 550: All pixels in a grid where the number of black pixels is greater than the number of white pixels are set as black pixels as black symbol blocks, and all pixels in a grid where the number of white pixels is greater than the number of black pixels are set as white pixels as white symbol blocks, to obtain a candidate standard DM code image. After obtaining the candidate standard DM code image, the dimension of the candidate standard DM code image can be obtained by detecting the total number of black symbol blocks and white symbol blocks on the clock mark.

[0102] The above is only a preferred embodiment of the present application, and the present application is not limited to the above embodiments. It is understood that other improvements and changes directly derived or associated by those skilled in the art without departing from the spirit and concept of the present application should be considered to be included in the protection scope of the present application.

Claims

1. A DM code positioning and recognition method combining deep learning with pixel-level detection, characterized in that: The DM code positioning and identification method includes: Extracting an image of the DM code region from the original image to be detected using a coarse positioning model to obtain a DM code coarse positioning image, wherein the coarse positioning model is trained based on a target detection network; After completing the binarization preprocessing of the DM code coarse positioning image, a pixel-by-pixel traversal is performed, and a plurality of candidate corner point combinations are extracted based on the pixel value changes of the traversed pixels, each candidate corner point combination including the candidate coordinates of each positioning corner point of the DM code; Performing semantic segmentation extraction on the DM code coarse positioning image using a semantic segmentation model to obtain the outline of the DM code, and obtaining a plurality of candidate corner point combinations based on the vertex coordinates of the minimum circumscribed oblique rectangle of the outline of the DM code; All candidate corner point combinations obtained are traversed in sequence. For each traversed candidate corner point combination, the DM code coarse positioning image is parsed pixel by pixel based on the candidate coordinates of each positioning corner point contained in the candidate corner point combination to obtain a corresponding candidate standard DM code image. When the candidate standard DM code image is decoded successfully, the positioning and recognition of the DM code is completed. When the candidate standard DM code image is decoded unsuccessfully, the next candidate corner point combination is traversed.

2. The DM code positioning and identification method according to claim 1, characterized in that: The extraction of several candidate corner point combinations based on the pixel value changes of the traversed pixels includes: Traversing the pixels in the DM code coarse positioning image row by row and extracting the horizontal separation points in each row of pixels, performing least squares fitting on the horizontal separation points in each pixel row whose row coordinates are within the same interval to obtain a vertical straight line, and fitting a total of several vertical straight lines; wherein the horizontal separation points are black pixels adjacent to white pixels in the same row; Traversing the pixels in the DM code coarse positioning image column by column and extracting the longitudinal separation points in each column of pixels, performing least squares fitting on the longitudinal separation points in each pixel column whose column coordinates are within the same interval to obtain a horizontal straight line, and fitting a total of several horizontal straight lines; wherein the longitudinal separation points are black pixels adjacent to white pixels in the same column; A plurality of L-shaped candidate positioning marks are obtained based on the obtained plurality of longitudinal straight lines and the obtained plurality of transverse straight lines, and a corresponding candidate corner point combination is extracted according to each candidate positioning mark.

3. The DM code positioning and identification method according to claim 2, characterized in that: Based on the obtained plurality of longitudinal lines and the obtained plurality of transverse lines, a plurality of L-shaped candidate positioning marks are obtained, including: For each longitudinal straight line obtained by fitting, when the proportion of white pixels in each of the plurality of parallel scanning columns on one side of the longitudinal straight line of the DM code coarse positioning image reaches a first threshold, and the proportion of black pixels in each of the plurality of parallel scanning columns on the other side of the longitudinal straight line of the DM code coarse positioning image reaches a second threshold, the longitudinal straight line is determined to be a candidate longitudinal boundary line; otherwise, the longitudinal straight line is filtered out; For each horizontal line obtained by fitting, when the proportion of white pixels in each of the plurality of parallel scanning lines on one side of the horizontal line of the DM code coarse positioning image reaches a third threshold, and the proportion of black pixels in each of the plurality of parallel scanning lines on the other side of the horizontal line of the DM code coarse positioning image reaches a fourth threshold, the horizontal line is determined to be a candidate horizontal boundary line; otherwise, the horizontal line is filtered out; A plurality of L-shaped candidate positioning marks are obtained based on the retained plurality of longitudinal candidate boundary lines and the plurality of transverse candidate boundary lines.

4. The DM code positioning and identification method according to claim 3, characterized in that: Based on the retained plurality of longitudinal candidate boundary lines and the plurality of transverse candidate boundary lines, a plurality of L-shaped candidate positioning marks are obtained, including: A plurality of boundary line combinations are obtained by screening the plurality of longitudinal candidate boundary lines and the plurality of transverse candidate boundary lines, each boundary line combination including a longitudinal candidate boundary line and a transverse candidate boundary line, and the angle between the longitudinal candidate boundary line and the transverse candidate boundary line in the same boundary line combination is within an angle range of 90°±θ, where θ is an error angle; For each boundary line combination, a longitudinal boundary line segment is extracted based on the pixel values ​​of the pixel points on the longitudinal candidate boundary line in the boundary line combination of the DM code coarse positioning image, and a transverse boundary line segment is extracted based on the pixel values ​​of the pixel points on the transverse candidate boundary line in the boundary line combination of the DM code coarse positioning image, thereby obtaining an L-shaped candidate positioning mark composed of the longitudinal boundary line segment and the transverse boundary line segment.

5. The DM code positioning and identification method according to claim 4, characterized in that: The extracted longitudinal boundary segments and transverse boundary segments include: Connect the black pixels on the candidate longitudinal boundary line in the DM code coarse positioning image and whose pixel distance does not exceed the distance threshold into a line segment, and use the continuous line segment formed by the black pixels on the candidate longitudinal boundary line as the longitudinal boundary segment; The black pixels in the DM code coarse positioning image that are located on the horizontal boundary line segment and whose pixel distance does not exceed the distance threshold are connected into a line segment, and the continuous line segment formed by the black pixels on the horizontal boundary line segment is used as the horizontal boundary line segment.

6. The DM code positioning and identification method according to claim 1, characterized in that: Based on each candidate corner point combination, the corresponding candidate standard DM code image includes: Performing an affine transformation on the DM code coarse positioning image according to the candidate coordinates of the four positioning corner points in the candidate corner point combination to obtain a posture-calibrated image; After completing the binarization preprocessing of the posture calibrated image, a pixel-by-pixel traversal is performed, and based on the pixel value changes of the traversed pixel points, an L-shaped positioning mark composed of a longitudinal positioning line segment and a transverse positioning line segment is extracted, and an image of the posture calibrated image after completing the binarization preprocessing and located within the rectangular area composed of the positioning mark is extracted as a target segmentation image; Determining a code element width based on the longitudinal positioning line segment and the transverse positioning line segment, and performing grid division on the target divided image according to the code element width to obtain a plurality of grids; All pixels in a grid where the number of black pixels is greater than the number of white pixels are set as black pixels, and all pixels in a grid where the number of white pixels is greater than the number of black pixels are set as white pixels to obtain a candidate standard DM code image.

7. The DM code positioning and identification method according to claim 6, characterized in that: Determining the symbol width and dividing the grid according to the symbol width includes: Starting from the longitudinal positioning line segment, sequentially detecting each pixel column adjacent to the longitudinal positioning line segment along the direction toward the other end of the transverse positioning line segment; when the proportion of black pixels in the detected pixel column reaches a second threshold, determining that the currently detected pixel column is a valid positioning column and continuing to detect the next pixel column along the detection direction; otherwise, terminating the detection and using the total number of the longitudinal positioning line segment and all valid positioning columns as the first code element width; Starting from the horizontal positioning line segment, sequentially detecting each continuous pixel row adjacent to the horizontal positioning line segment along a direction toward the other end of the vertical positioning line segment; when the proportion of black pixels in the detected pixel row reaches a fourth threshold, determining that the currently detected pixel row is a valid positioning row and continuing to detect the next pixel row along the detection direction; otherwise, terminating the detection and using the total number of the horizontal positioning line segment and all valid positioning rows as the second code element width; The target divided image is divided into a number of columns along the row direction according to the first code element width, and the target divided image is divided into a number of rows along the column direction according to the second code element width, thereby completing the grid division.

8. The DM code positioning and identification method according to claim 6, characterized in that: For any one of the images to be processed, the DM code coarse positioning image and the attitude calibrated image, performing binarization preprocessing on the image to be processed includes: The grayscale histogram of the pixel points in the central area of ​​the image to be processed is calculated and histogram equalization is performed; the image to be processed after the histogram equalization is subjected to USM sharpening and then divided into a number of local areas, and adaptive binarization processing is performed on each local area according to the pixel values ​​of the pixel points in each local area.

9. The DM code positioning and identification method according to claim 1, characterized in that: The candidate corner point combinations obtained based on the coordinates of the minimum oblique rectangle circumscribing the outline of the DM code include: The coordinates of the four vertices of the minimum oblique rectangle circumscribing the outline of the DM code are staggered and arranged in a clockwise order to obtain four candidate corner point combinations.

10. The DM code positioning and identification method according to claim 1, characterized in that: All candidate corner point combinations obtained by traversing in sequence include: The traversal is performed in the order of first traversing each candidate corner point combination obtained by pixel-by-pixel traversal, and then traversing each candidate corner point combination obtained by the semantic segmentation model.

Citation Information

Patent Citations

  • Two-dimensional code positioning method and system

    CN113705268A

  • DM code detection and identification method and device, computer equipment and storage medium

    CN116258155A