CN115661161A - Method, device, storage medium, equipment and program product for detecting defects of parts - Google Patents

Method, device, storage medium, equipment and program product for detecting defects of parts Download PDF

Info

Publication number
CN115661161A
CN115661161A CN202211702550.9A CN202211702550A CN115661161A CN 115661161 A CN115661161 A CN 115661161A CN 202211702550 A CN202211702550 A CN 202211702550A CN 115661161 A CN115661161 A CN 115661161A
Authority
CN
China
Prior art keywords
image
defect
images
target
parts
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202211702550.9A
Other languages
Chinese (zh)
Other versions
CN115661161B (en
Inventor
请求不公布姓名
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Shulian Cloud Computing Technology Co ltd
Original Assignee
Chengdu Shulian Cloud Computing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu Shulian Cloud Computing Technology Co ltd filed Critical Chengdu Shulian Cloud Computing Technology Co ltd
Priority to CN202211702550.9A priority Critical patent/CN115661161B/en
Publication of CN115661161A publication Critical patent/CN115661161A/en
Application granted granted Critical
Publication of CN115661161B publication Critical patent/CN115661161B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Abstract

The embodiment of the application discloses a method, a device, a storage medium, equipment and a program product for detecting the defects of parts, which relate to the technical field of artificial intelligence and comprise the following steps: based on the standard image, carrying out image correction transformation on a target image corresponding to the target part to obtain a corrected image; inputting the corrected image into the trained defect detection model for reasoning and testing to obtain defect information. The method has the advantages that the standard image is used as the basis, the images of the parts are corrected and transformed, the images with the problems of inclination, position deviation and the like in actual shooting are corrected, the training sample of the model is derived from the non-defective parts, the shot images of the non-defective parts are obtained through the corresponding standard image correction transformation, even if the unknown and unlearned defect types are faced, the defect information on the images can be detected in the inference test after the image data distribution condition of the non-defective parts is learned, and the defect detection method of the parts can be suitable for more working condition requirements.

Description

Method, device, storage medium, equipment and program product for detecting defects of parts
Technical Field
The application relates to the technical field of artificial intelligence, in particular to a method, a device, a storage medium, equipment and a program product for detecting defects of parts.
Background
The production and manufacture of industrial parts are composed of a plurality of processes, generally, machining and manufacturing are carried out on a plurality of machine tool devices, and various product defects are easily introduced in the complicated and complicated manufacturing process. Most of the defects are unacceptable for manufacturers, so that how to identify the 'healthy' state of the workpiece and complete high-quality inspection is very important.
In the field of quality inspection, a traditional method adopts a personnel detection method for judgment, but excessive inspection and missed inspection are easily caused when a large number of parts to be inspected are faced, and with the development of deep learning, target detection is gradually applied to the field of quality inspection, but the detection effect of the method excessively depends on the learned defects, and the defects which do not occur or occur rarely cannot be covered, so that the defect detection method cannot adapt to more working condition requirements.
Disclosure of Invention
The present application mainly aims to provide a method, an apparatus, a storage medium, a device and a program product for detecting a defect of a part, and aims to solve the problem that the method for detecting a defect of a part in the prior art cannot meet the requirements of more working conditions.
In order to achieve the above purpose, the embodiments of the present application adopt the following technical solutions:
in a first aspect, an embodiment of the present application provides a method for detecting a defect of a part, including the following steps:
based on the standard image, carrying out image correction transformation on a target image corresponding to the target part to obtain a corrected image;
inputting the corrected image into a trained defect detection model to perform inference test to obtain defect information; the defect detection model is obtained based on sample data set training, the sample data set comprises correction images of a plurality of non-defective parts, and the correction images of the non-defective parts are obtained by performing image correction transformation on shot images of the non-defective parts based on corresponding standard images.
The method comprises the steps of correcting and transforming images of a part needing to detect defects on the basis of a standard image, processing the images with inclination, position deviation and other part interference in actual shooting, and directly inputting the images into a defect detection model for reasoning and testing to obtain defect information on the images.
In a possible implementation manner of the first aspect, before inputting the corrected image into the trained defect detection model for inference test and obtaining defect information, the method for detecting a defect of a part further includes:
acquiring shot images of a plurality of non-defective parts;
based on the standard images corresponding to the non-defective parts, performing image correction transformation on the shot images of the non-defective parts to obtain corrected images of the non-defective parts;
and training to obtain a defect detection model based on the corrected images of the plurality of non-defective parts.
The defect detection model is trained in advance so as to be used repeatedly, the training means is similar to the target image processing means of the method, and the defect-free product is utilized, so that the defects on the product are not directly relied on, the shot image is also converted into the corrected image obtained under the corresponding standard state, the convergence rate of model training and the accuracy of detection by utilizing the model can be obviously improved, the quality of the model is improved, the model can widely cover all practical working conditions, and the defect detection effect is favorably improved.
In a possible implementation manner of the first aspect, after the image rectification transformation is performed on the captured images of the defect-free parts based on the standard images corresponding to the defect-free parts to obtain the rectified images of the defect-free parts, the method for detecting the defect of the part further includes:
performing template matching on the corrected images of the plurality of non-defective parts based on the standard images corresponding to the non-defective parts to obtain first corrected images of the non-defective parts;
based on the corrected images of a plurality of non-defective parts, training to obtain a defect detection model, which comprises the following steps:
and training to obtain a defect detection model based on the first corrected images of the plurality of non-defective parts.
Template matching is the most primitive and basic pattern recognition method, where a pattern of a specific object is located in an image is studied to further recognize the object, which is a matching problem, the template is a known small image, the template matching is to search for an object in a large image, the object to be found is known to exist in the image, the size, the direction and the image elements of the object and the template are the same, and the object can be found in the image through a certain algorithm to determine the coordinate position of the object. In the embodiment, the large image is a standard image, the small image is a corrected image, and all the images cannot necessarily be matched with the standard image due to the influence of actual shooting, so that adjustment is performed under template matching, and parts in the processed images are more regular in the images.
In one possible implementation manner of the first aspect, after acquiring the captured images of the plurality of non-defective parts, the method for detecting the defects of the parts further includes:
preprocessing a shot image of a non-defective part according to the type of the target defect to obtain a preprocessed image;
based on the standard image corresponding to the non-defective part, the image correction transformation is carried out on the shot images of the plurality of non-defective parts to obtain the corrected images of the plurality of non-defective parts, and the method comprises the following steps:
and performing image rectification transformation on the preprocessed image based on the standard image corresponding to the non-defective part to obtain a plurality of rectified images of the non-defective part.
In an actual detection task, defects can be roughly divided into obvious defects and tiny defects, when reasoning test is carried out in a model, as the model does not have the capability of determining the size of the defects, the obvious defects can be easily determined according to the self saliency, and the tiny defects have different detection requirements under different scenes, training data are obviously preprocessed, so that the model can be forced to pay attention to or ignore the tiny defects during training, the model is matched with the actual detection requirements, and the detection with better effect is finished.
In one possible implementation manner of the first aspect, the preprocessing the captured image of the non-defective part according to the target defect type to obtain a preprocessed image includes:
and (3) preprocessing the shot image of the non-defective part by adopting a method of randomly generating Gaussian noise according to the type of the target defect to obtain a preprocessed image.
The method for randomly generating the Gaussian noise is adopted to match the working condition that the fine defect does not need to be detected, the fine defect on the image is ignored after the processing by the method, the definition of the image is reduced and the image becomes fuzzy from the aspect of image form, but the detection is not influenced by the fuzzy due to the fact that the fine defect does not need to be detected.
In a possible implementation manner of the first aspect, the preprocessing the shot image of the non-defective part by using a method of randomly generating gaussian noise according to the type of the target defect to obtain a preprocessed image includes:
generating a Gaussian distribution random number sequence according to the target defect type as a non-tiny defect type;
obtaining Gaussian noise according to the Gaussian distribution random number sequence;
a preprocessed image is obtained by adding Gaussian noise based on a photographed image of a non-defective part.
The target defect type is a non-fine defect type, which means that fine defects can be ignored, firstly a Gaussian distribution random number sequence is generated according to a method for randomly generating Gaussian noise, then Gaussian noise is obtained, the Gaussian noise is additive noise, the image after noise addition is obtained by adding the Gaussian noise on the basis of a shot image of a non-defective part, finally the fine defects on the image are ignored, interference on a sample image in model training is further reduced, and the quality of the model is favorably improved.
In one possible implementation manner of the first aspect, the preprocessing the captured image of the non-defective part according to the target defect type to obtain a preprocessed image includes:
and preprocessing the shot image of the non-defective part by adopting a mean filtering method according to the type of the target defect to obtain a preprocessed image.
The mean filtering method is adopted to match the working condition that the tiny defects need to be detected, the image processed by the method can learn more regular data distribution during model training, and the tiny defects can be found more easily by the model during reasoning test.
In a possible implementation manner of the first aspect, the preprocessing the captured image of the non-defective part by using a mean filtering method according to the type of the target defect to obtain a preprocessed image includes:
respectively obtaining each pixel point on the shot image of the non-defective part according to the fact that the target defect type is a small defect type;
taking the pixel point as a central pixel point, and obtaining the pixels of eight pixel points around the central pixel point;
taking the average value of the pixels of the eight pixel points and the pixel of the central pixel point as the pixel of the central pixel point to obtain a target pixel value of the central pixel point;
and obtaining a preprocessed image according to the target pixel values of the central pixel points.
Under the condition of traversing by using a pixel template, all pixels on the image can be processed, and because the amplitudes are approximately equal and are randomly distributed on different positions, the image can be smoothed by the mean filtering processing, the processing speed is high, the algorithm is simple, small defects can be more easily noticed, and the accurate detection work is completed.
In a possible implementation manner of the first aspect, after performing image rectification transformation on a target image corresponding to a target part based on a standard image to obtain a rectified image, the method for detecting a defect of the part further includes:
performing template matching on the corrected image based on the standard image to obtain a first corrected image;
inputting the corrected image into a trained defect detection model for reasoning and testing to obtain defect information, wherein the defect information comprises the following steps:
inputting the first correction image into the trained defect detection model for reasoning and testing to obtain defect information.
In an actual situation, the target image has an automatic transmission influence and has influence factors such as adjustment in the image acquisition process, and the target image may not correspond to the standard image, so that the target image is normalized on the basis of the standard image by adopting a template matching method, all the target images can be subjected to subsequent processing under the same standard, and the detection quality is improved.
In a possible implementation manner of the first aspect, before performing image rectification transformation on a target image corresponding to a target part based on a standard image to obtain a rectified image, the method for detecting a defect of the part further includes:
and carrying out gray processing on the shot image of the target part to obtain a target image.
Because the shot image is a picture in an actual state and is a multi-channel color image, the gray processing is favorable for reducing the data dimension and eliminating the interference of other noises on the image.
In a second aspect, an embodiment of the present application provides a defect detection apparatus for a part, including:
the correction transformation module is used for carrying out image correction transformation on a target image corresponding to the target part based on the standard image to obtain a corrected image;
the reasoning testing module is used for inputting the corrected image into the trained defect detection model to carry out reasoning testing to obtain defect information; the defect detection model is obtained based on sample data set training, the sample data set comprises correction images of a plurality of non-defective parts, and the correction images of the non-defective parts are obtained by performing image correction transformation on shot images of the non-defective parts based on corresponding standard images.
In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is loaded and executed by a processor, the method for detecting a defect of a part as described in any one of the first aspect above is implemented.
In a fourth aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, wherein,
the memory is used for storing a computer program;
the processor is configured to load and execute a computer program to enable the electronic device to perform the defect detection method for the part as provided in any one of the above first aspects.
In a fifth aspect, the present application provides a computer program product, which includes a computer program, when the computer program is executed, for executing the defect detection method of the part as provided in any one of the above first aspects.
Compared with the prior art, the beneficial effects of this application are:
the method comprises the steps of carrying out image correction transformation on a target image corresponding to a target part based on a standard image to obtain a corrected image; inputting the corrected image into a trained defect detection model to perform inference test to obtain defect information; the defect detection model is obtained based on sample data set training, the sample data set comprises correction images of a plurality of non-defective parts, and the correction images of the non-defective parts are obtained by performing image correction transformation on shot images of the non-defective parts based on corresponding standard images. The method comprises the steps of correcting and transforming the image of a part needing to detect defects on the basis of a standard image, processing the image with inclination, position deviation and other part interference in actual shooting, and directly inputting the image into a defect detection model for reasoning and testing to obtain defect information on the image.
Drawings
Fig. 1 is a schematic structural diagram of an electronic device in a hardware operating environment according to an embodiment of the present application;
FIG. 2 is a schematic flowchart of a defect detection method for a part according to an embodiment of the present disclosure;
FIG. 3 is a block diagram of a defect detection apparatus for a part according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a target image in a defect detection method for a part according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a rectified image corresponding to the target image shown in FIG. 4;
the mark in the figure is: 101-processor, 102-communication bus, 103-network interface, 104-user interface, 105-memory.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application.
The main solution of the embodiment of the application is as follows: a method, an apparatus, a storage medium, a device and a program product for detecting defects of a part are provided, the method comprising: based on the standard image, carrying out image rectification transformation on a target image corresponding to the target part to obtain a rectified image; inputting the corrected image into a trained defect detection model to perform inference test to obtain defect information; the defect detection model is obtained based on sample data set training, the sample data set comprises correction images of a plurality of non-defective parts, and the correction images of the non-defective parts are obtained by performing image correction transformation on shot images of the non-defective parts based on corresponding standard images.
Industrial parts production consists of multiple processes, generally requiring machining in multiple machine tools, and various product defects are easily introduced in this complicated and cumbersome manufacturing process. Most of the defects are unacceptable for manufacturers, so that it is important to identify the defects and judge the health status of the workpiece. In the face of a large number of parts to be detected, the traditional mode of adopting personnel detection easily causes over-detection and missed detection, the detection efficiency is difficult to match with the actual requirements, along with the development of deep learning technology, the mode of utilizing the deep neural network technology starts to be generally applied, the mode utilizes a detection model to accurately position and classify the learned defects, but because some defects do not occur or rarely occur, the sample quantity of the training model is insufficient, the detection model cannot be trained, or the detection effect of the trained model is not ideal, so that the detection method is limited by the condition of sample data, and the requirements of all scenes cannot be completely covered.
Therefore, the application provides a solution, based on a standard image, the image of a part needing to detect defects is corrected and transformed, the image with inclination, position offset and other part interference in actual shooting is processed, and then the image is directly input into a defect detection model for inference test to obtain defect information on the image, because a training sample of the defect detection model is from a non-defective part, and the shot image of the non-defective part is corrected and transformed by the corresponding standard image, the quality of the model can be improved from two aspects of convergence speed and detection accuracy in model training, even if the image is in the face of an unknown and unlearned defect type, after the image data distribution condition of the non-defective part is learned, the image of the part to be detected and the image of the non-defective part in a standard state can be compared and analyzed in the inference test to detect the defect information on the image, so that the defect detection method of the part can adapt to more working condition requirements and has good detection effect.
Referring to fig. 1, fig. 1 is a schematic structural diagram of an electronic device in a hardware operating environment according to an embodiment of the present application, where the electronic device may include: a processor 101, such as a Central Processing Unit (CPU), a communication bus 102, a user interface 104, a network interface 103, and a memory 105. Wherein the communication bus 102 is used for enabling connection communication between these components. The user interface 104 may comprise a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 104 may also comprise a standard wired interface, a wireless interface. The network interface 103 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The Memory 105 may be a storage device independent from the processor 101, and the Memory 105 may be a high-speed Random Access Memory (RAM) Memory or a Non-Volatile Memory (NVM), such as at least one disk Memory; the processor 101 may be a general-purpose processor including a central processing unit, a network processor, etc., and may also be a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components.
Those skilled in the art will appreciate that the configuration shown in fig. 1 is not intended to be limiting of the electronic device and may include more or fewer components than shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, the memory 105, which is a storage medium, may include therein an operating system, a data storage module, a network communication module, a user interface module, and an electronic program.
In the electronic device shown in fig. 1, the network interface 103 is mainly used for data communication with a network server; the user interface 104 is mainly used for data interaction with a user; the processor 101 and the memory 105 in the present application may be disposed in an electronic device, and the electronic device invokes a defect detection apparatus of a part stored in the memory 105 through the processor 101 and executes a defect detection method of the part provided in the embodiment of the present application.
Referring to fig. 2, based on the hardware device of the foregoing embodiment, an embodiment of the present application provides a defect detection method for a part, including the following steps:
s10: and carrying out gray processing on the shot image of the target part to obtain a target image.
In the specific implementation process, the target part is a part to be detected, and the shot image is an image shot by an image acquisition device such as a camera in an actual state, such as an industrial camera, an automatic optical detection device, and the like, and is grayed, in an RGB model, if R = G = B, the color represents a gray color, wherein the value of R = G = B is called a gray value, so that each pixel of the gray image only needs one byte to store the gray value (also called an intensity value and a brightness value), and the gray range is 0-255. Because the shot image is a picture in an actual state and is a multi-channel color picture, the gray processing is favorable for reducing data dimensionality and eliminating the interference of other noise on the image, the target image is obtained after the gray processing, and when the image is actually collected, if the AOI automatic optical detection equipment is adopted, the equipment can directly output the gray image, so that the gray processing is not needed when the AOI equipment is used for image acquisition.
S20: and carrying out image rectification transformation on the target image corresponding to the target part based on the standard image to obtain a rectified image.
In the specific implementation process, the standard image is an image of a product of the same type as the target part, the acquisition mode of the standard image can be selected according to the actual situation, and if the detection precision requirement is very high, the standard design drawing of the part can be used as the standard image; the requirement of detection precision is general, and can be obtained by collecting the image of standard part, and the standard part is the qualified product that has been manufactured, wherein it should be noted that, the standard image should be obtained based on the same visual angle as the target image, in the standard design drawing, because can use the image processing software to operate, can conveniently adjust and obtain the image, and need to pay attention when shooting and obtaining, should use for example the camera to shoot the same position to obtain the image when shooting different objects. Then, the correction transformation can be based on a standard image, a target image with the problems of certain inclination, position deviation and other part interference under the shooting of an actual working condition is corrected, so that parts in the target image can be transformed to a standard state, the comparison with the standard image is facilitated, the target image is shown as a figure 4, the corrected image shown as a figure 5 is obtained after the correction transformation, and a certain inclination exists.
S30: inputting the corrected image into a trained defect detection model to perform inference test to obtain defect information; the defect detection model is obtained based on sample data set training, the sample data set comprises correction images of a plurality of non-defective parts, and the correction images of the non-defective parts are obtained by performing image correction transformation on shot images of the non-defective parts based on corresponding standard images.
In the specific implementation process, the trained defect detection model is obtained by training with a sample data set based on an existing deep learning model, and since the sample data set contains a corrected image of a non-defective part, the corrected image is obtained by performing correction transformation on a shot image of the non-defective part based on a standard image, it should be noted that the standard image here should be a standard image corresponding to the non-defective part collected in this step, that is, if the non-defective part is an a part, the standard image should be an a part. The parts may be the same as or different from the parts in step S20, because in this step, the model can learn the capability of comparing the input object with the standard image thereof by itself under unsupervised learning by using the sample data, so as to perform inference test, output the result, and judge the place where the result is different from the standard image distribution by the professional, so as to obtain the defect information. The result of the reasoning test can adopt a mode of outputting an image result, the image result is similar to finite element analysis in mechanical design, and defect information can be obtained from colors and color distribution conditions on the image.
In the embodiment, the image of the part needing to detect the defect is corrected and transformed on the basis of the standard image, the image with inclination, position offset and other part interference in actual shooting is processed, and then the image is directly input into the defect detection model for inference test to obtain the defect information on the image.
In one embodiment, before inputting the corrected image into the trained defect detection model for inference test and obtaining defect information, the method for detecting defects of a part further includes:
acquiring shot images of a plurality of parts without defects;
based on the standard images corresponding to the non-defective parts, performing image correction transformation on the shot images of the non-defective parts to obtain corrected images of the non-defective parts;
and training to obtain a defect detection model based on the corrected images of the plurality of non-defective parts.
In the specific implementation process, the defect detection model is trained in advance so as to be used repeatedly, the training means is similar to the target image processing means, the defect-free product is used, the defects on the product are not directly depended on, the shot image is also converted into the corrected image obtained under the corresponding standard state, the convergence rate of model training and the accuracy of detection by using the model can be obviously improved, the quality of the model is improved, the model can widely cover all practical working conditions, and the defect detection effect is favorably improved.
In one embodiment, after the image rectification transformation is performed on the shot images of the defect-free parts based on the standard images corresponding to the defect-free parts to obtain the rectified images of the defect-free parts, the defect detection method for the parts further includes:
and carrying out template matching on the corrected images of the plurality of non-defective parts based on the standard images corresponding to the non-defective parts to obtain a first corrected image of the non-defective parts.
In the specific implementation process, template matching is the most primitive and basic pattern recognition method, and is used for researching where a pattern of a specific object is located in an image, and further recognizing the object, namely, a matching problem. In the embodiment, the large image is a standard image, the small image is a corrected image, and due to the influence of actual shooting, all the images cannot be matched with the standard image, so that adjustment is performed under template matching, so that parts in the processed images are more regular in the images, and the image at this time is also the first corrected image.
Based on the operation of carrying out template matching on the images in the previous step to obtain a first corrected image, and based on the corrected images of a plurality of non-defective parts, training to obtain a defect detection model, comprising the following steps of:
and training to obtain a defect detection model based on the first corrected images of the plurality of non-defective parts.
In one embodiment, after acquiring the captured images of the defect-free parts, the method for detecting defects of the parts further comprises:
and preprocessing the shot image of the non-defective part according to the target defect type to obtain a preprocessed image.
In the specific implementation process, in the actual detection task, the defects can be roughly divided into obvious defects and tiny defects, when reasoning test is carried out in the model, as the model does not have the capability of determining the size of the defects, the obvious defects can be easily determined according to the self saliency, and the tiny defects have different detection requirements under different scenes, the training data is obviously preprocessed, so that the model can be forced to pay attention to or ignore the tiny defects during training, the model is matched with the actual detection requirements, and the detection with better effect is finished.
Based on the operation of preprocessing the shot images in the previous steps, based on the standard images corresponding to the non-defective parts, the shot images of the plurality of non-defective parts are subjected to image rectification transformation to obtain the rectified images of the plurality of non-defective parts, and the method comprises the following steps:
and performing image rectification transformation on the preprocessed image based on the standard image corresponding to the non-defective part to obtain a plurality of rectified images of the non-defective part.
In one embodiment, preprocessing the captured image of the non-defective part according to the target defect type to obtain a preprocessed image comprises:
and (3) preprocessing the shot image of the non-defective part by adopting a method of randomly generating Gaussian noise according to the type of the target defect to obtain a preprocessed image.
In the specific implementation process, a preprocessing means is provided, namely a method for randomly generating Gaussian noise is adopted to match the working condition without detecting the fine defects, the fine defects on the image are ignored after the preprocessing, the definition of the image is reduced and the image becomes fuzzy from the aspect of image morphology, but the detection is not influenced by the fuzzy due to the fact that the fine defects do not need to be detected. Specifically, the method comprises the following steps:
according to the type of the target defect, preprocessing a shot image of a non-defective part by adopting a method for randomly generating Gaussian noise to obtain a preprocessed image, wherein the method comprises the following steps:
generating a Gaussian distribution random number sequence according to the target defect type as a non-tiny defect type;
obtaining Gaussian noise according to the Gaussian distribution random number sequence;
a preprocessed image is obtained by adding Gaussian noise based on a shot image of a non-defective part.
In the specific implementation process, the target defect type is a non-fine defect type, which means that fine defects can be ignored, firstly a Gaussian distribution random number sequence is generated according to a method for randomly generating Gaussian noise, then Gaussian noise is obtained, the Gaussian noise is additive noise, the image after noise addition is obtained by adding the Gaussian noise on the basis of a shot image of a non-defective part, and finally the fine defects on the image are ignored, the interference on a sample image in model training is further reduced, and the quality of the model is favorably improved. According to the formula of noise addition, the larger the coefficient of gaussian noise is, the stronger the gaussian noise is, the more blurred the image is reflected, and since the noise follows gaussian distribution, the larger the variance is, the more scattered the data is, the more the noise is, both of the above two are expressed as the blurring degree of the image, the mean value determines the brightness degree of the image, the larger the absolute value of the mean value is, the darker or brighter the image is indicated, and the brightness and darkness of the image are respectively determined by the signs.
In one embodiment, preprocessing the captured image of the non-defective part according to the target defect type to obtain a preprocessed image comprises:
and preprocessing the shot image of the non-defective part by adopting a mean filtering method according to the type of the target defect to obtain a preprocessed image.
In the specific implementation process, another preprocessing means is provided, namely a mean filtering method is adopted to match the working condition of detecting the tiny defects, the images processed by the method can learn more regular data distribution during model training, and the tiny defects can be found more easily by the model during reasoning and testing. Mean filtering is a typical linear filtering algorithm, which means that a template is given to a target pixel on an image, the template comprises adjacent pixels around the target pixel, which can be understood as a squared box, and 8 pixels around the target pixel are used as the center to form a filtering template, namely the filtering template comprises the target pixel itself, and the original pixel value is replaced by the average value of all pixels in the template. Specifically, the method comprises the following steps: according to the target defect type, preprocessing the shot image of the non-defective part by adopting a mean filtering method to obtain a preprocessed image, wherein the preprocessing comprises the following steps:
respectively obtaining each pixel point on the shot image of the non-defective part according to the fact that the target defect type is a small defect type;
taking the pixel point as a central pixel point, and obtaining the pixels of eight pixel points around the central pixel point;
taking the average value of the pixels of the eight pixel points and the pixel of the central pixel point as the pixel of the central pixel point to obtain a target pixel value of the central pixel point;
and obtaining a preprocessed image according to the target pixel values of the central pixel points.
In the specific implementation process, all pixels on the image can be processed under the traversal by using the pixel template, and because the amplitudes are approximately equal and are randomly distributed on different positions, the image can be smoothed by the mean filtering processing, the processing speed is high, the algorithm is simple, small defects can be more easily noticed, and the accurate detection work is completed.
In an embodiment, based on the standard image, the method for detecting the defect of the part after performing image rectification transformation on the target image corresponding to the target part to obtain a rectified image further includes:
performing template matching on the corrected image based on the standard image to obtain a first corrected image;
in the specific implementation process, similar to the principle of template matching in the foregoing embodiment, because the target image has an automatic transmission influence in an actual situation and has influence factors such as adjustment in the image acquisition process, and the target image may not correspond to the standard image, the target image is normalized on the basis of the standard image by using the template matching method, so that all the target images can be subjected to subsequent processing under the same standard, and the detection quality is improved.
Inputting the corrected image into a trained defect detection model for inference test based on the template matching operation to obtain defect information, wherein the defect information comprises:
inputting the first correction image into the trained defect detection model for reasoning and testing to obtain defect information.
Referring to fig. 3, based on the same inventive concept as the previous embodiment, the embodiment of the present application further provides a defect detecting apparatus for a part, the apparatus including:
the correction transformation module is used for carrying out image correction transformation on a target image corresponding to the target part based on the standard image to obtain a corrected image;
the reasoning testing module is used for inputting the corrected image into the trained defect detection model for reasoning testing to obtain defect information; the defect detection model is obtained based on sample data set training, the sample data set comprises correction images of a plurality of non-defective parts, and the correction images of the non-defective parts are obtained by performing image correction transformation on shot images of the non-defective parts based on corresponding standard images.
It should be understood by those skilled in the art that the division of each module in the embodiment is only a division of a logic function, and all or part of the division may be integrated onto one or more actual carriers in actual application, and all of the modules may be implemented in a form called by a processing unit through software, may also be implemented in a form of hardware, or implemented in a form of combination of software and hardware.
Based on the same inventive concept as that in the foregoing embodiments, embodiments of the present application further provide a computer-readable storage medium, which stores a computer program, and when the computer program is loaded and executed by a processor, the method for detecting defects of a part as provided in the embodiments of the present application is implemented.
Based on the same inventive concept as the foregoing embodiments, embodiments of the present application further provide an electronic device, including a processor and a memory, wherein,
the memory is used for storing a computer program;
the processor is used for loading and executing the computer program to enable the electronic device to execute the defect detection method of the part as provided by the embodiment of the application.
Furthermore, based on the same inventive concept as the foregoing embodiments, embodiments of the present application also provide a computer program product comprising a computer program for executing the defect detection method of the part as provided by the embodiments of the present application when the computer program is executed.
In some embodiments, the computer-readable storage medium may be memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories. The computer may be a variety of computing devices including intelligent terminals and servers.
In some embodiments, the executable instructions may be in the form of a program, software module, script, or code written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and it may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
By way of example, executable instructions may, but need not, correspond to files in a file system, and may be stored in a portion of a file that holds other programs or data, such as in one or more scripts in a hypertext Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code).
By way of example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrases "comprising one of 8230; \8230;" 8230; "does not exclude the presence of additional like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., a rom/ram, a magnetic disk, an optical disk) and includes instructions for enabling a multimedia terminal (e.g., a mobile phone, a computer, a television receiver, or a network device) to perform the method according to the embodiments of the present application.
In summary, the present application provides a method, an apparatus, a storage medium, a device and a program product for detecting a defect of a component, which includes: based on the standard image, carrying out image correction transformation on a target image corresponding to the target part to obtain a corrected image; inputting the corrected image into a trained defect detection model to perform inference test to obtain defect information; the defect detection model is obtained based on sample data set training, the sample data set comprises correction images of a plurality of non-defective parts, and the correction images of the non-defective parts are obtained by performing image correction transformation on shot images of the non-defective parts based on corresponding standard images. The method comprises the steps of correcting and transforming images of parts needing to detect defects on the basis of standard images, processing the images with inclination, position deviation and other part interference in actual shooting, and directly inputting the images into a defect detection model for inference testing to obtain defect information on the images.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (14)

