Defect detection method, electronic device, and storage medium

CN122657005APending Publication Date: 2026-08-28深圳模德宝科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610694766.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-19
Publication Date
2026-08-28

AI Technical Summary

Technical Problem

[0003]有鉴于此,本申请实施例提供了瑕疵检测方法、电子设备及存储介质,可以解决现有技术中细小瑕疵漏检率较高的问题

Benefits of technology

[0016] The beneficial effects of this application embodiment compared with the prior art are as follows: By acquiring the image to be detected, multiple sub-images are obtained by cropping the image to be detected without scaling it. The resolution of the sub-images is the same as that of the image to be detected. Flaw detection is performed on each sub-image to obtain the location of flaws in the sub-image. This transforms flaw detection in a large image into flaw detection in multiple sub-images, avoiding the problem of flaw pixel loss caused by shrinking the large image, and effectively improving the detection rate of small flaws. Then, the flaw location in the image to be detected is determined based on the flaw location in the sub-image and the position of the sub-image in the image to be detected. This achieves the unification of the flaw location in the coordinate system of the image to be detected, making it easier to identify the location of small flaws in the image to be detected.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122657005A_ABST
    Figure CN122657005A_ABST
Patent Text Reader

Abstract

The application relates to the field of industrial detection, and provides a flaw detection method, an electronic device and a storage medium. The flaw detection method comprises the following steps: acquiring a to-be-detected image; under the condition that the to-be-detected image is not scaled, the to-be-detected image is cropped to obtain multiple sub-images and position information of each sub-image in the to-be-detected image, and the resolution of the sub-image is the same as that of the to-be-detected image; each sub-image is subjected to flaw detection to obtain a flaw position in the sub-image; and the flaw position in the to-be-detected image is determined according to the flaw position in the sub-image and the position information of the sub-image in the to-be-detected image, so that the problem of flaw pixel loss caused by the reduction of a large image is avoided, and the detection rate of small flaws is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of industrial inspection, and in particular relates to defect detection methods, electronic equipment and storage media. Background Technology

[0002] In industrial inspection, it is necessary to detect minor defects (such as scratches, stains, and missing parts) on the surfaces of products such as PCBs, films, glass, and metal parts. Generally, these defects are small in size and have low contrast. Current technology typically requires downsizing a high-resolution image of the product before inputting it into the inspection model for defect detection. In the downsized image, the number of pixels occupied by minor defects is further reduced, causing them to become blurred. This results in a high rate of missed detection for these minor defects, making it difficult to meet inspection requirements. Summary of the Invention

[0003] In view of this, embodiments of this application provide a defect detection method, electronic device, and storage medium, which can solve the problem of high missed detection rate of small defects in the prior art.

[0004] The first aspect of this application provides a defect detection method, including: Acquire the image to be detected; Without scaling the image to be detected, the image to be detected is cropped to obtain multiple sub-images and the position information of each sub-image in the image to be detected. The resolution of each sub-image is the same as the resolution of the image to be detected. Perform defect detection on each of the sub-images to obtain the location of defects in the sub-images; The location of the defect in the image to be detected is determined based on the location of the defect in the sub-image and the position information of the sub-image in the image to be detected.

[0005] In one embodiment, the image to be detected is cropped to obtain multiple sub-images and the position information of each sub-image in the image to be detected, including: The image to be detected is cropped according to the coordinate information of the preset effective area to obtain multiple sub-images and the position information of each sub-image in the image to be detected.

[0006] In one embodiment, the image to be detected is cropped according to the coordinate information of a preset effective region to obtain multiple sub-images and the position information of each sub-image in the image to be detected, including: The clipping region is determined based on the coordinate information of the effective region; The cropped area is expanded to obtain updated coordinate information; The image to be detected is cropped based on the updated coordinate information to obtain multiple sub-images and the position information of each sub-image in the image to be detected.

[0007] In one embodiment, before cropping the image to be detected according to the coordinate information of a preset effective region to obtain multiple sub-images and the position information of each sub-image in the image to be detected, the method further includes: A matching operation is performed on the image to be detected and the template image to obtain the offset information of the image to be detected relative to the template image; Based on the coordinate information of the target region in the template image and the offset information, the coordinate information of the effective region in the image to be detected is determined.

