Focusing method and device for defect detection of rigid-flex circuit board and storage medium

By using a method of mapping and matching line scan cameras with CAM drawings and regional focusing, the problem of unclear imaging of rigid-soft circuit boards was solved, achieving efficient and high-precision defect detection.

CN121664977APending Publication Date: 2026-03-13SHANGHAI GANTU NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-17
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Traditional inspection methods cannot simultaneously achieve high-precision scanning of rigid-flex circuit boards, resulting in unclear imaging, which affects the accuracy and efficiency of defect detection and easily leads to missed detections.

Method used

Linear scanning is performed using preset parameters of a line scan camera. By mapping and matching the scan line image with the CAM file, the focal length is adjusted in different regions. The camera focal length is adjusted using image sharpness feedback to obtain high-definition images of the flexible board and rigid board regions respectively.

Benefits of technology

It improves the accuracy and efficiency of defect detection in rigid-flex circuit boards, reduces the false negative rate, and enhances the versatility of the testing equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121664977A_ABST
    Figure CN121664977A_ABST
Patent Text Reader

Abstract

The invention discloses a focusing method and device for defect detection of a rigid-flex circuit board and a storage medium, and relates to the field of image detection. Performing linear scanning on the rigid-flex board by using preset parameters of the line scanning camera to obtain a scanning line image; carrying out mapping matching on the pixel contour of the scanning line image and a rigid-flex board CAM drawing file, and respectively determining scanning line images meeting the requirements of flexible board scanning and rigid board scanning; adjusting the preset focal length of the line scanning camera, scanning the selected target scanning line image, adjusting the focal length of the camera according to the image definition feedback until the obtained target scanning line image reaches the target precision, and determining the corresponding focal length of the camera as the target parameter of the scanning target area. According to the scheme, the rigid-flex board scanning line image is determined through mapping matching, the focal length of the camera is adaptively adjusted based on image definition feedback, the problem that imaging is not clear due to the height difference of the rigid-flex board is solved, and the defect detection accuracy and efficiency of the rigid-flex board are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to image detection, and more particularly to a focusing method, apparatus, and storage medium for detecting defects in rigid-flex circuit boards. Background Technology

[0002] A PCB, also known as a printed circuit board, is a carrier for electrical connections between electronic components. Especially in high-precision instruments and equipment such as foldable screens, a combination of flexible and rigid PCBs is used. For example... Figure 2 The schematic diagram shown illustrates a rigid-flex PCB, where the rigid portion is typically slightly thicker than the flexible portion. During PCB manufacturing, due to the complexity of the process and environmental factors, various defects, flaws, and imperfections are inevitably generated.

[0003] Traditional inspection methods primarily rely on manual visual inspection or automated inspection equipment with single optical parameters, but these methods have significant limitations. For the unique structure of rigid-flex PCBs, which exhibit significant height differences, traditional line scan cameras cannot simultaneously meet the high-precision scanning requirements of both circuit boards in a single pass. Currently, high-precision cameras have limited depth of field; for example, a 2.5μm precision camera has a depth of field of only 60μm, and a 5μm precision camera has a depth of field of only 76μm. However, the height difference between the flexible and rigid areas in a rigid-flex PCB can reach approximately 2mm, far exceeding the camera's depth of field. When the camera's Z-axis height is adjusted to clearly image the rigid area, the flexible area becomes blurry, and vice versa. This unclear imaging directly affects the accuracy of defect detection.

[0004] There is an urgent need to develop detection methods that can adapt to different height regions. Traditional technologies using single-parameter scanning are not only inefficient but also prone to missed detections, failing to meet the high-precision detection requirements of modern electronics manufacturing. Summary of the Invention

[0005] This application provides a focusing method, device, and storage medium for detecting defects in rigid-flex circuit boards, which has the advantages of improving the accuracy and efficiency of defect detection in rigid-flex circuit boards.

[0006] On one hand, this application provides a focusing method for detecting defects in rigid-flex circuit boards, the method comprising: The rigid-flex PCB is linearly scanned using the preset parameters of the line scan camera to obtain scan line images; The pixel contours of the scanned images are mapped and matched with the CAM files of the rigid-flex board to determine at least one set of flexible board scanned images that satisfy flexible board scanning and rigid board scanned images that satisfy rigid board scanning. The preset focal length of the line scan camera is adjusted to scan the selected target scan line image. The camera focal length is adjusted based on image sharpness feedback until the acquired target scan line image reaches the target accuracy. The corresponding camera focal length is then determined as the target parameter for the scanned target area. Specifically, adjusting the camera focus based on image sharpness feedback until the acquired target scan line image reaches the target accuracy includes: Candidate parameter points are uniformly sampled according to the camera's preset focal length range. The candidate parameter points are then polled and the target row is scanned to obtain several corresponding candidate images. Different focal length parameters correspond to different image sharpness. Select the image with the highest resolution from several candidate images and compare it with the target accuracy. If the target accuracy is not achieved, the focal length adjustment range is determined by taking the camera focal length corresponding to the candidate image as the center and the adjacent candidate parameter points. The candidate parameter points are resampled, and the polling scan and selection of the highest resolution image steps are repeated until the acquired target scan line image reaches the target accuracy.

[0007] Specifically, target light sources are used for the scanned images of the flexible circuit board and the scanned images of the rigid circuit board, respectively. The camera focal length is adjusted by successively approaching the image using a liquid lens, and the target parameters of the flexible circuit board used for scanning the flexible circuit board area and the target parameters of the rigid circuit board used for scanning the rigid circuit board area are determined respectively.

[0008] Specifically, mapping and matching the pixel contours of the scanned image with the CAM file of the rigid-flex PCB includes: The scanned row image is mapped to the CAM file, and the number of valid pixels in the scanned row image is filtered according to the contour region in the CAM file; wherein, pixels located in the valid area of ​​the circuit board are valid pixels. When the proportion of valid pixels in the selected scan line image exceeds a set threshold, the scan line image is determined as a valid scan line image, and the flexible board scan line image or the rigid board scan line image is determined.

[0009] Specifically, determining at least one set of flexible board scan row images that satisfy flexible board scanning and one set of rigid board scan row images that satisfy rigid board scanning includes: The mapping relationship between the selected valid scan line images and the CAM file is used to extract the proportion of flexible board pixels and rigid board pixels in the valid scan line images, respectively. When the proportion of flexible board pixels in the effective scan line image exceeds a set threshold, it is determined to be a flexible board scan line image; when the proportion of rigid board pixels in the effective scan line image exceeds a set threshold, it is determined to be a rigid board scan line image.

[0010] Specifically, the line scan camera randomly selects the scan line image. When the proportion of valid pixels in the selected scan line image does not exceed a set threshold, it rescans and judges at intervals of at least N scan line spacings until the valid scan line image is obtained.

