A high-precision two-dimensional code recognition method

By combining a high-precision industrial camera and a ring light source with the multi-scale Retinex algorithm, adaptive threshold binarization, and generative adversarial network model, the problem of recognizing circuit board QR codes in complex scenarios has been solved, achieving high-precision and stable QR code recognition, which is suitable for real-time traceability in industrial production.

CN122113959APending Publication Date: 2026-05-29JIANG XI XU SHENG DIAN ZI GU FEN YOU XIAN GONG SI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610187600.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-10
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies have a low success rate when recognizing QR codes on circuit boards, especially in complex scenarios such as uneven ink, scratched pins, metal reflection, solder residue, oil stains, and small-sized high-precision QR codes. This makes it difficult to meet the real-time, high-precision traceability requirements of industrial production.

Method used

A high-precision industrial camera is used in conjunction with a ring light source. The multi-scale Retinex algorithm, adaptive threshold binarization, and morphological opening operation are combined to perform QR code region segmentation and defect repair through a generative adversarial network model, and decoding is performed by combining the Reed-Solomon error correction algorithm.

Benefits of technology

Significantly improves the success rate and accuracy of QR code recognition under complex working conditions, meeting the real-time traceability needs of industrial production, with a stable recognition rate of over 99.5%, and supports compatible recognition of multiple QR code types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122113959A_ABST
    Figure CN122113959A_ABST
Patent Text Reader

Abstract

The application discloses a high-precision two-dimensional code recognition method, through the synergistic processing of light compensation and contrast enhancement, the image details under extreme light difference are effectively balanced, and the feature recognition degree of a low-quality two-dimensional code area is greatly improved; the region segmentation link fuses adaptive threshold binarization, morphological open operation and geometric feature screening logic, accurately separates the two-dimensional code from complex background elements such as dense lines and pads, and greatly reduces the misjudgment and omission rate caused by background interference; the generative adversarial network model based on the improved U-Net architecture realizes the accurate completion of multiple types of damage such as positioning angle defects and data module missing, solves the pain point that the traditional algorithm has insufficient processing capacity for a multiple-defect concurrent scene; through the accurate sampling and grid division strategy of a high-resolution industrial camera, the integrity of the data matrix in the code is ensured, and the recognition success rate is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of circuit board manufacturing technology, specifically a high-precision QR code recognition method. Background Technology

[0002] A circuit board QR code is a unique identifier on a printed circuit board (PCB) used for traceability, similar to an "ID card" for the circuit board. It mainly contains information such as model, batch, and serial number, and its entire lifecycle data can be traced by scanning it.

[0003] Existing QR code recognition methods have significant limitations when dealing with the special scenarios of circuit board QR codes: For issues such as incomplete or blurred QR codes caused by uneven ink distribution or scratches during printing, traditional edge detection and threshold segmentation algorithms are prone to contour extraction errors and struggle to accurately capture the QR code's positioning markers; Metal reflections, solder residue, or oil stains on the circuit board surface can cause uneven illumination in the QR code area, and existing adaptive threshold algorithms are insufficient in handling extreme lighting differences, easily losing key information points; QR codes are often adjacent to dense circuit patterns, pads, and other elements, resulting in severe background interference, and traditional background separation models struggle to effectively distinguish the QR code area from surrounding circuit features, leading to misjudgments or missed recognitions; For small-sized, high-precision QR codes (such as microcodes with a side length less than 2mm), existing recognition algorithms lack sufficient pixel sampling accuracy, failing to fully reconstruct the data matrix within the code, significantly reducing the recognition success rate. Furthermore, existing methods are mostly optimized for single defect scenarios and lack a comprehensive processing mechanism for concurrent scenarios with multiple defects in circuit board QR codes. This makes it difficult to meet the real-time, high-precision traceability requirements in industrial production, necessitating a high-precision recognition solution that can adapt to complex circuit board environments. Therefore, this invention provides a high-precision QR code recognition method. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides a high-precision QR code recognition method, aiming to solve the aforementioned problems.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a high-precision QR code recognition method, comprising the following steps:

