Positioning method and device for DM bar code and bar code recognition equipment
By segmenting DM barcode images into blocks and performing texture feature analysis, effective blocks are selected and statistical information is fused. Combined with the structural features of DM codes, the problem of low positioning accuracy of damaged barcodes is solved, and efficient positioning under complex working conditions is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-04-03
AI Technical Summary
In existing technologies, the positioning accuracy of DM barcodes decreases under conditions of oil stains, wear, scratches, or background interference, making reliable identification difficult under complex working conditions.
The DM barcode image is divided into multiple image blocks. Valid texture blocks are selected by using the histogram of the gradient direction of the blocks. The statistical information of all blocks is fused to determine the approximate boundary direction. The boundary is determined by fitting the texture boundary line and then verified by combining the structural features of the DM code.
It improves the robustness and accuracy of positioning damaged DM barcodes, enabling accurate positioning under complex working conditions, effectively connecting broken edge segments due to damage, suppressing background interference, and significantly improving the positioning success rate.
Smart Images

Figure CN121787448A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of barcode recognition technology, such as a positioning method and apparatus for DM barcodes, and a barcode recognition device. Background Technology
[0002] DM (Data Matrix) codes, as a type of high-density, high-reliability two-dimensional matrix barcode, have been widely used in key fields such as consumer electronics, industrial manufacturing, logistics traceability, and medical device management due to their powerful data carrying capacity and error correction performance in a very small space. Ensuring reliable identification under complex working conditions is of great significance for safeguarding the integrity of production processes and data chains. Currently, mainstream DM code positioning and decoding algorithms generally rely on boundary tracking technology. Its core logic is: first, detect the edge contours in the image, and then find a quadrilateral structure that conforms to the combination characteristics of an "L"-shaped solid edge (lookahead pattern) and an "L"-shaped dashed edge (clock track), thereby completing the barcode positioning.
[0003] In the process of implementing the embodiments of this disclosure, at least the following problems were found in the related art: In real-world industrial settings, DM codes often become severely damaged due to oil, wear, scratches, or background interference. When the 'L' locator or 'L' shaped railway line of the DM barcode is severely damaged, it can easily lead to a decrease in the positioning accuracy of the DM barcode.
[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] To provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. This summary is not intended as a general commentary, nor is it intended to identify key / important components or describe the scope of protection of these embodiments, but rather as a prelude to the detailed description that follows.
[0006] This disclosure provides a method and apparatus for locating DM barcodes, as well as a barcode recognition device, to improve the positioning accuracy of DM barcodes when they are damaged.
[0007] In some embodiments, the method for locating a DM barcode includes: dividing a DM barcode image containing the DM barcode into multiple image blocks and determining the DM barcode image blocks within the image blocks; determining the approximate boundary direction of the DM barcode image based on the DM barcode image blocks; fitting the texture boundary line of the DM barcode image using the approximate boundary direction as a reference direction; and determining the DM barcode boundary using the texture boundary line.
[0008] In some embodiments, the positioning device for DM barcodes includes a processor and a memory storing program instructions, the processor being configured to execute the aforementioned positioning method for DM barcodes when the program instructions are executed.
[0009] In some embodiments, the barcode recognition device includes: a barcode recognition device body; and the aforementioned positioning device for DM barcodes, disposed on the barcode recognition device body.
[0010] The positioning method and apparatus for DM barcodes and the barcode recognition device provided in this disclosure can achieve the following technical effects: In this disclosed technical solution, a DM barcode image containing a DM barcode is divided into multiple image blocks, and the DM barcode image blocks within the image blocks are determined. The approximate boundary direction of the DM barcode image is determined based on the DM barcode image blocks. Then, the approximate boundary direction is used as a reference direction to fit the texture boundary line of the DM barcode image. The DM barcode boundary is determined using the texture boundary line. In this way, the DM barcode image to be identified is divided into multiple image blocks, transforming the global localization problem into a statistical analysis of local texture features. Even if the "L"-shaped boundary of the barcode is locally broken or blurred due to dirt, as long as enough effective black and white modules are retained within the block, it can still show the double vertical peaks that characterize the DM code structure, thus being identified as a valid DM barcode image block. Subsequently, by fusing the statistical information of all DM barcode image blocks, the approximate boundary direction, which is not affected by local dirt, is estimated. Using the approximate boundary direction as a strong constraint, the texture boundary line of the DM barcode image is fitted, which can accurately focus on the angle range where the real boundary is located, effectively connecting the edge fragments that are broken due to dirt, thereby determining the DM barcode boundary and achieving accurate localization of the dirt-damaged DM barcode.
[0011] The above general description and the description below are exemplary and illustrative only and are not intended to limit this application. Attached Figure Description
[0012] One or more embodiments are illustrated by way of example with reference to the accompanying drawings. These illustrations and drawings do not constitute a limitation on the embodiments. Elements having the same reference numerals in the drawings are shown as similar elements. The drawings are not to be scaled. And wherein: Figure 1 This is a flowchart illustrating a method for locating DM barcodes provided in an embodiment of this disclosure; Figure 2 This is a flowchart illustrating another method for locating DM barcodes provided in an embodiment of this disclosure; Figure 3 This is a flowchart illustrating another method for locating DM barcodes provided in an embodiment of this disclosure; Figure 4 This is a flowchart illustrating another method for locating DM barcodes provided in an embodiment of this disclosure; Figure 5 This is a block gradient orientation histogram of an image block provided in an embodiment of this disclosure; Figure 6 This is a schematic diagram of the four-four boundary feature of a DM barcode provided in an embodiment of this disclosure; Figure 7 This is a schematic diagram of the structure of a positioning device for DM barcodes provided in an embodiment of this disclosure; Figure 8 This is a schematic diagram of the structure of a barcode recognition device provided in an embodiment of this disclosure. Detailed Implementation
[0013] To provide a more detailed understanding of the features and technical content of the embodiments of this disclosure, the implementation of the embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for illustrative purposes only and are not intended to limit the embodiments of this disclosure. In the following technical description, for ease of explanation, several details are used to provide a full understanding of the disclosed embodiments. However, one or more embodiments may still be implemented without these details. In other cases, well-known structures and devices may be simplified in their depiction to simplify the drawings.
[0014] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this disclosure described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion.
[0015] Unless otherwise stated, the term "multiple" means two or more. In embodiments of this disclosure, the character " / " indicates that the preceding and following objects are in an "OR" relationship. For example, A / B means: A or B. The term "and / or" describes an association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B. The term "correspondence" can refer to an association or binding relationship; A corresponding to B means that there is an association or binding relationship between A and B.
[0016] DM barcodes are two-dimensional matrix barcodes defined by the international standard ISO / IEC 16022. They use black and white squares arranged in a two-dimensional space to encode data, and are known for their extremely high data density and powerful built-in error correction capabilities, enabling them to encode dozens of characters within an area of several square millimeters. Figure 6As shown, the DM barcode includes: an L-shaped solid edge, an L-shaped solid line, a data area, and a quiet area. The L-shaped solid edge consists of two consecutive solid lines on the left and bottom sides of the DM barcode, forming an "L" shape. It serves as the initial positioning reference during decoding, determining the physical boundary and orientation of the barcode. The L-shaped solid line is located at the top and right boundaries of the DM barcode, opposite the L-shaped solid edge. It consists of alternating black and white squares in a 1:1:1:1 ratio, resembling a railway track, and provides a synchronization clock signal to determine the center position of individual modules (squares) and the precise size of the DM barcode (i.e., the number of rows / columns). The data area is an internal matrix composed of black and white squares, used to store the actual encoded data and error correction codes. The quiet area is the blank area that must be left around the DM barcode. It is a crucial prerequisite for ensuring that the barcode recognition device can reliably distinguish the barcode from background interference and is also an important basis for verifying the legality of the boundary in the positioning algorithm.
[0017] Combination Figure 1 As shown in the embodiments of this disclosure, a method for locating DM barcodes is provided, including the following steps: S101, divide the DM barcode image containing the DM barcode into multiple image blocks, and determine the DM barcode image blocks in the image blocks.
[0018] Optionally, the DM barcode image containing the DM barcode is divided into multiple image blocks, including: determining the number of target pixel modules in each image block; and dividing the DM barcode image into multiple image blocks according to the number of target pixel modules.
[0019] In some possible implementations, the number of target pixel modules in each image block is determined, including: the number of target pixel modules in each image block is a fixed number.
[0020] For example, each image block contains 5×5 pixel modules. Assuming the pixel module size is 4×4 pixels, the image block size is calculated as: 5 modules × 4 pixels / module = 20×20 pixels. For a 400×300 pixel DM barcode image: number of horizontal image blocks: 400÷20=20 image blocks; number of vertical image blocks: 300÷20=15 image blocks; total division: 20×15 = 300 image blocks.
[0021] Each block contains the same number of pixel modules to ensure the robustness of the gradient orientation histogram statistical features.
[0022] In some possible implementations, determining the number of target pixel modules in each image block includes: performing an image pyramid on the DM barcode image with a fixed image block size to determine the number of target pixel modules in each image block.
[0023] In some possible implementations, an image pyramid is performed on the DM barcode image to determine the number of target pixel modules within each image block. This includes: determining a fixed image block size and constructing an image pyramid for the input DM barcode image; at each image pyramid level, dividing the current-scale DM barcode image into grids using the fixed image block size to obtain multiple image blocks; estimating the number of pixel modules contained in each image block and evaluating different pixel module numbers to determine the most suitable first pixel module number. The first pixel module number is the target pixel module number within each image block.
[0024] In practical applications, constructing an image pyramid involves starting with the original DM barcode image and generating multiple scales of DM barcode images through Gaussian blurring and downsampling operations. The pyramid can contain 3-5 levels, with scale factors typically powers of 2 (e.g., 1:1, 1:2, 1:4, etc.), and each pyramid level represents a DM barcode image at a different observation scale.
[0025] By using pyramid multi-scale analysis, the physical size or imaging ratio of the DM barcode image can be found automatically to determine the most suitable feature extraction scale for the number of pixel modules, thus improving classification accuracy, without needing to know it in advance.
[0026] In some possible implementations, determining the number of target pixel modules in each image block includes: performing an image pyramid on the image blocks with a fixed DM barcode image size to determine the number of target pixel modules in each image block.
[0027] In some possible implementations, an image pyramid is performed on the image blocks to determine the number of target pixel modules within each image block. This includes: determining a fixed DM barcode image size and constructing a block pyramid for the image blocks; at each block pyramid level, dividing the fixed-size DM barcode image using the block size of the current level to obtain multiple image blocks; estimating the number of pixel modules contained in each image block and evaluating different pixel module numbers to determine the most suitable second pixel module number. The second pixel module number is the target pixel module number within each image block.
[0028] By combining fixed image size with block pyramids, the accuracy of feature extraction is ensured while maintaining computational efficiency.
[0029] S102, determine the approximate boundary direction of the DM barcode image based on the DM barcode image blocks.
[0030] Here, the approximate boundary directions of the DM barcode image are two nearly perpendicular principal directions extracted from the DM barcode image to represent the orientation of its internal grid texture. For example, the approximate boundary directions of the DM barcode image are determined to be θ1 and θ2.
[0031] S103, using the approximate boundary direction as the reference direction, fits the texture boundary line of the DM barcode image.
[0032] Using approximate boundary directions θ1 and θ2 as reference directions, the fitting angle ranges are determined respectively. For example, the first fitting angle range is [θ1-Δθ, θ1+Δθ], and the second fitting angle range is [θ2-Δθ, θ2+Δθ], where Δθ is the tolerance angle, with a value range of [2°, 5°]. A straight line is searched within the first fitting angle range to obtain the texture boundary line set L1, and a straight line is searched within the second fitting angle range to obtain the texture boundary line set L2.
[0033] S104, using texture boundary lines to determine the boundaries of the DM barcode.
[0034] After determining the orientation of the DM barcode based on the texture boundary line, the DM barcode boundary is determined based on the orientation. The correct DM barcode boundary is then selected using the four boundary features of the DM barcode, thereby achieving DM barcode positioning.
[0035] The positioning method for DM barcodes provided in this embodiment divides the DM barcode image containing the DM barcode into multiple image blocks, determines the DM barcode image blocks within the image blocks, determines the approximate boundary direction of the DM barcode image based on the DM barcode image blocks, and then uses the approximate boundary direction as a reference direction to fit the texture boundary line of the DM barcode image. The DM barcode boundary is then determined using the texture boundary line. In this way, the DM barcode image to be identified is divided into multiple image blocks, transforming the global localization problem into a statistical analysis of local texture features. Even if the "L"-shaped boundary of the barcode is locally broken or blurred due to dirt, as long as enough effective black and white modules are retained within the block, it can still show the double vertical peaks that characterize the DM code structure, thus being identified as a valid DM barcode image block. Subsequently, by fusing the statistical information of all DM barcode image blocks, the approximate boundary direction, which is not affected by local dirt, is estimated. Using the approximate boundary direction as a strong constraint, the texture boundary line of the DM barcode image is fitted, which can accurately focus on the angle range where the real boundary is located, effectively connecting the edge fragments that are broken due to dirt, thereby determining the DM barcode boundary and achieving accurate localization of the dirt-damaged DM barcode.
[0036] In some embodiments, determining the DM barcode image block in an image block includes: constructing a block gradient direction histogram for each image block; determining the DM barcode image block in the image block based on the gradient direction and gradient magnitude of the block gradient direction histogram; wherein the first gradient direction and the second gradient direction in the block gradient direction histogram of the DM barcode image block satisfy a preset direction condition, and the first gradient magnitude corresponding to the first gradient direction and the second gradient magnitude corresponding to the second gradient direction satisfy a preset magnitude condition.
[0037] The preset direction conditions include: the first gradient direction and the second gradient direction are perpendicular; or, the angle difference between the first gradient direction and the second gradient direction is between [85°, 95°]; the preset amplitude conditions include: the amplitude of the first gradient and the amplitude of the second gradient are both at least twice the average gradient amplitude, or, the sum of the amplitudes of the first gradient and the second gradient is greater than 60% of the total amplitude of the histogram of the gradient directions of the block.
[0038] For example, for a clean image block, its gradient direction histogram shows two prominent peaks, such as one at 15° and the other at 105°. Then, the angle difference between the first and second gradient directions is 90°, satisfying the preset direction condition; the sum of the magnitudes of the first and second gradients accounts for 70% of the total magnitude of the block's gradient direction histogram, satisfying the preset magnitude condition. Therefore, the clean image block is determined to be a DM barcode image block.
[0039] For example, in an image block partially contaminated with oil, the oil covers a portion of the module, but there are still many intact black and white alternating grids within the block. The histogram of the block's gradient direction still shows two roughly perpendicular peaks, for example, one at 15° and the other at 100°. Then, the angle difference between the first and second gradient directions is 85°, satisfying the preset direction condition; the sum of the magnitudes of the first and second gradients accounts for 61% of the total magnitude of the block's gradient direction histogram, satisfying the preset magnitude condition. Therefore, this partially oil-contaminated image block is identified as a DM barcode image block.
[0040] This method for identifying DM barcode image blocks does not require the block image to be intact; instead, it relies on the overall statistical characteristics of the undisturbed portions. As long as the contamination does not completely destroy the mesh texture pattern within the block, the block can be detected, thus overcoming the stringent dependence of traditional edge detection methods on contour integrity.
[0041] Optionally, combined Figure 5As shown, constructing a block gradient direction histogram for each image block includes: uniformly dividing the gradient direction value range of the image block into multiple gradient intervals; locating the target gradient interval among the multiple gradient intervals corresponding to the target gradient direction of each pixel in the image block; and statistically analyzing the gradient magnitude of the pixels in the target gradient interval to generate a block gradient direction histogram.
[0042] For example, if the gradient direction of an image block ranges from [0° to 180°], the gradient direction range of the image block can be evenly divided into 6 intervals, each spanning 30°: interval 0: [0°, 30°), interval 30: [30°, 60°), interval 60: [60°, 90°), ..., interval 150: [150°, 180°).
[0043] The image blocks are traversed pixel by pixel, and the difference values dx and dy in the horizontal and vertical directions are obtained respectively. Then, the gradient magnitude of the current pixel is calculated. gradient direction By accumulating the gradient magnitudes to the corresponding gradient intervals, the gradient direction histogram of the current block can be obtained. The gradient direction and magnitude of four pixels are calculated: pixel 1: gradient direction 10°, gradient magnitude 15; pixel 2: gradient direction 25°, gradient magnitude 40; pixel 3: gradient direction 80°, gradient magnitude 30; pixel 4: gradient direction 85°, gradient magnitude 35. The direction of each pixel is mapped to the corresponding gradient interval: pixel 1 belongs to interval 0, pixel 2 belongs to interval 0, pixel 3 belongs to interval 60, and pixel 4 belongs to interval 60. Using the gradient magnitude as the weight, the gradient magnitudes of pixels in the target gradient intervals are calculated: the accumulated gradient magnitude for interval 0 is 55, for interval 30 it is 0, for interval 60 it is 65, and for intervals 90, 120, and 150 it is 0. This generates the block's gradient direction histogram.
[0044] The pixel-level gradient vectors (gradient direction, gradient magnitude) are quantized and aggregated into a concise statistical chart. The gradient direction of a single pixel is susceptible to noise interference, but by accumulating its magnitude across its interval, the consistent directional signal generated by the real texture is enhanced, while random noise directions are dispersed across various intervals due to inconsistency, resulting in a small cumulative magnitude. This makes the dominant direction representing the real boundary stand out as a "peak" in the block gradient direction histogram, filtering out noise and amplifying the vertical bidirectional features representing the regular grid of the DM code. This provides reliable, stable, and easily processed input features for the entire localization algorithm.
[0045] Optionally, determining the approximate boundary direction of the DM barcode image based on the DM barcode block includes: determining the target block gradient direction histogram of the DM barcode image block; accumulating all target block gradient direction histograms to obtain the global block gradient direction histogram of the DM barcode image block; and using the gradient direction corresponding to the peak gradient magnitude in the global block gradient direction histogram as the approximate boundary direction.
[0046] For example, in the global block gradient direction histogram, if the gradient direction corresponding to the peak value of the first gradient is 105° and the gradient direction corresponding to the peak value of the second gradient is 15°, then the approximate boundary directions of the DM barcode image are determined to be 15° and 105°, with an angle of 90° between them, which conforms to the vertical texture characteristics of the DM code. Alternatively, in the global block gradient direction histogram, if the gradient direction interval corresponding to the peak value of the first gradient is [90°, 120°], and the center direction of the gradient direction interval is taken as 105°, and the gradient direction interval corresponding to the peak value of the second gradient is [0°, 30°], and the center direction of the gradient direction interval is taken as 15°, then the approximate boundary directions of the DM barcode image are determined to be 15° and 105°, with an angle of 90° between them, which conforms to the vertical texture characteristics of the DM code.
[0047] A single image block might calculate an incorrect orientation due to a blemish or low local contrast. However, by accumulating the statistical information from hundreds or thousands of blocks, the correct orientation becomes apparent because it is supported by the majority of blocks, while the orientations of random noise cancel each other out. This ensures that the extracted orientation represents a global attribute of the overall barcode pose, rather than a random local feature, providing reliable and consistent guidance for subsequent boundary fitting.
[0048] Combination Figure 2 As shown, the positioning method for DM barcodes includes the following steps: S201, divide the DM barcode image containing the DM barcode into multiple image blocks.
[0049] S202, construct the block gradient direction histogram for each image block.
[0050] S203, determine the DM barcode image block in the image block based on the gradient direction and gradient magnitude of the block gradient direction histogram.
[0051] S204, Determine the target block gradient direction histogram of the DM barcode image block.
[0052] S205, sum the gradient direction histograms of all target blocks to obtain the global block gradient direction histogram of the DM barcode image block.
[0053] S206, take the gradient direction corresponding to the peak value of the gradient magnitude in the global block gradient direction histogram as the approximate boundary direction.
[0054] S207, using the approximate boundary direction as the reference direction, fits the texture boundary line of the DM barcode image.
[0055] S208 uses texture boundary lines to determine the boundaries of DM barcodes.
[0056] In this embodiment, the robustness of positioning damaged DM barcodes is effectively improved by shifting the positioning basis from relying on intact physical edges to analyzing statistical texture features. First, effective texture blocks are selected through image segmentation and gradient direction histograms to isolate local damage and ensure the stability of feature extraction. Second, statistical information from all DM barcode image blocks is fused to obtain a robust global direction, overcoming local noise and bias. Then, texture boundary fitting is performed using this direction as a strong constraint, which can accurately connect broken edges and suppress background interference. Finally, the inherent "L-shaped solid edge-railway line" structural feature of the DM barcode is used for verification to accurately determine the boundary, thereby significantly improving the overall positioning success rate and accuracy of DM barcodes under complex working conditions.
[0057] In some embodiments, fitting the texture boundary line of the DM barcode image using the approximate boundary direction as a reference direction includes: using the approximate boundary direction as a reference direction, performing a texture boundary fitting algorithm to obtain the texture boundary line of the DM barcode image; wherein the texture boundary fitting algorithm includes the Hough transform algorithm, the LSD algorithm, or the edge gradient clustering algorithm.
[0058] In some possible implementations, the approximate boundary direction is used as a reference direction, and the Hough transform algorithm is performed to obtain the texture boundary line of the DM barcode image. This includes: determining the fitting angle range through the approximate boundary direction; searching for a straight line within the fitting angle range to obtain the texture boundary line of the DM barcode image.
[0059] Using approximate boundary directions θ1 and θ2 as reference directions, the fitting angle ranges are determined respectively. For example, the first fitting angle range is [θ1-Δθ, θ1+Δθ], and the second fitting angle range is [θ2-Δθ, θ2+Δθ], where Δθ is the tolerance angle, with a value range of [2°, 5°]. In the first fitting angle range, a straight line is searched. Points with significant peaks at edge points roughly corresponding to θ1 are detected as straight lines, resulting in texture boundary line set L1. In the second fitting angle range, a straight line is searched again. Points with significant peaks at edge points roughly corresponding to θ2 are detected as straight lines, resulting in texture boundary line set L2. Texture boundary line sets L1 and L2 serve as candidate lines for DM code boundaries.
[0060] The Hough transform algorithm is employed because it can aggregate spatially discontinuous edge points in the same direction. Even if a solid edge of the DM code is broken into several segments due to contamination, as long as the direction of these line fragments is still within the range of θ1±Δθ, all edge points will accumulate near the same point in the parameter space and will eventually be fused and identified as the same complete straight line, thus effectively crossing the contamination area.
[0061] In some possible implementations, the approximate boundary direction is used as a reference direction, and the LSD algorithm is executed to obtain the texture boundary line of the DM barcode image. This includes: determining the fitting angle range through the approximate boundary direction; and selecting line segments within the fitting angle range from all line segments obtained by LSD to obtain the texture boundary line of the DM barcode image.
[0062] The LSD algorithm is adopted because the output of the LSD algorithm is a line segment, which is easier to combine directly into an "L" shaped solid edge. The line segment form does not require additional calculation of intersection points or truncation, which is more in line with the boundary expression of the physical world.
[0063] In some possible implementations, the approximate boundary direction is used as a reference direction to perform an edge gradient clustering algorithm to obtain the texture boundary line of the DM barcode image. This includes: extracting edge points and the gradient direction corresponding to the edge points; performing directional clustering of edge points with the approximate boundary direction as the cluster center; and performing straight line fitting on points of the same class to obtain the texture boundary line of the DM barcode image.
[0064] In practical applications, edge points can be clustered directionally by calculating the minimum angular distance from each edge point to the two cluster centers. For points within each cluster, a straight line is fitted using methods such as least squares.
[0065] Employing an edge gradient clustering algorithm, spatially discontinuous edge points can be aggregated and fitted into the same straight line as long as their gradient directions are consistent. This algorithm can penetrate the interference caused by contamination and reconstruct the obscured geometry, making it particularly suitable for handling extreme contamination scenarios such as severe fractures, point corrosion, or a large amount of noise.
[0066] Optionally, the boundary of the DM barcode is determined using texture boundary lines, including: traversing the texture boundary lines and taking the texture boundary lines that satisfy the DM barcode boundary conditions as the DM barcode boundary; wherein, the DM barcode boundary conditions include one or more of the following conditions: barcode front and back color attribute constraint conditions; barcode opposite edge feature constraint conditions; barcode solid edge side white space constraint conditions.
[0067] In some possible implementations, the texture boundary line is determined to satisfy the barcode positive and negative color attribute constraint as follows: at adjacent positions on both sides of the normal direction of each texture boundary line, pixels are sampled respectively; the first average gray value of the sampled pixels in the inner barcode area and the second average gray value of the sampled pixels in the outer quiet area are calculated; if the gray value difference between the first average gray value and the second average gray value is greater than the gray value difference threshold, the texture boundary line is determined to satisfy the barcode positive and negative color attribute constraint.
[0068] Here, the normal direction is the direction that points from the perpendicular boundary into the barcode.
[0069] In some possible implementations, the texture boundary line is determined to satisfy the barcode edge feature constraint as follows: when two adjacent texture boundary lines form an L-shaped solid edge, and when two adjacent texture boundary lines form an L-shaped railway line corresponding to the L-shaped solid edge, the texture boundary line is determined to satisfy the barcode edge feature constraint.
[0070] In some possible implementations, combining Figure 6 As shown, the texture boundary line is determined to satisfy the barcode solid edge white space constraint condition in the following way: a white space detection scan line is set at a preset distance from the texture boundary line; if the ratio of the legal white space length to the detection scan line length is greater than the set ratio threshold, the texture boundary line is determined to satisfy the barcode solid edge white space constraint condition.
[0071] Here, the legal white space length is the length of the scan line composed of pixels whose gray value is higher than the background threshold in the detection scan line. The preset distance can be 1 / 2 pixel module width, and the set ratio threshold can be 0.5, 0.6 or 0.7.
[0072] By setting boundary conditions for DM barcodes, all false boundaries are eliminated from candidate lines with extremely high precision, ensuring the uniqueness and correctness of the output results.
[0073] Combination Figure 3 As shown, the positioning method for DM barcodes includes the following steps: S301, divide the DM barcode image containing the DM barcode into multiple image blocks, and determine the DM barcode image blocks in the image blocks.
[0074] S302, determine the approximate boundary direction of the DM barcode image based on the DM barcode image blocks.
[0075] S303, using the approximate boundary direction as the reference direction, executes a texture boundary fitting algorithm to obtain the texture boundary line of the DM barcode image.
[0076] S304, Traverse the texture boundary lines and take the texture boundary lines that satisfy the DM barcode boundary conditions as the DM barcode boundary.
[0077] This embodiment significantly improves the robustness and accuracy of localization of contaminated DM barcodes through a multi-level collaborative processing mechanism: First, by segmenting the image and performing local texture statistical analysis, the localization basis is transformed from fragile physical edges to robust gradient direction features, effectively isolating the interference of local contamination and filtering out effective areas; Second, statistical information of DM barcode image blocks is fused to estimate the accurate global boundary direction, providing a reliable prior for subsequent steps; Next, boundary fitting is performed with this direction as a strong constraint, which can accurately focus on and connect the real boundary segments broken due to contamination, while eliminating most background interference; Finally, by traversing and verifying whether the candidate boundary lines meet the inherent structural conditions of the DM code, the correct physical boundary can still be output when the quiet area is contaminated, thus realizing the whole-process anti-contamination optimization from feature perception, direction guidance to structure verification.
[0078] In some specific practical applications, combined with Figure 4 As shown, the positioning method for DM barcodes includes the following steps: S401 divides the DM barcode image containing the DM barcode into multiple image blocks.
[0079] S402, construct the block gradient direction histogram for each image block.
[0080] S403, determine the DM barcode image block in the image block based on the gradient direction and gradient magnitude of the block gradient direction histogram.
[0081] S404, Determine the target block gradient direction histogram of the DM barcode image block.
[0082] S405, sum the gradient direction histograms of all target blocks to obtain the global block gradient direction histogram of the DM barcode image block.
[0083] S406 uses the gradient direction corresponding to the peak value of the gradient magnitude in the global block gradient direction histogram as the approximate boundary direction.
[0084] S407, using the approximate boundary direction as the reference direction, executes a texture boundary fitting algorithm to obtain the texture boundary line of the DM barcode image.
[0085] S408: Traverse the texture boundary lines and use the texture boundary lines that satisfy the DM barcode boundary conditions as the DM barcode boundary.
[0086] This technical solution effectively improves the localization effect of contaminated DM codes through a systematic processing flow: First, image segmentation and gradient direction histogram analysis transform the dependent object from physical contours into robust texture statistical features. Even if the local "L"-shaped edge is contaminated, the grid texture preserved in the block can still be identified as a valid region through the bimodal histogram. Second, the statistical information of all valid blocks is fused to obtain an interference-resistant approximate boundary direction. This serves as a strong constraint to guide the boundary fitting algorithm, which can accurately connect broken edges and filter background clutter. Finally, by verifying whether the candidate boundary conforms to the structural constraints of the DM code, such as the "solid edge-rail line" pairing and probabilistic white space, it ensures that accurate boundaries can still be output when the quiet area is contaminated, thus achieving robust localization with high tolerance to contamination as a whole.
[0087] This disclosure discloses a method based on block gradient orientation histograms to determine DM barcode image blocks within an image block and to determine the approximate boundary orientation of the DM barcode image. In practical applications, methods based on deep learning and frequency domain texture analysis can also be used to determine DM barcode image blocks within an image block and to determine the approximate boundary orientation of the DM barcode image.
[0088] In some possible implementations, determining the DM barcode image block in the image block includes: obtaining a lightweight fully convolutional network (FCN); inputting multiple image blocks of the DM barcode image into the fully convolutional network, wherein the output of the fully convolutional network is a pixel-level segmentation map of the same size as the input image (or downsampled proportionally); and taking the connected pixel groups in the pixel-level segmentation map that are predicted to be DM code regions as DM barcode image blocks.
[0089] Determining the approximate boundary direction of a DM barcode image based on DM barcode image blocks includes: inputting the DM barcode image blocks into a fully convolutional network, wherein the output of the fully convolutional network is the two principal direction angle values of the DM barcode image; and using the two principal direction angle values as the approximate boundary direction.
[0090] In some possible implementations, determining the DM barcode image block in the image block includes: performing a two-dimensional Fourier transform (2D-FFT) on each image block to obtain a frequency domain spectrum, thereby converting the image block from the spatial domain to the frequency domain; analyzing the frequency domain spectrum to calculate the distribution concentration of frequency domain energy at different angles; and identifying the image block with concentrated frequency domain energy at a specific angle as the DM barcode image block.
[0091] Determining the approximate boundary direction of a DM barcode image based on DM barcode image blocks includes: analyzing the direction of the line connecting conjugate bright spots in the Fourier spectrum of the DM barcode image block; and using the direction of the line connecting conjugate bright spots as the approximate boundary direction.
[0092] Combination Figure 7As shown, this embodiment of the disclosure provides a positioning device (e.g., a computer, controller, etc.) 700 for DM barcodes, including a processor 70 and a memory 71, and may also include a communication interface 72 and a bus 73. The processor 70, communication interface 72, and memory 71 can communicate with each other via the bus 73. The communication interface 72 can be used for information transmission. The processor 70 can call logical instructions in the memory 71 to execute the positioning method for DM barcodes described in the above embodiment.
[0093] Furthermore, the logic instructions in the aforementioned memory 71 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.
[0094] The memory 71, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of this disclosure. The processor 70 executes functional applications and data processing by running the program instructions / modules stored in the memory 71, that is, it implements the positioning method for DM barcodes in the above method embodiments.
[0095] The memory 71 may include a program storage area and a data storage area. The program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the terminal device. Furthermore, the memory 71 may include high-speed random access memory and may also include non-volatile memory.
[0096] The positioning device for DM barcodes provided in this disclosure divides the DM barcode image to be identified into multiple image blocks, transforming the global positioning problem into a statistical analysis of local texture features. Even if the "L"-shaped boundary of the barcode is partially broken or blurred due to dirt, as long as enough effective black and white modules are retained within the block, it can still display the double vertical peaks that characterize the DM code structure, thus being identified as a valid DM barcode image block. Subsequently, by fusing the statistical information of all DM barcode image blocks, the approximate boundary direction, which is not affected by local dirt, is estimated. Using the approximate boundary direction as a strong constraint, the texture boundary line of the DM barcode image is fitted, which can accurately focus on the angle range where the real boundary is located, effectively connecting the edge fragments that are broken due to dirt, thereby determining the DM barcode boundary and achieving accurate positioning of the dirt-damaged DM barcode.
[0097] In some embodiments, combined with Figure 8As shown, the barcode recognition device 800 includes: a barcode recognition device body 80; and the aforementioned positioning device 700 for DM barcodes, which is disposed on the barcode recognition device body 80.
[0098] This disclosure provides a computer-readable storage medium storing computer-executable instructions configured to perform the above-described positioning method for DM barcodes.
[0099] This disclosure provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions that, when executed by a computer, cause the computer to perform the above-described positioning method for DM barcodes.
[0100] The aforementioned computer-readable storage medium may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.
[0101] The technical solutions of this disclosure can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes one or more instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in this disclosure. The aforementioned storage medium can be a non-transitory storage medium, including: a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and other media capable of storing program code; it can also be a transient storage medium.
[0102] The foregoing description and accompanying drawings fully illustrate embodiments of the present disclosure to enable those skilled in the art to practice them. Other embodiments may include structural, logical, electrical, procedural, and other changes. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the order of operation may vary. Parts and features of some embodiments may be included or substituted for parts and features of other embodiments. The scope of the embodiments of this disclosure includes the entire scope of the claims and all available equivalents of the claims. While the terms “first,” “second,” etc., may be used in this application to describe elements, these elements should not be limited by these terms. These terms are used only to distinguish one element from another. For example, a first element may be called a second element without changing the meaning of the description, and similarly, a second element may be called a first element, provided that all occurrences of “first element” are consistently renamed and all occurrences of “second element” are consistently renamed. First and second elements are both elements, but may not be the same element. Moreover, the terminology used in this application is only for describing embodiments and is not intended to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “the” are intended to also include the plural forms. Similarly, the term “and / or” as used herein means including one or more of the associated listed any and all possible combinations. Additionally, when used herein, the terms “comprise” and its variations “comprises” and / or “comprising” refer to the presence of stated features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof. Without further limitations, an element defined by the phrase “comprising an…” does not exclude the presence of additional identical elements in the process, method, or apparatus that includes said element. In this document, each embodiment may focus on the differences from other embodiments, and similar or identical parts between embodiments can be referred to mutually. For methods, products, etc., disclosed in the embodiments, if they correspond to the method section disclosed in the embodiments, the relevant parts can be referred to the description of the method section.
[0103] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this disclosure. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0104] The methods and products disclosed in the embodiments herein (including but not limited to devices and equipment) can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of units may be merely a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to implement this embodiment according to actual needs. In addition, the functional units in the embodiments of this disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0105] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than that shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different blocks may also occur in a different order than disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. Each block in a block diagram and / or flowchart, and combinations of blocks in a block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
Claims
1. A positioning method for DM barcodes, characterized in that, include: Divide the DM barcode image containing the DM barcode into multiple image blocks, and determine the DM barcode image blocks within the image blocks; Determine the approximate boundary direction of the DM barcode image based on the DM barcode image blocks; Using the approximate boundary direction as a reference direction, the texture boundary line of the DM barcode image is fitted. The boundaries of the DM barcode are determined using texture boundary lines.
2. The positioning method according to claim 1, characterized in that, The DM barcode image containing the DM barcode is divided into multiple image blocks, including: Determine the number of target pixel modules in each image block; The DM barcode image is divided into multiple image blocks according to the number of target pixel modules.
3. The positioning method according to claim 1, characterized in that, Identify the DM barcode image block within the image block, including: Construct a histogram of gradient orientations for each image block; The DM barcode image block in the image block is determined based on the gradient direction and gradient magnitude of the block gradient direction histogram. Among them, the first gradient direction and the second gradient direction in the block gradient direction histogram of the DM barcode image block satisfy the preset direction conditions, and the first gradient magnitude corresponding to the first gradient direction and the second gradient magnitude corresponding to the second gradient direction satisfy the preset magnitude conditions.
4. The positioning method according to claim 3, characterized in that, Constructing a histogram of gradient orientations for each image block, including: The gradient direction range of the image block is evenly divided into multiple gradient intervals; Locate the target gradient interval among multiple gradient intervals corresponding to the target gradient direction of each pixel in the image block; The gradient magnitudes of pixels within the target gradient interval are statistically analyzed, and a histogram of gradient directions for each block is generated.
5. The positioning method according to claim 1, characterized in that, Determining the approximate boundary direction of the DM barcode image based on the DM barcode blocks includes: Determine the target block gradient orientation histogram of the DM barcode image block; The gradient orientation histograms of all target blocks are summed to obtain the global block gradient orientation histogram of the DM barcode image blocks; The gradient direction corresponding to the peak gradient magnitude in the global block gradient direction histogram is taken as the approximate boundary direction.
6. The positioning method according to claim 1, characterized in that, Using the approximate boundary direction as a reference direction, the texture boundary line of the DM barcode image is fitted, including: Using the approximate boundary direction as a reference direction, a texture boundary fitting algorithm is executed to obtain the texture boundary line of the DM barcode image; Among them, texture boundary fitting algorithms include Hough transform algorithm, LSD algorithm or edge gradient clustering algorithm.
7. The positioning method according to any one of claims 1 to 6, characterized in that, Determine the boundaries of the DM barcode using texture boundary lines, including: Traverse the texture boundary lines and use the texture boundary lines that satisfy the DM barcode boundary conditions as the DM barcode boundary; wherein, the DM barcode boundary conditions include one or more of the following conditions: Barcode front and back color attribute constraints; Barcode edge feature constraints; Barcode solid edge margin constraint.
8. The positioning method according to claim 7, characterized in that, The texture boundary line should satisfy the barcode solid edge white space constraint as follows: Set a white space detection scan line at a preset distance from the texture boundary line; If the ratio of the legal blank length to the detection scan line length is greater than the set ratio threshold, the texture boundary line is determined to meet the blank constraint condition of the barcode solid edge side.
9. A positioning device for DM barcodes, comprising a processor and a memory storing program instructions, characterized in that, The processor is configured to perform the positioning method for DM barcodes as described in any one of claims 1 to 8 when executing the program instructions.
10. A barcode recognition device, characterized in that, include: Barcode recognition device body; The positioning device for DM barcodes as described in claim 9 is disposed on the body of the barcode recognition device.