[0011] Specifically, after determining the target parameters of the target area, the method further includes: The line scan images of the rigid-flex PCB are obtained by scanning and stitching the rigid-flex PCB line by line using the target parameters of the flexible PCB and the rigid PCB. For the selected line scan image, the flexible board contour area and the rigid board contour area are determined by aligning and mapping with the corresponding CAM file, and the flexible board and rigid board overlap area is determined based on the positional relationship between the flexible board contour area and the rigid board contour area. CV defect detection is performed on the rigid board contour image extracted from the first-line scan image to obtain the rigid board area defect detection result; AI defect detection is performed on the extracted rigid board overlapping image to obtain the rigid board overlapping area detection result. CV defect detection is performed on the flexible circuit board contour image extracted from another line scan image to obtain the flexible circuit board area detection result; AI defect detection is performed on the extracted flexible circuit board overlap image to obtain the flexible circuit board overlap area detection result.

[0012] Specifically, determining the hard and soft board overlap area includes: Use one CAM file to map a clear hardboard outline area in a line scan image, and use another CAM file to map a clear flexible board outline area in another line scan image. The hardboard overlap area is determined at the edge of the hardboard outline area based on the coordinates of the clear hardboard outline area, and the softboard overlap area is determined at the edge of the softboard outline area based on the coordinates of the clear hardboard outline area.

[0013] On the other hand, this application provides a computer device including a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set or instruction set, wherein the at least one instruction, the at least one program, the code set or instruction set is loaded and executed by the processor to implement the focusing method for detecting defects in rigid-flex circuit boards as described above.

[0014] In another aspect, this application provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the focusing method for detecting defects in rigid-flex circuit boards as described above.

[0015] The beneficial effects of the technical solution provided in this application include at least the following: By introducing a regional focal length adjustment mechanism, the system can accurately distinguish between flexible board areas and rigid board areas by mapping and matching the scanned line images with CAM files. This step is the basis for subsequent regional focusing, ensuring the targeted nature of the focal length adjustment. Subsequently, for each selected target scanned line image of a flexible board or rigid board area, the system adaptively adjusts the camera focal length through an image sharpness feedback mechanism until the acquired image reaches the target accuracy. This ability to dynamically adjust the focal length according to the height differences of different areas enables the line scan camera to acquire high-definition images for both flexible and rigid board areas. Therefore, this method can ensure that each area of ​​the flexible-rigid bonded board can obtain clear images, providing a high-quality image data foundation for subsequent defect detection, thereby significantly improving the accuracy and efficiency of defect detection, reducing the false negative rate, and enhancing the versatility of the machine. Attached Figure Description

[0016] Figure 1 This is a flowchart of a focusing method for detecting defects in rigid-flex circuit boards provided in an embodiment of this application; Figure 2 A line scan image of a rigid-flex PCB in one possible form is shown; Figure 3 A schematic diagram of obtaining scanned line images by random line scanning is shown; Figure 4 An example diagram illustrates the selection of two scan lines; Figure 5 This diagram illustrates the mapping of target regions and overlapping areas in local line scan images under two target parameters. Figure 6 This is a schematic diagram of incremental fusion of defect detection results from two line scan images; Figure 7 A structural block diagram of a focusing device for detecting defects in rigid-flex circuit boards is shown. Figure 8 A structural block diagram of a computer device provided in an exemplary embodiment of this application is shown. Detailed Implementation

[0017] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0018] In this article, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0019] In traditional PCB defect detection processes, the height difference between the flexible and rigid areas of a rigid-flex PCB exceeds the depth of field of a line scan camera, making it impossible to simultaneously acquire clear images of both areas in a single scan. Specifically, this height difference causes the flexible area to appear blurred when the camera focuses on the rigid area, as it is outside the depth of field. This affects the accuracy of defect detection, resulting in decreased image quality and reduced reliability of defect identification.

[0020] For example, in the PCB production line of foldable screen electronic devices, the rigid board area of ​​the rigid-flex PCB is thicker than the flexible board area, resulting in a significant height difference. When scanning with a fixed-focal-length line scan camera, the image of the rigid board area is clearly visible, while the image of the flexible board area is blurry because the height difference prevents it from being on the same focal plane. Consequently, minute defects in the flexible board area cannot be effectively identified, and the inspection process requires repeated adjustments to the scanning parameters to attempt to cover different height areas, causing inspection interruptions and wasting resources.

[0021] If the above problems are not addressed, the defect detection process will face an increased risk of missed detections, affecting the stability of product quality control. Simultaneously, detection efficiency will decrease due to repetitive parameter adjustments, further reducing the overall operating efficiency of the production line. Furthermore, the limited versatility of existing testing equipment makes it difficult to adapt to the testing needs of rigid-flex PCBs of different specifications, potentially hindering its application in diverse production environments.

[0022] Therefore, this application provides a flowchart of a focusing method suitable for defect detection of rigid-flex circuit boards, such as... Figure 1 As shown, it includes the following steps: S1. Use the preset parameters of the line scan camera to perform a linear scan on the rigid-flex PCB to obtain a scan line image; A rigid-flex PCB is a type of printed circuit board that combines the characteristics of flexible circuit boards (flexible boards) and rigid circuit boards (rigid boards). For example... Figure 2 One possible form is shown, characterized by differences in thickness, material properties, and surface height in different regions, which poses a challenge to high-precision optical inspection.

[0023] Preset parameters refer to a series of initial operating parameters set for a line scan camera before image acquisition, such as exposure time, gain, line speed, and initial focal length. Proper setting of these parameters is fundamental to obtaining preliminary scanned images.

[0024] A line scan camera is an industrial camera that acquires images by scanning line by line. Its working principle is to collect data for only one line at a time, and then stitch the data from multiple lines into a complete two-dimensional image through mechanical movement or the movement of the object being inspected. Line scan cameras are typically used in high-speed, high-resolution continuous inspection scenarios.

[0025] The preset parameters of a line scan camera typically refer to a series of initial operating parameters set for the line scan camera before image acquisition, such as exposure time, gain, line speed, and initial focal length. Properly setting these parameters is fundamental to obtaining the initial scanned image. For example, these preset parameters can be set initially based on historical scan data or a rough estimate of the camera's Z-axis height and circuit board characteristics.

[0026] Linear scanning is a process of acquiring image data from the surface of a rigid-flex PCB by controlling a line scan camera to follow a predetermined path and speed. This method can cover a portion or the entire area to be inspected and obtain a series of continuous scan lines. In this embodiment, the optimal parameters for both flexible and rigid PCB areas are adjusted through several line scans, such as... Figure 3 This diagram illustrates the process of obtaining scan line images through random line scanning, with the yellow portion representing the scan line images.

