Defect detection method and device, storage medium, and program product

By calculating the gray gradient amplitude and brightness correction images and merging them into three-channel images, the problem of identifying low and high gray areas in welding defect detection is solved, and the accuracy and reliability of defect detection are improved.

CN114596290BActive Publication Date: 2024-08-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210242790.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-11
Publication Date
2024-08-27
Estimated Expiration
2042-03-11

AI Technical Summary

Technical Problem

In the detection of welding defects in the existing technology, it is difficult to accurately identify defects in low gray value areas and high gray value areas, resulting in missed detection problems.

Method used

By calculating the gray gradient amplitude image and brightness correction image of the image, merge them into a three-channel image, perform defect detection processing, reduce the gray value difference and balance the brightness difference, thereby improving the accuracy of defect identification.

Benefits of technology

It improves the identification accuracy of welding defects, reduces the probability of missed detection, and enhances the ability to detect welding defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114596290B
    Figure CN114596290B
Patent Text Reader

Abstract

The present application discloses a defect detection method and its device, storage medium, and program product. After acquiring an image to be processed, a grayscale gradient amplitude image and a brightness correction image are calculated based on the image to be processed, and then the image to be processed, the grayscale gradient amplitude image, and the brightness correction image are combined into a three-channel image, and then the three-channel image is subjected to defect detection processing to obtain a first defect image. The present application can improve the recognition accuracy of defects, thereby reducing the probability of missed detection. The present application can be widely used in image processing technologies of devices such as smart phones, tablet computers, laptops, desktop computers, servers, and vehicle-mounted terminals.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a defect detection method and its device, storage medium, and program product. Background Art

[0002] As a basic process method, welding is widely used in the fields of electricity, gas, petroleum, shipbuilding and general mechanical equipment production. However, due to various factors, defects such as pores or cracks may appear during the welding process, which not only affects the quality and reliability of the product, but may even bring catastrophic consequences. Therefore, it is essential to detect welding defects.

[0003] In the related art, a solution is proposed for automatically identifying welding defects in weld images based on an artificial intelligence algorithm. However, when welding defects exist in both low grayscale value areas and high grayscale value areas in the weld image, the solution in the related art cannot accurately identify the welding defects, resulting in missed detection problems. Summary of the invention

[0004] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.

[0005] The embodiments of the present application provide a defect detection method and device, a storage medium, and a program product, which can improve the accuracy of defect recognition and thus reduce the probability of missed detection.

[0006] On the one hand, an embodiment of the present application provides a defect detection method, comprising the following steps:

[0007] Get the image to be processed;

[0008] Obtaining a grayscale gradient amplitude image of the image to be processed by calculation according to the image to be processed;

[0009] Obtaining a brightness-corrected image of the image to be processed by calculation according to the image to be processed;

[0010] Merging the image to be processed, the grayscale gradient amplitude image and the brightness correction image into a three-channel image;

[0011] Perform defect detection processing on the three-channel image to obtain a first defect image.

[0012] On the other hand, an embodiment of the present application further provides a defect detection device, including:

[0013] A first acquisition unit, used for acquiring an image to be processed;

[0014] A second acquisition unit, configured to calculate a grayscale gradient amplitude image of the image to be processed according to the image to be processed;

[0015] A third acquisition unit, configured to calculate a brightness-corrected image of the image to be processed according to the image to be processed;

[0016] An image merging unit, used for merging the image to be processed, the grayscale gradient amplitude image and the brightness correction image into a three-channel image;

[0017] The defect detection unit is used to perform defect detection processing on the three-channel image to obtain a first defect image.

[0018] Optionally, there are multiple images to be processed, and the first acquisition unit includes:

[0019] A fourth acquisition unit, used to acquire a target image;

[0020] An image enhancement unit, used for performing image enhancement processing on the target image to obtain an enhanced image;

[0021] The multi-scale conversion unit is used to perform multi-scale conversion processing on the target image and the enhanced image respectively to obtain a plurality of images to be processed.

[0022] Optionally, the number of the image to be processed, the grayscale gradient amplitude image, the brightness correction image and the three-channel image is multiple, and there is a one-to-one correspondence between the image to be processed, the grayscale gradient amplitude image, the brightness correction image and the three-channel image; the defect detection unit includes:

[0023] An image detection unit, used to perform defect detection processing on the plurality of three-channel images to obtain a plurality of defect-labeled images;

[0024] A scale mapping unit, used for mapping the plurality of defect annotated images to the same scale to obtain a plurality of candidate defect images;

[0025] The suppression merging unit is used to perform non-maximum suppression merging processing on the multiple candidate defect images to obtain the first defect image.

[0026] Optionally, the fourth acquiring unit includes:

[0027] A fifth acquisition unit, configured to acquire a first weld image, wherein the first weld image contains a weld area;

[0028] A weld recognition unit, configured to perform weld recognition processing on the first weld image to obtain a weld mask image corresponding to the weld area;

[0029] An image capture unit is used to perform a screenshot process on the weld area in the first weld image according to the weld mask image to obtain the target image.

[0030] Optionally, the first defect image is marked with a defect position; and the defect detection device further includes:

[0031] a defect determination unit, configured to determine a target defect area in the first defect image according to the weld mask image;

[0032] An image deletion unit is used to delete a target defect position in the first defect image to obtain a second defect image, wherein the target defect position is a defect position in the first defect image that is outside the target defect area.

[0033] Optionally, there are multiple first weld images, and the fifth acquisition unit includes:

[0034] An image receiving unit, used for receiving a second weld image;

[0035] A first size acquisition unit, used to acquire first length information of the second weld image;

[0036] The image segmentation unit is used to segment the second weld image to obtain a plurality of the first weld images when the first length information is greater than a first preset length threshold.

[0037] Optionally, the image segmentation unit includes:

[0038] A parameter acquisition unit, used to acquire a segmentation length threshold, a segmentation width threshold, an overlap ratio value, and first width information of the second weld image;

[0039] a coordinate calculation unit, configured to calculate segmentation coordinate information according to the segmentation length threshold, the segmentation width threshold, the overlap ratio value, the first length information, and the first width information;

[0040] The image segmentation subunit is used to segment the second weld image according to the segmentation coordinate information to obtain a plurality of the first weld images.

[0041] Optionally, the defect detection device further includes:

[0042] A coordinate acquisition unit, used to acquire target coordinate information of a defect position in the second defect image;

[0043] An information mapping unit is used to map the target coordinate information to the second weld image to obtain a target defect image.

[0044] Optionally, the image capture unit includes:

[0045] A first frame acquisition unit, used to acquire a first boundary frame of the weld mask image;

[0046] A first coordinate determining unit, configured to determine first mask coordinate information of the weld mask image according to the first boundary box;

[0047] The first interception unit is used to perform a screenshot process on the weld area in the first weld image according to the first mask coordinate information to obtain the target image.

[0048] Optionally, the image capture subunit includes:

[0049] A first size calculation unit, used for calculating the second length information and the second width information of the weld mask image according to the first mask coordinate information;

[0050] a rotation processing unit, configured to, when the second length information is greater than the second width information, perform rotation processing on the weld mask image to obtain a rotated mask image, and perform the rotation processing on the first weld image to obtain a rotated weld image;

[0051] A second frame acquisition unit, used to acquire a second boundary frame of the rotating mask image;

[0052] A second coordinate determining unit, configured to determine second mask coordinate information of the rotated mask image according to the second bounding box;

[0053] The second interception unit is used to perform a screenshot process on the weld area in the rotation weld image according to the second mask coordinate information to obtain the target image.

[0054] Optionally, the second intercepting unit includes:

[0055] A second size calculation unit, configured to calculate and obtain third length information of the rotating mask image according to the second mask coordinate information;

[0056] a segmentation processing unit, configured to segment the rotating mask image and the rotating weld seam image according to a second preset length threshold when the third length information is greater than a second preset length threshold, to obtain a plurality of segmented rotating mask images and a plurality of segmented rotating weld seam images;

[0057] A third frame acquisition unit, used to acquire a third boundary frame of the segmented rotating mask image;

[0058] a third coordinate determining unit, configured to determine third mask coordinate information of the segmented rotating mask image according to the third bounding box;

[0059] The third interception unit is used to perform a screenshot process on the weld area in the segmented rotation weld image according to the third mask coordinate information to obtain the target image.

[0060] On the other hand, an embodiment of the present application further provides a defect detection device, including:

[0061] at least one processor;

[0062] at least one memory for storing at least one program;

[0063] When at least one of the programs is executed by at least one of the processors, the defect detection method as described above is implemented.

[0064] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, which stores a program executable by a processor, and the program executable by the processor is used to implement the defect detection method as described above when executed by the processor.

[0065] On the other hand, an embodiment of the present application also provides a computer program product, including a computer program or computer instructions, wherein the computer program or the computer instructions are stored in a computer-readable storage medium, a processor of a computer device reads the computer program or the computer instructions from the computer-readable storage medium, and the processor executes the computer program or the computer instructions, so that the computer device performs the defect detection method as described above.

[0066] The embodiments of the present application include at least the following beneficial effects: after acquiring the image to be processed, a grayscale gradient amplitude image and a brightness correction image are calculated based on the acquired image to be processed, and then the image to be processed, the grayscale gradient amplitude image and the brightness correction image are merged into a three-channel image, and then the three-channel image is subjected to defect detection processing to obtain a first defect image. Since the grayscale gradient amplitude image can map defects in low grayscale value areas and defects in high grayscale value areas to the same grayscale range, thereby reducing the grayscale value difference between defects, and the brightness correction image can balance the brightness difference between low grayscale value areas and high grayscale value areas, thereby improving the probability of defect detection, therefore, performing defect detection processing on the three-channel image merged by the image to be processed, the grayscale gradient amplitude image and the brightness correction image can improve the recognition accuracy of defects, thereby reducing the probability of missed detection.

[0067] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.

[0069] Figure 1 It is a schematic diagram of an implementation environment provided by an embodiment of the present application;