[0006] S1. Image Acquisition: An industrial camera is used in conjunction with a ring light source to acquire the original QR code image on the surface of the workpiece being tested;

[0007] S2. Illumination Compensation: Based on the multi-scale Retinex algorithm, the illumination component and reflection component of the original image are decomposed, and the illumination component is dynamically compressed to obtain an illumination-compensated image.

[0008] S3. Contrast Enhancement: Perform contrast-limited adaptive histogram equalization on the illumination-compensated image to obtain an enhanced image;

[0009] S4. Region segmentation: Adaptive threshold binarization and morphological opening are performed on the enhanced image. Candidate QR code regions are selected and fitted based on the geometric features of the QR code to obtain the target QR code region.

[0010] S5. Incomplete Repair: Input the target QR code area into a trained generative adversarial network model to complete the missing parts of the positioning angle and / or data module, and obtain the repaired QR code image.

[0011] S6. Decoding Output: Perform grid sampling, binarization, and Reed-Solomon error correction on the repaired QR code image to obtain the final recognition result.

[0012] Preferably, the industrial camera has a resolution of not less than 20 million pixels, the optical axis of the industrial camera is perpendicular to the surface of the workpiece being measured, and the working distance is 150mm to 200mm, so as to control the image distortion within ±0.5%, and the ring light source is a 360° uniformly distributed cool white LED with a color temperature of 5500K to 6500K.

[0013] Preferably, before S2, an image preprocessing step is included: performing adaptive median filtering on the original image, wherein the size of the filtering window can be dynamically expanded between 3×3 and 11×11 until the noise is suppressed, while maintaining the smallest window when edge pixels are detected to preserve the edge details of the QR code.

[0014] Preferably, the multi-scale Retinex algorithm uses three Gaussian filter kernels of different scales for image decomposition. The scales of the Gaussian filter kernels are set to 20, 80 and 320, respectively. The final illumination-compensated image is obtained by weighted averaging of the reflection components at each scale, with weighting coefficients of 0.3, 0.5 and 0.2, respectively.

[0015] Preferably, the contrast-limited adaptive histogram equalization divides the image into 8×8 non-overlapping sub-blocks, limits the contrast threshold to 0.02, and uses bilinear interpolation to fuse the results of adjacent sub-blocks to eliminate block artifacts.

[0016] Preferably, the region segmentation further includes:

[0017] Adaptive thresholding binarization is performed on the image after contrast enhancement. By setting a dynamic threshold for local areas, the image is converted into a black and white binary form, and the QR code foreground and the complex background of the circuit board are initially separated.

[0018] Morphological opening operations are used to eliminate interference from minute noise and isolated line segments on region identification;

[0019] Extract all connected regions in the image and filter out candidate QR code regions based on typical geometric features of the QR code (such as the aspect ratio of the circumscribed rectangle being close to 1, the area ratio being within a preset range, and the number of edge corner points conforming to the outline features of a square).

[0020] Then, the minimum bounding rectangle algorithm is used to fit the contour of the candidate region, and the Hough transform is used to detect the edge lines to verify whether the region boundary is a regular rectangle.

[0021] The region that meets all the characteristic conditions is identified as the target QR code region, and the segmentation is completed.

[0022] Preferably, the generative adversarial network model includes:

[0023] The generator adopts an improved U-Net architecture and includes two sub-modules: an encoder and a decoder. The encoder extracts multi-scale features of the incomplete QR code image step by step through 5 layers of convolution operations. The decoder restores the image resolution through transposed convolutional layers and skip connections. At the same time, it integrates the detailed features of the corresponding layers of the encoder to achieve accurate completion of the positioning angle and the incomplete area of ​​the data module.

[0024] The discriminator adopts the PatchGAN structure, which consists of 4 convolutional layers. It takes the repaired QR code image blocks as input and outputs the real and fake probability value of each block to determine whether the image is a real and complete QR code.