[0027] S2. Map and match the pixel contours of the scanned row images with the CAM files of the rigid-flex board to determine at least one set of flexible board scan row images that satisfy flexible board scanning and rigid board scan row images that satisfy rigid board scanning. CAM files are computer-aided manufacturing (CAM) files that contain precise design data for a circuit board, including traces, pads, holes, and the geometry and location information of different areas (such as flexible and rigid board areas). The CAM files in this application serve as a reference for comparison and mapping with actual scanned images, as well as for subsequent defect detection.

[0028] The mapping matching process involves aligning and comparing the pixel contours of the actual acquired scanned image with the design contours in the CAM file. Through mapping matching, the relationship between each region in the scanned image and its corresponding region in the CAM file can be determined, thereby identifying flexible and rigid board regions.

[0029] In this application, to improve camera parameter tuning accuracy, the line scan image is further subdivided into flexible circuit board scan line images and rigid circuit board scan line images based on the number of pixels. In one possible implementation, the line image mainly containing features of the flexible circuit board area can be defined as a flexible circuit board scan line image, and the line image mainly containing features of the rigid circuit board area can be defined as a rigid circuit board scan line image.

[0030] Since the height of the rigid and flexible boards is basically the same globally, at least one set of flexible board scan row images and one set of rigid board scan row images are sufficient. Of course, to improve accuracy and verification, multiple sets can be selected for weighted calculation. These images will be used for subsequent focus adjustment and defect detection in the rigid and flexible board areas.

[0031] S3. Adjust the preset focal length of the line scan camera, scan the selected target scan line image, and adjust the camera focal length according to the image clarity feedback until the acquired target scan line image reaches the target accuracy. Then, determine the corresponding camera focal length as the target parameter for the scanned target area.

[0032] The preset focal length is the initial focal length set by the line scan camera before scanning begins. The accuracy of the focal length directly affects the image sharpness. For the aforementioned determined flexible board scan line images and rigid board scan line images (i.e., target scan line images), multiple feedback focusing operations are performed. Each focusing scan of the target line image is performed, and the image sharpness (e.g., edge sharpness, contrast, high-frequency components, etc.) is judged to determine whether it meets the preset requirements. This assesses whether the current focal length setting is appropriate and provides a basis for focal length adjustment. Target accuracy refers to an acceptable minimum standard for image sharpness set during the focal length adjustment process. When the acquired image sharpness reaches or exceeds this standard, the focal length adjustment is considered complete.

[0033] Suppose a circuit board manufacturing plant needs to inspect a batch of rigid-flex circuit boards for defects. There is a height difference of about 2 mm between the flexible and rigid areas of these circuit boards. When using a single-focal-length line scan camera for inspection, the rigid area is often clear while the flexible area is blurry, or vice versa, resulting in a high rate of missed defects.

[0034] To address this, the focusing method proposed in this application is applied to the detection system. First, the line scan camera is set with a set of common preset parameters, such as an exposure time of 50 microseconds, a gain of 8dB, and a line speed of 10,000 lines per second. Then, the rigid-flex PCB passes through the line scan camera's field of view on a conveyor belt at a constant speed. The line scan camera performs a line-by-line linear scan of the circuit board, thereby obtaining a series of continuous scan line images.

[0035] Next, the system maps and matches the pixel contours of these scanned images with the CAM drawings of the batch of circuit boards. Specifically, image processing algorithms identify the main geometric features in the scanned images and align them with the corresponding design features in the CAM drawings. Based on the predefined boundary information of the flexible and rigid board areas in the CAM drawings, the system can accurately determine which scanned images mainly cover the flexible board area, thus identifying them as flexible board scanned images; and which mainly cover the rigid board area, thus identifying them as rigid board scanned images. For example, the system identifies that images from row 100 to row 200 mainly belong to the flexible board area, while images from row 500 to row 600 mainly belong to the rigid board area.

[0036] Subsequently, the system selects a flexible circuit board scan row image (e.g., row 150) as the target scan row image and begins adjusting the focal length of the line scan camera. The initial focal length may be a generic value. The system scans the target scan row image and acquires image sharpness feedback in real time. For example, image sharpness is quantified by calculating the Laplacian operator value or high-frequency energy in the frequency domain. If the current image sharpness does not reach the preset target accuracy (e.g., a sharpness score of 80 or higher), the system fine-tunes the camera focal length and scans again to acquire the image, repeating this process. When the sharpness score of row 150 reaches the target accuracy, the corresponding camera focal length (e.g., 10.5 mm at the Z-axis position) is determined as the target parameter for scanning the flexible circuit board area. Similarly, the system selects a rigid circuit board scan row image (e.g., row 550) as the target scan row image and repeats the above focal length adjustment process until the acquired image sharpness reaches the target accuracy, at which point the corresponding camera focal length (e.g., 12.3 mm at the Z-axis position) is determined as the target parameter for scanning the rigid circuit board area.

[0037] Therefore, this method obtains optimal focal length parameters for both the flexible and rigid plate regions, resolving the imaging blurring problem caused by height differences. Furthermore, after determining the target parameters for each region, the line scan camera is controlled to use these parameters to perform high-precision scanning of the corresponding regions, and then defect detection is performed on the acquired scan images.

[0038] Based on the above examples, this application introduces a regional focus adjustment mechanism. By mapping and matching the scanned line images with CAM files, the system can accurately distinguish between flexible and rigid board areas. This step forms the basis for subsequent regional focusing, ensuring the targeted nature of focus adjustment. Subsequently, for each selected target scanned line image in either the flexible or rigid board area, the system adaptively adjusts the camera focus through an image sharpness feedback mechanism until the acquired image achieves the target accuracy.

[0039] For example, in this case, the flexible circuit board area was determined to require a focal length of 10.5 mm, while the rigid circuit board area required a focal length of 12.3 mm. This ability to dynamically adjust the focal length based on the height differences between different areas allows the line scan camera to acquire high-resolution images of both the flexible and rigid circuit board areas. Therefore, the method of this application ensures that clear images are obtained for all areas of the rigid-flex board, providing a high-quality image data foundation for subsequent defect detection. This significantly improves the accuracy and efficiency of defect detection, reduces the false negative rate, and enhances the versatility of the equipment. In some embodiments, the camera focal length is adjusted based on image sharpness feedback until the acquired target scan line image reaches the target accuracy. This process can be implemented through the following steps: 1. Uniformly sample candidate parameter points according to the camera's preset focal length range, and scan the target row by setting the candidate parameter points in a round-robin fashion to obtain several corresponding candidate images; different focal length parameters correspond to different image sharpness; 2. Select the image with the highest clarity from several candidate images and compare it with the target accuracy; 3. If the target accuracy is not achieved, take the camera focal length corresponding to the candidate image as the center, determine the focal length adjustment range with adjacent candidate parameter points, resample the candidate parameter points, and repeat the polling scan and the selection of the highest resolution image steps until the acquired target scan line image reaches the target accuracy.