[0070] Figure 2 is a flow chart of a defect detection method provided by an embodiment of the present application;

[0071] Figure 3 This is a schematic diagram of the correspondence between grayscale intensity values ​​and grayscale gradient values ​​provided by an embodiment of the present application;

[0072] Figure 4 yes Figure 2 A specific method flow chart of step 110;

[0073] Figure 5a is a schematic diagram of an original target image provided by an embodiment of the present application;

[0074] Figure 5b is a schematic diagram of an enhanced image after image enhancement processing provided by an embodiment of the present application;

[0075] Figure 6 yes Figure 2 A specific method flow chart of step 150;

[0076] Figure 7 is a schematic diagram of performing defect detection processing on multiple three-channel images provided by an embodiment of the present application;

[0077] Figure 8 It is a schematic diagram of mapping multiple defect annotation images to the same scale and performing non-maximum suppression merging processing on multiple candidate defect images provided by an embodiment of the present application;

[0078] Fig. 9 yes Figure 4 A specific method flow chart of step 141;

[0079] Fig.10 is a schematic diagram of performing screenshot processing on a weld area in a first weld image provided by an embodiment of the present application;

[0080] Fig.11 is a flow chart of a defect detection method provided by another embodiment of the present application;

[0081] Fig.12ais a schematic diagram of a first defect image provided by an embodiment of the present application;

[0082] Figure 12b is a schematic diagram of a weld mask image provided by an embodiment of the present application;

[0083] Fig.12c is a schematic diagram of a second defect image provided by an embodiment of the present application;

[0084] Fig.13 yes Fig. 9 A specific method flow chart of step 1411;

[0085] Fig.14 is a schematic diagram of segmenting a second weld image and performing weld recognition processing provided by an embodiment of the present application;

[0086] Fig.15 is a schematic diagram of mapping target coordinate information to a second weld image provided by an embodiment of the present application;

[0087] Fig.16 yes Fig. 9 A specific method flow chart of step 1413;

[0088] Fig.17 yes Fig.16 A specific method flow chart of step 14133;

[0089] Fig.18 It is a processing flow chart of defect detection of weld images by a server provided in a specific example of the present application;

[0090] Fig.19 yes Fig.18 A specific method flow chart of step 203;

[0091] Fig. 20 yes Fig.18 A specific method flow chart of step 207;

[0092] Fig.21 is a schematic diagram of a defect detection device provided by an embodiment of the present application;

[0093] Fig. 22 It is a schematic diagram of a defect detection device provided in another embodiment of the present application. DETAILED DESCRIPTION

[0094] The present application is further described below in conjunction with the accompanying drawings and specific embodiments. The described embodiments should not be regarded as limiting the present application, and all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.

[0095] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0096] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0097] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0098] 1) Grayscale gradient amplitude image refers to an image composed of the grayscale gradient amplitude of an image. The grayscale gradient amplitude of an image refers to the change value between a certain pixel of the grayscale image and its adjacent pixels in the X-axis direction and the Y-axis direction. It is a two-dimensional vector, including two components: the X-axis change value and the Y-axis change value. One calculation method is: the X-axis change value is the pixel value on the right side of the current pixel minus the pixel value on the left side of the current pixel; the Y-axis change value is the pixel value below the current pixel minus the pixel value above the current pixel.

[0099] 2) Non-Maximum Suppression (NMS), which can be used to suppress all values ​​except local maxima, which can indicate the locations with the strongest intensity value changes.

[0100] 3) Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. Basic artificial intelligence technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0101] 4) Computer Vision (CV): It is a science that studies how to make machines "see". To be more specific, it refers to machine vision such as using cameras and computers to replace human eyes to identify and measure targets, and further perform graphic processing so that the computer processing becomes an image that is more suitable for human eye observation or transmission to instrument detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.

[0102] 5) Machine Learning (ML): A multi-disciplinary interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning and other technologies.

[0103] 6) Deep Learning (DL): Deep learning is a new research direction in the field of machine learning. It is used to learn the inherent laws and representation levels of sample data. The information obtained in the learning process is very helpful for interpreting data such as text, images and sounds. Its ultimate goal is to enable machines to have analytical learning capabilities like humans and to recognize data such as text, images and sounds.

[0104] 7) Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer and application service layer. The underlying blockchain platform can include processing modules such as user management, basic services and smart contracts. Among them, the user management module is responsible for the identity information management of all blockchain participants, including maintaining the generation of public and private keys (account management), key management, and the maintenance of the corresponding relationship between the user's real identity and the blockchain address (authority management), etc., and under authorization, supervise and audit the transactions of certain real identities and provide risk control rule configuration (risk control audit); the basic service module is deployed on all blockchain node devices to verify the validity of business requests, and record the valid requests to the storage after consensus is completed. For a new business request, the basic service first adapts the interface to parse and authenticate (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus management), and transmits it to the shared account book completely and consistently after encryption (network communication), and records and stores it; the smart contract module is responsible for the registration and issuance of contracts, contract triggering and contract execution. Developers can define the contract logic in a certain programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, call the key or other events to trigger the execution to complete the contract logic, and also provide the function of contract upgrade and cancellation. The platform product service layer provides the basic capabilities and implementation framework of typical applications. Developers can complete the blockchain implementation of business logic based on these basic capabilities and superimpose the characteristics of the business. The application service layer provides application services based on blockchain solutions for business participants to use.

[0105] As a basic process, welding is widely used in the fields of electricity, gas, petroleum, shipbuilding and general mechanical equipment production. The quality of welding technology directly affects the quality and safety performance of products. For example, in the welding of oil and gas pipelines, if there are welding defects such as pores or cracks at the welding position, it may bring disastrous consequences. Therefore, it is essential to detect welding defects.

[0106] X-rays have strong penetrating power and can be used to see through the defects inside the material. They are often used in the field of non-destructive testing. The traditional detection method is for the film reviewer to confirm the defects of the X-ray weld film, but this method has a huge workload, and the imaging quality of the X-ray weld film is uneven, which is easy to lead to missed detection. In order to solve this problem, the relevant technology proposes a solution based on artificial intelligence algorithm to realize automatic identification of welding defects in weld images. Specifically, computer vision technology is used to scan the X-ray weld film into a digital image by using a digital scanning device, and then the digitized image is located and identified by a computer to achieve film rating and risk assessment of the welding part. However, when the X-ray weld film is scanned into a digital image by a digital scanning device, the contrast and brightness of some images are low due to the influence of the imaging device and the data acquisition personnel, resulting in poor imaging quality. At this time, if there are welding defects in both the low gray value area and the high gray value area in the image, such a solution cannot accurately identify the welding defects, resulting in missed detection.

[0107] In order to improve the recognition accuracy of defects, the embodiments of the present application provide a defect detection method, a defect detection device, a computer-readable storage medium, and a computer program product. After acquiring the image to be processed, a grayscale gradient amplitude image and a brightness correction image are calculated based on the acquired image to be processed, and then the image to be processed, the grayscale gradient amplitude image, and the brightness correction image are merged into a three-channel image, and then the three-channel image is processed for defect detection to obtain a first defect image. Since the grayscale gradient amplitude image can map defects in low grayscale value areas and defects in high grayscale value areas to the same grayscale range, thereby reducing the grayscale value difference between defects, and the brightness correction image can balance the brightness difference between low grayscale value areas and high grayscale value areas, thereby improving the probability of defect detection, therefore, the three-channel image merged by the image to be processed, the grayscale gradient amplitude image, and the brightness correction image is processed for defect detection, which can improve the recognition accuracy of defects and reduce the probability of missed detection.

[0108] Figure 1 Schematic diagram of an implementation environment provided by an embodiment of the present application. Figure 1 The implementation environment includes a terminal 101 and a server 102, and the terminal 101 and the server 102 are directly or indirectly connected through wired or wireless communication. The terminal 101 and the server 102 can be nodes in the blockchain, and this embodiment does not specifically limit this.

[0109] The terminal 101 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a vehicle-mounted terminal, etc., but is not limited thereto. Optionally, the terminal 101 may be installed with an application, and the terminal 101 may use the application to perform weld defect detection on the image to be processed, or the image to be processed may be uploaded to the server 102 through the application, so that the server 102 may perform weld defect detection on the image to be processed.

[0110] The terminal 101 has at least functions such as obtaining an image to be processed and displaying weld defect detection results. For example, after obtaining the image to be processed, the terminal 101 can perform weld defect detection on the image to be processed to obtain a weld defect detection result, and then display the weld defect detection result. For another example, after obtaining the image to be processed, the terminal 101 can upload the image to be processed to the server 102, so that the server 102 performs weld defect detection on the image to be processed to obtain a weld defect detection result, and then receives the weld defect detection result sent by the server 102, and then displays the weld defect detection result.

[0111] Server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network) and big data and artificial intelligence platforms.

[0112] The server 102 has at least functions such as acquiring the image to be processed and performing weld defect detection on the image to be processed. For example, after receiving the image to be processed sent by the terminal 101, it can perform weld defect detection on the image to be processed to obtain a weld defect detection result, and then send the weld defect detection result to the terminal 101, so that the terminal 101 displays the weld defect detection result.

[0113] It should be noted that the above functions of the terminal 101 and the server 102 can be applied to different application scenarios, for example:

[0114] In an application scenario, the terminal 101 is a detection instrument for detecting weld defects of oil and gas pipelines, etc. The terminal 101 is equipped with a camera for shooting images, an application for performing weld defect detection on images, and a display screen for displaying defect detection results. In response to the user triggering the camera to shoot images of the welding position of the oil and gas pipeline through the application, the terminal 101 obtains the image to be processed, and sends the image to be processed to the server 102 through the application; in response to obtaining the image to be processed, the server 102 calculates the grayscale gradient amplitude image and the brightness correction image of the image to be processed according to the image to be processed, and then merges the image to be processed, the grayscale gradient amplitude image and the brightness correction image into a three-channel image, and then performs defect detection processing on the three-channel image to obtain a first defect image, and then sends the first defect image to the terminal 101; in response to receiving the first defect image, the terminal 101 displays the first defect image to the user through the display screen.

