DM code detection method, system and device, storage medium and product
Through the precise positioning of the target detection model and the L-shaped solid edge characteristics, the problem of low success rate of DM code detection is solved, the identification accuracy in complex environments is improved, and its application scope in manufacturing and logistics industries is expanded.
Patent Information
- Application Number
- CN202510356257.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-07-04
AI Technical Summary
In the prior art, the success rate of DM code detection is not high, especially in complex environments, which affects its application in the manufacturing and logistics industries.
The object detection model is used to initially locate the DM code area, and the position and width are obtained by detecting the edges of the solid edge of the L-shaped shape are calculated, and the fine positioning image reconstruction is performed, and finally decoded.
It improves the detection success rate of DM codes, especially the identification accuracy in complex environments, and enhances its application effect in manufacturing and logistics industries.
Smart Images

Figure CN120258020A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image detection technology, and particularly to a method, system, device, storage medium and product for detecting DM codes. Background Art
[0002] The DM code (Data Matrix) is currently the two-dimensional barcode with the smallest printable size. The DM code can store 30 digits in an area of 25mm. 2 The DM code has excellent error correction ability. In some cases, only 20% of the barcode information needs to be read to accurately identify the barcode content.
[0003] Due to the advantages of small size and strong error correction ability, the DM code has a wide range of applications in some manufacturing and logistics industries with harsh environments. For example, it is used for the identification of small parts in complex environments such as those prone to chemical reagent pollution, mechanical wear, high temperature and high heat.
[0004] In industrial production, due to differences in the reflective properties of the substrate and manufacturing processes (such as silk screen printing or laser printing), as well as the "dot matrix" addition, the quality and pixel size of DM codes vary greatly. In related technologies, the detection success rate of DM codes is not high and needs to be improved. Summary of the Invention
[0005] For this reason, this application proposes a method for detecting DM codes, which can effectively improve the detection success rate of DM codes.
[0006] This application also proposes a system for detecting DM codes.
[0007] This application also proposes a device for detecting DM codes.
[0008] This application also proposes a computer-readable storage medium.
[0009] This application also proposes a computer program product.
[0010] The method for detecting DM codes according to the first aspect embodiment of this application includes the following steps:
[0011] Obtain an initial image, and preliminarily detect the area where the DM code is located through a target detection model;
[0012] By detecting the edge of the L-shaped solid edge of the DM code, obtain the position and width of the L-shaped solid edge, and deduce the version of the DM code;
[0013] According to the position of the L-shaped solid edge, extract the fine positioning image of the DM code in the initial image;
[0014] After reconstructing the fine positioning image, decode the DM code.
[0015] The DM code detection method according to the embodiment of the present application has at least the following beneficial effects: the target detection model preliminarily detects the area where the DM code is located, and then according to the characteristics of the L-shaped real edge of the DM code, completes the precise positioning of the L-shaped real edge, thereby extracting the precise positioning image of the DM code from the initial image, which helps to improve the success rate of decoding; in the decoding process, the decoding success rate of the DM code can be further improved by reconstructing the precise positioning image of the DM code.
[0016] According to some embodiments of the present application, the “detecting the edge of the L-shaped real side of the DM code, obtaining the position and width of the L-shaped real side, and calculating the version of the DM code” includes the following steps:
[0017] Gray-scaling, filtering and binarizing the image in the region to obtain a binarized image;
[0018] Using a rectangular envelope frame to tightly frame the L-shaped real edge in the binary image, screening out the rectangular envelope frames with the smallest area and within a set aspect ratio range, and selecting a group of rectangular envelope frames with the largest area and reaching a set duty ratio;
[0019] Extracting a rough positioning image of the DM code in the binary image according to the rectangular envelope, and preliminarily aligning the rough positioning image;
[0020] Performing a first opening operation on the coarse positioning image using a horizontal kernel operator, and performing a second opening operation on the coarse positioning image using a vertical kernel operator, thereby obtaining the endpoints and intersection points of the L-shaped real edge, and then determining the position of the L-shaped real edge;
[0021] The width of the L-shaped real edge is calculated based on the image of the coarse positioning image after the first opening operation and the image of the coarse positioning image after the second opening operation, thereby inferring the version of the DM code.
[0022] According to some embodiments of the present application, the “using a rectangular envelope frame to tightly frame the L-shaped real edge in the binary image, screening out the rectangular envelope frame with the smallest area and within the set aspect ratio range, and selecting a group of rectangular envelope frames with the largest area and reaching the set duty cycle” also includes the following steps:
[0023] If the rectangular envelope with the smallest area and within the set aspect ratio range cannot be screened out, the binary image is expanded in an accumulative and progressive manner, and the rectangular envelope with the smallest area and within the set aspect ratio range is screened out again.
[0024] According to some embodiments of the present application, the “reconstructing the precise positioning image” comprises the following steps:
[0025] Align the fine positioning image according to the position of the L-shaped solid edge;
[0026] Gray-scale the fine positioning image to obtain a gray-scale image;
[0027] According to the version of the DM code, divide the gray-scale image into grids equally to obtain the size of the grids;
[0028] Taking the gray value of the central area of the grid as a representative, comprehensively determine the black-and-white attribution of the grid by combining the global mean and local strength;
[0029] Identify the L-shaped solid edge and L-shaped virtual edge to complete the reconstruction of the DM code.
[0030] According to some embodiments of the present application, the "taking the gray value of the central area of the grid as a representative, comprehensively determine the black-and-white attribution of the grid by combining the global mean and local strength" includes the following steps:
[0031] Extract the maximum gray value and minimum gray value of the gray-scale image;
[0032] For the initial image with uniform illumination, use the average value of the maximum gray value and the minimum gray value as the global threshold to binarize the gray-scale image;
[0033] For the initial image with non-uniform illumination, use a sliding window dynamic threshold to binarize the gray-scale image.
[0034] According to some embodiments of the present application, the "decode the DM code" includes the following steps:
[0035] If the decoding is successful, output the decoding information;
[0036] If the decoding is not successful, perform several anti-interference processes on the reconstructed fine positioning image, and decode once after each anti-interference process until the decoding is successful.
[0037] According to some embodiments of the present application, the anti-interference process includes the following steps:
[0038] Based on the set neighborhood conditions, perform a pixel transformation operation on the reconstructed fine positioning image.
[0039] According to some embodiments of the present application, the "based on the set neighborhood conditions, perform a pixel transformation operation on the reconstructed fine positioning image" includes the following steps:
[0040] For any center point, if all the pixel points within the 3×3 four-neighborhood of the center point are white, and the number of pixel points within the 3×3 four-neighborhood whose gray values are higher than the gray value of the center point is greater than two, then change the center point from white to black.
[0041] According to some embodiments of the present application, the "performing a pixel transformation operation on the reconstructed fine-positioned image based on set neighborhood conditions" includes the following steps:
[0042] For any center point, if all the pixel points within the 3×3 four-neighborhood of the center point are black, and the number of pixel points within the 3×3 four-neighborhood whose gray values are lower than the gray value of the center point is greater than two, then change the center point from black to white.
[0043] According to some embodiments of the present application, the "performing a pixel transformation operation on the reconstructed fine-positioned image based on set neighborhood conditions" includes the following steps:
[0044] For any center point, if the gray value of the center point is lower than the median value of the pixel points within the 3×3 eight-neighborhood of the center point by a set amplitude, then change the center point from white to black.
[0045] According to some embodiments of the present application, the "performing a pixel transformation operation on the reconstructed fine-positioned image based on set neighborhood conditions" includes the following steps:
[0046] For any center point, if the gray value of the center point is higher than the median value of the pixel points within the 3×3 eight-neighborhood of the center point by a set amplitude, then change the center point from black to white.
[0047] A DM code detection system according to the second aspect embodiments of the present application includes:
[0048] A detection module, configured to obtain an initial image and preliminarily detect the area where the DM code is located through a target detection model;
[0049] A positioning module, configured to obtain the position and width of the L-shaped solid edge by detecting the edge of the L-shaped solid edge of the DM code, and deduce the version of the DM code;
[0050] An extraction module, configured to extract the fine-positioned image of the DM code in the initial image according to the position of the L-shaped solid edge;
[0051] A decoding module, configured to decode the DM code after reconstructing the fine-positioned image.
[0052] The DM code detection system according to the embodiments of the present application has at least the following beneficial effects: The target detection model initially detects the area where the DM code is located, and then, according to the characteristics of the L-shaped solid edge of the DM code, completes the accurate positioning of the L-shaped solid edge, so as to extract the accurately positioned image of the DM code from the initial image, which helps to improve the decoding success rate; during the decoding process, by reconstructing the accurately positioned image of the DM code, the decoding success rate of the DM code can be further improved.
[0053] A DM code detection device according to the third aspect embodiment of the present application includes:
[0054] A memory storing a computer program;
[0055] A processor, when the processor executes the computer program, can implement the steps of the DM code detection method as described above.
[0056] The DM code detection device according to the embodiments of the present application has at least the following beneficial effects: By implementing the above DM code detection method, the detection success rate of the DM code can be effectively improved.
[0057] A computer-readable storage medium according to the fourth aspect embodiment of the present application, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the DM code detection method as described above.
[0058] The DM code detection device according to the embodiments of the present application has at least the following beneficial effects: By implementing the above DM code detection method, the detection success rate of the DM code can be effectively improved.
[0059] A computer program product according to the fifth aspect embodiment of the present application, including a computer program, and when the computer program is executed by a processor, it implements the steps of the DM code detection method as described above.
[0060] The computer program product according to the embodiments of the present application has at least the following beneficial effects: By implementing the above DM code detection method, the detection success rate of the DM code can be effectively improved.
[0061] Additional aspects and advantages of the present application will be given in part in the following description, become apparent in part from the following description, or be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The following further describes the present application with reference to the drawings and embodiments, where:
[0063] Figure 1 is a flowchart of the DM code detection method according to the first embodiment of the present application;
[0064] Figure 2Example of the detection result of the DM code detection method according to the embodiment of the present application;
[0065] Figure 3 Flowchart of the DM code detection method according to the second embodiment of the present application;
[0066] Figure 4 Schematic diagram of the DM code detection system according to the first embodiment of the present application;
[0067] Figure 5 Schematic diagram of the DM code detection device according to the first embodiment of the present application.
[0068] Reference numerals: DM code detection system 100, detection module 110, positioning module 120, extraction module 130, decoding module 140;
[0069] DM code detection device 200, memory 210, processor 220. Detailed implementation manners
[0070] The embodiments of the present application will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals indicate the same or similar elements or elements with the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application and should not be construed as a limitation of the present application.
[0071] In the description of the present application, it should be understood that the orientation or positional relationship indicated by terms such as up, down, front, back, left, right, etc. is based on the orientation or positional relationship shown in the accompanying drawings. It is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as a limitation of the present application.
[0072] In the description of the present application, the meaning of several is one or more, the meaning of multiple is two or more, greater than, less than, exceeding, etc. are understood as not including the present number, and above, below, within, etc. are understood as not including the present number. If there is a description of first and second, it is only for the purpose of distinguishing technical features and should not be construed as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features or implicitly indicating the sequence of the indicated technical features.
[0073] In the description of the present application, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense. Those skilled in the art can reasonably determine the specific meanings of the above terms in the present application in combination with the specific content of the technical solution.
[0074] In the description of the present application, the description with reference to terms such as "one embodiment", "some embodiments", "schematic embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.
[0075] Referring to Figure 1 and Figure 2 , it should be noted that Figure 2 the solid rectangular frame in Figure 2 represents the detection result of the target detection model, and
[0076] S100. Obtain an initial image, and preliminarily detect the area where the DM code is located through the target detection model;
[0077] S200. By detecting the edges of the L-shaped solid edge of the DM code, obtain the position and width of the L-shaped solid edge, and deduce the version of the DM code;
[0078] S300. According to the position of the L-shaped solid edge, extract the fine positioning image of the DM code in the initial image;
[0079] S400. After reconstructing the fine positioning image, decode the DM code.
[0080] The DM code detection method according to the embodiment of the present application has at least the following beneficial effects: The target detection model preliminarily detects the area where the DM code is located, and then according to the characteristics of the L-shaped solid edge of the DM code, completes the accurate positioning of the L-shaped solid edge, so as to extract the fine positioning image of the DM code from the initial image, which helps to improve the decoding success rate; during the decoding process, by reconstructing the fine positioning image of the DM code, the decoding success rate of the DM code can be further improved.
[0081] It should be noted that the L-shaped solid edge is a set of vertical implementation edges of the DM code and is the search and positioning identifier of the DM code. The target detection model can be obtained by training the YOLO series detection models.
[0082] Referring to Figure 2 , in some embodiments of the present application, "by detecting the edges of the L-shaped solid edge of the DM code, obtaining the position and width of the L-shaped solid edge, and deducing the version of the DM code" includes the following steps:
[0083] Gray-scale, filter and binarize the image in the region to obtain a binary image;
[0084] Use a rectangular envelope frame to tightly frame the L-shaped real edge in the binary image, screen out the rectangular envelope frame with the smallest area and within the set aspect ratio range, and select a group of rectangular envelope frames with the largest area and reaching the set duty ratio;
[0085] According to the rectangular envelope, the rough positioning image of the DM code in the binary image is extracted, and the rough positioning image is preliminarily aligned;
[0086] Performing a first opening operation on the coarse positioning image using a horizontal kernel operator, and performing a second opening operation on the coarse positioning image using a vertical kernel operator, thereby obtaining the endpoints and intersection points of the L-shaped real edge, and then determining the position of the L-shaped real edge;
[0087] According to the image of the coarse positioning image after the first opening operation and the image of the coarse positioning image after the second opening operation, the width of the L-shaped real edge is calculated, thereby inferring the version of the DM code.
[0088] Graying, filtering and binarizing the area detected by the target detection model can reduce computational complexity, remove noise and highlight edges. The rectangular envelope has the smallest area and can locate the L-shaped real edge more accurately. Since the aspect ratio of the DM code is limited (for example, the aspect ratio of the rectangular DM code is 4:9 to 1:3), filtering the rectangular envelope within the set aspect ratio range can remove interference items. Through the first opening operation and the second opening operation, the shape of the L-shaped real edge can be made clearer and the positioning more accurate.
[0089] In summary, the significant feature of the DM code, that is, the L-shaped real edge, is conducive to accurately completing the positioning of the DM code and determining the version of the DM code.
[0090] Specifically, the filtering may be a median filter, and the binarization may be a single-threshold binarization or a multi-threshold adaptive binarization.
[0091] Reference Figure 2 In the improved scheme of the above embodiment, "using a rectangular envelope frame to tightly frame the L-shaped real edge in the binary image, screening out a rectangular envelope frame with the smallest area and within the set aspect ratio range, and selecting a group of rectangular envelope frames with the largest area and reaching the set duty cycle" also includes the following steps:
[0092] If the rectangular envelope with the smallest area and within the set aspect ratio range cannot be screened out, the binary image is expanded in an accumulative and progressive manner, and the rectangular envelope with the smallest area and within the set aspect ratio range is screened out again.
[0093] By dilating the binary image in an accumulative and progressive manner, the edges of the broken L-shaped real edges can be connected, the contour of the L-shaped real edges can be highlighted, and the contrast between the L-shaped real edges and the background can be increased, which is beneficial to improving the success rate of locating the L-shaped real edges.
[0094] Reference Figure 2 In some embodiments of the present application, "reconstructing the precise positioning image" includes the following steps: aligning the precise positioning image according to the position of the L-shaped real edge; graying the precise positioning image to obtain a grayed image; dividing the grayed image into grids according to the version of the DM code to obtain the size of the grid; using the gray value of the central area of the grid as a representative, combining the global mean and the local strength to comprehensively determine the black and white attribution of the grid; identifying the L-shaped real edge and the L-shaped imaginary edge to complete the reconstruction of the DM code.
[0095] By straightening the precise positioning image, it is helpful to meet the requirements of the decoding algorithm. By graying and grid-dividing the precise positioning image, the amount of data processing can be reduced, and precise positioning and feature extraction can be facilitated, which is beneficial to the subsequent DM code decoding.
[0096] Reference Figure 2 In the improved scheme of the above embodiment, "taking the grayscale value of the central area of the grid as a representative, combining the global mean and the local strength to comprehensively determine the black and white affiliation of the grid" includes the following steps: extracting the maximum grayscale value and the minimum grayscale value of the grayscale image; for the initial image with uniform illumination, using the average of the maximum grayscale value and the minimum grayscale value as the global threshold to binarize the grayscale image; for the initial image with uneven illumination, using the sliding window dynamic threshold to binarize the grayscale image.
[0097] For different lighting conditions, different binarization processing methods are used to process the initial image in a targeted manner, thereby retaining more detail information close to the initial image, which is beneficial to improving the decoding success rate of the DM code.
[0098] Reference Figure 2 In some embodiments of the present application, the "decoding the DM code" includes the following steps: if the decoding is successful, the decoding information is output; if the decoding is unsuccessful, the reconstructed precise positioning image is subjected to several anti-interference processings, and each time the anti-interference processing is completed, the image is decoded once until the decoding is successful.
[0099] By performing decoding processing after several times of anti-interference processing, it is helpful to reduce the interference of image noise on decoding, thereby further improving the decoding success rate of DM code.
[0100] Reference Figure 2, in some embodiments of the present application, the anti-interference processing includes the following steps: performing a pixel transformation operation on the reconstructed precise positioning image based on the set neighborhood conditions.
[0101] Performing a pixel transformation operation on the reconstructed precise positioning image based on the set neighborhood conditions can suppress noise and reduce the interference of factors such as uneven illumination, which is beneficial to improving the decoding success rate of the DM code.
[0102] Referring to Figure 2 , in the improved solution of the above embodiment, "performing a pixel transformation operation on the reconstructed precise positioning image based on the set neighborhood conditions" includes the following steps:
[0103] For any center point, if the pixel points within the 3×3 four-neighborhood of the center point are all white, and the number of pixel points within the 3×3 four-neighborhood whose gray value is higher than the gray value of the center point is greater than two, then change the center point from white to black.
[0104] The above operation helps to highlight the detailed parts in the image, that is, it can highlight the boundary of the DM code and remove local noise, which is beneficial to improving the decoding success rate of the DM code.
[0105] Referring to Figure 2 , in the improved solution of the above embodiment, "performing a pixel transformation operation on the reconstructed precise positioning image based on the set neighborhood conditions" includes the following steps:
[0106] For any center point, if the pixel points within the 3×3 four-neighborhood of the center point are all black, and the number of pixel points within the 3×3 four-neighborhood whose gray value is lower than the gray value of the center point is greater than two, then change the center point from black to white.
[0107] The above operation can adjust the dark area, helps to adjust the contrast and brightness of the dark part of the image, can highlight the boundary of the DM code and remove local noise, which is beneficial to improving the decoding success rate of the DM code.
[0108] Referring to Figure 2 , in the improved solution of the above embodiment, "performing a pixel transformation operation on the reconstructed precise positioning image based on the set neighborhood conditions" includes the following steps:
[0109] For any center point, if the gray value of the center point is lower than the median value of the pixel points within the 3×3 eight-neighborhood of the center point by a set amplitude, then change the center point from white to black.
[0110] The above operation has a larger neighborhood judgment range, better integrity, better anti-noise performance, stronger adaptability to light changes, can highlight the boundary of the DM code and remove local noise, which is beneficial to improving the decoding success rate of the DM code.
[0111] Reference Figure 2 In the improvement scheme of the above embodiment, "performing a pixel transformation operation on the reconstructed fine-positioning image based on the set neighborhood condition" includes the following steps:
[0112] For any center point, if the gray value of the center point is higher than the median of the pixel points within the 3×3 eight-neighborhood of the center point by a set amplitude, then the center point is changed from black to white.
[0113] The neighborhood judgment range of the above operation is larger, the integrity is better, the anti-noise performance is better, the adaptability to light changes is stronger, the boundary of the DM code can be highlighted, and local noise can be removed. Therefore, it is beneficial to improve the decoding success rate of the DM code.
[0114] It should be noted that the above four pixel transformation operations can be used separately. For example, the above four pixel transformation operations are respectively performed on the reconstructed fine-positioning image to obtain four images, and each image is decoded once. Several of the above four pixel transformation operations can also be selected for cumulative use. For example, the above four pixel transformation operations are successively performed on the reconstructed fine-positioning image to obtain one image, and this image is decoded.
[0115] Reference Figure 2 and Figure 3 to specifically describe the DM code detection method of an embodiment of the present application.
[0116] The DM code detection method of an embodiment of the present application is mainly divided into three major steps.
[0117] I. Preliminary detection
[0118] Function: Detect whether there is a DM code in the image. If so, give its position area.
[0119] Principle: As an important branch of visual tasks, object detection has seen the emergence of many excellent open-source deep learning detection frameworks in recent years. Among them, the YOLO series is particularly well-known. The DM code has some relatively stable graphic structures, which can be used as its common features for training and extraction to achieve detection.
[0120] Implementation method:
[0121] 1.1. Dataset collation.
[0122] Collect as many physical lighting images of DM codes in different versions and styles as possible, perform operations such as rotation, mirroring, slicing, and polarity flipping after annotation to enrich the samples.
[0123] 1.2 Model training.
[0124] Train the model in Python and export it as a model file after completion. Train once and use it anywhere.
[0125] 1.3. Deploy the application.
[0126] Load the model file in the C++ environment, call the inference interface, perform detection on the memory image, and obtain the results.
[0127] 2. Fine positioning
[0128] Function: In the detection area obtained in the previous step, the DM code is framed more compactly, the version is preliminarily estimated, and the orientation of its "L-shaped real edge" is determined.
[0129] Principle: Each candidate region obtained in step 1 is detected, such as Figure 2 The solid rectangular frame shown does not tightly frame the DM code, nor does it indicate the location of the "L-shaped real edge", which is not convenient for subsequent reconstruction, so further fine positioning is required. The unique L-shaped real edge and L-shaped virtual edge of the DM code become the key to positioning; based on the contour relationship, the "L-shaped real edge" is searched, and the combination is screened according to the aspect ratio of the minimum area envelope, and the group with the largest area is taken as the target item, and the version is inferred based on this.
[0130] Implementation method:
[0131] 2.1. Smoothing filtering.
[0132] According to the pixel size of the candidate area, median filtering can be performed using 3, 5, 7, or 9 sizes to remove some noise interference.
[0133] 2.2. Binarization.
[0134] The optional methods are single threshold binarization and multi-threshold adaptive binarization.
[0135] 2.3. L-shaped solid edge.
[0136] To extract the contour of a binary image, first select the contour with the largest size and the most square / rectangular shape, and it must reach a certain "duty cycle". If it fails, try again after dilating the binary image in an accumulative and progressive way and extracting the contour.
[0137] 2.4 Inferred boundaries.
[0138] According to the envelope frame, the code area image is extracted to achieve preliminary "straightening", and then the horizontal and vertical operators are used to perform opening operations to obtain the endpoints and intersection points of the L-shaped real edge, and then determine the orientation of the L-shaped real edge.
[0139] 2.5. Speculative version.
[0140] Based on the two opening operation result images in the previous step, the width of the L-shaped real edge is calculated, and then the version is derived.
[0141] 2.6 Take the picture and straighten it.
[0142] The grayscale image is transformed so that the entry point (intersection point) of the L-shaped real edge is located at the lower left corner to meet the subsequent decoding algorithm.
[0143] 3. Multi-Scheme Gradual Reconstruction
[0144] Function: Binarize the grayscale image, and convert each grid into a black or white point.
[0145] Principle: According to the version derived above, the grayscale image is divided into two grids to obtain the grid size, and then the grayscale value of the center area of the grid is used as a representative, and its black and white attribution is determined by combining the global mean and local strength. Finally, the L-shaped real edge and L-shaped imaginary edge are directly identified, thereby completing the reconstruction of the DM code.
[0146] Implementation method:
[0147] 3.1. Downsampling of the central area.
[0148] According to the current version, the grayscale image is evenly divided into grids, and the mean value of the central area of each grid is taken as the representative, which is compatible with the "dot matrix" method.
[0149] 3.2. Binarization operation.
[0150] In the obtained grayscale image, the maximum and minimum grayscale values are extracted. For the embodiment with uniform illumination, the average of the two maximum values can be used as the global threshold for binarization; for the embodiment with uneven illumination, the sliding window dynamic threshold binarization is used to obtain the initial reconstructed image.
[0151] 3.3. First decoding.
[0152] Set the L-shaped real edge and L-shaped imaginary edge to fixed styles respectively, and then use the standard process to decode. If successful, end here, otherwise continue.
[0153] 3.4. Secondary decoding.
[0154] In the initial reconstructed image, the center point that satisfies "the 3*3 four-neighborhood is white and the number of grayscale values higher than the center point is greater than two" is changed from white to black, and then the measures in step 3.3 are used to try to decode.
[0155] 3.5. Three decodings.
[0156] In the initial reconstructed image, the center point that satisfies "the 3*3 four-neighborhood is black and the number of grayscale values lower than the center point is greater than two" is changed from black to white, and then the measures in step 3.3 are used to try to decode.
[0157] 3.6, Fourth decoding.
[0158] In the initial reconstructed image, for the central points that satisfy "a certain amplitude lower than the median value of the 3*3 eight-neighborhood", change from white to black, and then attempt decoding using the measures in step 3.3.
[0159] 3.7, Fifth decoding.
[0160] In the initial reconstructed image, for the central points that satisfy "a certain amplitude higher than the median value of the 3*3 eight-neighborhood", change from black to white, and then attempt decoding using the measures in step 3.3.
[0161] Beneficial effects: The object detection model based on deep learning adopted in this application can initially detect the area where the DM code is located, eliminating the structured empirical tuning in traditional algorithms, having good universality, and being able to support "multiple codes in one image" from the source; then, automatically extract the threshold edges for each area respectively, and then accurately locate based on the contour relationship and estimate the layout; finally, gradually and multi-level alternately reconstruct and decode the "righted" grayscale DM image, greatly improving the success rate. Application examples are as Figure 2 shown. The solid rectangular frame is the detection result of the object detection model, the dashed rectangular frame is the fine positioning result, and the string "TEXT123456789" is the decoding result.
[0162] Refer to Figure 4 , A DM code detection system 100 according to an embodiment of the second aspect of the present application includes a detection module 110, a positioning module 120, an extraction module 130, and a decoding module 140. The detection module 110 is used to obtain an initial image and initially detect the area where the DM code is located through an object detection model. The positioning module 120 is used to obtain the position and width of the L-shaped solid edge by detecting the edge of the L-shaped solid edge of the DM code and calculate the version of the DM code. The extraction module 130 is used to extract the fine positioning image of the DM code in the initial image according to the position of the L-shaped solid edge. The decoding module 140 is used to decode the DM code after reconstructing the fine positioning image.
[0163] The DM code detection system 100 according to an embodiment of the present application has at least the following beneficial effects: The object detection model initially detects the area where the DM code is located, and then completes the accurate positioning of the L-shaped solid edge according to the characteristics of the L-shaped solid edge of the DM code, so as to extract the fine positioning image of the DM code from the initial image, which helps to improve the success rate of decoding; during the decoding process, by reconstructing the fine positioning image of the DM code, the decoding success rate of the DM code can be further improved.
[0164] Refer to Figure 5, A DM code detection device 200 according to an embodiment of the third aspect of the present application includes a memory 210 and a processor 220. The memory 210 stores a computer program. When the processor 220 executes the computer program, it can implement the steps of the DM code detection method as described above.
[0165] The DM code detection device 200 according to the embodiment of the present application has at least the following beneficial effects: By implementing the above DM code detection method, the detection success rate of the DM code can be effectively improved.
[0166] The memory 210 includes at least one type of readable storage medium. The readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 210 may be an internal storage unit of the DM code detection device 200, such as the hard disk or memory of the DM code detection device 200. In other embodiments, the memory 210 may also be an external storage device of the DM code detection device 200, such as a plug-in hard disk equipped on the DM code detection device 200, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Of course, the memory 210 may also include both the internal storage unit of the DM code detection device 200 and its external storage device. In this embodiment, the memory 210 is generally used to store the operating system installed on the DM code detection device 200 and various application software, such as the program code of the DM code detection method. In addition, the memory 210 may also be used to temporarily store various data that have been output or will be output.
[0167] In some embodiments, the processor 220 may be a Central Processing Unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 220 is generally used to control the overall operation of the DM code detection device 200. In this embodiment, the processor 220 is used to run the program code stored in the memory 210 or process data, such as running the program code of the DM code detection method.
[0168] In addition, the DM code detection device 200 generally further includes a display, a communication interface, and a bus. The memory 210, the processor 220, the display, and the communication interface can communicate with each other through the bus. The display screen is set to display the user operation interface preset in the initial setting mode, and at the same time, the display screen can also display the process control window. The communication interface may include a wireless network interface or a wired network interface.
[0169] According to an embodiment of the fourth aspect of the present application, a computer-readable storage medium stores a computer program thereon. When the computer program is executed by the processor 220, the steps of the above-mentioned DM code detection method are implemented.
[0170] The DM code detection device 200 according to the embodiment of the present application has at least the following beneficial effects: By implementing the above-mentioned DM code detection method, the detection success rate of the DM code can be effectively improved.
[0171] The computer-readable storage medium provided by the embodiment of the present application may be a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination of the above. More specific embodiments of the computer-readable storage medium may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, or magnetic storage devices, or any suitable combination of the above.
[0172] In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program can be used by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable storage medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0173] The above-mentioned computer-readable storage medium may be included in an electronic device or may exist separately without being loaded into the electronic device.
[0174] The computer program for executing the present application can be written in one or more programming languages or a combination thereof. The above-mentioned programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0175] A computer program product according to an embodiment of the fifth aspect of the present application includes a computer program. When the computer program is executed by a processor 220, it implements the steps of the DM code detection method as described above.
[0176] The computer program product according to the embodiment of the present application has at least the following beneficial effects: By implementing the above-mentioned DM code detection method, the detection success rate of the DM code can be effectively improved.
[0177] The embodiments of the present application have been described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the above embodiments. Within the scope of knowledge possessed by those of ordinary skill in the art, various changes can be made without departing from the purpose of the present application. In addition, the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
Claims
1. A method for detecting DM codes, characterized in that, The following steps are involved: Get the initial image and preliminarily detect the area where the DM code is located through the target detection model; By detecting the edge of the L-shaped real side of the DM code, the position and width of the L-shaped real side are obtained, and the version of the DM code is deduced; extracting a precise positioning image of the DM code in the initial image according to the position of the L-shaped real edge; After reconstructing the precise positioning image, the DM code is decoded.
2. The DM code detection method according to claim 1, wherein The "detecting the edge of the L-shaped real side of the DM code, obtaining the position and width of the L-shaped real side, and calculating the version of the DM code" includes the following steps: Gray-scaling, filtering and binarizing the image in the region to obtain a binarized image; Using a rectangular envelope frame to tightly frame the L-shaped real edge in the binary image, screening out the rectangular envelope frames with the smallest area and within a set aspect ratio range, and selecting a group of rectangular envelope frames with the largest area and reaching a set duty ratio; Extracting a rough positioning image of the DM code in the binary image according to the rectangular envelope, and preliminarily aligning the rough positioning image; Performing a first opening operation on the coarse positioning image using a horizontal kernel operator, and performing a second opening operation on the coarse positioning image using a vertical kernel operator, thereby obtaining the endpoints and intersection points of the L-shaped real edge, and then determining the position of the L-shaped real edge; The width of the L-shaped real edge is calculated based on the image of the coarse positioning image after the first opening operation and the image of the coarse positioning image after the second opening operation, thereby inferring the version of the DM code.
3. The DM code detection method according to claim 2, wherein The method of "using a rectangular envelope frame to tightly frame the L-shaped real edge in the binary image, screening out the rectangular envelope frames with the smallest area and within the set aspect ratio range, and selecting a group of rectangular envelope frames with the largest area and reaching the set duty cycle" also includes the following steps: If the rectangular envelope with the smallest area and within the set aspect ratio range cannot be screened out, the binary image is expanded in an accumulative and progressive manner, and the rectangular envelope with the smallest area and within the set aspect ratio range is screened out again.
4. The DM code detection method according to claim 1, wherein The “reconstructing the precise positioning image” comprises the following steps: According to the position of the L-shaped real edge, straightening the precise positioning image; Gray-scaling the precise positioning image to obtain a gray-scaling image; Dividing the grayscale image into grids according to the version of the DM code to obtain the size of the grids; Taking the gray value of the central area of the grid as a representative, combining the global mean and the local strength to comprehensively determine whether the grid is black or white; The L-shaped real edge and the L-shaped imaginary edge are identified to complete the reconstruction of the DM code.
5. The DM code detection method according to claim 4, characterized in that The "using the grayscale value of the central area of the grid as a representative, combining the global mean and the local strength to comprehensively determine the black and white attribution of the grid" includes the following steps: Extracting the maximum grayscale value and the minimum grayscale value of the grayscale image; For the initial image with uniform illumination, using the average of the maximum grayscale value and the minimum grayscale value as a global threshold, binarizing the grayscale image; For the initial image with uneven illumination, a sliding window dynamic threshold is used to binarize the grayscale image.
6. The DM code detection method according to claim 1, wherein The "decoding the DM code" includes the following steps: If the decoding is successful, the decoded information is output; If the decoding is unsuccessful, the refined localization image after reconstruction is subjected to several anti-interference processes, and each time after the anti-interference process, decoding is performed until the decoding is successful.
7. The DM code detection method according to claim 6, wherein The anti-interference process includes the following steps: Based on the set neighborhood conditions, a pixel transformation operation is performed on the refined localization image after reconstruction.
8. The DM code detection method according to claim 7, characterized in that, The "performing a pixel transformation operation on the refined localization image after reconstruction based on the set neighborhood conditions" includes the following steps: For any center point, if the pixel points within the 3×3 four-neighborhood of the center point are all white, and the number of the pixel points within the 3×3 four-neighborhood whose grayscale values are higher than the grayscale value of the center point is greater than two, then the center point is changed from white to black.
9. The DM code detection method according to claim 7, characterized in that The "performing a pixel transformation operation on the refined localization image after reconstruction based on the set neighborhood conditions" includes the following steps: For any center point, if the pixel points within the 3×3 four-neighborhood of the center point are all black, and the number of the pixel points within the 3×3 four-neighborhood whose grayscale values are lower than the grayscale value of the center point is greater than two, then the center point is changed from black to white.
10. The DM code detection method according to claim 7, wherein The "performing a pixel transformation operation on the refined localization image after reconstruction based on the set neighborhood conditions" includes the following steps: For any center point, if the grayscale value of the center point is lower than the median value of the pixel points within the 3×3 eight-neighborhood of the center point by a set amplitude, then the center point is changed from white to black.
11. The DM code detection method according to claim 7, wherein The "performing a pixel transformation operation on the refined localization image after reconstruction based on the set neighborhood conditions" includes the following steps: For any center point, if the grayscale value of the center point is higher than the median value of the pixel points within the 3×3 eight-neighborhood of the center point by a set amplitude, then the center point is changed from black to white.
12. A DM code detection system, characterized in that, It includes: A detection module, configured to obtain an initial image and preliminarily detect the area where the DM code is located through a target detection model; A localization module, configured to obtain the position and width of the L-shaped solid edge by detecting the edge of the L-shaped solid edge of the DM code, and deduce the version of the DM code; An extraction module, configured to extract the refined localization image of the DM code in the initial image according to the position of the L-shaped solid edge; A decoding module, configured to reconstruct the refined localization image and then decode the DM code.
13. A DM code detection device, characterized in that, It includes: A memory, storing a computer program; A processor, when the processor executes the computer program, can implement the steps of the DM code detection method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, it implements the steps of the DM code detection method according to any one of claims 1 to 11.
15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the DM code detection method according to any one of claims 1 to 11.