[0040] In the above process, candidate parameter points are sampled evenly according to the camera's preset focal length range. This is to ensure that possible focal length values ​​are fully covered in the initial stage of focal length adjustment, and to avoid missing the best setting point.

[0041] As one implementation method, the camera's preset focal length range can be a set value from the minimum focal length to the maximum focal length, or it can be a range determined by historical experience values. Uniform sampling can be achieved by selecting focal length values ​​at equal intervals within this range. For example, if the preset range is 10mm to 20mm, a focal length point can be selected every 1mm to balance sampling density and adjustment efficiency.

[0042] The process involves polling candidate parameter points to scan the target row, acquiring several corresponding candidate images. The aim is to progressively approximate the optimal parameters, providing a data foundation for subsequent sharpness evaluation. Specifically, sharpness evaluation can be performed on all acquired candidate images, such as calculating the Tenengrad value for each image, and then selecting the image with the highest Tenengrad value as the candidate image with the highest sharpness. The target accuracy can be preset to a sharpness threshold; for example, a sharpness evaluation value of 0.9 or higher is considered to have met the target accuracy. Alternatively, image processing software can automatically calculate the sharpness index of each image and select the image with the highest sharpness index. Then, the sharpness index of this image is compared with a preset acceptance standard to determine whether it meets the requirements for defect detection.

[0043] When the target accuracy is not reached, the focal length adjustment range is determined by using the camera focal length corresponding to the candidate image as the center and adjacent candidate parameter points. Candidate parameter points are resampled, and the polling scan and selection of the highest-resolution image are repeated until the acquired target scan line image reaches the target accuracy. This iterative optimization of focal length adjustment gradually approaches the optimal focal length, improving adjustment efficiency and accuracy. If the first sampling fails to reach the target accuracy, the range between the two adjacent candidate parameter points of the current highest-resolution image is used as the center. Within this new adjustment range, denser, more uniform sampling can be performed using smaller step sizes. Alternatively, the sampling density and range can be dynamically adjusted based on the trend of the sharpness curve. For example, if the sharpness curve exhibits a single-peak characteristic, a new sampling center and range can be determined based on the peak position and the downward trend on both sides, and optimization algorithms such as the bisection method or the golden section method can be used for sampling to accelerate focal length convergence.

[0044] In the specific execution process, the line scan camera will also synchronize parameters such as light source, and use target light source for the scan lines of flexible circuit board and rigid circuit board respectively. The camera focal length is adjusted by successively approaching the image with a liquid lens, and the adjustment step size is gradually reduced (for example, first take pictures with a step size of 0.1 mm, and then fine-tune with a step size of 0.01 mm). The target parameters of the flexible circuit board used for scanning the flexible circuit board area and the target parameters of the rigid circuit board used for scanning the rigid circuit board area are determined respectively.

[0045] Assume the preset focal length range of the line scan camera is 40mm to 160mm. First, the system performs uniform sampling in 20mm increments to obtain candidate parameter points: 40mm, 60mm, 80mm, 100mm, 120mm, 140mm, 160mm, and 180mm. Then, the line scan camera sequentially adjusts its focal length to these points and scans the target line, acquiring eight candidate images. Using an image sharpness evaluation algorithm, such as calculating the Tenengrad value for each image, it is found that the image sharpness is highest at a focal length of 60mm, with a Tenengrad value of 0.8. At this point, comparing this value with the preset target accuracy (e.g., 0.9), it is found that the target accuracy has not yet been reached. Therefore, the system uses 60mm as the center and its adjacent candidate parameter points of 40mm and 80mm as boundaries to determine a new focal length adjustment range of 40mm to 80mm. Within this new range, the system can use a finer step size, such as 5mm, to resample uniformly, obtaining candidate parameter points: 45mm, 50mm, 55mm, 60mm, 65mm, 70mm, 75mm, and 80mm. A polling scan and sharpness evaluation are performed again. Assuming the highest image sharpness is found at a focal length of 55mm, with a Tenengrad value of 0.88, and since the target accuracy of 0.9 is still not achieved, the system will further narrow the adjustment range, centering on 55mm and using 50mm and 60mm as boundaries, determining a new adjustment range of 50mm to 60mm. Within this range, the system can further sample with a step size of 1mm and repeat the above scanning and evaluation steps. Finally, when the focal length is adjusted to 57mm, the image sharpness reaches 0.91, meeting the target accuracy requirement. At this point, 57mm is determined as the target parameter for the target area. The step size in this embodiment is only an example; actual adjustments should be made according to the project and camera characteristics, and the specific value is not limited.

[0046] Through the above technical solution, this application can efficiently and accurately determine the optimal focal length parameters of the line scan camera, avoiding the time waste and inefficiency caused by blind trial and error and repeated adjustments in traditional methods. This iterative optimization adjustment method ensures that the acquired target scan line image can achieve the preset clarity target, thereby providing high-quality image data for subsequent defect detection. Especially for rigid-flex circuit boards, this solution can perform precise focal length adjustments for flexible and rigid board areas of different heights, significantly improving the accuracy and reliability of defect detection and effectively solving the imaging blurring problem caused by height differences.

[0047] In the above embodiments, mapping matching is used to determine the scan line images of flexible boards and rigid boards. However, in this process, the scan line images may contain invalid pixels (such as background or non-circuit board areas), which makes it impossible to accurately distinguish between flexible board and rigid board areas, thereby affecting the accuracy of subsequent focusing and defect detection.

[0048] Therefore, this application performs the following screening on the scanned image obtained from arbitrary line scanning to ensure the accuracy of subsequent adjustments: A. Map the scanned row image to the CAM file, and filter the number of valid pixels in the scanned row image according to the contour area in the CAM file; among them, pixels located in the valid area of ​​the circuit board are valid pixels. B. When the proportion of valid pixels in the selected scan line image exceeds the set threshold, the scan line image is determined as a valid scan line image, and either a flexible board scan line image or a rigid board scan line image is determined. C. When the proportion of valid pixels in the selected scan line image does not exceed the set threshold, rescan and judge at intervals of at least N scan line spacings until a valid scan line image is obtained.

[0049] Valid pixels refer to pixels located within the effective circuit area of ​​the rigid-flex PCB, excluding pixels on the board edges, in gaps, or other non-circuit areas. First, the camera scans rows randomly. For the initially acquired scan row image, it is precisely mapped and matched with the CAM file of the rigid-flex PCB. For example, a feature-point-based registration method can be used to automatically detect and match unique feature points in the scan row image and the CAM file. Then, geometric transformation parameters are calculated using these matching points, and the scan row image is corrected and projected onto the coordinate system of the CAM file. Another approach is region-correlation-based registration, which finds the optimal alignment position by calculating the similarity between local regions of the scan row image and the CAM file. This mapping ensures that subsequent analysis of image content is based on an accurate spatial reference.