[0008] In one embodiment, after determining the location of the defect in the image to be detected based on the defect location in the sub-image and the position information of the sub-image in the image to be detected, the method further includes: The multiple defect locations are deduplicated, and the deduplicated defect locations are output.

[0009] In one embodiment, defect detection is performed on each of the sub-images to obtain the location of defects in the sub-images, including: For each of the sub-images, perform defect detection to obtain the location and type of defects in the sub-image.

[0010] In one embodiment, acquiring the image to be detected includes: Obtain the original images of the product to be tested by taking photographs; Feature detection is performed on the original image to determine the image to be detected in the original image.

[0011] In one embodiment, cropping the image to be detected includes: cropping the image to be detected using the Halcon algorithm; and / or, Performing defect detection on each of the sub-images to obtain the defect locations in the sub-images includes: using the YOLO algorithm to perform defect detection on each of the sub-images to obtain the defect locations in the sub-images.

[0012] A second aspect of this application provides a defect detection device, comprising: The acquisition module is used to acquire the image to be detected; The cropping module is used to crop the image to be detected without scaling it, to obtain multiple sub-images and the position information of each sub-image in the image to be detected, wherein the resolution of the sub-images is the same as the resolution of the image to be detected. The detection module is used to perform defect detection on each of the sub-images to obtain the location of defects in the sub-images; The output module is used to determine the location of the defect in the image to be detected based on the defect location in the sub-image and the location information.

[0013] A third aspect of this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the defect detection method as described in the first aspect above.

[0014] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the defect detection method as described in the first aspect above.

[0015] A fifth aspect of this application provides a computer program product that, when run on an electronic device, causes the electronic device to perform the method described in any one of the first aspects.

[0016] The beneficial effects of this application embodiment compared with the prior art are as follows: By acquiring the image to be detected, multiple sub-images are obtained by cropping the image to be detected without scaling it. The resolution of the sub-images is the same as that of the image to be detected. Flaw detection is performed on each sub-image to obtain the location of flaws in the sub-image. This transforms flaw detection in a large image into flaw detection in multiple sub-images, avoiding the problem of flaw pixel loss caused by shrinking the large image, and effectively improving the detection rate of small flaws. Then, the flaw location in the image to be detected is determined based on the flaw location in the sub-image and the position of the sub-image in the image to be detected. This achieves the unification of the flaw location in the coordinate system of the image to be detected, making it easier to identify the location of small flaws in the image to be detected. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.

[0018] Figure 1 This is a schematic diagram illustrating the implementation process of a defect detection method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the defect detection device provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0019] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0020] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0021] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0022] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0023] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrases "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0024] The defect detection method provided in this application is illustrated below.

[0025] Please see the appendix Figure 1 One embodiment of this application provides a defect detection method including: S101: Acquire the image to be detected.

[0026] The image to be inspected is an image of the product to be inspected (e.g., PCBs, films, glass, metal parts, etc., which are prone to minor defects). This image can be acquired from a camera or read from a pre-stored file. In one embodiment, the original image of the product to be inspected is first acquired by taking a picture. Then, feature detection is performed on the original image to determine the region where the product to be inspected is located; this region is the image to be inspected. For example, a Blob analysis method can be used to sequentially perform threshold segmentation, morphological processing, region filling, and selection of the largest region to extract the effective region corresponding to the product to be inspected from the original image. The image to be inspected is then obtained based on this effective region, avoiding computational waste caused by background interference.

[0027] In one embodiment, after determining the effective region in the original image, image noise can be reduced by preprocessing methods such as image enhancement and filtering (median filtering or Gaussian filtering), and image contrast can be improved by preprocessing methods such as grayscale transformation and histogram equalization. The image to be detected is obtained based on the preprocessed effective region, thereby improving the image quality of the image to be detected and thus improving the accuracy of defect detection.