[0025] During model training, a composite loss function combining adversarial loss and perceptual loss is used. The adversarial loss is based on cross-entropy to calculate the game error between the generator and the discriminator. The perceptual loss extracts high-level features of the restored image and the real image through a pre-trained VGG16 network and calculates the mean square error to improve the visual consistency and module accuracy of the restoration results.

[0026] The training dataset consists of complete QR code images collected in industrial scenarios and artificially generated incomplete samples. The incomplete samples simulate damage in real-world applications by randomly occluding the positioning angle and using missing data modules. The Adam optimizer is used during training, with a learning rate of 0.0002, a batch size of 8, and 200 epochs of iterative training until the loss function converges.

[0027] Preferably, the decoding output specifically includes the following steps:

[0028] The repaired QR code image is subjected to grid sampling: the grid division size is determined according to the QR code version information, a coordinate system is established with the four positioning angles of the target QR code area as the reference, and the image is evenly divided into square grid units that correspond one-to-one with the QR code module.

[0029] For each grid cell, the local grayscale mean is calculated, and the Otsu adaptive thresholding algorithm is used to determine the binarization threshold. The grid cells are converted into binary module values ​​of 0 or 1 to form a binary matrix of QR codes.

[0030] Extract the functional modules and data regions from the matrix, and parse the data codeword sequence according to the QR code encoding rules;

[0031] The Reed-Solomon error correction algorithm is used to process data codeword sequences: error-correcting codewords are generated according to the error correction level, and erroneous codewords in the sequence that meet the error correction capability are detected and corrected.

[0032] The corrected codeword sequence is converted into a specified character encoding format, and the final recognition result string or structured data is output.

[0033] Preferably, the method further includes S7, verification and feedback of the recognition result, specifically including:

[0034] The final recognition result of the decoding output is validated to check whether the result conforms to the preset character format rules and encoding logic;

[0035] The verified identification results are sent to the production management system and compared with the pre-stored unique identification information of the workpiece in the system to verify data consistency.

[0036] If a match is successful, record the timestamp, device number, workpiece batch, and other metadata of this identification, and mark the workpiece as qualified for identification;

[0037] If the matching fails or the recognition result is invalid, analyze the reason for the failure and generate a detailed log containing the failure scene image and the error type.

[0038] Based on the error log statistics of high-frequency failure reasons, corresponding optimization strategies are automatically triggered: for image acquisition problems, the brightness level of the ring light source or the exposure parameters of the industrial camera are dynamically adjusted; for the problem of insufficient model repair, similar incomplete samples are collected to supplement the training dataset, incremental training of the generative adversarial network model is started, and the model repair effect is iteratively optimized.

[0039] Regularly summarize the identification data and optimization results, generate system performance reports, and provide data support for subsequent system upgrades.

[0040] Preferably, the method supports multiple QR code types (such as QR codes and Data Matrix codes), and achieves compatible recognition of different types of QR codes by dynamically loading the corresponding code decoding library.

[0041] Beneficial effects

[0042] Compared with the prior art, the present invention has the following advantages:

[0043] This invention effectively balances image details under extreme lighting differences through the synergistic processing of multi-scale Retinex illumination compensation and CLAHE contrast enhancement, greatly improving the feature recognition of low-quality QR code areas. The region segmentation stage integrates adaptive threshold binarization, morphological opening operations, and geometric feature filtering logic to accurately separate QR codes from complex background elements such as dense lines and pads, significantly reducing misjudgments and missed judgments caused by background interference. Based on a generative adversarial network model with an improved U-Net architecture, combined with a composite training strategy of adversarial loss and perceptual loss, it achieves accurate completion of various types of damage, such as incomplete positioning angles and missing data modules, solving the pain point of traditional algorithms' insufficient ability to handle concurrent multi-defect scenarios. Through precise sampling and grid division strategies using high-resolution industrial cameras, the complete restoration of the data matrix within the code is ensured, greatly improving the recognition success rate. An identification result verification and feedback mechanism is introduced, continuously optimizing the system's adaptability to complex industrial scenarios by dynamically adjusting acquisition parameters and incrementally training the repair model. The recognition speed is controlled within 200ms, and the recognition rate is stable at over 99.5%, fully meeting the real-time traceability needs of industrial production. It supports QR codes and Data... It supports the recognition of multiple code types, such as Matrix code, and adapts to the traceability identification applications of different code systems in circuit board production by dynamically loading the corresponding decoding library. Attached Figure Description