[0115] In another application scenario, the terminal 101 is a desktop computer, and the terminal 101 is installed with an application for processing images, and the application integrates a trained weld defect detection model downloaded from the server 102. In response to the user inputting the image to be processed into the terminal 101, the terminal 101 calls the application to calculate the gray gradient amplitude image and the brightness correction image of the image to be processed, and then merges the image to be processed, the gray gradient amplitude image and the brightness correction image into a three-channel image, and then inputs the three-channel image into the trained weld defect detection model to obtain a first defect image; in response to obtaining the first defect image, the terminal 101 displays the first defect image to the user.

[0116] Figure 2 1 is a flow chart of a defect detection method provided in an embodiment of the present application. In this embodiment, a server is used as an example for explanation. Figure 2 , the defect detection method includes but is not limited to steps 110 to 150.

[0117] Step 110: Obtain an image to be processed.

[0118] It should be noted that the image to be processed may be an image obtained by photographing, an image input by a user, or an image obtained from a database, etc., and is not specifically limited here.

[0119] It should be noted that the image to be processed may be an original image, a local image obtained by segmenting the original image, an image preprocessed by graying the original image, etc., and is not specifically limited here.

[0120] It should be noted that the image to be processed can be an image of a product to be inspected for defects on the surface, for example, an image of the weld position of an oil and gas pipeline, an image of the weld position of a metal sheet, or a surface image of other metal parts, etc., and no specific limitation is given here.

[0121] Step 120: Calculate the grayscale gradient amplitude image of the image to be processed according to the image to be processed.

[0122] In this step, since the image to be processed is acquired in step 110, the grayscale gradient amplitude image of the image to be processed can be calculated based on the image to be processed, wherein the grayscale gradient amplitude image can map defects in low grayscale value areas and defects in high grayscale value areas to the same grayscale range, thereby reducing the grayscale value difference between the defects. Therefore, when defects exist in both low grayscale value areas and high grayscale value areas, the grayscale gradient amplitude image can help improve the recognition accuracy of the defects, thereby reducing the probability of missed detection.

[0123] It should be noted that there are different implementation methods for calculating the grayscale gradient amplitude image of the image to be processed based on the image to be processed, and it can be appropriately selected according to the actual application situation. For example, the grayscale gradient amplitude image of the image to be processed can be calculated using the Sobel operator, or the grayscale gradient amplitude image of the image to be processed can be calculated using the Scharr operator, or the grayscale gradient amplitude image of the image to be processed can be calculated using the Laplacian operator. Among them, the Sobel operator is used to obtain the first-order derivative or the second-order derivative, which is a combination of Gaussian smoothing and differential operation, and has good noise resistance. The Scharr operator is a partial optimization of the Sobel operator, and is also used to obtain the first-order derivative or the second-order derivative. When the convolution kernel size is -1, the effect of using the Scharr operator to calculate the grayscale gradient amplitude image will be better than the effect of using the Sobel operator to calculate the grayscale gradient amplitude image; the Laplacian operator is used to obtain the second-order derivative. When calculating the Laplacian operator, the Sobel operator can be called to calculate the second-order derivative of the Sobel operator.

[0124] The following example illustrates the role of grayscale gradient amplitude image. Figure 3 , Figure 3 It is a schematic diagram of the corresponding relationship between the grayscale intensity value and the grayscale gradient value of the image to be processed. Figure 3 The upper curve graph is the gray intensity curve graph of the image to be processed, where the horizontal axis is the pixel index and the vertical axis is the gray intensity value; Figure 3The following curve graph is the grayscale gradient curve graph of the image to be processed, where the horizontal axis is the pixel index and the vertical axis is the grayscale gradient value. According to the grayscale intensity curve graph, when the pixel index is 100 and 350, the grayscale intensity curve has a "spike", indicating that there are defects at these two positions, where the defect corresponding to the pixel index of 100 belongs to the defect in the low grayscale value area, and the defect corresponding to the pixel index of 350 belongs to the defect in the high grayscale value area. Since these two defects are in different grayscale ranges, there is a large grayscale value difference, which increases the difficulty of identifying these two defects. In order to reduce the difficulty of identifying these two defects, the grayscale gradient curve can be calculated based on the grayscale intensity curve. According to the grayscale gradient curve, when the pixel index is 100 and 350, the corresponding grayscale gradient value is at the same level, that is, the defect in the low grayscale value area and the defect in the high grayscale value area can be mapped to the same grayscale range, reducing the grayscale value difference between the two defects, thereby reducing the difficulty of identifying the two defects and improving the probability of defect detection. Therefore, the grayscale gradient amplitude image calculated according to the image to be processed can map the defects in the low grayscale value area and the defects in the high grayscale value area to the same grayscale range, thereby reducing the grayscale value difference between the defects and achieving the purpose of increasing the probability of defect detection.

[0125] It should be noted that when the image to be processed is a single-channel grayscale image, the grayscale gradient amplitude image of the image to be processed can be directly calculated based on the image to be processed; when the image to be processed is not a single-channel grayscale image, the image to be processed can be first preprocessed by graying, etc., and the image to be processed can be converted into a single-channel grayscale image, and then the grayscale gradient amplitude image of the image to be processed can be calculated based on the image to be processed.

[0126] Step 130: Calculate and obtain a brightness-corrected image of the image to be processed according to the image to be processed.

[0127] It should be noted that, after research and analysis, there may be subtle defects that are difficult to distinguish in the image to be processed. In order to reduce the probability of missed detection of such subtle defects, the brightness of the low grayscale area can be increased and the brightness of the high grayscale area can be compressed to make such subtle defects easy to detect. Therefore, in this step, the brightness correction image of the image to be processed can be calculated based on the image to be processed, wherein the brightness correction image can balance the brightness difference between the low grayscale value area and the high grayscale value area, thereby improving the probability of defect detection. Therefore, when there are subtle defects that are difficult to distinguish in the image to be processed, the brightness correction image can help improve the detection probability of subtle defects, thereby reducing the probability of missed detection.

[0128] It should be noted that the brightness correction image of the image to be processed can be calculated by the following formula (1):

[0129] I γ =I γ ,(0<γ<1) (1)

[0130] In formula (1), I is the image to be processed, γ is the brightness correction index, and I γ Correct the image for brightness.

[0131] In some embodiments, the brightness correction index may be a gamma correction index. By correcting the image to be processed using the gamma correction index, the brightness of pixels in the image to be processed can be adjusted to increase the brightness of low grayscale areas and compress the brightness of high grayscale areas, thereby improving the ability to detect subtle defects in the image to be processed.

[0132] Step 140: Merge the image to be processed, the grayscale gradient amplitude image and the brightness correction image into a three-channel image.

[0133] In this step, since the grayscale gradient amplitude image of the image to be processed is obtained in step 120 and the brightness correction image of the image to be processed is obtained in step 130, the image to be processed, the grayscale gradient amplitude image and the brightness correction image can be merged into a three-channel image, so that the image to be processed, the grayscale gradient amplitude image and the brightness correction image form a whole. In this way, the three-channel image contains both the original information of the image to be processed and the image information after enhanced processing, which is beneficial to the defect detection processing performed in the subsequent steps, so that the detection result has higher accuracy and lower missed detection rate.

[0134] It should be noted that merging the image to be processed, the grayscale gradient amplitude image and the brightness correction image into a three-channel image can include the following steps: for a pixel point P in the three-channel image to be processed, obtaining the corresponding pixel value P1 from the image to be processed, obtaining the corresponding pixel value P2 from the grayscale gradient amplitude image, and obtaining the corresponding pixel value P3 from the brightness correction image, and then combining the pixel value P1, the pixel value P2 and the pixel value P3 to represent the pixel value of the pixel point P in the three-channel image, that is, the pixel value of the pixel point P in the three-channel image is (P1, P2, P3), and thus completing the processing of each pixel point in the image to be processed, and finally obtaining a three-channel image.

[0135] Step 150: Perform defect detection processing on the three-channel image to obtain a first defect image.

[0136] In this step, since the image to be processed, the grayscale gradient amplitude image and the brightness correction image are merged into a three-channel image in step 140, the three-channel image contains both the original information of the image to be processed and the image information after enhancement processing. Therefore, the three-channel image can be processed for defect detection to obtain a first defect image, so that the first defect image has a higher defect recognition accuracy and a lower defect missed detection rate.

[0137] It should be noted that a pre-trained defect detection model can be used to perform defect detection processing on the three-channel image to obtain a first defect image, wherein the defect detection model can be a Faster-RCNN model, a YOLO (You Only LookOnce) model, or a CascadeRCNN model, etc., which can be appropriately selected according to the actual application situation and is not specifically limited here.

[0138] The Faster-RCNN model uses convolutional neural networks (CNN) to generate reference frames by itself and shares the CNN with the target detection network, which greatly reduces the number of reference frames and improves detection efficiency and accuracy.

[0139] The YOLO model applies a single CNN to the entire image, divides the entire image into multiple grids, and predicts the category probability and the size of the target detection box corresponding to each grid. The YOLO model can predict the probability of an object existing in the target detection box. If the probability is greater than or equal to the preset probability threshold, it can be considered that the corresponding object is recognized. If the probability is less than the preset probability threshold, it can be considered that the corresponding object is not recognized.

[0140] The CascadeRCNN model can cascade multiple RCNN networks (Region Convolutional Neural Networks) based on different IoU thresholds, thereby continuously optimizing the detection results. The output of the previous RCNN network can be used as the input of the next RCNN network, and the IoU thresholds of positive and negative samples defined by the later RCNN networks are constantly increasing.

[0141] It should be noted that in order to improve the detection accuracy of the defect detection model, appropriate model parameters can be set for the defect detection model. Different types of models will have different model parameters, which can be appropriately set according to the actual application situation and are not specifically limited here.

[0142] The following uses the CascadeRCNN model as an example to illustrate the defect detection model:

[0143] Assuming that the CascadeRCNN model is used to process the defect detection of the three-channel image, in order to improve the accuracy of detection and reduce the probability of missed detection, HRNet32 (i.e., 32-layer HRNet) can be used as the backbone network of the CascadeRCNN model, and the bounding box regression loss function uses the smooth-l1 loss function, and the reference box (Anchor) is set to include 0.03125, 0.0625, 0.125, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0 and other sizes to cover defects with different aspect ratios, such as narrow cracks, incomplete penetration and other defects. In addition, when training the CascadeRCNN model, for defect categories with a small sample proportion but high importance, the Copypaste algorithm can be used to amplify the sample data. Specifically, the defects are cut out and randomly pasted into the weld area, which can not only increase the number of samples, but also improve the recall rate for such defects.

[0144] It should be noted that HRNet (High-Resolution Net) can generate features of multiple resolutions. In the process of network advancement, it will not only maintain a large feature map, but also perform some downsampling processing in parallel to reduce the feature map. In this way, it will iterate and finally generate multiple sets of feature maps with different resolutions, and then fuse these feature maps and perform segmentation map prediction processing.

[0145] In this embodiment, through the defect detection method including the above steps 110 to 150, after obtaining the image to be processed, the grayscale gradient amplitude image and the brightness correction image are calculated according to the image to be processed, and then the image to be processed, the grayscale gradient amplitude image and the brightness correction image are merged into a three-channel image, and then the three-channel image is subjected to defect detection processing to obtain a first defect image. Since the grayscale gradient amplitude image can map defects in low grayscale value areas and defects in high grayscale value areas to the same grayscale range, thereby reducing the grayscale value difference between defects, and the brightness correction image can balance the brightness difference between low grayscale value areas and high grayscale value areas, thereby improving the probability of defect detection, therefore, the defect detection processing of the three-channel image merged by the image to be processed, the grayscale gradient amplitude image and the brightness correction image can improve the recognition accuracy of defects, thereby reducing the probability of missed detection.

[0146] Reference Figure 4 As shown, an embodiment of the present application further illustrates step 110. When there are multiple images to be processed, step 110 may include but is not limited to steps 111 to 113.

[0147] Step 141: Acquire a target image.

[0148] It should be noted that the target image may be an image obtained by photographing, an image input by a user, or an image obtained from a database, etc., and is not specifically limited here.

[0149] It should be noted that the target image may be an original image, a local image obtained by segmenting the original image, an image obtained by preprocessing the original image such as grayscale conversion, etc., and is not specifically limited here.

[0150] It should be noted that the target image can be an image of a product to be inspected for defects on the surface, for example, an image of the weld position of an oil and gas pipeline, an image of the weld position of a metal sheet, or a surface image of other metal parts, etc., and no specific limitation is given here.

[0151] Step 142: Perform image enhancement processing on the target image to obtain an enhanced image.

[0152] It should be noted that the target image may have problems such as low contrast, low brightness or blurred edge contours, which may easily lead to inaccurate subsequent defect detection results. In order to solve this problem, the target image can be first enhanced to obtain an enhanced image, and then subsequent defect detection processing can be performed based on the enhanced image to improve the accuracy of the defect detection results.

[0153] It should be noted that different image enhancement processing can be performed according to different problems existing in the target image. For example, the contrast of the target image can be improved, the brightness of the target image can be improved, or the target image can be sharpened, etc. Appropriate selection can be made according to the actual application situation, and no specific limitation is made here.

[0154] Let's take an example to illustrate. Assuming that the target image has a low contrast problem, in order to improve the contrast of the target image, a contrast adaptive equalization algorithm can be used to perform image enhancement processing on the target image. For example, the cv2.createCLAHE function in OpenCV can be called to adjust the contrast of the target image. Among them, OpenCV is an open source, cross-platform computer vision and machine learning software library, which provides a variety of general algorithms for image processing and computer vision. The cv2.createCLAHE function can be used to generate an adaptively equalized image, which includes two parameters: clip_limits and tile_sizes. Clip_limits represents the contrast threshold, and tile_sizes represents the grid size of pixel equalization. These two parameters can be appropriately selected according to the actual application. For example, in some feasible implementations, the parameters of the cv2.createCLAHE function can be set to clip_limits=2, tile_sizes=8. Figure 5a and Figure 5b As shown, Figure 5a is the original target image, Figure 5b is the enhanced image after image enhancement processing, according to Figure 5a and Figure 5b It can be seen that the details in the enhanced image are more obvious than those in the target image. Therefore, performing defect detection processing based on the enhanced image in the subsequent steps can improve the accuracy of the defect detection results.

[0155] Step 143: Perform multi-scale conversion processing on the target image and the enhanced image respectively to obtain a plurality of images to be processed.

[0156] It should be noted that, although the target image is enhanced in step 142 to obtain an enhanced image, the scale of the image is fixed, and some defects may not be detected due to being relatively small. In order to solve this problem, in this step, the target image and the enhanced image can be respectively subjected to multi-scale conversion processing to obtain multiple images to be processed, so that relatively small defects can increase with the increase of the image scale, thereby improving the detection accuracy of the defect detection processing in the subsequent steps. In addition, if the subsequent steps use a defect detection model to implement defect detection processing, then, when the target image and the enhanced image are respectively subjected to multi-scale conversion processing to obtain multiple images to be processed, these images to be processed can involve multiple scales, thereby improving the defect detection capability of the defect detection model for images of different scales, and further improving the scope of application of the defect detection model.

[0157] It should be noted that when performing multi-scale conversion processing on the target image and the enhanced image respectively, different scale parameters can be set according to the actual application situation. For example, in some feasible implementations, three different scale parameters can be set in the multi-scale conversion processing, for example, the pixel sizes can be set to 600×600, 450×450 and 300×300.

[0158] Reference Figure 6 As shown, an embodiment of the present application further illustrates step 150. When there are multiple images to be processed, step 150 may include but is not limited to steps 151 to 153.

[0159] Step 151: performing defect detection processing on a plurality of three-channel images to obtain a plurality of defect annotated images.

[0160] It should be noted that the defect annotated image refers to an image with defect locations annotated thereon, for example, an image with a detection frame for indicating the defect locations.

[0161] It should be noted that since the grayscale gradient amplitude image and the brightness correction image are both calculated based on the image to be processed, and the three-channel image is obtained by merging the image to be processed, the grayscale gradient amplitude image and the brightness correction image, therefore, when there are multiple images to be processed, the number of grayscale gradient amplitude images, the brightness correction image and the three-channel images are all multiple, and there is a one-to-one correspondence between the image to be processed, the grayscale gradient amplitude image, the brightness correction image and the three-channel image. In addition, since the multiple images to be processed involve multiple scales, the multiple three-channel images obtained will also involve multiple scales. Therefore, in this step, defect detection processing is performed on the multiple three-channel images to obtain multiple defect annotation images, which can improve the defect detection capability for images of different scales and is conducive to reducing the probability of missed detection of defects.

[0162] It should be noted that a pre-trained defect detection model can be used to perform defect detection processing on the three-channel image to obtain multiple defect annotated images. For example, the Faster-RCNN model, the YOLO (You Only Look Once) model or the CascadeRCNN model can be used to perform defect detection processing on the three-channel image, and no specific limitation is made here.

[0163] The following is an example to illustrate: Figure 7 As shown, Figure 7This is a schematic diagram of an example of defect detection processing on multiple three-channel images. Assuming there are three three-channel images, and the scales of these three three-channel images are 600×600, 450×450 and 300×300 respectively, then after these three three-channel images are input into the CascadeRCNN model respectively, three defect annotation images can be obtained (the detection box marks the location of the defect in the weld area), where the scales of these three defect annotation images are 600×600, 450×450 and 300×300 pixel sizes respectively.

[0164] Step 152: Map multiple defect annotated images to the same scale to obtain multiple candidate defect images.

[0165] It should be noted that, since multiple three-channel images involve multiple scales, the multiple defect annotation images obtained will also involve multiple scales. However, these defect annotation images are all for the same image to be processed, so the defect positions in these defect annotation images may be repeated, which will cause confusion in the detection results. Moreover, since the scales of these defect annotation images are not the same, the accuracy of the final defect detection results may be affected. In order to avoid this problem, after executing step 151 to obtain defect annotation images of multiple scales, these defect annotation images can be mapped to the same scale to obtain multiple candidate defect images, so that in subsequent steps, these candidate defect images with unified scales can be subjected to non-maximum suppression merging processing to obtain accurate defect detection results.

[0166] In some feasible implementations, a target defect annotation image may be selected from these defect annotation images, and the scale of the target defect annotation image may be used as a reference scale. The scales of other defect annotation images may then be converted to the reference scale to obtain multiple candidate defect images.

[0167] Step 153: performing non-maximum suppression merging processing on multiple candidate defect images to obtain a first defect image.

[0168] In this step, since a plurality of candidate defect images are obtained in step 152 and the scales of these candidate defect images are consistent, these candidate defect images can be subjected to non-maximum suppression merging processing to obtain an accurate first defect image.

[0169] In some feasible implementations, the process of performing non-maximum suppression merging processing on multiple candidate defect images can be: first, merge these candidate defect images into a merged image, so that the merged image includes the detection frames for indicating the defect positions in all candidate defect images; then determine the confidence of these detection frames, and select the detection frame with the highest confidence; then determine the intersection and union ratio of the detection frame with the highest confidence with other detection frames, discard the detection frames with an intersection and union ratio greater than the intersection and union ratio threshold, and mark the detection frame with the highest confidence; then select the detection frame with the highest confidence from the remaining detection frames, repeat the above steps until all marked detection frames are determined; then map these marked detection frames to the merged image to obtain a first defect image.