[0028] In one embodiment, after acquiring the original image, image indicators such as sharpness, contrast, and noise of the original image can be determined first. If the image quality does not meet the preset quality requirements based on the image indicators, an instruction to reacquire the image is output, thereby avoiding the problem of abnormal detection results caused by image quality issues.

[0029] S102: Without scaling the image to be detected, crop the image to be detected to obtain multiple sub-images and the position information of each sub-image in the image to be detected, wherein the resolution of the sub-image is the same as the resolution of the image to be detected.

[0030] Specifically, a subgraph is a part of the image to be detected. The subgraph can be a regular shape or an irregular shape. The position information of the subgraph in the image to be detected can be the coordinates of one of the vertices of the subgraph or the center of the subgraph in the image to be detected, or the coordinates of the vertex or center of the smallest bounding rectangle of the subgraph in the image to be detected.

[0031] In one embodiment, the coordinate information of the effective region is pre-defined. The effective region refers to the area that needs to be detected for defects, i.e., the area where defects may occur. The coordinate information of the effective region can be the row and column coordinates of the boundary of the effective region. There are multiple effective regions in the image to be detected. By cropping the image to be detected based on the coordinate information of the effective region, multiple sub-images and the position information of each sub-image in the image to be detected can be obtained, thereby ensuring that the image resolution is not lost during the image cropping process. The Halcon algorithm (e.g., calling the ReduceDomain operator and the CropDomain operator in sequence) can be used to crop the image to be detected to obtain multiple sub-images. Cropping by using the pre-defined coordinate information of the effective region allows the cropping operation to focus on the core area of ​​the product to be detected (i.e., the area where defects may occur), avoiding meaningless background area cropping, reducing the number of invalid sub-images, and improving the efficiency of subsequent defect detection.

[0032] In one embodiment, before cropping the image to be inspected, a template image is acquired. The template image is a reference image containing standard product features. A matching operation is performed between the image to be inspected and the template image. For example, the Halcon operator is called to determine the feature regions (e.g., preset markers or reference points) in the image to be inspected. The feature regions in the image to be inspected and the feature regions in the template image are matched to determine the offset information of the image to be inspected relative to the template image. The offset information may include the offset amount and rotation angle of the center coordinates of the image to be inspected relative to the template image. After determining the offset information, based on the coordinate information of the target region (i.e., the region to be inspected) in the template image and the offset information, an affine transformation matrix is ​​calculated to perform an affine transformation on the target region of the template image to obtain the coordinate information of the effective region in the image to be inspected. This completes the dynamic positioning of the effective region, which can adapt to scenarios where the position of the product to be inspected is offset or rotated in the image to be inspected. This solves the problem of misalignment of the cropping area caused by the non-fixed position of the product to be inspected, ensuring that the cropping area is always accurately aligned with the part to be inspected on the product to be inspected, thus guaranteeing the stability and accuracy of the inspection.

[0033] In one embodiment, after obtaining the coordinate information of the effective region, a cropping region for extracting sub-images can be delineated based on the coordinate information of the effective region. Then, the cropping region is dilated to increase its area, resulting in updated coordinate information, i.e., the coordinate information of the dilated region. For example, the Halcon dilation operator can be used for dilation. The dilation parameters can be flexibly configured according to the common distribution location and size of product defects, and differentiated dilation coefficients can be set for different product inspection parts. After obtaining the updated coordinate information, the image to be inspected is cropped according to the updated coordinate information to obtain multiple sub-images, and the position information of each sub-image in the image to be inspected is recorded. By dilating the cropping region, the coverage area of ​​the cropping can be expanded, effectively avoiding the problem that small defects at the product edges cannot be detected due to being truncated by the cropping region boundary, further improving the detection rate of small defects.

[0034] In the above embodiments, by calling the Halcon operator for template matching and image cropping, the accuracy and stability of the cropping operation are ensured, and the position information of the sub-image output by the Halcon operator in the image to be detected can be used to subsequently align the defect position to the image to be detected, thereby improving the detection accuracy.

[0035] In one embodiment, after determining the cropping region based on the coordinate information of the effective region, the cropping region can be adjusted by methods such as region smoothing and shape correction, and then cropping or dilation can be performed to improve image quality.