[0044] Figure 1 This is a flowchart of the process of this invention;

[0045] Figure 2 This is a flowchart illustrating the region segmentation process in this invention.

[0046] Figure 3 This is a flowchart of the generative adversarial network model in this invention;

[0047] Figure 4 This is a flowchart of the decoding output process in this invention;

[0048] Figure 5 This is a flowchart of the identification result verification and feedback process in this invention. Detailed Implementation

[0049] 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.

[0050] Please see Figure 1-5 This embodiment provides a high-precision QR code recognition method, including the following steps:

[0051] S1. Image Acquisition: An industrial camera is used in conjunction with a ring light source to acquire the original QR code image on the surface of the workpiece being tested;

[0052] S2, Illumination Compensation: Based on the multi-scale Retinex algorithm, the illumination component and reflection component of the original image are decomposed, and the illumination component is dynamically compressed to obtain the illumination-compensated image.

[0053] S3, Contrast Enhancement: Performs contrast-limited adaptive histogram equalization on the illumination-compensated image to obtain an enhanced image;

[0054] S4. Region segmentation: Adaptive threshold binarization and morphological opening are performed on the enhanced image. Candidate QR code regions are selected and fitted based on the geometric features of the QR code to obtain the target QR code region.

[0055] S5. Incomplete Repair: Input the target QR code area into the trained generative adversarial network model to complete the missing parts of the positioning angle and / or data module, and obtain the repaired QR code image.

[0056] S6. Decoding Output: Perform grid sampling, binarization, and Reed-Solomon error correction on the repaired QR code image to obtain the final recognition result.

[0057] The above steps enable high-precision and robust recognition of QR codes with uneven lighting, surface wear, or module defects, greatly improving the success rate and accuracy of QR code recognition under complex working conditions. This meets the needs for fast and reliable QR code reading in scenarios such as industrial production, logistics traceability, and intelligent manufacturing, and makes up for the shortcomings of traditional recognition methods in performance limitations under extreme conditions, providing strong technical support for digital management and intelligent upgrading in various industries.

[0058] Specifically, the industrial camera has a resolution of no less than 20 megapixels, its optical axis is perpendicular to the surface of the workpiece being measured, and its working distance is 150mm to 200mm. This allows image distortion to be controlled within ±0.5%, ensuring clear details and sharp module edges in the acquired QR code image. This provides high-quality raw image data support for subsequent preprocessing steps such as adaptive threshold binarization and morphological opening operations, ensuring the complete preservation of the QR code's positioning angle and key information of the data module. It effectively reduces candidate region selection deviations caused by image blurring or distortion, facilitating accurate fitting of the target QR code region and subsequent defect repair. The decoding and output stages lay a solid foundation, further improving the stability and accuracy of QR code recognition under complex working conditions. The ring light source is a 360° evenly distributed cool white LED, which can provide uniform and soft illumination, effectively eliminating local overexposure or dark areas caused by uneven material, coating reflection, or ambient light interference on the surface of the workpiece being tested, and avoiding uneven brightness in the QR code module. In addition, the color temperature range of 5500K to 6500K ensures high image color reproduction, and the grayscale difference between the QR code module and the background is significant, laying the foundation for accurate differentiation between the module and the background in the subsequent adaptive threshold binarization step.

[0059] Specifically, before S2, an image preprocessing step is included: adaptive median filtering is performed on the original image, and the filtering window size can be dynamically expanded between 3×3 and 11×11 until the noise is suppressed. When edge pixels are detected, the minimum window is maintained to preserve the edge details of the QR code. This effectively balances the dual requirements of noise suppression and edge preservation, efficiently filtering out common industrial noises such as salt-and-pepper noise, random impulse noise, and low-frequency stray light interference, while preserving the sharp edges and fine contours of the QR code module to the greatest extent. The background noise of the processed image is significantly reduced, the grayscale contrast between the module and the background is further enhanced, and the feature points of the QR code positioning angle are more prominent. This removes obstacles for the rapid and accurate detection of the positioning angle and extraction of candidate regions in the subsequent S2 step, ensuring stable recognition of the target QR code's position information under complex working conditions.

