Data matrix code recognition method, device, equipment and medium
By combining global scanning and target detection, the data matrix code is cropped and locally decoded step by step, which solves the problems of code region detail loss and low decoding efficiency in complex images, and achieves decoding results with high recall and accurate localization.
Patent Information
- Application Number
- CN202611414587.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-11
- Publication Date
- 2026-11-27
AI Technical Summary
When processing complex industrial images, existing technologies are prone to loss of detail in the data matrix code area due to scaling operations, resulting in low decoding efficiency and the decoding results failing to correspond to the physical location of the image, leading to low recognition recall and low efficiency of manual review.
The initial code value is obtained by global scanning and decoding, and the number of candidate boxes is obtained by object detection. The comparison is used to determine the subsequent processing flow. Unsolved candidate boxes are subjected to step-by-step edge expansion and cropping and local decoding. Variants are dynamically sorted and processed using image quality assessment. Finally, an annotation map is generated through spatial correlation verification.
It improves the decoding recall rate under complex working conditions, reduces invalid computation time, provides accurate area positioning guidance, and improves the efficiency of manual verification.
Smart Images

Figure CN123180192A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision and machine-readable tag recognition technology, and in particular to a data matrix code recognition method, apparatus, device and medium. Background Technology
[0002] In the medical device and IVD product supply chain, DataMatrix codes are often engraved, printed, or affixed to product packaging, labels, or process carriers as data carriers for product identification and end-to-end traceability. After on-site acceptance personnel complete product confirmation, the relevant coding information needs to be collected using equipment. In the actual collected images, there are cases where the code area boundaries are incomplete, the background texture is complex, there is glare, low contrast, blurriness, tilt, or partial obstruction.
[0003] Existing technologies for processing the aforementioned industrial images typically involve directly calling a general-purpose decoder to process the entire original image, which presents the following problems: 1. The code area occupies a small proportion in a large image, and scaling operations will cause the loss of module details, resulting in missed reads; 2. Repeatedly performing enhancement and decoding processing on the entire image results in low computational efficiency and easily introduces interference from irrelevant areas; 3. The decoder only outputs a list of code values, and the operator cannot determine the physical location of each code value in the original image, and cannot locate the code area to be verified; 4. When multiple code regions exist simultaneously in an image or the decoding result is incomplete, the correspondence between code values and actual positions can easily become confused.
[0004] Therefore, a scheme is needed that can first locate the candidate regions of the DataMatrix using a dedicated object detection model, then perform hierarchical enhancement decoding on the candidate regions, and verify and visualize the decoding results and their locations, in order to improve the recognition recall, processing efficiency, and manual verification efficiency in complex images. Summary of the Invention
[0005] Based on this, it is necessary to propose a data matrix code recognition method, device, equipment, and medium to address the above-mentioned problems. This is to solve the technical problems of existing technologies when processing complex industrial images, such as the easy loss of small-size code details due to relying solely on full-image scaling and decoding, the low processing efficiency caused by repeatedly performing time-consuming image enhancement on the full image, and the fact that the decoding output only provides code values and cannot be verified and traced against the physical location of the image.
[0006] To achieve the above objectives, the present invention provides the following technical solution: In a first aspect, the present invention provides a data matrix code recognition method, comprising the following steps: The image to be processed is acquired, global scanning decoding is performed on the image to be processed, and deduplication, length filtering and inclusion relationship filtering are performed on the global scanning decoding result to obtain an initial set of identified code values, and the number of first code values in the initial set of identified code values is counted. In response to enabling AI-enhanced recognition, target detection is performed on the image to be processed to obtain an initial candidate box set representing the region containing the data matrix code. Non-maximum suppression is performed on the initial candidate box set according to the intersection-union ratio to obtain a deduplicated candidate box set, and the number of second candidate boxes in the deduplicated candidate box set is counted. Comparing the number of the first code values with the number of the second candidate boxes, when the number of the first code values is less than the number of the second candidate boxes, for each candidate box in the deduplicated candidate box set, multiple progressively increasing edge expansion amounts are determined based on the size information of the candidate box, and edge expansion and cropping are performed sequentially to obtain a multi-level cropped image; for each level of cropped image, multiple image processing variants are generated sequentially and local decoding is performed until a valid code value is obtained, at which point the processing is terminated, and the valid code values are merged into the initial identified code value set to obtain the final identified code value set; Obtain the four-corner coordinates corresponding to each code value in the final identified code value set. By determining the spatial intersection-union ratio and center point distance between the area enclosed by the four-corner coordinates and each candidate box in the deduplicated candidate box set, perform spatial association verification on the code values and candidate boxes. Based on the verification results, generate a labeled map containing different matching confidence states and output results.
[0007] Furthermore, after comparing the number of the first code values with the number of the second candidate boxes, the method further includes: when the number of the first code values is greater than or equal to the number of the second candidate boxes, determining that the global scanning decoding has covered all detected candidate regions, skipping the multi-level pruning and local decoding process performed on the deduplicated candidate box set, and directly proceeding to the step of obtaining the four-corner coordinates corresponding to each code value in the final identified code value set and performing spatial association verification.
[0008] Furthermore, the step of sequentially generating multiple image processing variants and performing local decoding for each level of cropped image specifically includes: performing image quality assessment on the current cropped image to determine the contrast, sharpness, and noise level indices of the cropped region; dynamically sorting the image enhancement pipeline according to the image quality assessment results, and sequentially generating image processing variants and performing local decoding according to the sorting priority; wherein, local contrast enhancement is prioritized for low-contrast images, median filtering or denoising and sharpening is prioritized for high-noise images, and anti-masking sharpening is prioritized for blurred images. After performing local decoding until a valid code value is obtained and the processing is terminated, the method further includes: if the multi-level cropped image corresponding to each level of edge expansion amount does not obtain a valid code value after the variant decoding, and the size of the current cropped area is smaller than a preset value, the cropped area is interpolated and enlarged by a preset multiple, and after copying the edge pixels to form a border, the variant decoding is performed again.
[0009] Furthermore, in response to enabling AI-enhanced recognition, target detection is performed on the image to be processed to obtain an initial candidate box set representing regions containing data matrix codes. Specifically, this includes: performing inference on the same image to be processed with at least two input sizes, and applying a detection confidence threshold lower than the conventional standard and / or enabling test-time enhancement for at least one input size to obtain multiple candidate boxes; when the size of the image to be processed exceeds a preset size, target detection is performed on patches with overlapping areas, and the local detection boxes are converted to full-image coordinates by offsetting the coordinates of the top left corner of the patch; the candidate boxes obtained from each round of inference and each patch are merged to obtain the initial candidate box set.
[0010] Further, by determining the spatial intersection-union ratio and center point distance between the enclosed area of the four corner coordinates and each candidate box in the deduplicated candidate box set, spatial association verification is performed on the code value and the candidate box; based on the verification results, a labeled map containing different matching confidence states and output results are generated, specifically including: when the spatial intersection-union ratio is greater than or equal to a preset threshold and the center point distance is less than a preset proportion of the diagonal length of the corresponding candidate box, it is determined as a valid match and the corresponding candidate box is associated with the code value; for candidate boxes that have not yet been associated, the candidate box and the preset edge area are cropped and re-decoded, and associated with another color when the recognition is successful; when there are still unassociated candidate boxes and unassociated code values, one-by-one exclusion matching is performed according to the remaining set; based on the above multi-layer verification mechanism, different colors or marks are used to represent different levels of matching confidence in the labeled map, and candidate boxes without any matching code values are marked with a warning color as areas to be verified.
[0011] Furthermore, the step of performing global scan decoding on the image to be processed specifically includes: obtaining the scan level selected by the user, wherein the scan level includes at least a fast level, a balanced level, and a powerful level; different scan levels correspond to different scaling scales, image blocks, and preprocessing sets; in response to selecting a balanced level or a powerful level, after performing a full-image basic scan, further sliding at a step size smaller than a preset window size to crop blocks with overlapping windows and perform local supplementary scan decoding.
[0012] Furthermore, determining multiple progressively increasing edge expansion amounts based on the size information of the candidate box specifically includes: determining multiple percentage levels and corresponding minimum pixel values based on the maximum side length of the candidate box to calculate progressively increasing edge expansion amounts; adaptively adjusting the edge expansion amounts based on the aspect ratio of the candidate box, configuring a larger expansion amount in the length direction of the candidate box, and limiting all cropping boundaries to the range of the image to be processed.
[0013] In a second aspect, the present invention provides a data matrix code recognition device, the device comprising: The global scanning module is used to acquire the image to be processed, perform global scanning decoding on the image to be processed, and perform deduplication, length filtering and inclusion relationship filtering on the global scanning decoding result to obtain an initial set of identified code values, and count the number of first code values in the initial set of identified code values. The target detection module is used to respond to the activation of AI-enhanced recognition by performing target detection on the image to be processed, obtaining an initial candidate box set representing the region containing the data matrix code, performing non-maximum suppression on the initial candidate box set according to the intersection-union ratio to obtain a deduplicated candidate box set, and counting the number of second candidate boxes in the deduplicated candidate box set. The local rescue decoding module is used to compare the number of the first code values with the number of the second candidate boxes. When the number of the first code values is less than the number of the second candidate boxes, for each candidate box in the deduplicated candidate box set, multiple progressively increasing edge expansion amounts are determined based on the size information of the candidate box, and edge expansion and cropping are performed sequentially to obtain multi-level cropped images. For each level of cropped image, multiple image processing variants are generated sequentially and local decoding is performed until a valid code value is obtained, at which point the processing is terminated, and the valid code value is merged into the initial identified code value set to obtain the final identified code value set. The spatial verification and annotation module is used to obtain the four-corner coordinates corresponding to each code value in the final identified code value set, and to perform spatial association verification on the code value and the candidate box by determining the spatial intersection-union ratio and center point distance between the area enclosed by the four-corner coordinates and each candidate box in the deduplicated candidate box set; and to generate an annotation map and output results containing different matching confidence states based on the verification results.
[0014] Thirdly, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the method described in the first aspect.
[0015] Fourthly, the present invention provides a computer device including a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method as described in the first aspect.
[0016] The embodiments of the present invention have the following beneficial effects: The present invention provides a data matrix code recognition method. First, a global scan decoding is performed on the image to obtain the number of initially recognized code values. Then, the number of candidate boxes is obtained by object detection. The subsequent process is determined by comparing the relationship between the two numbers. When the number of initial code values is less than the number of candidate boxes, the edge expansion amount is set incrementally based on the size of the unsolved candidate boxes to perform edge expansion and cropping. Multiple image processing variants are generated to perform local decoding. Finally, spatial correlation verification is performed by determining the intersection and union ratio of the four corner coordinates of the code values and the candidate boxes to output a state annotation map. This technical solution achieves on-demand allocation and scheduling of image processing computing power by logically comparing the number of decoded images with the number predicted by the detection model. When no missed reads are determined, subsequent processing is skipped, reducing the invalid computation time in the batch processing. By generating progressively increasing expansion amounts based on the candidate box size for cropping, the static area necessary for decoding the data matrix code is compensated. At the same time, combined with multi-variant image processing, the edge truncation and detail loss problems of small-sized or low-contrast code areas are overcome, improving the decoding recall rate under complex working conditions. By calculating the spatial intersection-union ratio and the distance to the center point to perform spatial matching, the simple text decoding result is transformed into a visual label with location attributes, providing accurate area positioning guidance for the subsequent manual verification process. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] in: Figure 1 This is a flowchart of a data matrix code recognition method in one embodiment. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] In one embodiment, a data matrix code recognition method is proposed, such as... Figure 1 As shown, the method includes the following steps: Step S1: Obtain the image to be processed, perform global scanning decoding on the image to be processed, and perform deduplication, length filtering and inclusion relationship filtering on the global scanning decoding result to obtain an initial set of identified code values, and count the number of first code values in the initial set of identified code values.
[0021] Specifically, the global scan decoding of the image to be processed includes: obtaining the scan level selected by the user, wherein the scan level includes at least a fast level, a balanced level, and a powerful level; different scan levels correspond to different scaling scales, image chunks, and preprocessing sets; in response to selecting a balanced level or a powerful level, after performing a basic full-image scan, further sliding at a step size smaller than a preset window size to crop chunks with overlapping windows and perform local supplementary scan decoding. In length filtering, the preset minimum effective code value length can be 15 characters, and longer code values are retained for results with inclusion relationships.
[0022] The Fast level can limit the original image to the first maximum side length (e.g., 1600 pixels) and perform a basic decoding; the Equalized level can limit the original image to the second maximum side length (e.g., 2500 pixels), and after scanning the entire image, it can be cut into blocks according to the first window size (e.g., 1000×1000 pixels) for supplementary scanning; the Powerful level can first perform a preview scan with a higher upper limit scaling of the image, and then slide on the original image in steps smaller than the window size, and crop with overlapping windows, thereby avoiding the code area located at the block boundary being truncated.
[0023] Before each decoding, edge pixels of the image or image block can be copied to form a border to fill the DataMatrix still area close to the cropping boundary. One or more scaling ratios can be used for different scan levels, preferably including the original ratio, the reduced ratio, and the enlarged ratio.
[0024] By setting up multi-level scanning configurations and inclusion relationship filtering mechanisms, clear code areas that can be identified under normal conditions can be quickly filtered out, establishing a benchmark identified set and providing an accurate data foundation for subsequent data comparison.
[0025] Step S2: In response to enabling AI-enhanced recognition, target detection is performed on the image to be processed to obtain an initial candidate box set representing the region containing the data matrix code. Non-maximum suppression is performed on the initial candidate box set according to the intersection-union ratio to obtain a deduplicated candidate box set, and the number of second candidate boxes in the deduplicated candidate box set is counted.
[0026] Specifically, the target detection employs a model trained on data matrix code region annotation samples, such as the YOLO series models. The model does not directly output the DataMatrix content, but rather outputs the location and confidence score of the region containing the data matrix code. Training data is collected from real-world industrial scenarios such as medical device packaging and labeling. Annotated samples cover complex conditions including varying lighting, shooting angles, partial occlusion, blur, and low contrast, and a multi-scale annotation strategy is used to adapt to code regions of different sizes. During model training, the data matrix code region is distinguished from other code types such as QR codes and barcodes to reduce the false detection rate. In the inference phase, based on the precision-recall curve of the validation set, an optimal confidence threshold can be determined under preset recall constraints, replacing the fixed threshold and reducing invalid candidate boxes entering subsequent decoding pipelines.
[0027] The process of performing object detection to obtain an initial candidate box set includes: performing inference on the same image to be processed with at least two input sizes (e.g., 640, 1280, 1920 pixels), and applying a detection confidence threshold lower than the conventional standard (e.g., 0.10 to 0.15) and / or enabling test-time enhancement for at least one input size to obtain multiple candidate boxes; when the size of the image to be processed exceeds a preset size (e.g., 2500 pixels), performing object detection on patches with overlapping regions respectively, and converting the local detection boxes to full-image coordinates by offsetting the coordinates of the top left corner of the patch; merging the candidate boxes obtained from each round of inference and each patch to obtain the initial candidate box set, wherein the cross-union threshold for non-maximum suppression is set to 0.5.
[0028] By combining multi-scale inference with large image overlay and slicing, it can adapt to high-resolution images captured by industrial cameras. By setting a low confidence level and non-maximum suppression, it retains potential code regions in environments with blurred edges or weak contrast, thereby reducing the false negative rate in the target detection stage.
[0029] Step S3: Compare the number of the first code values with the number of the second candidate boxes, and determine the computing power allocation path based on the comparison result: when the number of the first code values is greater than or equal to the number of the second candidate boxes, it is determined that the global scanning decoding has covered all candidate regions, skip step S4 and trigger step S5; when the number of the first code values is less than the number of the second candidate boxes, step S4 is triggered. Specifically, the number of identified code values obtained in the previous step is compared with the number of candidate boxes output by the object detection. If the number of the first code value is greater than or equal to the number of the second candidate box, it indicates that the full-image scanning decoding has covered all detected candidate code areas, and it is determined that there is no missed reading in the current image. Therefore, it is not necessary to enable the missed reading remediation process based on object detection, and the subsequent edge expansion and image enhancement variant steps are skipped directly, and the verification and annotation stage is entered.
[0030] If the number of first code values is less than the number of second candidate boxes, it indicates that there are candidate code regions that were not successfully identified by the full-image scan but were circled by the target detection model. According to the predetermined branch, the regions not covered by the global scan are input into the local image enhancement decoding step for secondary parsing.
[0031] A bypass skipping mechanism was constructed by comparing the number of the first code values with the number of the second candidate boxes. When the global scan has completely covered the detection results, the resource-intensive local enhancement decoding link is eliminated, thereby improving the overall throughput efficiency of the system.
[0032] Step S4: For each candidate box in the deduplicated candidate box set, determine multiple progressively increasing edge expansion amounts based on the size information of the candidate box, and perform edge expansion and cropping sequentially to obtain multi-level cropped images; for each level of cropped image, generate multiple image processing variants sequentially and perform local decoding until a valid code value is obtained, then terminate the processing, and merge the valid code value into the initial identified code value set to obtain the final identified code value set.
[0033] Specifically, determining multiple progressively increasing edge expansion amounts includes: determining multiple percentage levels (e.g., 15%, 30%, 50%) and corresponding minimum pixel values (e.g., 30, 60, 100 pixels) based on the maximum side length of the candidate box, to calculate progressively increasing edge expansion amounts; adaptively adjusting the edge expansion amounts according to the aspect ratio of the candidate box, configuring a larger expansion amount in the length direction of the candidate box, and limiting all cropping boundaries within the range of the image to be processed.
[0034] The process of generating multiple image processing variants and performing local decoding includes: performing image quality assessment on the current cropped image to determine the contrast, sharpness, and noise level indices of the cropped region; dynamically sorting the image enhancement pipeline according to the image quality assessment results, and generating image processing variants in sequence according to the sorting priority to perform local decoding; wherein, for low-contrast images, local contrast enhancement (such as CLAHE) is performed first; for high-noise images, median filtering or denoising followed by sharpening is performed first; and for blurred images, anti-masking sharpening is performed first; if the multi-level cropped images corresponding to each level of edge expansion do not obtain valid code values after the variant decoding, and the size of the current cropped region is smaller than a preset value (e.g., the maximum side is less than 150 pixels), the cropped region is interpolated and enlarged by a preset multiple (e.g., four times), and after copying the edge pixels to form a border, the variant decoding is performed again.
[0035] By adopting an adaptive edge expansion strategy, the background region can be gradually introduced as a quiet zone compensation for the data matrix code, avoiding the cutting of key modules caused by single fixed-size cropping. Combined with dynamically sorted image processing variants and a mechanism that terminates upon the first result, the system can perform targeted repair of blurred and noisy images in the shortest possible time. The introduction of a fallback strategy of enlarging and copying edges solves the problem that the decoder cannot recognize small code distances due to insufficient pixel information.
[0036] Step S5: Obtain the four-corner coordinates corresponding to each code value in the final identified code value set. By determining the spatial intersection-union ratio and center point distance between the area enclosed by the four-corner coordinates and each candidate box in the deduplicated candidate box set, perform spatial association verification on the code value and the candidate box. Based on the verification results, generate a labeled map containing different matching confidence states and output results.
[0037] Specifically, the steps of performing spatial association verification and generating a state include: when the spatial intersection-union ratio is greater than or equal to a preset threshold (e.g., 0.3) and the distance to the center point is less than a preset proportion (e.g., 0.5) of the diagonal length of the corresponding candidate box, it is determined to be a valid match and the corresponding candidate box is associated with the code value, and a first confirmation state is assigned; for candidate boxes that have not yet been associated, the candidate box and the preset edge region are cropped and re-decoded, and when the recognition is successful, they are associated with another color, and a second local confirmation state is assigned; when there are still unassociated candidate boxes and unassociated code values, one-to-one exclusion matching is performed according to the remaining set, and a third estimated association state is assigned; Based on the aforementioned multi-layered verification mechanism, different colors or markers are used in the annotation image to represent the matching credibility at different levels, and candidate boxes with no matching code values are marked with a warning color (e.g., a question mark) as areas to be verified. The output results include a summary table containing the image name, the final number of decoded codes, and the number of areas to be verified, as well as a detailed table for each code value.
[0038] By employing a multi-layered verification mechanism that utilizes the inclusion and distance relationships of geometric spatial coordinates, the decoded information is matched and locked with the corresponding local features of the image. The hierarchical confirmation strategy can effectively distinguish between results with clear correspondence and inferred results. By marking color warnings, the review system can intuitively point out the locations of abnormal or undecoded code areas, reducing information omissions.
[0039] This invention first performs global scanning decoding on the image to obtain the initial number of identified code values, then uses object detection to obtain the number of candidate boxes, and determines the subsequent process by comparing the quantity relationship between the two; when the initial number of code values is less than the number of candidate boxes, the edge expansion amount is set incrementally based on the size of the unsolved candidate boxes to perform edge expansion and cropping, and multiple image processing variants are generated to perform local decoding. Finally, spatial correlation verification is performed by determining the intersection and union ratio of the four corner coordinates of the code values and the candidate boxes to output a state annotation map. This technical solution achieves on-demand allocation and scheduling of image processing computing power by logically comparing the number of decoded images with the number predicted by the detection model. When no missed reads are determined, subsequent processing is skipped, reducing the invalid computation time in the batch processing. By generating progressively increasing expansion amounts based on the candidate box size for cropping, the static area necessary for decoding the data matrix code is compensated. At the same time, combined with multi-variant image processing, the edge truncation and detail loss problems of small-sized or low-contrast code areas are overcome, improving the decoding recall rate under complex working conditions. By calculating the spatial intersection-union ratio and the distance to the center point to perform spatial matching, the simple text decoding result is transformed into a visual label with location attributes, providing accurate area positioning guidance for the subsequent manual verification process.
[0040] In one embodiment, a data matrix code recognition device is provided, the device comprising: The global scanning module is used to acquire the image to be processed, perform global scanning decoding on the image to be processed, and perform deduplication, length filtering and inclusion relationship filtering on the global scanning decoding result to obtain an initial set of identified code values, and count the number of first code values in the initial set of identified code values. The target detection module is used to respond to the activation of AI-enhanced recognition by performing target detection on the image to be processed, obtaining an initial candidate box set representing the region containing the data matrix code, performing non-maximum suppression on the initial candidate box set according to the intersection-union ratio to obtain a deduplicated candidate box set, and counting the number of second candidate boxes in the deduplicated candidate box set. The local rescue decoding module is used to compare the number of the first code values with the number of the second candidate boxes. When the number of the first code values is less than the number of the second candidate boxes, for each candidate box in the deduplicated candidate box set, multiple progressively increasing edge expansion amounts are determined based on the size information of the candidate box, and edge expansion and cropping are performed sequentially to obtain multi-level cropped images. For each level of cropped image, multiple image processing variants are generated sequentially and local decoding is performed until a valid code value is obtained, at which point the processing is terminated, and the valid code value is merged into the initial identified code value set to obtain the final identified code value set. The spatial verification and annotation module is used to obtain the four-corner coordinates corresponding to each code value in the final identified code value set, and to perform spatial association verification on the code value and the candidate box by determining the spatial intersection-union ratio and center point distance between the area enclosed by the four-corner coordinates and each candidate box in the deduplicated candidate box set; and to generate an annotation map and output results containing different matching confidence states based on the verification results.
[0041] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the following steps: The image to be processed is acquired, global scanning decoding is performed on the image to be processed, and deduplication, length filtering and inclusion relationship filtering are performed on the global scanning decoding result to obtain an initial set of identified code values, and the number of first code values in the initial set of identified code values is counted. In response to enabling AI-enhanced recognition, target detection is performed on the image to be processed to obtain an initial candidate box set representing the region containing the data matrix code. Non-maximum suppression is performed on the initial candidate box set according to the intersection-union ratio to obtain a deduplicated candidate box set, and the number of second candidate boxes in the deduplicated candidate box set is counted. Comparing the number of the first code values with the number of the second candidate boxes, when the number of the first code values is less than the number of the second candidate boxes, for each candidate box in the deduplicated candidate box set, multiple progressively increasing edge expansion amounts are determined based on the size information of the candidate box, and edge expansion and cropping are performed sequentially to obtain a multi-level cropped image; for each level of cropped image, multiple image processing variants are generated sequentially and local decoding is performed until a valid code value is obtained, at which point the processing is terminated, and the valid code values are merged into the initial identified code value set to obtain the final identified code value set; Obtain the four-corner coordinates corresponding to each code value in the final identified code value set. By determining the spatial intersection-union ratio and center point distance between the area enclosed by the four-corner coordinates and each candidate box in the deduplicated candidate box set, perform spatial association verification on the code values and candidate boxes. Based on the verification results, generate a labeled map containing different matching confidence states and output results.
[0042] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, causes the processor to perform the following steps: The image to be processed is acquired, global scanning decoding is performed on the image to be processed, and deduplication, length filtering and inclusion relationship filtering are performed on the global scanning decoding result to obtain an initial set of identified code values, and the number of first code values in the initial set of identified code values is counted. In response to enabling AI-enhanced recognition, target detection is performed on the image to be processed to obtain an initial candidate box set representing the region containing the data matrix code. Non-maximum suppression is performed on the initial candidate box set according to the intersection-union ratio to obtain a deduplicated candidate box set, and the number of second candidate boxes in the deduplicated candidate box set is counted. Comparing the number of the first code values with the number of the second candidate boxes, when the number of the first code values is less than the number of the second candidate boxes, for each candidate box in the deduplicated candidate box set, multiple progressively increasing edge expansion amounts are determined based on the size information of the candidate box, and edge expansion and cropping are performed sequentially to obtain a multi-level cropped image; for each level of cropped image, multiple image processing variants are generated sequentially and local decoding is performed until a valid code value is obtained, at which point the processing is terminated, and the valid code values are merged into the initial identified code value set to obtain the final identified code value set; Obtain the four-corner coordinates corresponding to each code value in the final identified code value set. By determining the spatial intersection-union ratio and center point distance between the area enclosed by the four-corner coordinates and each candidate box in the deduplicated candidate box set, perform spatial association verification on the code values and candidate boxes. Based on the verification results, generate a labeled map containing different matching confidence states and output results.
[0043] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0044] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0045] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A data matrix code recognition method, characterized in that, The method includes: The image to be processed is acquired, global scanning decoding is performed on the image to be processed, and deduplication, length filtering and inclusion relationship filtering are performed on the global scanning decoding result to obtain an initial set of identified code values, and the number of first code values in the initial set of identified code values is counted. In response to enabling AI-enhanced recognition, target detection is performed on the image to be processed to obtain an initial candidate box set representing the region containing the data matrix code. Non-maximum suppression is performed on the initial candidate box set according to the intersection-union ratio to obtain a deduplicated candidate box set, and the number of second candidate boxes in the deduplicated candidate box set is counted. Comparing the number of the first code values with the number of the second candidate boxes, when the number of the first code values is less than the number of the second candidate boxes, for each candidate box in the deduplicated candidate box set, multiple progressively increasing edge expansion amounts are determined based on the size information of the candidate box, and edge expansion and cropping are performed sequentially to obtain a multi-level cropped image; for each level of cropped image, multiple image processing variants are generated sequentially and local decoding is performed until a valid code value is obtained, at which point the processing is terminated, and the valid code values are merged into the initial identified code value set to obtain the final identified code value set; Obtain the four-corner coordinates corresponding to each code value in the final identified code value set. By determining the spatial intersection-union ratio and center point distance between the area enclosed by the four-corner coordinates and each candidate box in the deduplicated candidate box set, perform spatial association verification on the code values and candidate boxes. Based on the verification results, generate a labeled map containing different matching confidence states and output results.
2. The data matrix code recognition method according to claim 1, characterized in that, After comparing the number of the first code values with the number of the second candidate boxes, the method further includes: When the number of the first code values is greater than or equal to the number of the second candidate boxes, it is determined that the global scanning decoding has covered all detected candidate regions. The multi-level pruning and local decoding process performed on the deduplicated candidate box set is skipped, and the process directly proceeds to obtain the four-corner coordinates corresponding to each code value in the final identified code value set and perform spatial association verification.
3. The data matrix code recognition method according to claim 1, characterized in that, The process of sequentially generating multiple image processing variants for each level of cropped image and performing local decoding specifically includes: The image quality of the current cropped image is evaluated to determine the contrast, sharpness, and noise level of the cropped region. Based on the results of the image quality evaluation, the image enhancement pipeline is dynamically sorted, and image processing variants are generated in sequence according to the sorting priority to perform local decoding. Specifically, local contrast enhancement is performed first for low-contrast images, median filtering or denoising and sharpening is performed first for high-noise images, and anti-masking sharpening is performed first for blurred images. After performing local decoding until a valid code value is obtained and the processing is terminated, the method further includes: if the multi-level cropped image corresponding to each level of edge expansion amount does not obtain a valid code value after the variant decoding, and the size of the current cropped area is smaller than a preset value, the cropped area is interpolated and enlarged by a preset multiple, and after copying the edge pixels to form a border, the variant decoding is performed again.
4. The data matrix code recognition method according to claim 1, characterized in that, In response to enabling AI-enhanced recognition, target detection is performed on the image to be processed to obtain an initial set of candidate boxes representing regions containing data matrix codes, specifically including: Inference is performed on the same image to be processed with at least two input sizes, and a detection confidence threshold lower than the standard is applied to at least one input size and / or test-time enhancement is enabled to obtain multi-way candidate boxes; When the size of the image to be processed exceeds the preset size, target detection is performed on patches with overlapping areas, and the local detection box is converted into full-image coordinates by offsetting the coordinates of the upper left corner of the patch. The candidate boxes obtained from each round of reasoning and each tile are merged to obtain the initial candidate box set.
5. The data matrix code recognition method according to claim 1, characterized in that, The step involves determining the spatial intersection-union ratio and center point distance between the area enclosed by the four corner coordinates and each candidate box in the deduplicated candidate box set, and then performing spatial association verification between the code value and the candidate box. Based on the verification results, an annotation map and output results containing different matching confidence levels are generated, specifically including: When the spatial intersection-union ratio is greater than or equal to a preset threshold and the distance between the center points is less than a preset proportion of the diagonal length of the corresponding candidate box, it is determined to be a valid match and the corresponding candidate box is associated with the code value. For candidate boxes that have not yet been associated, the candidate box and the preset edge area are cropped and re-decoded, and associated with a different color when the recognition is successful. If there are still unassociated candidate boxes and unassociated code values, perform one-by-one elimination matching based on the remaining set; Different colors or symbols are used to represent different levels of matching confidence in the annotation diagram, and candidate boxes with no matching code values are marked with warning colors as areas to be checked.
6. The data matrix code recognition method according to claim 1, characterized in that, The step of performing global scanning decoding on the image to be processed specifically includes: Obtain the scan level selected by the user, which includes at least three scan levels: fast, balanced, and powerful. Different scan levels correspond to different scaling scales, image slicing, and preprocessing sets; In response to the selection of equalization level or intensity level, after performing a full-image basic scan, the system further slides in steps smaller than the preset window size to crop blocks with overlapping windows and perform local supplementary scanning decoding.
7. The data matrix code recognition method according to claim 1, characterized in that, The step of determining multiple progressively increasing edge expansion amounts based on the candidate box size information specifically includes: Based on the maximum side length of the candidate box, multiple percentage levels and corresponding minimum pixel values are determined to calculate the progressively increasing edge expansion amount; The edge expansion amount is adaptively adjusted according to the aspect ratio of the candidate box, a larger expansion amount is configured in the length direction of the candidate box, and all cropping boundaries are limited to the range of the image to be processed.
8. A data matrix code recognition device, characterized in that, The device includes: The global scanning module is used to acquire the image to be processed, perform global scanning decoding on the image to be processed, and perform deduplication, length filtering and inclusion relationship filtering on the global scanning decoding result to obtain an initial set of identified code values, and count the number of first code values in the initial set of identified code values. The target detection module is used to respond to the activation of AI-enhanced recognition by performing target detection on the image to be processed, obtaining an initial candidate box set representing the region containing the data matrix code, performing non-maximum suppression on the initial candidate box set according to the intersection-union ratio to obtain a deduplicated candidate box set, and counting the number of second candidate boxes in the deduplicated candidate box set. The local rescue decoding module is used to compare the number of the first code values with the number of the second candidate boxes. When the number of the first code values is less than the number of the second candidate boxes, for each candidate box in the deduplicated candidate box set, multiple progressively increasing edge expansion amounts are determined based on the size information of the candidate box, and edge expansion and cropping are performed sequentially to obtain multi-level cropped images. For each level of cropped image, multiple image processing variants are generated sequentially and local decoding is performed until a valid code value is obtained, at which point the processing is terminated, and the valid code value is merged into the initial identified code value set to obtain the final identified code value set. The spatial verification and annotation module is used to obtain the four-corner coordinates corresponding to each code value in the final identified code value set, and to perform spatial association verification on the code value and the candidate box by determining the spatial intersection-union ratio and center point distance between the area enclosed by the four-corner coordinates and each candidate box in the deduplicated candidate box set; and to generate an annotation map and output results containing different matching confidence states based on the verification results.
9. A computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the data matrix code recognition method as described in any one of claims 1 to 7.
10. A computer device comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the data matrix code recognition method as described in any one of claims 1 to 7.
