A method and system for identifying a two-dimensional code of a PCB board and an electronic device
By utilizing a built-in camera on the PCB board combined with a multi-level recognition strategy involving large-model localization and adaptive preprocessing, the problems of high cost and poor robustness of traditional recognition schemes are solved, achieving low-cost, high-stability QR code recognition that is adaptable to various processes and environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU FENGMING INTELLIGENT TECH CO LTD
- Filing Date
- 2026-03-27
- Publication Date
- 2026-06-09
Smart Images

Figure CN122174853A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of electronic manufacturing inspection technology, and in particular relates to a method, system and electronic device for recognizing QR codes on PCB boards. Background Technology
[0002] As the electronics manufacturing industry upgrades towards lean and intelligent manufacturing, the unique identification and full lifecycle traceability of PCBs have become key means to ensure product quality and meet compliance requirements. DataMatrix and Quick Response Code (QRCode) are widely used for full-process traceability in PCB production, testing, and after-sales service due to their high information density and convenient identification.
[0003] Currently, PCB board QR codes are mostly manufactured using processes such as laser engraving, etching, through-hole printing, and inkjet printing, resulting in various forms such as etched codes, through-hole codes, and inkjet codes. In actual production, QR codes are easily affected by dirt, minor scratches, local damage, low contrast, and uneven lighting, making it difficult for traditional recognition solutions to decode stably. Existing dedicated code readers are costly and have strong hardware dependencies, and cannot be compatible with special process code types such as through-hole codes; general recognition algorithms have poor robustness, insufficient adaptability to defective codes, and some solutions rely on complex AI models, consuming large amounts of computing resources and making it difficult to run efficiently on embedded devices such as repair machines.
[0004] Furthermore, traditional QR code reading solutions lack adaptive processes and parameter self-optimization mechanisms, and are cumbersome to deploy and debug, failing to meet the low-cost, lightweight, and highly stable identification requirements of industrial sites. Therefore, developing a PCB QR code recognition method that is compatible with multiple processes, has strong anti-interference capabilities, low resource consumption, and can directly reuse existing cameras has become an urgent technical problem to be solved in the industry. Summary of the Invention
[0005] The technical problem to be solved by this application is to provide a method, system and electronic device for recognizing QR codes on PCB boards, so as to solve the problems mentioned in the background art.
[0006] To address the aforementioned technical problems, this application provides the following technical solution: Firstly, this application provides a method for recognizing QR codes on PCB boards, including: A first image of a PCB board containing a QR code is obtained, and the first image is preprocessed to obtain a second image. The QR code includes a data matrix code, and the code type of the data matrix code includes through-hole code and etched code. Using a preset image positioning and recognition model, the location information and code pattern of the QR code in the second image are obtained; Based on the location information, the QR code is recognized. If the recognition is successful, the recognition information is output. If recognition fails, corresponding recognition processing will be performed based on the code type classification result of the QR code.
[0007] Furthermore, the method for constructing the preset image localization and recognition model is as follows: Acquire image information of various types of QR codes, and input the image information of various types of QR codes into a preset image recognition model for training to obtain a trained image recognition model; Based on the trained image recognition model, a preset image localization and recognition model is generated.
[0008] Further, the step of recognizing the QR code based on the location information, and outputting recognition information if the recognition is successful, includes: Based on the location information of the QR code, an adaptive binarization algorithm is used to recognize the QR code. If the recognition is successful, the recognition information is output.
[0009] Furthermore, if recognition fails, corresponding recognition processing is performed based on the QR code pattern, including: If the QR code's code type classification result is an etched code, then the etched code recognition method shall be used for recognition; If the QR code type classification result is a through-hole code, then the through-hole code recognition method is used for recognition; If both the etching code recognition method and the through-hole code recognition method fail to recognize the code, then an unrecognizable message will be output.
[0010] Furthermore, the identification step of the etched code includes: Based on the location information of the QR code, the etched code image is extracted from the second image; The etched code image is processed sequentially using a color level adjustment algorithm and a grid segmentation algorithm. After each algorithm processing, the etched code image is recognized. If the recognition is successful, the recognized content is output. If the etched code image still cannot be recognized after processing by the grid segmentation algorithm, then unrecognizable information will be output.
[0011] Furthermore, the identification step of the through-hole code includes: Based on the location information of the QR code, the through-hole code image is extracted from the second image; A circle-finding algorithm is used to find all the circular holes in the through-hole code image. Based on all the circular holes in the through-hole code image, reconstruct the through-hole code image to form a second through-hole code image; The second through-hole code image is recognized. If the recognition is successful, the recognized content is output; if the recognition fails, the unrecognizable information is output.
[0012] Secondly, this application also provides a method for recognizing QR codes on PCB boards, including: A third image of a PCB board containing a QR code is obtained, and the third image is preprocessed to obtain a fourth image. The QR code includes a data matrix code, and the code type of the data matrix code includes through-hole code and etched code. The fourth image is subjected to a circle-finding algorithm to determine whether there is a through-hole code in the fourth image; If it exists, the through-hole code identification method will be used for identification, and the identification result will be output. If it does not exist, the fourth image is binarized and then identified. If the identification is successful, the identification result is output; if the identification fails, the information that it cannot be identified is output.
[0013] Thirdly, this application also provides a method for recognizing QR codes on PCB boards, including: A fifth image of a PCB board containing a QR code is obtained, and the fifth image is preprocessed to obtain a sixth image, wherein the QR code includes a quick response code; The sixth image is subjected to color level adjustment and binarization processing in sequence, and the processed sixth image is then recognized. If the recognition is successful, the recognition result is output; if the recognition fails, the information that it cannot be recognized is output.
[0014] Fourthly, this application also provides a QR code recognition system for PCB boards, including: The acquisition module is used to acquire a first image of a PCB board containing a QR code, and preprocess the first image to obtain a second image, wherein the QR code includes a data matrix code, and the code type of the data matrix code includes through-hole code and etched code. The image positioning and recognition module is used to obtain the location information and code pattern of the QR code in the second image by using a preset image positioning and recognition model. The first recognition module is used to recognize the QR code based on the location information, and if the recognition is successful, it outputs the recognition information. The second recognition module is used to perform corresponding recognition processing based on the code type classification result of the QR code if recognition fails.
[0015] Fifthly, this application also provides a computer electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the QR code recognition method described in any of the above claims.
[0016] Sixthly, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the QR code recognition method as described in any of the preceding claims.
[0017] The present application provides a method, system, and electronic device for recognizing QR codes on PCB boards, the advantages of which are: 1. Reduce hardware costs and maintenance complexity This application fully utilizes the built-in camera of the PCB inspection machine for image acquisition, eliminating the need for expensive third-party industrial barcode reader hardware. This not only directly reduces the enterprise's hardware procurement costs but also simplifies the equipment structure, reduces subsequent maintenance costs and downtime risks due to hardware failures, and achieves efficient reuse of hardware and software resources.
[0018] 2. High recognition rate for QR codes used in complex processes For etched codes and through-hole codes formed by special marking processes on PCBs (such as laser engraving, drilling, inkjet printing, etching, etc.), and for potential dirt, scratches, or damage, this invention adopts a multi-level processing strategy: Large-scale model localization and classification: The large-scale model inference is used to automatically obtain the precise location of the bounding rectangle of the QR code and identify the type of code (etched code or through-hole code), providing a basis for subsequent targeted processing.
[0019] Adaptive preprocessing: Combining OpenCV algorithms, different image processing flows are automatically matched according to the type of code (such as multiple adaptive threshold processing for etched codes and circle reconstruction algorithm for through-hole codes), effectively solving the problem that traditional general-purpose code readers are difficult to adapt to special PCB textures.
[0020] Multiple fault-tolerance mechanisms: Gamma correction and grid segmentation reconstruction algorithms are introduced. When conventional binarization recognition fails, the system can automatically attempt to adjust the image's brightness and contrast or reconstruct data points through grid analysis of pixels, significantly improving the recognition success rate in cases of low contrast or local damage.
[0021] 3. High degree of customizability and flexibility Unlike third-party barcode readers, which have fixed functions and operate in a black box, this application's solution is highly customizable.
[0022] Adjustable parameters: It can automatically traverse key parameters such as test color gamma value, large model inference rotation angle, and number of grid segments to find the optimal configuration and apply it to adapt to different customer site lighting environments and barcode quality.
[0023] Algorithm Iteration: The architecture of this application supports gradual updates and iterations. It can flexibly develop and deploy targeted image processing algorithms according to newly emerging QR code types or special scenario requirements, ensuring continuous coverage of most PCB code reading application scenarios.
[0024] 4. Integration of convenient and automated operation This application can run automatically at startup as a Windows service and provides a standard Web API interface.
[0025] Seamless integration: Clients (such as maintenance machine control systems) only need to send a simple HTTP request to trigger code reading, without the need for complex driver installation or SDK integration, which greatly reduces the difficulty of system integration.
[0026] Easy deployment: It provides a dedicated installer that supports one-click installation, IP port configuration and model management, making it easy to quickly deploy and manage versions on different production line equipment. Attached Figure Description
[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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.
[0028] Figure 1 This is a flowchart illustrating a method for recognizing QR codes on a PCB board according to an embodiment of this application. Figure 2 This is a flowchart illustrating another method for recognizing QR codes on a PCB board according to an embodiment of this application. Figure 3 This is a flowchart illustrating another method for recognizing QR codes on a PCB board according to an embodiment of this application. Figure 4 This is a schematic diagram of the structure of a QR code recognition system for a PCB board according to an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a computer electronic device according to an embodiment of this application. Detailed Implementation
[0029] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0030] Please see Figure 1 The present application provides a method for recognizing QR codes on PCB boards, which includes at least the following steps: S101. Obtain a first image of a PCB board containing a QR code, and preprocess the first image to obtain a second image, wherein the QR code includes a data matrix code, and the code type of the data matrix code includes through-hole code and etched code.
[0031] Specifically, in this embodiment, the PCB board is photographed using an industrial camera built into the PCB board repair machine, and the original image is saved to a specified path on the disk. Then, the system acquires the original image of the PCB board containing a QR code captured by the PCB repair machine's camera, which is recorded as the first image; image preprocessing is performed on the first image to obtain the preprocessed second image.
[0032] It should be noted that before preprocessing the image, a path validity check is performed: first, it checks if the image path is empty; if so, it returns an invalid path error message; second, it checks if the image file at the corresponding path exists; if not, it returns a file not found error message.
[0033] In this embodiment, the QR code is a DataMatrix code, which includes two types: through-hole code and etched code. Through-hole code is an array of circular holes formed on the PCB board using mechanical drilling or laser drilling processes, while etched code is a marking code of varying depths formed on the PCB board surface using laser engraving or chemical etching processes.
[0034] In one embodiment of this application, the preprocessing includes, but is not limited to: Image grayscale processing converts a color image into a single-channel grayscale image, reducing computational load and highlighting light and dark features; Median filtering removes noise, dirt, and grain interference from the image while preserving the edge information of the QR code. Image size adjustment: Fill the image with a border and uniformly scale it to the model's size to improve the stability of subsequent localization and recognition. Contrast enhancement and gamma correction improve recognition difficulties caused by low contrast, excessive darkness, and excessive brightness.
[0035] The above preprocessing significantly improves image quality and reduces interference from PCB surface traces, pads, oil stains, scratches, etc., providing a high-quality image foundation for subsequent positioning and recognition.
[0036] S102. Using a preset image positioning and classification model, obtain the location information of the QR code in the second image and the code type classification result of the QR code.
[0037] Specifically, the preprocessed second image is input into a preset image localization model, which then performs inference and prediction on the image, outputting the location information of the QR code in the image. The location information includes the coordinates of the circumscribed rectangle of the QR code, the coordinates of the center point, the rotation angle, and the size. The code type classification results include etched codes and through-hole codes.
[0038] In one embodiment of this application, the method for constructing a preset image localization and classification model includes: Acquire image information of various types of QR codes, and input the image information of various types of QR codes into a preset image recognition model for training to obtain a trained image recognition model; Based on the trained image recognition model, a preset image localization and classification model is generated.
[0039] Specifically, the preset image localization model can be constructed using the following methods: Training data preparation: Collect image information of QR codes on various PCB boards, including etched codes, through-hole codes, inkjet codes, etc. formed by different coding processes (laser engraving, drilling, inkjet, etching, mechanical drilling), as well as QR code images with dirt, slight scratches or damage.
[0040] Model training: Input the image information of the various types of QR codes into the preset image recognition model for training to obtain the trained image recognition and classification model.
[0041] Model Deployment: Based on the trained image recognition model, a preset image localization and classification model is generated and deployed in the code reading service.
[0042] S103. Based on the location information, the QR code is recognized. If the recognition is successful, the recognition information is output.
[0043] Specifically, based on the QR code location information obtained in step S102, the target area of the QR code is located in the second image, and the initial recognition process is performed directly on the area; if the initial recognition is successful, the QR code content is parsed and the recognition information is output, thus completing the recognition process.
[0044] In one embodiment, the initial identification process specifically includes: Based on the located QR code area, an adaptive binarization algorithm is used for initial recognition, including: Use OpenCV to convert the image to grayscale; perform median filtering to remove image noise; apply adaptive thresholding to automatically determine the binarization threshold based on local pixel distribution; and perform erosion and dilation operations to optimize the image morphology.
[0045] Then, the decoding library is called to decode the binarized QR code; if the decoding is successful, the character information, recognition result and status are output.
[0046] This step can quickly identify clear, undamaged, and high-contrast QR codes, improving overall recognition efficiency.
[0047] S104. If recognition fails, perform corresponding recognition processing according to the QR code pattern.
[0048] Specifically, in this step, if the initial recognition fails, the current QR code is determined to be either a through-hole code or an etched code based on the code type classification result output by the image localization and classification model, and then the corresponding dedicated recognition process is initiated.
[0049] In one embodiment, step S104 includes: S1041. If the code type classification result of the QR code is an etched code, then the etched code recognition method shall be used for recognition. S1042. If the QR code is a through-hole code, then the through-hole code recognition method shall be used for recognition. S1043. If both the etching code recognition method and the through-hole code recognition method fail, then output the unrecognizable information.
[0050] In this step, a multi-level identification attempt mechanism was designed to ensure that there are still multiple alternative solutions to improve the identification success rate after the conventional identification fails.
[0051] In a specific embodiment, the identification step of the etched code includes: S10411. Based on the location information of the QR code, extract the etched code image from the second image.
[0052] S10412. The etched code image is processed sequentially using the color level adjustment algorithm and the grid segmentation algorithm. After each algorithm processing, the etched code image is recognized. If the recognition is successful, the recognized content is output.
[0053] S10413. If the etched code image still cannot be recognized after the grid segmentation algorithm, output the unrecognizable information.
[0054] Specifically, in this embodiment, firstly, the etched code image is extracted: Based on the coordinates of the circumscribed rectangle output by the positioning model, the QR code area is accurately cropped from the second image, and PCB background interference is eliminated to obtain the etched code image.
[0055] Secondly, color level adjustment and recognition are performed. A color level adjustment algorithm is applied to the etched code image to optimize the image brightness and contrast by adjusting the gamma value, thereby improving the low contrast problem caused by uneven laser engraving depth, green oil occlusion, and dirt. The adjusted image is then binarized and morphologically processed, and a decoding attempt is made. If the recognition is successful, the recognized content is directly output.
[0056] Finally, grid segmentation is used for reconstruction and recognition: If the image still cannot be recognized after adjusting the color level, a grid segmentation algorithm is then executed: the etched code image is divided into several small unit grids according to a preset number of grids; the pixel mean and grayscale features are calculated for each grid to determine whether each grid is a valid data point; the complete data matrix code is reconstructed based on the point information, and module information caused by scratches, damage, or missing parts is also removed; the reconstructed QR code is decoded; if recognition is successful, the recognized content is output; if it still fails, the message "cannot be recognized" is output.
[0057] In one embodiment, the identification step of the through-hole code includes: S10421. Based on the position information of the QR code, extract the through-hole code image from the second image; S10422. Use a circle-finding algorithm on the through-hole code image to find all the circular holes in the through-hole code image; S10423. Based on all the circular holes in the through-hole code image, reconstruct the through-hole code image to form a second through-hole code image; S10424. Recognize the second through-hole code image. If the recognition is successful, output the recognized content. If the recognition fails, output the information that cannot be recognized.
[0058] Specifically, in this embodiment, firstly, the through-hole code image is extracted, as follows: based on the position information output by the positioning model, the through-hole code area is cropped from the second image to obtain the through-hole code image.
[0059] Secondly, the circle-finding algorithm is used as follows: the Hough circle transform algorithm is applied to the through-hole code image to find all the circular holes in the through-hole code image; the number of circles determines whether it is a through-hole code (the through-hole code is characterized by a regularly arranged array of circular holes); the center coordinates and radius information of each circular hole are recorded.
[0060] Next, the through-hole code image is reconstructed as follows: First, the number of cells of the four edge codes is found to construct a grid coordinate system; the positioning edge is selected from the edges, that is, the edge with more cells is selected as the reference edge; the grid is traversed cyclically starting from the top left corner; it is determined whether the center of the circular hole is in the grid. If it exists, it is determined as a data point (value 1), otherwise it is determined as blank (value 0); based on the above judgment, the second through-hole code image (standard binarized DataMatrix code image) is reconstructed.
[0061] Finally, the QR code is decoded and recognized as follows: The reconstructed second through-hole code image is recognized by calling the ZXing.Net library; if the recognition is successful, the recognized QR code content information is output; if the recognition fails, the unrecognizable information is output and returned to the caller.
[0062] It should be noted that the technical solution of this application has adjustable parameters during the recognition process. It can automatically traverse key parameters such as test color gamma value, AI inference rotation angle, and number of grid segments to find the optimal configuration and apply it to the normal mode, adapting to different lighting environments and barcode quality at different customer sites.
[0063] The present application provides a method for recognizing QR codes on PCB boards, the advantages of which are: 1. Reduce hardware costs and maintenance complexity This application fully utilizes the built-in camera of the PCB inspection machine for image acquisition, eliminating the need for expensive third-party industrial barcode reader hardware. This not only directly reduces the enterprise's hardware procurement costs but also simplifies the equipment structure, reduces subsequent maintenance costs and downtime risks due to hardware failures, and achieves efficient reuse of hardware and software resources.
[0064] 2. High recognition rate for QR codes used in complex processes For etched codes and through-hole codes formed by special marking processes on PCBs (such as laser engraving, drilling, inkjet printing, etching, etc.), and for potential dirt, scratches, or damage, this invention adopts a multi-level processing strategy: Large-scale model localization and classification: The large-scale model inference is used to automatically obtain the precise location of the bounding rectangle of the QR code and identify the type of code (etched code or through-hole code), providing a basis for subsequent targeted processing.
[0065] Adaptive preprocessing: Combining OpenCV algorithms, different image processing flows are automatically matched according to the type of code (such as multiple adaptive threshold processing for etched codes and circle reconstruction algorithm for through-hole codes), effectively solving the problem that traditional general-purpose code readers are difficult to adapt to special PCB textures.
[0066] Multiple fault-tolerance mechanisms: Gamma correction and grid segmentation reconstruction algorithms are introduced. When conventional binarization recognition fails, the system can automatically attempt to adjust the image's brightness and contrast or reconstruct data points through grid analysis of pixels, significantly improving the recognition success rate in cases of low contrast or local damage.
[0067] 3. High degree of customizability and flexibility Unlike third-party barcode readers, which have fixed functions and operate in a black box, this application's solution is highly customizable.
[0068] Adjustable parameters: It can automatically traverse key parameters such as test color gamma value, large model inference rotation angle, and number of grid segments to find the optimal configuration and apply it to adapt to different customer site lighting environments and barcode quality.
[0069] Algorithm Iteration: The architecture of this application supports gradual updates and iterations. It can flexibly develop and deploy targeted image processing algorithms according to newly emerging QR code types or special scenario requirements, ensuring continuous coverage of most PCB code reading application scenarios.
[0070] 4. Integration of convenient and automated operation This application can run automatically at startup as a Windows service and provides a standard Web API interface.
[0071] Seamless integration: Clients (such as maintenance machine control systems) only need to send a simple HTTP request to trigger code reading, without the need for complex driver installation or SDK integration, which greatly reduces the difficulty of system integration.
[0072] Easy deployment: It provides a dedicated installer that supports one-click installation, IP port configuration and model management, making it easy to quickly deploy and manage versions on different production line equipment.
[0073] Please see Figure 2 This application also provides a method for recognizing QR codes on PCB boards, including: S201. Obtain a third image of a PCB board containing a QR code, and preprocess the third image to obtain a fourth image, wherein the QR code includes a data matrix code, and the code type of the data matrix code includes through-hole code and etched code.
[0074] Specifically, in this step, the third image is acquired by taking a picture of the PCB board using an industrial camera or image acquisition device built into the PCB board repair machine, and saving the original RGB color image to a specified path on the disk as the third image.
[0075] The QR code is a DataMatrix code, a type of two-dimensional barcode composed of black and white modules arranged in a square matrix. The data matrix code pattern includes: Through-hole code: A circular hole array code formed on a PCB board through mechanical drilling or laser drilling. It is characterized by regularly arranged circular through holes that penetrate the PCB board and appear as dark circular areas in the image.
[0076] Etched code: Marking codes of varying depths formed on the surface of a PCB board through laser engraving or chemical etching processes. Its characteristics are surface texture variations, which appear as grayscale differences rather than obvious hole structures in images.
[0077] It should be noted that before preprocessing the image, a path validity check is performed: first, it checks if the image path is empty; if so, it returns an invalid path error message; second, it checks if the image file at the corresponding path exists; if not, it returns a file not found error message.
[0078] In one embodiment of this application, the preprocessing includes, but is not limited to: Image grayscale processing converts a color image into a single-channel grayscale image, reducing computational load and highlighting light and dark features; Median filtering removes noise, dirt, and grain interference from the image while preserving the edge information of the QR code. Image resizing involves filling the image with borders and uniformly scaling it to a specified size to improve the stability of subsequent positioning and recognition. Contrast enhancement and gamma correction improve recognition difficulties caused by low contrast, excessive darkness, and excessive brightness. S202. The circle-finding algorithm is used on the fourth image to determine whether there is a through-hole code in the fourth image.
[0079] Specifically, in this step, a circle-finding algorithm is used to detect whether there are characteristic circular holes for through-hole codes in the image. Specific implementation methods include: Algorithm selection for circle detection: The Hough Circle Transform algorithm is adopted for circle hole detection. This algorithm can effectively identify circular features in images and is suitable for detecting circle hole arrays in through-hole codes.
[0080] Circle detection parameter settings: Set the minimum and maximum circle radii, configured according to the actual hole diameter range of the PCB board via codes; set the center distance threshold to avoid detecting overlapping or too close circles; set the accumulator threshold to control the sensitivity of circle detection.
[0081] Through-hole code judgment logic: Count the number of detected holes; if the number of holes reaches a preset threshold (e.g., ≥10) and the holes exhibit a regular array distribution, then through-hole codes are determined to exist in the fourth image; if the number of holes is less than the preset threshold, or the hole distribution has no obvious pattern, then through-hole codes are determined not to exist in the fourth image, and may be etched codes or other code types. Hole information recording: For each detected hole, record its center coordinates (x, y) and radius r for subsequent through-hole code reconstruction and recognition.
[0082] Boundary case handling: If the number of holes detected by the circle-finding algorithm is at a critical value, the results of AI model inference can be combined for auxiliary judgment to improve the accuracy of code recognition.
[0083] S203. If it exists, the through-hole code identification method is used for identification, and the identification result is output.
[0084] Specifically, if a through-hole code exists, it is identified according to the through-hole code identification method. The through-hole code identification method can be found in the description above, and will not be repeated here.
[0085] S204. If it does not exist, the fourth image is binarized and then recognized. If the recognition is successful, the recognition result is output; if the recognition fails, the information that it cannot be recognized is output.
[0086] Specifically, if it is determined in step S202 that there is no through-hole code in the image, the current QR code is assumed to be an etched code, and it is identified according to the etched code identification method. The etched code identification method can be referred to the description of the etched code identification method above, and will not be repeated here.
[0087] The QR code recognition method for PCB boards provided in this embodiment has the following advantages: The overall technical solution of this embodiment is lightweight and logically simple, requiring no high-performance computing resources, no complex deep learning models, and no extensive parameter debugging. It can run stably on conventional industrial control computers and embedded devices. Furthermore, it can reuse the built-in camera of the PCB repair machine for image acquisition and recognition, eliminating the need for dedicated barcode reader hardware. This significantly reduces hardware investment, deployment costs, and system resource consumption, making it more suitable for the low-cost, high-stability, and high-efficiency operational needs of industrial sites. Please see Figure 3 This application also provides a method for recognizing QR codes on PCB boards, including: S301. Obtain a fifth image of a PCB board containing a QR code, and preprocess the fifth image to obtain a sixth image, wherein the QR code includes a quick response code.
[0088] Specifically, in this step, the fifth image is acquired by taking a picture of the PCB board using an industrial camera or image acquisition device built into the PCB board repair machine, and saving the original RGB color image to a specified path on the disk as the fifth image.
[0089] It should be noted that the QR code is a Quick Response Code (QR code).
[0090] In one embodiment of this application, the preprocessing includes, but is not limited to: Image grayscale processing converts a color image into a single-channel grayscale image, reducing computational load and highlighting light and dark features; Median filtering removes noise, dirt, and grain interference from the image while preserving the edge information of the QR code. Image size adjustment: Fill the image with a border and uniformly scale it to the model's size to improve the stability of subsequent localization and recognition. Contrast enhancement and gamma correction improve recognition difficulties caused by low contrast, excessive darkness, and excessive brightness.
[0091] S302. Perform color level adjustment and binarization processing on the sixth image in sequence, and then perform recognition on the processed sixth image. If the recognition is successful, output the recognition result; if the recognition fails, output the information that it cannot be recognized.
[0092] Specifically, in the steps, the preprocessed sixth image undergoes batch level adjustment and binarization processing in sequence, and the processed image is then decoded and recognized, as follows: 1. Levels adjustment processing A multi-level gamma adjustment strategy is employed, sequentially adjusting image brightness and contrast within a preset range at fixed steps to adapt to fast response codes with varying printing depths, laser engraving intensities, and levels of dirt coverage. Through trials with multiple brightness parameters, the system aims to restore blurry, dark, and bright code image information to the greatest extent possible.
[0093] 2. Binarization processing For each set of color-level adjusted images, adaptive binarization or optimal threshold binarization is performed to convert grayscale images into black-and-white binary images, highlighting the positioning points of the fast response code, the correction graphics and data modules; optionally, morphological operations such as erosion and dilation are used to repair module breakpoints, remove edge burrs, and fill in minor defects, further improving the decoding success rate.
[0094] Identification and Results 3. Output: Decode the image after color level adjustment and binarization using fast response codes. If decoding is successful under any set of adjusted parameters, the recognized content and recognition result will be output immediately. If decoding still fails after trying all gear parameters, it is determined that the recognition has failed and an unrecognizable message is output.
[0095] This application provides a method for recognizing QR codes on PCB boards, which has the following advantages: This application preprocesses the original image by performing grayscale conversion, filtering and denoising, size regularization, and contrast enhancement. This effectively removes dirt, minor scratches, uneven brightness, and background interference from the PCB surface, improving the clarity of the fast response code image. By employing a combination of multi-level color adjustment and adaptive binarization, it enhances the contrast of QR codes with different processes and depths, improving recognition difficulties caused by light engraving or local dirt, and increasing the decoding success rate under complex working conditions. The overall process algorithm is lightweight and logically simple, requiring no large computing resources, complex AI models, or high-performance hardware. It can run stably and quickly on conventional industrial control equipment and can directly reuse the built-in camera of the repair machine for recognition, eliminating the need for an external dedicated barcode reader. This significantly reduces hardware investment and deployment costs, and combines the advantages of strong versatility, high stability, and easy integration.
[0096] Please see Figure 4 This application also provides a QR code recognition system for PCB boards, including: The acquisition module 401 is used to acquire a first image of a PCB board containing a QR code, and preprocess the first image to obtain a second image, wherein the QR code includes a data matrix code, and the code type of the data matrix code includes through-hole code and etched code. The image localization and classification module 402 is used to obtain the location information of the QR code in the second image and the code pattern classification result of the QR code by using a preset image localization and recognition model; The first recognition module 403 is used to recognize the QR code according to the location information, and output the recognition information if the recognition is successful. The second recognition module 404 is used to perform corresponding recognition processing according to the code type classification of the QR code if recognition fails.
[0097] Please see Figure 5 This application also provides a computer electronic device 500, including a memory 503 and a processor 502. The memory 503 stores a computer program, and the processor 502 executes the computer program to implement the steps of the QR code recognition method described in any of the above claims.
[0098] Specifically, the computer electronic device 500 includes: a transceiver 501, a bus interface, and a processor 502. The processor 502 is used to acquire a first image of a PCB board containing a QR code, and preprocess the first image to obtain a second image. The QR code includes a data matrix code, and the code type of the data matrix code includes: through-hole code and etched code. A preset image positioning model is used to obtain the position information of the QR code in the second image. According to the position information, the QR code is recognized. If the recognition is successful, the recognition information is output. If the recognition fails, the code type of the QR code is determined, and corresponding recognition processing is performed according to the code type of the QR code.
[0099] In this embodiment of the application, the computer electronic device 500 further includes a memory 503. Figure 5 In this context, the bus architecture can include any number of interconnected buses and bridges, specifically linking various circuits of one or more processors 502 (represented by processor 502) and memory 503 (represented by memory 503). The bus architecture can also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides an interface. The transceiver 501 can be multiple elements, including transmitters and receivers, providing a unit for communicating with various other devices over a transmission medium. Processor 502 is responsible for managing the bus architecture and general processing, and memory 503 can store data used by processor 502 during operation.
[0100] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the QR code recognition method described above.
[0101] In this embodiment, the computer-readable storage medium can be a non-volatile storage medium or a volatile storage medium. For example, the computer storage medium may include, but is not limited to, various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0102] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as limitations; therefore, other examples of exemplary embodiments may have different values.
[0103] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0104] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, in alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0105] In addition, the functional modules or units in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0106] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a terminal device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0107] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for recognizing QR codes on a PCB board, characterized in that, include: A first image of a PCB board containing a QR code is obtained, and the first image is preprocessed to obtain a second image. The QR code includes a data matrix code, and the code type of the data matrix code includes through-hole code and etched code. Using a pre-defined image localization and classification model, the location information of the QR code in the second image and the code type classification result of the QR code are obtained; Based on the location information, the QR code is recognized. If the recognition is successful, the recognition information is output. If recognition fails, corresponding recognition processing will be performed based on the code type classification result of the QR code.
2. The identification method according to claim 1, characterized in that, The method for constructing the image localization and classification model using a preset model includes: Acquire image information of various types of QR codes, and input the image information of various types of QR codes into a preset image recognition model for training to obtain a trained image recognition model; Based on the trained image recognition model, a preset image localization and classification model is generated.
3. The identification method according to claim 1, characterized in that, The step involves recognizing the QR code based on the location information. If the recognition is successful, the recognition information is output, including: Based on the location information of the QR code, an adaptive binarization algorithm is used to recognize the QR code. If the recognition is successful, the recognition information is output.
4. The identification method according to claim 1, characterized in that, If recognition fails, then according to the QR code pattern, corresponding recognition processing is performed, including: If the QR code's code type classification result is an etched code, then the etched code recognition method shall be used for recognition; If the QR code type classification result is a through-hole code, then the through-hole code recognition method is used for recognition; If both the etching code recognition method and the through-hole code recognition method fail to recognize the code, then an unrecognizable message will be output.
5. The identification method according to claim 4, characterized in that, The steps for identifying the etched code include: Based on the location information of the QR code, the etched code image is extracted from the second image; The etched code image is processed sequentially using a color level adjustment algorithm and a grid segmentation algorithm. After each algorithm processing, the etched code image is recognized. If the recognition is successful, the recognized content is output. If the etched code image still cannot be recognized after processing by the grid segmentation algorithm, then unrecognizable information will be output.
6. The identification method according to claim 4, characterized in that, The identification steps for the through-hole code include: Based on the location information of the QR code, the through-hole code image is extracted from the second image; A circle-finding algorithm is used to find all the circular holes in the through-hole code image. Based on all the circular holes in the through-hole code image, reconstruct the through-hole code image to form a second through-hole code image; The second through-hole code image is recognized. If the recognition is successful, the recognized content is output; if the recognition fails, the unrecognizable information is output.
7. A method for recognizing QR codes on a PCB board, characterized in that, include: A third image of a PCB board containing a QR code is obtained, and the third image is preprocessed to obtain a fourth image. The QR code includes a data matrix code, and the code type of the data matrix code includes through-hole code and etched code. The fourth image is subjected to a circle-finding algorithm to determine whether there is a through-hole code in the fourth image; If it exists, the through-hole code identification method will be used for identification, and the identification result will be output. If it does not exist, the fourth image is binarized and then identified. If the identification is successful, the identification result is output; if the identification fails, the information that it cannot be identified is output.
8. A method for recognizing QR codes on a PCB board, characterized in that, include: A fifth image of a PCB board containing a QR code is obtained, and the fifth image is preprocessed to obtain a sixth image, wherein the QR code includes a quick response code; The sixth image is subjected to color level adjustment and binarization processing in sequence, and the processed sixth image is then recognized. If the recognition is successful, the recognition result is output; if the recognition fails, the information that it cannot be recognized is output.
9. A QR code recognition system for a PCB board, characterized in that, include: The acquisition module is used to acquire a first image of a PCB board containing a QR code, and preprocess the first image to obtain a second image, wherein the QR code includes a data matrix code, and the code type of the data matrix code includes through-hole code and etched code. The image localization and classification module is used to obtain the location information of the QR code in the second image and the code type classification result of the QR code by using a preset image localization and recognition model; The first recognition module is used to recognize the QR code based on the location information, and if the recognition is successful, it outputs the recognition information. The second recognition module is used to perform corresponding recognition processing based on the code type classification result of the QR code if recognition fails.
10. A computer electronic device, characterized in that, The device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the QR code recognition method according to any one of claims 1-8.