[0060] Specifically, the multi-scale Retinex algorithm uses three Gaussian filter kernels of different scales for image decomposition. The scales of the Gaussian filter kernels are set to 20, 80, and 320, respectively. The final illumination-compensated image is obtained by weighted averaging of the reflection components at each scale. The weighting coefficients are 0.3, 0.5, and 0.2, respectively, to balance local detail enhancement and global illumination balance. At the same time, to avoid noise amplification caused by over-enhancement, the reflection components are subjected to dynamic range compression processing with a compression coefficient of 0.8 to ensure that the image grayscale values ​​are distributed within the effective range of 0 to 255.

[0061] Specifically, the contrast-limited adaptive histogram equalization divides the image into 8×8 non-overlapping sub-blocks, limits the contrast threshold to 0.02, and uses bilinear interpolation to fuse the results of adjacent sub-blocks to eliminate block artifacts, thereby improving the average contrast between the QR code area and the background by no less than 30%.

[0062] Specifically, region segmentation also includes:

[0063] Adaptive thresholding binarization is performed on the image after contrast enhancement. By setting a dynamic threshold for local areas, the image is converted into a black and white binary form, and the QR code foreground and the complex background of the circuit board are initially separated.

[0064] Morphological opening operations are used to eliminate interference from minute noise and isolated line segments on region identification;

[0065] Extract all connected regions in the image and filter out candidate QR code regions based on typical geometric features of the QR code (such as the aspect ratio of the circumscribed rectangle being close to 1, the area ratio being within a preset range, and the number of edge corner points conforming to the outline features of a square).

[0066] Then, the minimum bounding rectangle algorithm is used to fit the contour of the candidate region, and the Hough transform is used to detect the edge lines to verify whether the region boundary is a regular rectangle.

[0067] The region that meets all the characteristic conditions is identified as the target QR code region, and the segmentation is completed.

[0068] The above steps effectively eliminate interference elements (such as redundant lines, solder joints, and identification characters) in complex backgrounds of circuit boards, accurately locate the target QR code area, and further improve the segmentation accuracy of the target area. Through dual verification of geometric feature filtering and contour verification, the probability of misselection of non-QR code areas is greatly reduced, and the false detection rate is controlled. It not only provides a precise area range to ensure that the correction algorithm can focus on the effective area for accurate transformation, but also lays a clear and interference-free image foundation for the decoding stage, greatly improving the overall efficiency and success rate of QR code recognition under complex working conditions. Even in scenes with high-density component occlusion and complex background textures, it can still stably output correct decoding results.

[0069] Specifically, generative adversarial network models include:

[0070] The generator adopts an improved U-Net architecture and includes two sub-modules: an encoder and a decoder. The encoder extracts multi-scale features of the incomplete QR code image step by step through 5 layers of convolution operations (each layer contains a 3×3 convolution kernel, a ReLU activation function, and a batch normalization layer). The decoder restores the image resolution through transposed convolutional layers and skip connections, and at the same time, it integrates the detailed features of the corresponding layers of the encoder to achieve accurate completion of the positioning angle and the incomplete area of ​​the data module.

[0071] The discriminator adopts the PatchGAN structure, which consists of 4 convolutional layers. It takes the repaired QR code image blocks as input and outputs the real and fake probability value of each block to determine whether the image is a real and complete QR code.

[0072] During model training, a composite loss function combining adversarial loss and perceptual loss is used. The adversarial loss is based on cross-entropy to calculate the game error between the generator and the discriminator. The perceptual loss extracts high-level features of the restored image and the real image through a pre-trained VGG16 network and calculates the mean square error to improve the visual consistency and module accuracy of the restoration results.