[0050] Based on this, the number of valid pixels in the scanned row image is filtered according to the contour region in the CAM drawing. This step utilizes the precise circuit board contour information contained in the CAM drawing to identify pixels in the scanned row image that truly belong to the circuit board. The CAM drawing typically defines the geometry of the circuit board and the boundaries of each functional area. After the scanned row image is mapped to the CAM drawing coordinate system, the system can judge each pixel in the scanned row image according to the predefined circuit board contour region in the CAM drawing. If the coordinates of a pixel fall within the circuit board contour region defined in the CAM drawing, it is marked as a valid pixel; otherwise, it is an invalid pixel.

[0051] The effective pixel percentage threshold can be flexibly adjusted. Assuming the percentage exceeds a set threshold of 75%, the scan line image is considered a valid scan line image. Based on this, CAM files typically contain clear identifiers for flexible and rigid board regions. The system can further count how many effective pixels in the valid scan line image fall within the flexible and rigid board regions of the CAM file. If the number of effective pixels falling within the flexible board region is dominant (e.g., exceeding 60% of the total effective pixels), the image is identified as a flexible board scan line image; conversely, if the number of effective pixels in the rigid board region is dominant, it is identified as a rigid board scan line image.

[0052] Figure 4 The example illustrates two scan line selection scenarios. Assuming the ratio of valid to invalid pixels is set appropriately (e.g., 40%), the upper scan line in the image meets the criteria, while the lower scan line, with an invalid pixel ratio exceeding 40%, is deemed invalid. This method allows for precise differentiation between the circuit board body and the background or other non-circuit board areas, providing clean data for subsequent analysis.

[0053] By precisely mapping the scanned row images to CAM files and selecting and determining the proportion of effective pixels based on the contour areas of the CAM files, it is ensured that the selected scanned row images truly represent the effective areas of the circuit board. This avoids processing invalid data containing large amounts of background or non-circuit board areas, significantly improving the accuracy and reliability of subsequent determination of flexible circuit board and rigid circuit board scanned row images. Ultimately, this provides high-quality, high-purity image data input for subsequent differentiated focusing and high-precision defect detection of flexible and rigid circuit board areas, thereby improving the efficiency of the entire defect detection system and the accuracy of the detection results.

[0054] If the calculated percentage of valid pixels does not reach the preset threshold, it indicates that the current image may not contain sufficient circuit information and is unsuitable for accurate defect detection. To avoid repeated scanning in invalid areas, the system does not simply restart but instructs the line scan camera to rescan and judge at intervals of at least N scan line spacings. This skip-scanning strategy effectively avoids redundant operations in consecutive invalid areas, significantly improving scanning efficiency. This process continues until a scan line image with a percentage of valid pixels exceeding the preset threshold is successfully acquired. In this way, this solution ensures that the determination of subsequent flexible circuit board scan line images or rigid circuit board scan line images, as well as the final defect detection, can be based on high-quality, highly effective image data, thereby improving the overall accuracy and efficiency of detection and effectively solving the problems of invalid scanning and low efficiency that may occur when randomly selecting scan line images.

[0055] In defect detection of rigid-flex PCBs, traditional methods, when mapping and matching the pixel contours of scanned images with CAM files to determine the scanned images of flexible and rigid PCBs, may result in scanned images containing mixed pixels from both types of boards. This difference in proportion can lead to blurred boundaries, affecting subsequent focusing and detection accuracy.

[0056] Therefore, this application provides a method for filtering flexible circuit board scan row images that meet the requirements for flexible circuit board scanning and rigid circuit board scan row images that meet the requirements for rigid circuit board scanning, comprising the following steps: a. Map the selected valid scan line images to the CAM file, and extract the proportion of flexible board pixels and rigid board pixels in the valid scan line images respectively. This step aims to quantify the pixel composition of different types of circuit board regions (flexible or rigid) in the valid scan line image. In previous steps, the scan line image was mapped to the CAM file, and valid pixels were selected, forming the valid scan line image. Based on this mapping, each pixel in the valid scan line image can be classified using predefined flexible and rigid board region information in the CAM file. For example, by comparing the coordinates of a pixel in the CAM file, it can be determined whether it falls within a flexible or rigid board region.

[0057] One method for extracting the proportions can be to: count the total number of pixels belonging to the flexible board region and the total number of pixels belonging to the rigid board region in the valid scan line image, and then divide each by the total number of pixels in the valid scan line image to obtain the proportions of flexible board pixels and rigid board pixels. Another method is to use image processing algorithms, such as region growing or edge detection, combined with the geometric information of the CAM file, to accurately identify and count the pixels in the flexible board and rigid board regions.

[0058] b. When the proportion of flexible board pixels in the valid scan line image exceeds the set threshold, it is determined to be a flexible board scan line image; when the proportion of rigid board pixels in the valid scan line image exceeds the set threshold, it is determined to be a rigid board scan line image.

[0059] This step is used to identify valid scan line images that primarily consist of the flexible circuit board area as flexible circuit board scan line images. The threshold is a preset percentage value used to define whether a scan line image is sufficiently "purely" representative of the flexible circuit board area. For example, this threshold can be set to 70%, 80%, or 90%, etc.

[0060] Suppose a valid scan line image has a total of 1000 valid pixels. After system analysis, 850 pixels belong to the flexible circuit board (PCB) area, 100 pixels belong to the rigid circuit board (PCB) area, and 50 pixels belong to other non-PCB areas. At this point, the PCB pixel ratio is 85%, and the rigid circuit board pixel ratio is 10%. If the preset PCB pixel ratio threshold is 80%, then since 85% exceeds 80%, this valid scan line image can be identified as a PCB scan line image. Similarly, if another valid scan line image has a rigid circuit board pixel ratio of 90%, and the preset rigid circuit board pixel ratio threshold is 80%, then this line image can be identified as a rigid circuit board scan line image. In this way, it can be ensured that the main components of the selected PCB or rigid circuit board scan line image are highly consistent with the target area, thus providing a reliable sample for subsequent precise focusing.

[0061] This pixel-based quantitative judgment allows subsequent focusing operations on flexible or rigid board areas to select more representative and pure sample row images. Therefore, it ensures more accurate and optimized focal length parameters are determined for flexible and rigid board areas respectively, significantly improving the imaging clarity and detection accuracy of the line scan camera in defect detection of flexible-rigid integrated circuit boards, and effectively reducing the missed detection rate and false positive rate.