1. A method for detecting defects of a part is characterized by comprising the following steps:
based on the standard image, carrying out image correction transformation on a target image corresponding to the target part to obtain a corrected image;
inputting the corrected image into a trained defect detection model for reasoning and testing to obtain defect information; the defect detection model is obtained based on sample data set training, the sample data set comprises correction images of a plurality of non-defective parts, and the correction images of the non-defective parts are obtained by performing image correction transformation on shot images of the non-defective parts based on corresponding standard images.
2. The method for detecting defects of a part according to claim 1, wherein before inputting the corrected image into a trained defect detection model for inference testing and obtaining defect information, the method for detecting defects of a part further comprises:
acquiring shot images of a plurality of defect-free parts;
based on the standard image corresponding to the non-defective part, performing image correction transformation on the shot images of the non-defective part to obtain corrected images of the non-defective part;
and training to obtain the defect detection model based on the corrected images of the plurality of non-defective parts.
3. The method for detecting defects in a part according to claim 2, wherein the method for detecting defects in a part, after the method for correcting and transforming the images of the plurality of non-defective parts based on the standard images corresponding to the non-defective parts to obtain corrected images of the plurality of non-defective parts, further comprises:
performing template matching on the corrected images of the non-defective parts based on the standard images corresponding to the non-defective parts to obtain first corrected images of the non-defective parts;
training to obtain the defect detection model based on the corrected images of the defect-free parts, wherein the training comprises the following steps:
training to obtain the defect detection model based on a plurality of first corrected images of the defect-free parts.
4. The method of detecting defects in a part according to claim 2, wherein after acquiring the captured images of a plurality of non-defective parts, the method further comprises:
preprocessing the shot image of the non-defective part according to the type of the target defect to obtain a preprocessed image;
the image rectification transformation is performed on the shot images of the defect-free parts based on the standard images corresponding to the defect-free parts to obtain the rectified images of the defect-free parts, and the image rectification transformation comprises the following steps:
and carrying out image rectification transformation on the preprocessed image based on the standard image corresponding to the non-defective part to obtain a plurality of rectified images of the non-defective part.
5. The method for detecting the defect of the part according to claim 4, wherein the preprocessing the shot image of the defect-free part according to the target defect type to obtain a preprocessed image comprises:
and preprocessing the shot image of the non-defective part by adopting a method of randomly generating Gaussian noise according to the type of the target defect to obtain a preprocessed image.
6. The method for detecting the defects of the parts according to claim 5, wherein the step of preprocessing the shot images of the non-defective parts by a method of randomly generating Gaussian noise according to the types of the target defects to obtain preprocessed images comprises the following steps:
generating a Gaussian distribution random number sequence according to the target defect type as a non-tiny defect type;
obtaining Gaussian noise according to the Gaussian distribution random number sequence;
and adding the Gaussian noise based on the shot image of the non-defective part to obtain a preprocessed image.
7. The method of detecting defects in a part according to claim 4, wherein said preprocessing the captured image of the non-defective part according to the target defect type to obtain a preprocessed image comprises:
and preprocessing the shot image of the non-defective part by adopting a mean filtering method according to the type of the target defect to obtain a preprocessed image.
8. The method for detecting defects of a part according to claim 7, wherein the step of preprocessing the shot image of the defect-free part by means of mean filtering according to the type of the target defect to obtain a preprocessed image comprises:
respectively obtaining each pixel point on the shot image of the non-defective part according to the fact that the target defect type is a small defect type;
taking the pixel point as a central pixel point, and obtaining the pixels of eight pixel points around the central pixel point;
taking the average value of the pixels of the eight pixel points and the pixel of the central pixel point as the pixel of the central pixel point to obtain a target pixel value of the central pixel point;
and obtaining a preprocessed image according to the target pixel values of the central pixel points.
9. The method for detecting defects of parts according to claim 1, wherein after the target image corresponding to the target part is subjected to image rectification transformation based on the standard image to obtain a rectified image, the method for detecting defects of parts further comprises:
performing template matching on the corrected image based on the standard image to obtain a first corrected image;
inputting the corrected image into a trained defect detection model for reasoning and testing to obtain defect information, wherein the defect information comprises:
inputting the first correction image into a trained defect detection model for reasoning and testing to obtain defect information.
10. The method for detecting defects of a part according to claim 1, wherein before the step of performing image correction transformation on the target image corresponding to the target part based on the standard image to obtain the corrected image, the method for detecting defects of a part further comprises:
and carrying out graying processing on the shot image of the target part to obtain the target image.
11. A defect detection apparatus for a part, comprising:
the correction transformation module is used for carrying out image correction transformation on a target image corresponding to the target part based on the standard image to obtain a corrected image;
the reasoning testing module is used for inputting the corrected image into the trained defect detection model to carry out reasoning testing to obtain defect information; the defect detection model is obtained based on sample data set training, the sample data set comprises correction images of a plurality of non-defective parts, and the correction images of the non-defective parts are obtained by performing image correction transformation on shot images of the non-defective parts based on corresponding standard images.
12. A computer-readable storage medium, storing a computer program, wherein the computer program, when loaded and executed by a processor, implements a method for defect detection of a part as claimed in any one of claims 1 to 10.
13. An electronic device comprising a processor and a memory, wherein,
the memory is used for storing a computer program;
the processor is configured to load and execute the computer program to cause the electronic device to perform the defect detection method of the part according to any one of claims 1 to 10.
14. A computer program product, characterized in that it comprises a computer program for executing the method of defect detection of a part according to any one of claims 1 to 10, when said computer program is executed.
CN202211702550.9A 2022-12-29 2022-12-29 Defect detection method, device, storage medium, apparatus and program product for parts Active CN115661161B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211702550.9A CN115661161B (en) 2022-12-29 2022-12-29 Defect detection method, device, storage medium, apparatus and program product for parts

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211702550.9A CN115661161B (en) 2022-12-29 2022-12-29 Defect detection method, device, storage medium, apparatus and program product for parts