[0073] The training dataset consists of complete QR code images collected in industrial scenarios and artificially generated incomplete samples. The incomplete samples are simulated by randomly occluding the positioning angle (area ratio of 5% to 20%) and missing data modules (number of 1 to 5). The Adam optimizer is used during training, with a learning rate of 0.0002, a batch size of 8, and iterative training for 200 epochs until the loss function converges.

[0074] Specifically, the decoding output includes the following steps:

[0075] Grid sampling is performed on the repaired QR code image: the grid division size is determined according to the QR code version information (version 1 corresponds to a 21×21 grid, version n corresponds to a (17+4n)×(17+4n) grid), a coordinate system is established with the four positioning angles of the target QR code area as the reference, and the image is evenly divided into square grid units that correspond one-to-one with the QR code module.

[0076] For each grid cell, the local grayscale mean is calculated, and the Otsu adaptive thresholding algorithm is used to determine the binarization threshold. The grid cells are converted into binary module values ​​of 0 (black) or 1 (white) to form a binary matrix of QR code.

[0077] Extract the functional modules (positioning angle, timing pattern, correction pattern) and data areas from the matrix, and parse the data codeword sequence according to the QR code encoding rules (mask mode, data encoding method);

[0078] The Reed-Solomon error correction algorithm is used to process the data codeword sequence: error-correcting codewords are generated according to the error correction level (L / M / Q / H), and erroneous codewords in the sequence that meet the error correction capability are detected and corrected;

[0079] Convert the corrected codeword sequence into a specified character encoding format (such as UTF-8 or ASCII), and output the final recognition result string or structured data.

[0080] Specifically, it also includes S7, recognition result verification and feedback, which specifically includes:

[0081] The final recognition result of the decoding output is validated to check whether the result conforms to the preset character format rules (such as fixed length, allowed character set range) and encoding logic;

[0082] The verified identification results are sent to the production management system and compared with the pre-stored unique identification information of the workpiece in the system to verify data consistency.

[0083] If a match is successful, record the timestamp, device number, workpiece batch, and other metadata of this identification, and mark the workpiece as qualified for identification;