[0170] The following is an example to illustrate: Figure 8 As shown, Figure 8 It is a schematic diagram of an example of mapping multiple defect annotation images to the same scale and performing non-maximum suppression merging processing on multiple candidate defect images. Assume that six candidate defect images are obtained in step 151, and the six candidate defect images include three candidate defect images corresponding to the previous target image and three candidate defect images corresponding to the previous enhanced image, wherein the detection frames in these candidate defect images mark the positions of defects in the weld area, and the six candidate defect images include three pixel sizes of 600×600, 450×450 and 300×300. Then, the scales of the six candidate defect images can be first mapped to a pixel size of 600×600, and the six candidate defect images can be merged into a merged image; then, the merged image is subjected to non-maximum suppression merging processing to obtain a first defect image, wherein, when performing the non-maximum suppression merging processing, the confidence threshold of the detection frame can be set to 0.3, and the intersection-over-union ratio threshold can be set to 0.5. Of course, the confidence threshold and the intersection-over-union ratio threshold can also be set to other values, which can be appropriately selected according to the actual application situation and are not specifically limited here.

[0171] Reference Fig. 9 As shown, an embodiment of the present application further illustrates step 141 , which may include but is not limited to steps 1411 to 1413 .

[0172] Step 1411: Acquire a first weld image, where the first weld image contains a weld area.

[0173] It should be noted that the first weld image may be an image obtained by photographing, an image input by a user, or an image obtained from a database, etc., and is not specifically limited here.

[0174] It should be noted that the first weld image may be an original image, a local image obtained by segmenting the original image, an image obtained by preprocessing the original image such as grayscale conversion, etc., and is not specifically limited here.

[0175] It should be noted that the first weld image may be an image of a weld position of an oil and gas pipeline, an image of a weld position of a metal sheet, or an image of a weld position of other metal parts, etc., and is not specifically limited here.

[0176] Step 1412: Perform weld recognition processing on the first weld image to obtain a weld mask image corresponding to the weld area.

[0177] It should be noted that since the first weld image contains weld areas and non-weld areas, if the first weld image is directly processed for defect detection, noise in the non-weld area may be introduced, resulting in inaccurate defect detection results. Therefore, in order to improve the accuracy of the defect detection results, the first weld image can first be processed for weld recognition to obtain a weld mask image corresponding to the weld area, so that in subsequent steps, a target image with the weld area as the main content can be captured in the first weld image according to the weld mask image, thereby improving the accuracy of subsequent defect detection.

[0178] It should be noted that a pre-trained weld recognition model can be used to perform weld recognition processing on the first weld image to obtain a weld mask image. For example, a deep neural network model or a convolutional neural network model can be used to perform weld recognition processing on the first weld image, which is not specifically limited here.

[0179] In some feasible implementations, considering the balance between performance and efficiency, the OCRNet model can be selected as the weld recognition model, wherein the backbone network adopts HRNet18 (i.e., 18-layer HRNet). It should be noted that in the process of training the OCRNet model, in order to cope with the problem of poor image quality, the training samples can be subjected to data augmentation processing such as random contrast, random brightness, random saturation, random atomization, random gamma correction, random blur, random image block discarding, etc., to improve the generalization ability of the OCRNet model. In addition, in order to reduce the missed detection of vertical welds, the training samples can be rotated 90 degrees with a random probability of 50% during the training process, and the input parameters of the model can be set to a pixel size of 1000×1000.

[0180] It should be noted that the OCRNet model can calculate the feature expressions of a set of object regions, and then propagate these object region feature representations to each pixel based on the similarity between the object region feature representation and the pixel feature representation, so that the semantic category of each pixel can be predicted.

[0181] Step 1413: Screenshot the weld area in the first weld image according to the weld mask image to obtain a target image.

[0182] It should be noted that since a weld mask image corresponding to the weld area is obtained in step 1412, the weld area in the first weld image can be screenshotted according to the weld mask image to obtain a target image, so that the target image can be enhanced and multi-scale converted in subsequent steps, thereby facilitating subsequent defect detection processing.

[0183] In some possible implementations, such as Fig.10 As shown, a target image is obtained by performing a screenshot processing on the weld area in the first weld image according to the weld mask image. Specifically, the weld mask image is first superimposed on the first weld image so that the weld mask area in the weld mask image overlaps with the weld area in the first weld image, and then a screenshot processing is performed on the first weld image according to the weld mask area to obtain a target image corresponding to the weld mask area.

[0184] In other feasible implementations, a target image is obtained by performing a screenshot processing on the weld area in the first weld image according to the weld mask image. Specifically, the coordinate information of the weld mask area in the weld mask image is first determined, and then the coordinate information of the weld mask area is mapped to the first weld image to obtain the mapping coordinate information, and then a screenshot processing is performed on the first weld image according to the mapping coordinate information to obtain the target image corresponding to the weld mask area.

[0185] Reference Fig.11 As shown, an embodiment of the present application further illustrates the defect detection method. When the defect position is marked in the first defect image, after executing step 150, the defect detection method may also include but is not limited to steps 160 and 170.

[0186] Step 160: Determine a target defect area in the first defect image according to the weld mask image.

[0187] It should be noted that the first defect image obtained in step 150 may include defects in the weld area and defects in the non-weld area, wherein the defects in the non-weld area may be false detections caused by noise in the non-weld area, and the defects in the non-weld area do not actually exist. Therefore, in order to improve the accuracy of defect detection, the target defect area (such as the effective area of ​​the target defect, etc.) can be first determined in the first defect image based on the weld mask image, so that the subsequent steps can determine the defect position in the target defect area, and the defect position in the target defect area is used as the detection result, thereby reducing the false detection rate and improving the accuracy of defect detection.

[0188] Step 170: Delete the target defect position in the first defect image to obtain a second defect image, wherein the target defect position is a defect position outside the target defect area in the first defect image.

[0189] In this step, since the target defect area is determined in step 160, the target defect position outside the target defect area in the first defect image can be deleted to obtain a second defect image with the defect position within the target defect area, thereby reducing the false detection rate and improving the accuracy of defect detection.