[0036] In one embodiment, when cropping the image to be detected, multiple sub-images can be obtained through parallel processing to improve cropping efficiency.

[0037] In one embodiment, the effective region is divided into a fine-grained cropping region and a regular cropping region, with the area of ​​the fine-grained cropping region being smaller than that of the regular cropping region. The fine-grained cropping region is an area prone to defects, where a smaller cropping granularity is used to obtain a smaller sub-image. The regular cropping region is an area less prone to defects, where a larger cropping granularity is used or no cropping is performed to obtain a larger sub-image, thereby balancing detection accuracy and computational efficiency.

[0038] In another embodiment, the image to be detected can also be divided into multiple parts (e.g., 9 or 16 parts) to obtain multiple sub-images.

[0039] S103: Perform defect detection on each of the sub-images to obtain the location of defects in the sub-images.

[0040] After performing defect detection on each sub-image, the system can mark the defect location within the sub-image and output information such as the center coordinates, width, and height of the detection box. The defect location in the sub-image represents the local coordinates of the defect within the sub-image.

[0041] In one embodiment, the sub-image can be converted into a format compatible with the detection model and then input into the detection model to obtain the defect locations in the sub-image output by the detection model. Compared to the image to be detected, the sub-image has a higher resolution, thereby increasing the probability of detecting small defects. The detection model is a model pre-trained using machine learning methods to detect defect locations in an image. The detection model can be a model based on the YOLO algorithm (e.g., YOLOv8, YOLOv11, YOLOv12, etc.). Using the YOLO algorithm for defect detection can effectively detect small defects with diverse shapes and complex textures, solving the problems of insufficient ability to detect complex defects and poor adaptability to novel defects in traditional machine vision, thus improving the reliability of the detection results.

[0042] In one embodiment, the sub-image can be preprocessed by normalization, adaptive size adjustment, enlargement or channel enhancement before being input into the detection model to adapt to different computing power conditions and detection accuracy requirements.

[0043] In one embodiment, the detection model can output the defect location along with the defect category. For example, the defect category can be any one of scratches, stains, missing material, etc., thus making it applicable to various types of defect detection scenarios. In addition to outputting the defect location, the model can also output the confidence level of the detection result, allowing users to review defect detection results with low confidence levels.

[0044] In one embodiment, after determining the location of the defect, the size of the defect is identified, and the defect level is output based on the size of the defect. For example, if the defect size is smaller than a first preset value, the defect level is minor; if the defect size is larger than the first preset value but smaller than a second preset value, the defect level is moderate; and if the defect size is larger than the second preset value, the defect level is severe.

[0045] In one embodiment, a detection model fused from multiple YOLO models and a lightweight detection model can be pre-trained. The multi-YOLO model fusion detection model can be a model trained on different types of defects and then fused together, resulting in higher detection accuracy. The lightweight detection model is a computationally less demanding model with lower detection accuracy. The choice between the multi-YOLO model fusion detection model and the lightweight detection model can be made based on the user-defined detection accuracy and computing power, thus adapting to different detection scenarios.

[0046] In one embodiment, subgraphs with low confidence or user-labeled abnormal detection results can also be collected. The detection model can then be retrained based on these subgraphs to obtain an optimized detection model. This optimized model is then used for defect detection to improve the accuracy of the detection results.

[0047] S104: Determine the location of the defect in the image to be detected based on the location of the defect in the sub-image and the location information of the sub-image in the image to be detected.

[0048] Specifically, for each sub-image where a defect location is detected, the coordinates of the defect location in the sub-image are summed with the coordinates of the corresponding sub-image in the image to be detected (e.g., row and column coordinates) to obtain the defect location in the image to be detected. This maps the defect location from the sub-image coordinate system to the coordinate system of the image to be detected, achieving accurate restoration of the defect location in the image to be detected. If the defect location information in the sub-image includes a segmentation mask (a binarized image of the contour or region of the defect location obtained by defect detection in the sub-image), the region of the segmentation mask can be mapped to the corresponding region in the image to be detected based on the region of the segmentation mask in the sub-image and the position information of the sub-image in the image to be detected, completing the complete restoration of the defect location in the image to be detected.