[0062] Based on the above embodiments, after determining the target parameters for different target areas (flexible board areas and rigid board areas), subsequent scanning and defect detection tasks can be performed. The process can be summarized as follows: A. Use the target parameters of the flexible board and the rigid board to scan and stitch the line scan images of the flexible and rigid board line by line to obtain their respective line scan images; B. For the selected line scan image, the flexible board contour area and the rigid board contour area are determined by aligning and mapping with the corresponding CAM file, and the flexible board and rigid board overlap area is determined based on the positional relationship between the flexible board contour area and the rigid board contour area. C. Perform CV defect detection on the hardboard contour image extracted from the first-line scan image to obtain the hardboard area defect detection result; perform AI defect detection on the extracted hardboard overlapping image to obtain the hardboard overlapping area detection result. D. Perform CV defect detection on the flexible circuit board contour image extracted from another line scan image to obtain the flexible circuit board area detection result; perform AI defect detection on the extracted flexible circuit board overlapping image to obtain the flexible circuit board overlapping area detection result.

[0063] For a selected line scan image, the flexible board contour area and the rigid board contour area are determined by aligning and mapping with the corresponding CAM drawing. This means that the image obtained by actual scanning is accurately matched with the design drawing (CAM drawing) to identify the physical boundaries of the flexible board and the rigid board in the image.

[0064] Furthermore, the spatial relationship between these two regions is analyzed to define specific areas where they are connected or overlap. For example, two methods can be used: One method is to predefine the overlapping area of ​​the flexible and rigid boards in the CAM file. This area is typically the boundary zone where the flexible and rigid boards physically connect or transition. After image alignment, this predefined area is directly extracted from the CAM file as the overlapping area. Another method is to perform image morphological operations on the determined flexible and rigid board contour areas—for example, dilating the flexible board contour area and eroding the rigid board contour area—and then take their intersection. Alternatively, the geometric intersection of the two contour areas can be directly calculated, and this intersection area can be extended outwards by a certain width to form an overlapping area that includes the actual physical connection and transition region.

[0065] CV (Visual Cognition) defect detection is a defect identification method based on traditional image processing algorithms. It can be implemented using techniques such as edge detection, morphological operations, or CAM (Computer-Aided Image) template matching. Its purpose is to efficiently process the geometric features of clear areas in an image and avoid computational redundancy caused by complex models. AI (AI Defect Detection), on the other hand, is a defect identification method based on machine learning models. It can be implemented using convolutional neural networks or deep learning architectures. Its purpose is to extract nonlinear features from blurred images and adapt to imaging uncertainties.

[0066] For the first line scan image, the CV1 model (input rigid board contour image) and the AI1 model (input rigid board overlapping image) are used for recognition respectively to obtain the detection results of rigid board area defects and rigid board overlapping area. For the second line scan image, the CV2 model (input flexible board contour image) and the AI2 model (input flexible board overlapping image) are used for recognition respectively to obtain the detection results of flexible board area defects and flexible board overlapping area.

[0067] Common defects in rigid PCB areas include short circuits, open circuits, foreign objects, scratches, and missing solder pads; common defects in flexible PCB areas include wrinkles, bubbles, indentations, and discoloration. The AI1 model can identify complex defect patterns that are difficult for the traditional CV1 algorithm to handle, such as microcracks, delamination, and poor bonding; the AI2 model can identify defects that are difficult for CV2 to identify, such as peeling, glue overflow, and broken connections.

[0068] As a specific implementation method, the solution of this application is implemented as follows: After acquiring the first line scan image, the rigid board contour image is extracted by matching the rigid board CAM image file, and the Sobel operator is used for edge detection to complete CV defect detection; at the same time, for the rigid board overlapping image, the pre-trained ResNet model is called to perform AI defect detection; after acquiring the second line scan image, the flexible board contour image is extracted by matching the flexible board CAM image file, and morphological opening operation is used for CV defect detection; at the same time, for the flexible board overlapping image, the U-Net network structure is applied to complete AI defect detection.

[0069] In one specific implementation, after determining the focusing parameters for the flexible and rigid board areas, the Z-axis height is set to the position corresponding to the optimal focal length of the flexible board. At this point, by controlling a high-precision linear motion platform, the rigid-flex board is scanned line by line at a constant speed below the camera, thereby acquiring a complete line scan image of the flexible board area with clarity. Subsequently, the system adjusts the line scan camera to the target parameters of the rigid board, that is, adjusts the Z-axis height to the optimal focal length position of the rigid board, and scans the same rigid-flex board line by line again to acquire another complete line scan image of the rigid board area with clarity.

[0070] After obtaining the two line scan images, the system selects one image (e.g., a clear line scan image of the rigid board) for processing. First, the line scan image is precisely aligned with the corresponding CAM drawing using an image registration algorithm. This can be achieved by identifying four preset corner points or specific patterns in the image as references, and then calculating the geometric transformation matrix between the image and the CAM drawing. After alignment, the system extracts the rigid board contour area from the line scan image based on the predefined rigid board region boundaries in the CAM drawing. Simultaneously, the system determines the rigid board overlap area based on the geometric relationship between the flexible board contour area and the rigid board contour area in the CAM drawing, for example, by extending the edge of the rigid board contour area outward by a preset width (e.g., 0.5 mm). For the extracted rigid board contour image, the system runs a series of rule-based CV algorithms for defect detection. For example, edge detection algorithms (such as the Canny operator) are used to detect broken or short-circuited circuits, and connected component analysis is used to detect foreign objects or missing pads, thereby obtaining the rigid board area defect detection results. For the extracted rigid board overlap image, the system calls a pre-trained deep learning model (such as a defect detection model based on YOLO or Mask R-CNN) to perform AI defect detection. This model can identify complex defects unique to the overlap area, such as delamination and poor bonding, and outputs the detection results for the rigid board overlap area. Similarly, for another clear line scan image of the flexible board, the system performs the same alignment, region extraction, and defect detection process, but adjusts the CV algorithm parameters according to the characteristics of the flexible board and uses another AI model specifically trained for the flexible board overlap area for detection, ultimately obtaining the detection results for the flexible board area and the detection results for the flexible board overlap area.

[0071] By employing a differentiated inspection strategy that combines CV and AI, standard defects can be detected efficiently and accurately in conventional areas of rigid and flexible boards. In overlapping areas with complex structures and varied defect patterns, the powerful capabilities of AI can be used to identify complex defects that are difficult to detect using traditional methods. This significantly improves the comprehensiveness and accuracy of defect detection for rigid-flex boards, reduces the incidence of missed and false detections, and improves product quality and production efficiency.

[0072] In some embodiments, the process of determining the rigid-flex PCB overlap area can use one CAM file to map a clear rigid PCB outline area in a line scan image, and another CAM file to map a clear flexible PCB outline area in another line scan image. Then, the rigid-flex PCB overlap area is determined at the edge of the rigid PCB outline area based on the coordinates of the clear flexible PCB outline area, and the flexible PCB overlap area is determined at the edge of the flexible PCB outline area based on the coordinates of the clear rigid PCB outline area.