[0190] like Fig.12a , Figure 12b and Fig.12c As shown, Fig.12a is a first defect image in an example, in which defects in the weld area and defects in the non-weld area (such as Fig.12a ) as indicated by the arrow in the figure; Figure 12b Here is an example weld mask image; Fig.12c is the second defect image in an example. Since the first defect image includes defects in the weld area and defects in the non-weld area, the defects in the non-weld area will affect the accuracy of the final defect detection. In order to improve the accuracy of defect detection, Figure 12b The weld mask image in Fig.12a The first defect image in the image is used to determine the target defect area, and then the defects in the non-weld area in the first defect image are deleted (such as Fig.12a As shown by the arrow in Fig.12c The second defect image shown in FIG. Since the second defect image only includes defects in the weld area, the accuracy of defect detection can be improved, thereby reducing the false detection rate.

[0191] Reference Fig.13 As shown, an embodiment of the present application further illustrates step 1411. When there are multiple first weld images, step 1411 may include but is not limited to steps 14111 to 14113.

[0192] Step 14111: Receive a second weld image.

[0193] It should be noted that the second weld image may be an image obtained by photographing, an image input by a user, or an image obtained from a database, etc., and is not specifically limited here.

[0194] It should be noted that the second weld image may be an original image, a local image obtained by segmenting the original image, an image obtained by preprocessing the original image such as grayscale conversion, etc., and is not specifically limited here.

[0195] It should be noted that the second weld image may be an image of the weld position of an oil and gas pipeline, an image of the weld position of a metal sheet, or an image of the weld position of other metal parts, etc., and is not specifically limited here.

[0196] Step 14112: Obtain first length information of the second weld image.

[0197] It should be noted that, for weld images (such as pipeline weld images), after research and analysis, it is found that the length distribution of these weld images is very wide, ranging from hundreds of pixels to tens of thousands of pixels. If these weld images are directly input into the weld recognition model, the output weld feature distribution difference will be too large, which greatly increases the difficulty of subsequent weld recognition processing, thereby affecting the accuracy of weld recognition. In order to solve this problem, the weld image can be segmented to obtain multiple weld image segments, reduce the difference in weld feature distribution, and then input these weld image segments into the weld recognition model for weld recognition processing, so as to improve the accuracy of weld recognition. Therefore, after executing step 14111 and receiving the second weld image, the first length information of the second weld image can be obtained first, so that the subsequent steps can determine whether the second weld image needs to be segmented according to the first length information.

[0198] Step 14113: When the first length information is greater than a first preset length threshold, segment the second weld image to obtain a plurality of first weld images.

[0199] In this step, since the first length information of the second weld image is obtained in step 14112, the first length information can be compared with the first preset length threshold to determine whether the length of the second weld image is too long. When the first length information is greater than the first preset length threshold, it can be considered that the length of the second weld image is too long, so the second weld image can be segmented to obtain multiple first weld images, thereby reducing the difficulty of subsequent weld recognition processing.

[0200] It should be noted that when the first length information is less than or equal to the first preset length threshold, it indicates that the length of the second weld image is not too long, and therefore the second weld image may not be segmented.

[0201] It should be noted that the first preset length threshold can be appropriately selected according to actual application conditions and is not specifically limited here. For example, the first preset length threshold can be set to 10,000 pixels.

[0202] In addition, in one embodiment of the present application, step 14113 is further described. Step 14113 may include but is not limited to the following steps:

[0203] Acquire a segmentation length threshold, a segmentation width threshold, an overlap ratio value, and first width information of the second weld image;

[0204] The segmentation coordinate information is calculated according to the segmentation length threshold, the segmentation width threshold, the overlap ratio value, the first length information and the first width information;

[0205] The second weld image is segmented according to the segmentation coordinate information to obtain a plurality of first weld images.

[0206] In this embodiment, when it is determined that the second weld image needs to be segmented according to the first length information and the first preset length threshold, the preset segmentation length threshold, the segmentation width threshold and the overlap ratio value can be obtained first, and the first width information of the second weld image can be obtained, and then the segmentation coordinate information for segmenting the second weld image is calculated according to the segmentation length threshold, the segmentation width threshold, the overlap ratio value, the first length information and the first width information, and then the second weld image is segmented according to the segmentation coordinate information to obtain a plurality of first weld images. In addition, by first segmenting the second weld image to obtain a plurality of first weld images, and then performing weld recognition processing on these first weld images, the problem of insufficient video memory of a graphics processing unit (GPU) due to an excessively large input image can be avoided.

[0207] In a feasible implementation, the segmentation coordinate information of the i-th first weld image can be calculated according to the following formula (2):

[0208]

[0209] In formula (2), W is the first width information of the second weld image, H is the first length information of the second weld image, and w s is the segmentation width threshold, h s is the segmentation length threshold, r is the overlap ratio value, i is the index value of the first weld image after segmentation, is the coordinate value of the upper left corner of the i-th first weld image in the X-axis direction, is the coordinate value of the upper left corner of the i-th first weld image in the Y-axis direction, is the coordinate value of the lower right corner of the i-th first weld image in the X-axis direction, is the coordinate value of the lower right corner of the i-th first weld image in the Y-axis direction.

[0210] It should be noted that when the second weld image is segmented, the defect position may be at the segmented position, which will cause the loss of defect features, which is not conducive to the defect detection process in the subsequent steps. In order to avoid this problem, the overlap ratio value between the two first weld images can be set so that when the second weld image is segmented, the segmentation of the defect position can be avoided to avoid the loss of defect features. The value of the overlap ratio value can be appropriately selected according to the actual application situation. For example, the value of the overlap ratio value can be determined based on the historical statistical data of the defect position in the second weld image, so that the value of the overlap ratio value can have a certain degree of general applicability.

[0211] It should be noted that, in this embodiment, by dividing the second weld image into multiple first weld images, not only the accuracy of weld recognition can be improved in specific applications, but also the consistency and diversity of training samples can be improved during model training. Fig.14 As shown, Fig.14 is a schematic diagram of segmenting and identifying the second weld image in a specific example. Fig.14 In the method, the second weld image with too long length is first segmented to obtain a plurality of first weld images with shorter lengths, and then the first weld images are respectively subjected to weld recognition processing to obtain a plurality of weld mask images.

[0212] In addition, an embodiment of the present application further describes the defect detection method. After executing step 170, the defect detection method may also include but is not limited to the following steps:

[0213] Acquire target coordinate information of the defect position in the second defect image;

[0214] The target coordinate information is mapped to the second weld image to obtain a target defect image.

[0215] It should be noted that, although a second defect image including only defects in the weld area is obtained in step 170, the second defect image only corresponds to a portion of the original second weld image, and therefore the accurate defect position in the second weld image cannot be directly obtained. Therefore, after obtaining the second defect image, the target coordinate information of the defect position in the second defect image can be obtained first, and then the target coordinate information is mapped to the second weld image to obtain a target defect image, wherein the target defect image is an image in which all defect positions in the weld area are marked in the second weld image, that is, at this time, the defect detection processing of the second weld image is completed.

[0216] It should be noted that the second defect image is marked with a detection frame for indicating the defect position, so the target coordinate information of the defect position can be determined based on the detection frame, wherein the target coordinate information is the coordinate information in the coordinate system belonging to the second defect image; then, the target coordinate information belonging to the coordinate system of the second defect image can be mapped to the coordinate system of the second weld image to obtain the coordinate information of the defect position in the coordinate system of the second weld image; then, based on the coordinate information of the defect position in the second weld image, the detection frame can be marked on the defect position in the second weld image to obtain the target defect image. For example Fig.15 As shown, Fig.15 is a schematic diagram of mapping the target coordinate information to the second weld image in a specific example. Fig.15 , obtain the target coordinate information of the defect position in the second defect image (i.e. Fig.15 The target coordinate information is then mapped to the second weld image to obtain the target defect image.

[0217] Reference Fig.16 As shown, in one embodiment of the present application, step 1413 is further described. Step 1413 may include but is not limited to the following steps:

[0218] Step 14131: Obtain a first bounding box of the weld mask image;

[0219] Step 14132: Determine first mask coordinate information of the weld mask image according to the first bounding box;

[0220] Step 14133: Screenshot the weld area in the first weld image according to the first mask coordinate information to obtain a target image.

[0221] In this embodiment, when it is necessary to perform screenshot processing on the weld area in the first weld image according to the weld mask image, it is first necessary to determine the coordinate information for taking the screenshot. Therefore, the first bounding box of the weld mask image can be first obtained, and then the first mask coordinate information of the weld mask image can be determined according to the first bounding box. Then, the weld area in the first weld image is screenshot processed according to the first mask coordinate information to obtain the target image. In this embodiment, by first obtaining the coordinate information that needs to be screenshotted, the screenshot accuracy of the weld area can be improved, and the noise introduced into the non-weld area can be reduced, thereby improving the accuracy of defect detection in subsequent steps.

[0222] It should be noted that when obtaining the first bounding box of the weld mask image, the circumscribed polygon of the weld mask image can be obtained first, and then the first bounding box of the weld mask image can be calculated based on the circumscribed polygon. When obtaining the circumscribed polygon of the weld mask image, the findContours function in OpenCV can be called to calculate all contours of the weld mask image, and then the contour with the largest area is selected as the circumscribed polygon of the weld mask image. In addition, assuming that the coordinates of the circumscribed polygon are Then, when calculating the first bounding box of the weld mask image according to the circumscribed polygon, the following formula (3) can be used for calculation:

[0223]

[0224] In formula (3), is the coordinate value of the upper left corner of the first bounding box in the X-axis direction, is the coordinate value of the upper left corner of the first bounding box in the Y-axis direction, is the coordinate value of the lower right corner of the first bounding box in the X-axis direction, The Y-axis coordinate value of the lower right corner of the first bounding box.

[0225] Reference Fig.17 As shown, in one embodiment of the present application, step 14133 is further described, and step 14133 may include but is not limited to the following steps:

[0226] Step 141331: Calculate the second length information and the second width information of the weld mask image according to the first mask coordinate information;

[0227] Step 141332: when the second length information is greater than the second width information, the weld mask image is rotated to obtain a rotated mask image, and the first weld image is rotated to obtain a rotated weld image;

[0228] Step 141333: Obtain a second bounding box of the rotated mask image;

[0229] Step 141334: Determine second mask coordinate information of the rotated mask image according to the second bounding box;

[0230] Step 141335: Screenshot the weld area in the rotation weld image according to the second mask coordinate information to obtain a target image.

[0231] It should be noted that, after research and analysis, the geometric features of weld images are generally presented as horizontally long and narrow or vertically long and narrow. Among them, the commonly used weld images are more often presented as horizontally long and narrow images, and only a small number of weld images are presented as vertically long and narrow images. Therefore, the samples used to train the defect detection model are mostly presented as horizontally long and narrow images. If the vertically long and narrow weld images are input into the defect detection model for defect detection processing, it will lead to inaccurate defect detection results. In order to solve this problem, the aspect ratio of the weld image can be first determined to rotate the vertical weld image into a horizontal weld image, and then the rotated horizontal weld image is screenshotted so that the defects can be accurately detected in the subsequent steps. Therefore, in this embodiment, when it is necessary to perform a screenshot processing on the weld area in the first weld image, the second length information and the second width information of the weld mask image can be first calculated according to the first mask coordinate information, and then it is determined whether the second length information is greater than the second width information. When the second length information is greater than the second width information, it means that the weld mask image and the first weld image are both vertically narrow and long. Therefore, the weld mask image can be rotated to obtain a rotated mask image, and the first weld image can be rotated to obtain a rotated weld image. Then, the second bounding box of the rotated mask image is obtained, and the second mask coordinate information of the rotated mask image is determined according to the second bounding box. Then, the weld area in the rotated weld image is screenshot processed according to the second mask coordinate information to obtain the target image.

[0232] It should be noted that when obtaining the second bounding box of the rotating mask image and determining the second mask coordinate information of the rotating mask image according to the second bounding box, the method described above can be used. Fig.16 The method in the embodiment shown in the figure obtains the second bounding box of the rotating mask image and determines the second mask coordinate information of the rotating mask image according to the second bounding box. The specific method can refer to the above Fig.16 In order to avoid redundant content, the relevant descriptions in the illustrated embodiments are not repeated here.

[0233] It should be noted that when rotating the weld mask image and the first weld image, a transposition operation or calling the swapaxes function in NumPy can be used. NumPy is an open source numerical computing extension tool that can be used to store and process large matrices and supports a large number of dimensional arrays and matrix operations. The swapaxes function can be used to perform a pairwise permutation of axes on a matrix. Therefore, the swapaxes function can be used to realize the rotation of the weld mask image and the first weld image.

[0234] In addition, in one embodiment of the present application, step 141335 is further described. Step 141335 may include but is not limited to the following steps:

[0235] Calculating third length information of the rotated mask image according to the second mask coordinate information;

[0236] When the third length information is greater than a second preset length threshold, segmenting the rotating mask image and the rotating weld seam image according to the second preset length threshold to obtain a plurality of segmented rotating mask images and a plurality of segmented rotating weld seam images;

[0237] Obtaining a third bounding box of the segmented rotated mask image;

[0238] Determining third mask coordinate information of the segmented rotated mask image according to the third bounding box;

[0239] The weld area in the segmented rotation weld image is processed by screenshot according to the third mask coordinate information to obtain a target image.

[0240] It should be noted that, after research and analysis, the geometric features of weld images are generally long and narrow horizontally or vertically, and the defect detection model constructed by neural network generally has a stronger fitting ability for images with similar input length and input width. Therefore, if the long and narrow weld images are directly processed for defect detection, the defect detection ability will be reduced, which is not conducive to accurate detection of defects. In order to solve this problem, the weld image can be segmented twice so that the segmented weld image can meet the requirements of the defect detection model for input data, thereby improving the defect detection ability; in addition, by first segmenting the weld image twice and then using the weld image after the secondary segmentation for defect detection, the problem of insufficient GPU video memory due to the input image being too large can be avoided. Therefore, in this embodiment, when it is necessary to perform screenshot processing on the weld area in the rotary weld image, the third length information of the rotary mask image can be first calculated according to the second mask coordinate information, and then it is determined whether the third length information is greater than the second preset length threshold. When the third length information is greater than the second preset length threshold, it means that both the rotary mask image and the rotary weld image fail to meet the input data requirements of the defect detection model. Therefore, the rotary mask image and the rotary weld image can be segmented according to the second preset length threshold to obtain a plurality of segmented rotary mask images and a plurality of segmented rotary weld images. Then, the third bounding box of the segmented rotary mask image is obtained, and the third mask coordinate information of the segmented rotary mask image is determined according to the third bounding box. Then, the weld area in the segmented rotary weld image is screenshot processed according to the third mask coordinate information to obtain the target image.

[0241] It should be noted that when obtaining the third bounding box of the segmented rotating mask image and determining the third mask coordinate information of the segmented rotating mask image according to the third bounding box, the method described above can be used. Fig.16 The method in the embodiment shown in the figure obtains the third bounding box of the segmented rotating mask image and determines the third mask coordinate information of the segmented rotating mask image according to the third bounding box. The specific method can refer to the above Fig.16 In order to avoid redundant content, the relevant descriptions in the illustrated embodiments are not repeated here.

[0242] It should be noted that the second preset length threshold can be appropriately selected according to actual application conditions and is not specifically limited here. For example, the second preset length threshold can be set to 600 pixels.

[0243] In order to more clearly illustrate the processing flow of the defect detection method provided in the embodiment of the present application, different specific examples are given below in combination with different application scenarios for illustration.

[0244] Scenario 1:

[0245] Reference Fig.18 , Fig.18 This is a flowchart of the process of defect detection on weld images by the server in a specific example.

[0246] When a user uses a detection instrument to capture images of welding positions of oil and gas pipelines and performs defect detection on the captured weld images, the detection instrument will send the captured weld images to the server; after the server receives the weld images, the server will perform the following steps:

[0247] Step 201: input a weld image;

[0248] Step 202: determine whether the length of the weld image exceeds the set length, if so, execute step 203, if not, execute step 204;

[0249] Step 203: performing image segmentation processing on the weld image to obtain a plurality of weld images after segmentation;

[0250] Step 204: performing weld recognition processing on the weld image to obtain a weld mask image;

[0251] Step 205: using the weld mask image to perform screenshot processing on the weld image to obtain a weld area image;

[0252] Step 206: judging whether it is necessary to rotate and perform secondary segmentation processing on the weld area image according to the weld mask image, if so, executing step 207, if not, executing step 208;

[0253] Step 207: rotating and performing secondary segmentation processing on the weld region image according to the weld mask image to obtain a processed weld region image;

[0254] Step 208: performing image enhancement and multi-scale conversion processing on the weld area image to obtain a plurality of target weld area images;

[0255] Step 209: performing defect detection processing on the target weld area images to obtain a plurality of defect images;

[0256] Step 210: Perform NMS merging processing on these defect images to obtain a target defect image;

[0257] Step 211: determine whether the target defect image has been rotated, if so, execute step 212, if not, execute step 213;

[0258] Step 212: rotating the detection frame in the target defect image to obtain a rotated detection frame;

[0259] Step 213: Map the detection frame in the target defect image to the weld image to obtain a defect detection result.

[0260] Among them, refer to Fig.19 , Fig.19 is a specific flow chart of step 203. Specifically, step 203 may include the following steps:

[0261] Step 2031: obtaining a segmentation length threshold, a segmentation width threshold, an overlap ratio value, and a length value and a width value of the weld image;

[0262] Step 2032: Calculate segmentation coordinate information according to the segmentation length threshold, the segmentation width threshold, the overlap ratio value, and the length value and width value of the weld image;

[0263] Step 2033: Segment the weld image according to the segmentation coordinate information;

[0264] Step 2034: Return multiple weld images that have been segmented and the corresponding image coordinate information.

[0265] Among them, refer to Fig. 20 , Fig. 20 is a specific flow chart of step 207. Specifically, step 207 may include the following steps:

[0266] Step 2071: Acquire a weld mask image;

[0267] Step 2072: Calculate the bounding box of the weld mask image and coordinate information of the bounding box;

[0268] Step 2073: judging whether the length of the weld mask image is greater than the width according to the boundary box of the weld mask image, if so, executing step 2074, if not, executing step 2075;

[0269] Step 2074: rotating the weld mask image, the bounding box and the weld image to obtain the rotated weld mask image, the bounding box and the weld image;

[0270] Step 2075: determine whether the length of the weld mask image is greater than the set length, if so, execute step 2076, if not, execute step 2077;

[0271] Step 2076: performing secondary segmentation on the weld mask image and the weld image, and recalculating the bounding box of the weld mask image after the secondary segmentation and the coordinate information of the bounding box;

[0272] Step 2077: The weld image is intercepted and processed according to the coordinate information of the boundary box to obtain a weld area image.

[0273] By executing the defect detection method in the above scenario one, the defect detection capability in large-size, low-quality pipeline weld images can be effectively improved, the risk of false detection in non-weld areas can be effectively reduced, and the problem of insufficient GPU video memory caused by excessively large input images can be avoided.

[0274] Scenario 2:

[0275] When a user uses a desktop computer to perform defect detection processing on a pre-stored metal plate weld image, the desktop computer can call an image processing application pre-installed therein to perform defect detection processing on the metal plate weld image. Specifically, first determine whether the length of the weld image exceeds the set length. If so, perform image segmentation processing on the weld image to obtain multiple weld images after segmentation. If not, perform weld recognition processing on the weld image to obtain a weld mask image. Then, use the weld mask image to screenshot the weld image to obtain a weld area image, and determine whether the weld area image needs to be rotated and segmented twice according to the weld mask image. If necessary, rotate the weld area image according to the weld mask image and segment it twice to obtain a processed weld area image. If not, perform image enhancement and multi-scale conversion processing on the weld area image to obtain multiple target weld area images. Then, perform defect detection processing on these target weld area images to obtain multiple defect images, and perform NMS merging processing on these defect images to obtain a target defect image. Further, determine whether the target defect image has been rotated. If so, rotate the detection frame in the target defect image to obtain a rotated detection frame. If not, map the detection frame in the target defect image to the weld image to obtain a defect detection result.

[0276] By executing the defect detection method steps in the above scenario 2, the ability to detect defects in large-size, low-quality metal plate weld images can be effectively improved, the risk of false detection in non-weld areas can be effectively reduced, and the problem of insufficient GPU video memory caused by excessively large input images can be avoided.

[0277] Reference Fig.21 The embodiment of the present application further discloses a defect detection device. The defect detection device 300 can implement the defect detection method of the previous embodiment. The defect detection device 300 includes:

[0278] A first acquisition unit 310 is used to acquire an image to be processed;

[0279] The second acquisition unit 320 is used to calculate the grayscale gradient amplitude image of the image to be processed according to the image to be processed;

[0280] A third acquisition unit 330 is used to calculate and obtain a brightness correction image of the image to be processed according to the image to be processed;

[0281] An image merging unit 340 is used to merge the image to be processed, the grayscale gradient amplitude image and the brightness correction image into a three-channel image;

[0282] The defect detection unit 350 is used to perform defect detection processing on the three-channel image to obtain a first defect image.

[0283] In one embodiment, there are multiple images to be processed, and the first acquisition unit 310 includes:

[0284] A fourth acquisition unit, used to acquire a target image;

[0285] An image enhancement unit, used for performing image enhancement processing on a target image to obtain an enhanced image;

[0286] The multi-scale conversion unit is used to perform multi-scale conversion processing on the target image and the enhanced image respectively to obtain multiple images to be processed.

[0287] In one embodiment, there are multiple images to be processed, grayscale gradient amplitude images, brightness correction images, and three-channel images, and there is a one-to-one correspondence between the images to be processed, the grayscale gradient amplitude images, the brightness correction images, and the three-channel images; the defect detection unit 350 includes:

[0288] An image detection unit, used for performing defect detection processing on a plurality of three-channel images to obtain a plurality of defect annotated images;

[0289] A scale mapping unit, used for mapping multiple defect annotation images to the same scale to obtain multiple candidate defect images;

[0290] The suppression merging unit is used to perform non-maximum suppression merging processing on multiple candidate defect images to obtain a first defect image.

[0291] In one embodiment, the fourth obtaining unit includes:

[0292] A fifth acquisition unit is used to acquire a first weld image, where the first weld image contains a weld area;

[0293] A weld recognition unit, used to perform weld recognition processing on the first weld image to obtain a weld mask image corresponding to the weld area;

[0294] The image capture unit is used to perform a capture process on the weld area in the first weld image according to the weld mask image to obtain a target image.

[0295] In one embodiment, the first defect image is marked with a defect position; the defect detection device 300 further includes:

[0296] A defect determination unit, configured to determine a target defect region in the first defect image according to the weld mask image;

[0297] The image deletion unit is used to delete the target defect position in the first defect image to obtain a second defect image, wherein the target defect position is a defect position outside the target defect area in the first defect image.

[0298] In one embodiment, the number of the first weld seam images is multiple, and the fifth acquisition unit includes:

[0299] An image receiving unit, used for receiving a second weld image;

[0300] A first size acquisition unit, used to acquire first length information of the second weld image;

[0301] The image segmentation unit is used to segment the second weld image to obtain multiple first weld images when the first length information is greater than a first preset length threshold.

[0302] In one embodiment, the image segmentation unit includes:

[0303] A parameter acquisition unit, used to acquire a segmentation length threshold, a segmentation width threshold, an overlap ratio value, and first width information of the second weld image;

[0304] A coordinate calculation unit, used to calculate segmentation coordinate information according to a segmentation length threshold, a segmentation width threshold, an overlap ratio value, the first length information and the first width information;

[0305] The image segmentation subunit is used to segment the second weld image according to the segmentation coordinate information to obtain a plurality of first weld images.

[0306] In one embodiment, the defect detection device 300 further includes:

[0307] A coordinate acquisition unit, used to acquire target coordinate information of a defect position in the second defect image;

[0308] The information mapping unit is used to map the target coordinate information to the second weld image to obtain a target defect image.

[0309] In one embodiment, the image capture unit includes:

[0310] A first frame acquisition unit, used to acquire a first boundary frame of the weld mask image;

[0311] A first coordinate determining unit, used to determine first mask coordinate information of the weld mask image according to the first boundary frame;

[0312] The first interception unit is used to perform a screenshot process on the weld area in the first weld image according to the first mask coordinate information to obtain a target image.

[0313] In one embodiment, the image capture subunit includes:

[0314] A first size calculation unit, used for calculating the second length information and the second width information of the weld mask image according to the first mask coordinate information;

[0315] A rotation processing unit, configured to rotate the weld mask image to obtain a rotated mask image, and to rotate the first weld image to obtain a rotated weld image when the second length information is greater than the second width information;

[0316] A second frame acquisition unit, used to acquire a second boundary frame of the rotated mask image;

[0317] A second coordinate determining unit, configured to determine second mask coordinate information of the rotated mask image according to the second boundary box;

[0318] The second interception unit is used to perform a screenshot process on the weld area in the rotation weld image according to the second mask coordinate information to obtain a target image.

[0319] In one embodiment, the second interception unit includes:

[0320] A second size calculation unit, used for calculating the third length information of the rotated mask image according to the second mask coordinate information;

[0321] a segmentation processing unit, configured to segment the rotating mask image and the rotating weld seam image according to the second preset length threshold value when the third length information is greater than the second preset length threshold value, so as to obtain a plurality of segmented rotating mask images and a plurality of segmented rotating weld seam images;

[0322] A third frame acquisition unit, used to acquire a third bounding box of the segmented rotating mask image;

[0323] a third coordinate determining unit, configured to determine third mask coordinate information of the segmented rotating mask image according to the third boundary box;

[0324] The third interception unit is used to perform a screenshot process on the weld area in the segmented rotation weld image according to the third mask coordinate information to obtain a target image.

[0325] It should be noted that since the defect detection device 300 of this embodiment can implement the defect detection method with the server as the execution body in the previous embodiment, the defect detection device 300 of this embodiment and the defect detection method with the server as the execution body in the previous embodiment have the same technical principles and the same beneficial effects. In order to avoid repetition of content, they will not be repeated here.

[0326] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0327] Reference Fig. 22 The embodiment of the present application further discloses a defect detection device, the defect detection device 400 comprises:

[0328] at least one processor 401;

[0329] At least one memory 402, used to store at least one program;

[0330] When at least one program is executed by at least one processor 401 , the defect detection method as described in any of the above embodiments is implemented.

[0331] An embodiment of the present application further discloses a computer-readable storage medium, which stores a program executable by a processor. When the program executable by the processor is executed by the processor, it is used to implement the defect detection method described in any of the previous embodiments.

[0332] An embodiment of the present application also discloses a computer program product, including a computer program or computer instructions, wherein the computer program or computer instructions are stored in a computer-readable storage medium, a processor of a computer device reads the computer program or computer instructions from the computer-readable storage medium, and the processor executes the computer program or computer instructions, so that the computer device executes the defect detection method described in any of the previous embodiments.

[0333] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0334] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0335] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

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

[0337] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0338] If the integrated unit is implemented in the form of 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, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.

[0339] The step numbers in the above method embodiment are only provided for the convenience of explanation and description, and no limitation is imposed on the order of the steps. The execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.

Claims

1. A defect detection method, It is characterized in that The following steps are involved: Get the image to be processed; Obtaining a grayscale gradient amplitude image of the image to be processed by calculation according to the image to be processed; Obtaining a brightness-corrected image of the image to be processed by increasing the brightness of a low-grayscale area of ​​the image to be processed and compressing the brightness of a high-grayscale area of ​​the image to be processed; Combining pixel values ​​corresponding to positions in the image to be processed, the grayscale gradient amplitude image, and the brightness correction image to obtain a three-channel image; wherein the number of the image to be processed, the grayscale gradient amplitude image, the brightness correction image, and the three-channel image is plural, and there is a one-to-one correspondence between the image to be processed, the grayscale gradient amplitude image, the brightness correction image, and the three-channel image; Performing defect detection processing on the plurality of three-channel images to obtain a plurality of defect annotated images; Mapping the plurality of defect annotated images to the same scale to obtain a plurality of candidate defect images; A non-maximum suppression merging process is performed on the plurality of candidate defect images to obtain a first defect image.

2. The defect detection method according to claim 1, It is characterized in that The number of the images to be processed is multiple, and the obtaining of the images to be processed includes: Get the target image; Performing image enhancement processing on the target image to obtain an enhanced image; The target image and the enhanced image are respectively subjected to multi-scale conversion processing to obtain a plurality of images to be processed.