[0049] In one embodiment, after obtaining the defect location in the image to be inspected, the defect location in the image to be inspected can be converted into the defect location in the product to be inspected based on the transformation relationship between the coordinate system of the image to be inspected and the world coordinate system of the product to be inspected. This allows for direct connection with the coordinate system of subsequent mechanical alignment, robot picking and placing, and other equipment, reducing coordinate transformation operations in subsequent processes and improving the overall linkage efficiency of the production line.

[0050] In one embodiment, after determining the location of defects in the image to be detected, multiple defect locations can be deduplicated, and the deduplicated defect locations can be output. For example, detection boxes can be marked at the deduplicated defect locations, and labels for defect categories can be added. A global non-maximum suppression algorithm can be used to determine the defect category and the intersection-union ratio (IUGR) between each defect location. For any two defect locations, if the IUGR is greater than a preset threshold and the defect categories are the same, the two defect locations are considered to overlap, and one of the defect locations is removed. This eliminates the problem of duplicate detection caused by overlapping adjacent cropping regions when cropping multiple sub-images, removes redundant defect detection results, and ensures the uniqueness and accuracy of the output defect locations.

[0051] The defect detection method provided in this application obtains sub-images by cropping the image to be detected, performs defect detection on each sub-image, and then unifies the defect locations of the sub-images to the image to be detected. This solves the technical problems in existing technologies, such as high false negative rates for small targets due to direct scaling of large images for detection, and the inability to unify coordinates of multi-region inference results. By combining the Halcon algorithm and the YOLO algorithm for image cropping and defect detection, it leverages the stability and interpretability advantages of traditional machine vision in industrial image preprocessing and cropping, while also utilizing the generalization ability advantages of deep learning in complex defect detection, thereby improving the accuracy of defect detection.

[0052] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0053] Corresponding to the defect detection method described in the above embodiments, Figure 2 A structural block diagram of the defect detection device provided in the embodiments of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.

[0054] like Figure 2 As shown, the defect detection device includes, Acquisition module 21 is used to acquire the image to be detected; The cropping module 22 is used to crop the image to be detected without scaling it, to obtain multiple sub-images and the position information of each sub-image in the image to be detected, wherein the resolution of the sub-images is the same as the resolution of the image to be detected. Detection module 23 is used to perform defect detection on each of the sub-images to obtain the location of defects in the sub-images; Output module 24 is used to determine the location of the defect in the image to be detected based on the location of the defect in the sub-image and the location information of the sub-image in the image to be detected.

[0055] In one embodiment, the trimming module 22 is specifically used for: The image to be detected is cropped according to the coordinate information of the preset effective area to obtain multiple sub-images and the position information of each sub-image in the image to be detected.

[0056] In one embodiment, the trimming module 22 is specifically used for: The clipping region is determined based on the coordinate information of the effective region; The cropped area is expanded to obtain updated coordinate information; The image to be detected is cropped based on the updated coordinate information to obtain multiple sub-images and the position information of each sub-image in the image to be detected.

[0057] In one embodiment, the cropping module 22 is further configured to: A matching operation is performed on the image to be detected and the template image to obtain the offset information of the image to be detected relative to the template image; Based on the coordinate information of the target region in the template image and the offset information, the coordinate information of the effective region in the image to be detected is determined.

[0058] In one embodiment, the output module 24 is further configured to: The multiple defect locations are deduplicated, and the deduplicated defect locations are output.

[0059] In one embodiment, the detection module 23 is specifically used for: For each of the sub-images, perform defect detection to obtain the location and type of defects in the sub-image.

[0060] In one embodiment, the acquisition module 21 is specifically used for: Obtain the original images of the product to be tested by taking photographs; Feature detection is performed on the original image to determine the image to be detected in the original image.

[0061] In one embodiment, the cropping module 22 is specifically used to: crop the image to be detected using the Halcon algorithm; and / or, the detection module 23 is specifically used to: perform defect detection on each of the sub-images using the YOLO algorithm to obtain the defect locations in the sub-images.