[0073] Figure 5 This diagram illustrates the mapping of target regions and overlapping areas between local line scan images under two target parameters. It can be understood as follows: In the left-side hardboard line scan image, a hardboard CAM file is used to map the hardboard region, resulting in a clear hardboard outline (i.e., region 1 on the left). In the right-side flexible board line scan image, a flexible board CAM file is used to map the flexible board region, resulting in a clear flexible board outline (i.e., region 1 on the right). The use of CAM files in each case aims to avoid mismatches in blurred areas. For the hardboard line scan image, a clear hardboard outline (i.e., region 1 on the left) is mapped, while the flexible board region in this image is blurred due to the height difference. For the flexible board line scan image, a clear flexible board outline (i.e., region 1 on the right) is mapped, while the hardboard region in this image is blurred due to the height difference.

[0074] Subsequently, based on the clear coordinates of the flexible board outline area in the right-side flexible board scan image (or the outline coordinates defined in the CAM file), the hardboard overlap area (i.e., region 2 on the left, which is a transition area extending from the edge of the hardboard outline area towards the flexible board) is determined at the edge of the hardboard outline area in the hardboard scan image. Similarly, based on the clear coordinates of the hardboard outline area in the hardboard scan image (or the outline coordinates defined in the CAM file), the flexible board overlap area (i.e., region 2 on the right, which is a transition area extending from the edge of the flexible board outline area towards the hardboard) is determined at the edge of the flexible board outline area in the flexible board scan image. This method, by using the precise coordinates of a clear area in one image to define the boundary of a blurred area in another image, achieves precise cross-image positioning of the overlap area boundary, thus solving the problem of boundary blurring in a single image due to height differences. This improves the accuracy of defect detection region segmentation and the reliability of detection results.

[0075] Special note: The dimensions of the clearly defined soft board outline area and hard board outline area are usually not strictly close to the overlapping area to avoid exceeding the defect identification range. The dimensions of the soft board overlapping area and the hard board overlapping area are determined by the model accuracy and are not completely symmetrical or equal.

[0076] Based on the separate processing and output results of the two line scan images, the detection outputs of the two overlapping regions are fused to output the final defect detection result. The specific process is as follows: The detection results of the hard board overlapping area and the soft board overlapping area are incrementally fused based on the defect coordinates and defect labels, and the final defect detection result is output by combining the defect detection results of the hard board area and the soft board area.

[0077] Figure 6 This diagram illustrates the incremental fusion of defect detection results from two line scan images. Defect coordinates represent the spatial location of the defect in the image, which can be quantified using pixel coordinates or physical coordinates. Specifically, image registration algorithms can map coordinates under different scanning parameters to a unified reference system, ensuring precise alignment of defect location information. Defect labels can be understood as type identification information for defects, defined using classification codes or semantic labels, such as categories like scratches, holes, or short circuits. This can be achieved through classification results output by machine learning models, aiming to clarify the nature and severity of the defect.

[0078] Incremental fusion is a fusion mechanism that dynamically supplements new information based on existing detection data. It can be achieved by constructing a defect feature database and performing incremental data merging operations. For example, a coordinate mapping algorithm is used to eliminate geometric deviations caused by differences in scanning parameters. Simultaneously, semantic consistency checks are performed on similar defects based on defect labels, filtering out conflicting or redundant detection entries. The incremental fusion mechanism dynamically integrates complementary information from two overlapping areas, supplementing missing details in overlapping regions based on existing rigid or flexible board area detection results, forming a complete defect distribution map. Finally, the final defect detection result is output by combining the rigid board area defect detection results and the flexible board area detection results. The detection results of the rigid and flexible board areas serve as baseline data, ensuring that highly reliable detection information in non-overlapping areas is fully preserved, while the fusion results of overlapping areas fill the detection gaps in boundary areas, thus constructing a seamless defect detection system covering the entire rigid-flex board.

[0079] Specifically, a defect database can be established, recording all defects detected in the rigid board overlap area (e.g., defect A: type "open circuit", coordinates (X1, Y1), confidence level 0.9) and all defects detected in the flexible board overlap area (e.g., defect B: type "open circuit", coordinates (X1+2, Y1+1), confidence level 0.8) one by one. During the recording process, the system can set a spatial threshold (e.g., 5 pixels). If a newly recorded defect is less than the coordinate distance of an existing defect in the database and has the same defect label (e.g., "open circuit"), the system can determine that it is the same defect. At this point, fusion can be performed according to preset rules, such as retaining the detection result with higher confidence, or merging the information of the two results (e.g., updating the average coordinates, maximum size, etc. of the defect), thereby avoiding duplicate reporting. For example, defect A and defect B can be merged into a single defect C with coordinates (X1+1, Y1+0.5), type "open circuit", and confidence level 0.9. After incremental fusion of the overlapping areas, the final defect detection results can be composed of the fused overlapping area defect C, as well as the rigid board area defect detection results (e.g., defect D: type "short circuit", coordinates (X2, Y2)) and the flexible board area detection results (e.g., defect E: type "foreign object", coordinates (X3, Y3)). These results can be integrated into a unified report file, such as an XML file containing detailed information on all defects, or annotated with different colors or symbols on the digital model of the circuit board on a graphical user interface for operator review and confirmation.

[0080] Through the above solution, this application achieves accurate integration of defect detection results in the interface area of ​​rigid-flex circuit boards, effectively solves the problem of defect coordinate offset and label conflict caused by different scanning parameters, avoids repeated detection or information omission, and ensures that the final output defect detection results maintain logical consistency in spatial location and type identification, thereby providing a reliable technical guarantee for high-precision quality inspection of rigid-flex circuit boards. Figure 7 This is a structural block diagram of a focusing device for detecting defects in rigid-flex circuit boards provided in an embodiment of this application. The device includes: The image scanning module 710 is used to perform linear scanning on the rigid-flex PCB using preset parameters of the line scan camera to obtain scan line images; The scanning determination module 720 is used to map and match the pixel contours of the scanned row images with the CAM files of the rigid-flex board, and determine at least one set of flexible board scan row images that satisfy flexible board scanning and rigid board scan row images that satisfy rigid board scanning. The parameter adjustment and detection module 730 is used to adjust the preset focal length of the line scan camera, scan the selected target scan line image, and adjust the camera focal length according to the image clarity feedback until the acquired target scan line image reaches the target accuracy, and determine the corresponding camera focal length as the target parameter of the scan target area.