3. The defect detection method according to claim 2, It is characterized in that The acquiring of the target image comprises: Acquire a first weld image, wherein the first weld image contains a weld area; Performing weld recognition processing on the first weld image to obtain a weld mask image corresponding to the weld area; The weld area in the first weld image is screenshoted according to the weld mask image to obtain the target image.

4. The defect detection method according to claim 3, It is characterized in that The first defect image is marked with a defect position; after the three-channel image is subjected to defect detection processing to obtain the first defect image, the defect detection method further includes: determining a target defect area in the first defect image according to the weld mask image; A second defect image is obtained by deleting a target defect position in the first defect image, wherein the target defect position is a defect position in the first defect image that is outside the target defect area.

5. The defect detection method according to claim 4, It is characterized in that The number of the first weld images is multiple, and the acquiring of the first weld images includes: receiving a second weld image; Acquire first length information of the second weld image; When the first length information is greater than a first preset length threshold, the second weld image is segmented to obtain a plurality of the first weld images.

6. The defect detection method according to claim 5, It is characterized in that The step of segmenting the second weld image to obtain a plurality of the first weld images comprises: Acquire a segmentation length threshold, a segmentation width threshold, an overlap ratio value, and first width information of the second weld image; Calculate segmentation coordinate information according to the segmentation length threshold, the segmentation width threshold, the overlap ratio value, the first length information, and the first width information; The second weld image is segmented according to the segmentation coordinate information to obtain a plurality of the first weld images.

7. The defect detection method according to claim 5, It is characterized in that After deleting the target defect position in the first defect image to obtain the second defect image, the defect detection method further includes: Acquire target coordinate information of the defect position in the second defect image; The target coordinate information is mapped to the second weld image to obtain a target defect image.

8. The defect detection method according to claim 3, It is characterized in that The step of performing screenshot processing on the weld area in the first weld image according to the weld mask image to obtain the target image comprises: Acquire a first bounding box of the weld mask image; Determining first mask coordinate information of the weld mask image according to the first bounding box; The weld area in the first weld image is screenshoted according to the first mask coordinate information to obtain the target image.

9. The defect detection method according to claim 8, It is characterized in that The step of performing screenshot processing on the weld area in the first weld image according to the first mask coordinate information to obtain the target image includes: Calculating second length information and second width information of the weld mask image according to the first mask coordinate information; When the second length information is greater than the second width information, the weld mask image is rotated to obtain a rotated mask image, and the first weld image is rotated to obtain a rotated weld image; Acquire a second bounding box of the rotated mask image; Determining second mask coordinate information of the rotated mask image according to the second bounding box; A screenshot process is performed on the weld area in the rotation weld image according to the second mask coordinate information to obtain the target image.

10. The defect detection method according to claim 9, It is characterized in that The step of performing screenshot processing on the weld area in the rotation weld image according to the second mask coordinate information to obtain the target image includes: Calculating third length information of the rotating mask image according to the second mask coordinate information; When the third length information is greater than a second preset length threshold, segmenting the rotating mask image and the rotating weld seam image according to the second preset length threshold to obtain a plurality of segmented rotating mask images and a plurality of segmented rotating weld seam images; Obtaining a third bounding box of the segmented rotated mask image; Determining third mask coordinate information of the segmented rotated mask image according to the third bounding box; The weld area in the segmented rotation weld image is processed by screenshot according to the third mask coordinate information to obtain the target image.

11. A defect detection device, It is characterized in that include: A first acquisition unit, used for acquiring an image to be processed; A second acquisition unit, configured to calculate a grayscale gradient amplitude image of the image to be processed according to the image to be processed; A third acquisition unit, configured to obtain a brightness-corrected image of the image to be processed by increasing the brightness of a low-grayscale region of the image to be processed and compressing the brightness of a high-grayscale region of the image to be processed; An image merging unit, used for combining pixel values ​​corresponding to positions in the image to be processed, the grayscale gradient amplitude image and the brightness correction image to obtain a three-channel image; wherein the number of the image to be processed, the grayscale gradient amplitude image, the brightness correction image and the three-channel image is plural, and there is a one-to-one correspondence between the image to be processed, the grayscale gradient amplitude image, the brightness correction image and the three-channel image; The defect detection unit is used to perform defect detection processing on the multiple three-channel images to obtain multiple defect annotation images; map the multiple defect annotation images to the same scale to obtain multiple candidate defect images; and perform non-maximum suppression merging processing on the multiple candidate defect images to obtain a first defect image.

12. A defect detection device, It is characterized in that include: at least one processor; at least one memory for storing at least one program; When at least one of the programs is executed by at least one of the processors, the defect detection method according to any one of claims 1 to 10 is implemented.

13. A computer-readable storage medium, It is characterized in that A program executable by a processor is stored therein, and when the program executable by the processor is executed by the processor, it is used to implement the defect detection method according to any one of claims 1 to 10.

14. A computer program product comprising a computer program or computer instructions, It is characterized in that The computer program or the computer instructions are stored in a computer-readable storage medium, and the processor of a computer device reads the computer program or the computer instructions from the computer-readable storage medium. The processor executes the computer program or the computer instructions, so that the computer device executes the defect detection method as described in any one of claims 1 to 10.