[0062] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0063] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may be a desktop computer, laptop, handheld computer, or cloud server, etc.

[0064] like Figure 3 As shown, the electronic device of this embodiment includes: a processor 31, a memory 32, and a computer program 33 stored in the memory 32 and executable on the processor 31. When the processor 31 executes the computer program 33, it implements the steps described in the alignment method embodiment above, for example... Figure 1The steps S101 to S105 are shown. Alternatively, when the processor 31 executes the computer program 33, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 2 The functions of the ranging module 21 to the output module 25 are shown.

[0065] For example, the computer program 33 may be divided into one or more modules / units, which are stored in the memory 32 and executed by the processor 31 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program 33 in the electronic device.

[0066] Those skilled in the art will understand that Figure 3 This is merely an example of an electronic device and does not constitute a limitation on the electronic device. It may include more or fewer components than illustrated, or combine certain components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.

[0067] The processor 31 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0068] The memory 32 can be an internal storage unit of the electronic device, such as a hard drive or memory. The memory 32 can also be an external storage device of the electronic device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 32 can include both internal and external storage units. The memory 32 is used to store the computer program and other programs and data required by the electronic device. The memory 32 can also be used to temporarily store data that has been output or will be output.

[0069] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0070] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0071] In the embodiments provided in this application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings or direct couplings or communication connections may be through some interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0072] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0073] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0074] If an integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.

[0075] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0076] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A defect detection method, characterized in that, include: Acquire the image to be detected; Without scaling the image to be detected, the image to be detected is cropped to obtain multiple sub-images and the position information of each sub-image in the image to be detected. The resolution of each sub-image is the same as the resolution of the image to be detected. Perform defect detection on each of the sub-images to obtain the location of defects in the sub-images; The location of the defect in the image to be detected is determined based on the location of the defect in the sub-image and the position information of the sub-image in the image to be detected.

2. The defect detection method according to claim 1, characterized in that, The image to be detected is cropped to obtain multiple sub-images and the position information of each sub-image in the image to be detected, including: The image to be detected is cropped according to the coordinate information of the preset effective area to obtain multiple sub-images and the position information of each sub-image in the image to be detected.

3. The defect detection method according to claim 2, characterized in that, The image to be detected is cropped according to the coordinate information of a preset effective region to obtain multiple sub-images and the position information of each sub-image in the image to be detected, including: The clipping region is determined based on the coordinate information of the effective region; The cropped area is expanded to obtain updated coordinate information; The image to be detected is cropped based on the updated coordinate information to obtain multiple sub-images and the position information of each sub-image in the image to be detected.

4. The defect detection method according to claim 2, characterized in that, Before cropping the image to be detected according to the coordinate information of the preset effective region to obtain multiple sub-images and the position information of each sub-image in the image to be detected, the method further includes: A matching operation is performed on the image to be detected and the template image to obtain the offset information of the image to be detected relative to the template image; Based on the coordinate information of the target region in the template image and the offset information, the coordinate information of the effective region in the image to be detected is determined.

5. The defect detection method according to claim 1, characterized in that, After determining the location of the defect in the image to be detected based on the defect location in the sub-image and the position information of the sub-image in the image to be detected, the method further includes: The multiple defect locations are deduplicated, and the deduplicated defect locations are output.

6. The defect detection method according to claim 1, characterized in that, For each of the sub-images, defect detection is performed to obtain the location of defects in the sub-image, including: For each of the sub-images, perform defect detection to obtain the location and type of defects in the sub-image.

7. The defect detection method according to claim 1, characterized in that, Acquire the image to be detected, including: Obtain the original images of the product to be tested by taking photographs; Feature detection is performed on the original image to determine the image to be detected in the original image.

8. The defect detection method according to claim 1, characterized in that, Cropping the image to be detected includes: cropping the image to be detected using the Halcon algorithm; and / or, Performing defect detection on each of the sub-images to obtain the defect locations in the sub-images includes: using the YOLO algorithm to perform defect detection on each of the sub-images to obtain the defect locations in the sub-images.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the defect detection method as described in any one of claims 1 to 8.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the defect detection method as described in any one of claims 1 to 8.