[0081] It should be noted that the focusing device for detecting defects in rigid-flex circuit boards provided in this embodiment is only illustrated by the above-described division of functional modules / units. In practical applications, the above functions can be assigned to different functional modules / units as needed, that is, the internal structure of the focusing device for detecting defects in rigid-flex circuit boards can be divided into different functional modules / units to complete all or part of the functions described above. Furthermore, the implementation method of the focusing method for detecting defects in rigid-flex circuit boards provided in the above method embodiments and the implementation method of the focusing device for detecting defects in rigid-flex circuit boards provided in this embodiment belong to the same concept. For details of the specific implementation process of the focusing device for detecting defects in rigid-flex circuit boards provided in this embodiment, please refer to the above method embodiments, which will not be repeated here.

[0082] Figure 8 This application provides a structural block diagram of a computer device according to an exemplary embodiment. The computer device can be a desktop computer, laptop computer, handheld computer, or cloud server, etc. The computer device may include, but is not limited to, a processor and memory. The processor and memory can be connected via a bus or other means. The processor can be a central processing unit (CPU) or other general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a graphics processing unit (GPU), an embedded neural network processor (NPU) or other dedicated deep learning coprocessor, discrete gate or transistor logic devices, discrete hardware components, or combinations of the above types of chips.

[0083] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the methods in the above embodiments of this application. The processor executes various functional applications and data processing by running the non-transitory software programs, instructions, and modules stored in the memory, thereby implementing the methods in the above embodiments. The memory may include a program storage area and a data storage area, wherein the program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created by the processor, etc. Furthermore, the memory may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0084] Those skilled in the art will understand that the structure shown in this embodiment does not constitute a limitation on the computer device, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0085] This application also discloses a computer-readable storage medium. Specifically, the computer-readable storage medium is used to store a computer program, which, when executed by a processor, implements the methods described in the above-described method embodiments. Those skilled in the art will understand that implementing all or part of the processes in the methods described above can be accomplished by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk (HDD), or solid-state drive (SSD), etc.; the storage medium can also include combinations of the above types of memory.

[0086] This specific embodiment is merely an explanation of the present invention and is not intended to limit the invention. After reading this specification, those skilled in the art can make modifications to this embodiment without contributing any inventive step, but such modifications are protected by patent law as long as they are within the scope of the claims of the present invention.

Claims

1. A focusing method for detecting defects in rigid-flex circuit boards, characterized in that, The method includes: The rigid-flex PCB is linearly scanned using the preset parameters of the line scan camera to obtain scan line images; The pixel contours of the scanned images are mapped and matched with the CAM files of the rigid-flex board to determine at least one set of flexible board scanned images that satisfy flexible board scanning and rigid board scanned images that satisfy rigid board scanning. Adjust the preset focal length of the line scan camera to scan the selected target scan line image, and adjust the camera focal length according to the image sharpness feedback until the acquired target scan line image reaches the target accuracy. Then, determine the corresponding camera focal length as the target parameter for the scanned target area.

2. The method according to claim 1, characterized in that, The step of adjusting the camera focus based on image sharpness feedback until the acquired target scan line image reaches the target accuracy includes: Candidate parameter points are uniformly sampled according to the camera's preset focal length range. The candidate parameter points are then polled and the target row is scanned to obtain several corresponding candidate images. Different focal length parameters correspond to different image sharpness. Select the image with the highest resolution from several candidate images and compare it with the target accuracy. If the target accuracy is not achieved, the focal length adjustment range is determined by taking the camera focal length corresponding to the candidate image as the center and the adjacent candidate parameter points. The candidate parameter points are resampled, and the polling scan and selection of the highest resolution image steps are repeated until the acquired target scan line image reaches the target accuracy.

3. The method according to claim 2, characterized in that, The flexible circuit board scan row image and the rigid circuit board scan row image are respectively treated with target light sources. The camera focal length is adjusted by successively approaching the image with a liquid lens to determine the flexible circuit board target parameters for scanning the flexible circuit board area and the rigid circuit board target parameters for scanning the rigid circuit board area.

4. The method according to claim 1, characterized in that, The step of mapping and matching the pixel contours of the scanned image with the CAM file of the rigid-flex PCB includes: The scanned row image is mapped to the CAM file, and the number of valid pixels in the scanned row image is filtered according to the contour region in the CAM file; wherein, pixels located in the valid area of ​​the circuit board are valid pixels. When the proportion of valid pixels in the selected scan line image exceeds a set threshold, the scan line image is determined as a valid scan line image, and the flexible board scan line image or the rigid board scan line image is determined.

5. The method according to any one of claims 1-4, characterized in that, The determination of at least one set of flexible board scan row images that satisfy flexible board scanning and rigid board scan row images that satisfy rigid board scanning includes: The mapping relationship between the selected valid scan line images and the CAM file is used to extract the proportion of flexible board pixels and rigid board pixels in the valid scan line images, respectively. When the proportion of flexible board pixels in the effective scan line image exceeds a set threshold, it is determined to be a flexible board scan line image; when the proportion of rigid board pixels in the effective scan line image exceeds a set threshold, it is determined to be a rigid board scan line image.

6. The method according to claim 4, characterized in that, The line scan camera randomly selects the scan line image. When the proportion of valid pixels in the selected scan line image does not exceed a set threshold, it re-scans and judges at intervals of at least N scan line spacings until the valid scan line image is obtained.

7. The method according to claim 1, characterized in that, After determining the target parameters of the target region, the method further includes: The line scan images of the rigid-flex PCB are obtained by scanning and stitching the rigid-flex PCB line by line using the target parameters of the flexible PCB and the rigid PCB. For the selected line scan image, the flexible board contour area and the rigid board contour area are determined by aligning and mapping with the corresponding CAM file, and the flexible board and rigid board overlap area is determined based on the positional relationship between the flexible board contour area and the rigid board contour area. CV defect detection is performed on the rigid board contour image extracted from the first-line scan image to obtain the rigid board area defect detection result; AI defect detection is performed on the extracted rigid board overlapping image to obtain the rigid board overlapping area detection result. CV defect detection is performed on the flexible circuit board contour image extracted from another line scan image to obtain the flexible circuit board area detection result; AI defect detection is performed on the extracted flexible circuit board overlap image to obtain the flexible circuit board overlap area detection result.

8. The method according to claim 7, characterized in that determining the hard-soft board overlap area includes: Use one CAM file to map a clear hardboard outline area in a line scan image, and use another CAM file to map a clear flexible board outline area in another line scan image. The hardboard overlap area is determined at the edge of the hardboard outline area based on the coordinates of the clear hardboard outline area, and the softboard overlap area is determined at the edge of the softboard outline area based on the coordinates of the clear hardboard outline area.

9. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one instruction, at least one program, a code set, or an instruction set, the at least one instruction, the at least one program, the code set, or the instruction set being loaded and executed by the processor to implement the focusing method for detecting defects in rigid-flex circuit boards as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The readable storage medium stores at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the focusing method for detecting defects in rigid-flex circuit boards as described in any one of claims 1 to 7.