Publications (2)

Publication Number Publication Date
CN115661161A true CN115661161A (en) 2023-01-31
CN115661161B CN115661161B (en) 2023-06-02

Family

ID=85023096

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211702550.9A Active CN115661161B (en) 2022-12-29 2022-12-29 Defect detection method, device, storage medium, apparatus and program product for parts

Country Status (1)

Country Link
CN (1) CN115661161B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116433664A (en) * 2023-06-13 2023-07-14 成都数之联科技股份有限公司 Panel defect detection method, device, storage medium, apparatus and program product
CN117036351A (en) * 2023-10-09 2023-11-10 合肥安迅精密技术有限公司 Element defect detection method and system and storage medium
CN117036335A (en) * 2023-08-29 2023-11-10 广州番禺职业技术学院 Image sensor defect detection method, system, device and medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109946304A (en) * 2019-03-11 2019-06-28 中国科学院上海技术物理研究所 Surface defects of parts on-line detecting system and detection method based on characteristic matching
WO2019176614A1 (en) * 2018-03-16 2019-09-19 日本電産株式会社 Image processing device, image processing method, and computer program
CN111242902A (en) * 2020-01-02 2020-06-05 天津瑟威兰斯科技有限公司 Method, system and equipment for identifying and detecting parts based on convolutional neural network
CN111640091A (en) * 2020-05-14 2020-09-08 阿丘机器人科技(苏州)有限公司 Method for detecting product defects and computer storage medium
CN111986178A (en) * 2020-08-21 2020-11-24 北京百度网讯科技有限公司 Product defect detection method and device, electronic equipment and storage medium
CN114862776A (en) * 2022-04-22 2022-08-05 深圳职业技术学院 Product surface defect detection method and device, computer equipment and medium
CN115294024A (en) * 2022-07-06 2022-11-04 珠海信易为科技有限公司 Selenium drum defect detection method and device, electronic equipment and storage medium
CN115471466A (en) * 2022-08-30 2022-12-13 长春理工大学 Steel surface defect detection method and system based on artificial intelligence

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019176614A1 (en) * 2018-03-16 2019-09-19 日本電産株式会社 Image processing device, image processing method, and computer program
CN109946304A (en) * 2019-03-11 2019-06-28 中国科学院上海技术物理研究所 Surface defects of parts on-line detecting system and detection method based on characteristic matching
CN111242902A (en) * 2020-01-02 2020-06-05 天津瑟威兰斯科技有限公司 Method, system and equipment for identifying and detecting parts based on convolutional neural network
CN111640091A (en) * 2020-05-14 2020-09-08 阿丘机器人科技(苏州)有限公司 Method for detecting product defects and computer storage medium
CN111986178A (en) * 2020-08-21 2020-11-24 北京百度网讯科技有限公司 Product defect detection method and device, electronic equipment and storage medium
CN114862776A (en) * 2022-04-22 2022-08-05 深圳职业技术学院 Product surface defect detection method and device, computer equipment and medium
CN115294024A (en) * 2022-07-06 2022-11-04 珠海信易为科技有限公司 Selenium drum defect detection method and device, electronic equipment and storage medium
CN115471466A (en) * 2022-08-30 2022-12-13 长春理工大学 Steel surface defect detection method and system based on artificial intelligence

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116433664A (en) * 2023-06-13 2023-07-14 成都数之联科技股份有限公司 Panel defect detection method, device, storage medium, apparatus and program product
CN116433664B (en) * 2023-06-13 2023-09-01 成都数之联科技股份有限公司 Panel defect detection method, device, storage medium, apparatus and program product
CN117036335A (en) * 2023-08-29 2023-11-10 广州番禺职业技术学院 Image sensor defect detection method, system, device and medium
CN117036351A (en) * 2023-10-09 2023-11-10 合肥安迅精密技术有限公司 Element defect detection method and system and storage medium