[0084] If the matching fails or the recognition result is invalid, analyze the reasons for the failure (including but not limited to the degree of damage to the QR code exceeding the model's repair capabilities, errors not covered by decoding and error correction, and data mismatch with the system library), and generate a detailed log containing images of the failure scenario and the error type.

[0085] Based on the error log statistics of high-frequency failure reasons, corresponding optimization strategies are automatically triggered: for image acquisition problems (such as uneven lighting), the brightness level of the ring light source or the exposure parameters of the industrial camera are dynamically adjusted; for the problem of insufficient model repair, similar incomplete samples are collected to supplement the training dataset, incremental training of the generative adversarial network model is started, and the model repair effect is iteratively optimized.

[0086] Regularly summarize the identification data and optimization results, generate system performance reports, and provide data support for subsequent system upgrades.

[0087] The above steps can effectively improve the accuracy and robustness of QR code recognition, effectively reduce the recognition failure rate caused by problems such as incomplete QR codes, uneven ambient lighting, or data mismatch, and ensure the stability and reliability of QR code recognition in industrial production scenarios.

[0088] Specifically, it supports multiple QR code types (such as QR codes and Data Matrix codes), and achieves compatible recognition of different types of QR codes by dynamically loading the corresponding code decoding library; that is, it can flexibly adapt to the diverse QR code application needs in different scenarios such as industrial production, logistics warehousing, and medical equipment traceability, and achieve stable and efficient recognition.

[0089] Working principle:

[0090] By utilizing a high-resolution industrial camera and a precise configuration of a 360° ring-shaped cool white LED light source, combined with adaptive median filtering technology, we can acquire and preprocess raw images with clear details, sharp edges, and sufficient noise suppression, providing high-quality data support for subsequent steps.

[0091] The illumination and reflection components are decomposed by multi-scale Retinex algorithm, and the illumination range is dynamically compressed to balance the global and local illumination effects. Then, the grayscale difference between the contrast-limited adaptive histogram equalization module and the background is enhanced, significantly improving the image recognizability.

[0092] Based on adaptive threshold binarization, morphological opening operation and geometric feature screening, the region segmentation technology accurately locates the target QR code region from complex backgrounds. The region accuracy is ensured by minimum bounding rectangle fitting and Hough transform verification.

[0093] To address the issue of incomplete QR codes, a generative adversarial network model with an improved U-Net architecture is introduced. This model combines adversarial loss and perceptual loss in a composite training strategy to intelligently complete the missing parts of the positioning angle and data modules.

[0094] Then, the QR code version size is matched by grid sampling, and the decoding is completed by binarization and Reed-Solomon error correction, outputting the preliminary recognition result;

[0095] Through validity verification, system data matching, and dynamic feedback optimization mechanisms—including adjusting acquisition parameters and incremental training to repair models—the robustness of the system is continuously improved through iteration.

[0096] The entire process forms a complete technology chain with each link closely connected. It not only covers all dimensions of image quality improvement but also incorporates innovative mechanisms such as intelligent repair and closed-loop feedback. This effectively breaks through the performance bottleneck of traditional methods under extreme conditions and provides efficient and reliable QR code recognition solutions for scenarios such as industrial production and logistics traceability.

[0097] Furthermore, any content not described in detail in this specification is existing technology known to those skilled in the art.

[0098] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0099] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A high-precision QR code recognition method, characterized in that, Includes the following steps: S1. Image Acquisition: An industrial camera is used in conjunction with a ring light source to acquire the original QR code image on the surface of the workpiece being tested; S2. Illumination Compensation: Based on the multi-scale Retinex algorithm, the illumination component and reflection component of the original image are decomposed, and the illumination component is dynamically compressed to obtain an illumination-compensated image. S3. Contrast Enhancement: Perform contrast-limited adaptive histogram equalization on the illumination-compensated image to obtain an enhanced image; S4. Region segmentation: Adaptive threshold binarization and morphological opening are performed on the enhanced image. Candidate QR code regions are selected and fitted based on the geometric features of the QR code to obtain the target QR code region. S5. Incomplete Repair: Input the target QR code area into a trained generative adversarial network model to complete the missing parts of the positioning angle and / or data module, and obtain the repaired QR code image. S6. Decoding Output: Perform grid sampling, binarization, and Reed-Solomon error correction on the repaired QR code image to obtain the final recognition result.

2. The high-precision QR code recognition method according to claim 1, characterized in that, The industrial camera has a resolution of no less than 20 million pixels, the optical axis of the industrial camera is perpendicular to the surface of the workpiece being measured, the working distance is 150mm to 200mm, and the ring light source is a 360° uniformly distributed cool white LED with a color temperature of 5500K to 6500K.

3. The high-precision QR code recognition method according to claim 1, characterized in that, Before S2, there is also an image preprocessing step: performing adaptive median filtering on the original image, with the filtering window size dynamically expanding between 3×3 and 11×11 until noise is suppressed, while keeping the minimum window size when edge pixels are detected to preserve QR code edge details.

4. The high-precision QR code recognition method according to claim 1, characterized in that, The multi-scale Retinex algorithm uses three Gaussian filter kernels of different scales for image decomposition. The scales of the Gaussian filter kernels are set to 20, 80 and 320 respectively. The final illumination-compensated image is obtained by weighted averaging of the reflection components at each scale, with weighting coefficients of 0.3, 0.5 and 0.2 respectively.

5. The high-precision QR code recognition method according to claim 1, characterized in that, The contrast-limited adaptive histogram equalization divides the image into 8×8 non-overlapping sub-blocks, limits the contrast threshold to 0.02, and uses bilinear interpolation to fuse the results of adjacent sub-blocks to eliminate block artifacts.

6. The high-precision QR code recognition method according to claim 1, characterized in that, The region segmentation also includes: Adaptive thresholding binarization is performed on the image after contrast enhancement. By setting a dynamic threshold for local areas, the image is converted into a black and white binary form, and the QR code foreground and the complex background of the circuit board are initially separated. Morphological opening operations are used to eliminate interference from minute noise and isolated line segments on region identification; Extract all connected regions in the image and filter out candidate QR code regions based on the typical geometric features of the QR code; Then, the minimum bounding rectangle algorithm is used to fit the contour of the candidate region, and the Hough transform is used to detect the edge lines to verify whether the region boundary is a regular rectangle. The region that meets all the characteristic conditions is identified as the target QR code region, and the segmentation is completed.

7. The high-precision QR code recognition method according to claim 1, characterized in that, The generative adversarial network model includes: The generator adopts an improved U-Net architecture and includes two sub-modules: an encoder and a decoder. The encoder extracts multi-scale features of the incomplete QR code image step by step through 5 layers of convolution operations. The decoder restores the image resolution through transposed convolutional layers and skip connections. At the same time, it integrates the detailed features of the corresponding layers of the encoder to achieve accurate completion of the positioning angle and the incomplete area of ​​the data module. The discriminator adopts the PatchGAN structure, which consists of 4 convolutional layers. It takes the repaired QR code image blocks as input and outputs the real and fake probability value of each block to determine whether the image is a real and complete QR code. During model training, a composite loss function combining adversarial loss and perceptual loss is used. The adversarial loss is based on cross-entropy to calculate the game error between the generator and the discriminator. The perceptual loss extracts high-level features of the restored image and the real image through a pre-trained VGG16 network and calculates the mean square error to improve the visual consistency and module accuracy of the restoration results. The training dataset consists of complete QR code images collected in industrial scenarios and artificially generated incomplete samples. The incomplete samples simulate damage in real-world applications by randomly occluding the positioning angle and using missing data modules. The Adam optimizer is used during training, with a learning rate of 0.0002, a batch size of 8, and 200 epochs of iterative training until the loss function converges.

8. The high-precision QR code recognition method according to claim 1, characterized in that, The decoding output specifically includes the following steps: The repaired QR code image is subjected to grid sampling: the grid division size is determined according to the QR code version information, a coordinate system is established with the four positioning angles of the target QR code area as the reference, and the image is evenly divided into square grid units that correspond one-to-one with the QR code module. For each grid cell, the local grayscale mean is calculated, and the Otsu adaptive thresholding algorithm is used to determine the binarization threshold. The grid cells are converted into binary module values ​​of 0 or 1 to form a binary matrix of QR codes. Extract the functional modules and data regions from the matrix, and parse the data codeword sequence according to the QR code encoding rules; The Reed-Solomon error correction algorithm is used to process data codeword sequences: error-correcting codewords are generated according to the error correction level, and erroneous codewords in the sequence that meet the error correction capability are detected and corrected. The corrected codeword sequence is converted into a specified character encoding format, and the final recognition result string or structured data is output.

9. A high-precision QR code recognition method according to any one of claims 1-8, characterized in that, It also includes S7, recognition result verification and feedback, specifically including: The final recognition result of the decoding output is validated to check whether the result conforms to the preset character format rules and encoding logic; The verified identification results are sent to the production management system and compared with the pre-stored unique identification information of the workpiece in the system to verify data consistency. If a match is successful, record the timestamp, device number, workpiece batch, and other metadata of this identification, and mark the workpiece as qualified for identification; If the matching fails or the recognition result is invalid, analyze the reason for the failure and generate a detailed log containing the failure scene image and the error type. Based on error log statistics of high-frequency failure reasons, corresponding optimization strategies are automatically triggered: for image acquisition problems, the brightness level of the ring light source or the exposure parameters of the industrial camera are dynamically adjusted; for model repair deficiencies, similar incomplete samples are collected to supplement the training dataset, incremental training of the generative adversarial network model is started, and the model repair effect is iteratively optimized. Regularly summarize the identification data and optimization results, generate system performance reports, and provide data support for subsequent system upgrades.

10. A high-precision QR code recognition method according to claim 1, characterized in that, The method supports multiple QR code types and achieves compatible recognition of different types of QR codes by dynamically loading the corresponding code decoding library.