Also Published As

Publication number Publication date
CN115661161B (en) 2023-06-02

Similar Documents

Publication Publication Date Title
CN115661161B (en) Defect detection method, device, storage medium, apparatus and program product for parts
JP7004145B2 (en) Defect inspection equipment, defect inspection methods, and their programs
US11830174B2 (en) Defect inspecting device, defect inspecting method, and storage medium
US6381366B1 (en) Machine vision methods and system for boundary point-based comparison of patterns and images
US6687402B1 (en) Machine vision methods and systems for boundary feature comparison of patterns and images
CN114240939B (en) Method, system, equipment and medium for detecting appearance defects of mainboard components
CN106501272B (en) Machine vision soldering tin positioning detection system
CN113034488B (en) Visual inspection method for ink-jet printed matter
CN114677567B (en) Model training method and device, storage medium and electronic equipment
CN115619787B (en) UV glue defect detection method, system, equipment and medium
CN107909554B (en) Image noise reduction method and device, terminal equipment and medium
CN114445410A (en) Circuit board detection method based on image recognition, computer and readable storage medium
CN117078677B (en) Defect detection method and system for starting sheet
CN112150375A (en) Tape inspection system, tape inspection method, and storage medium with tape inspection program
CN115479891A (en) Automatic detection system and method for circuit board mounted components based on image recognition
CN112750113B (en) Glass bottle defect detection method and device based on deep learning and linear detection
CN113012121B (en) Method and device for processing bare chip scanning result, electronic equipment and storage medium
CN112686851B (en) Image detection method, device and storage medium
CN115471684A (en) Injection molding workpiece template matching method, electronic equipment and storage medium
CN115239690A (en) PCB line sequence detection method and system based on image recognition
JP2021189239A (en) Belt inspection system and belt inspection program
JP2021189238A (en) Belt inspection system and belt inspection program
Golodov et al. Weld segmentation and defect detection in radiographic images of pipe welds
JP2021006854A (en) Belt inspection system and belt inspection program
CN114627114B (en) Method, system, device and medium for measuring severity of product defect

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant