Workpiece defect detection method, device, computer equipment and readable storage medium

By obtaining the pixel position information of the target area in the workpiece image and locating the defect detection points, the image of the area to be detected is selected for detection, which solves the problem in the existing technology that the image contains a large number of areas that do not need to be detected, and improves the accuracy and efficiency of workpiece defect detection. .

CN118521576BActive Publication Date: 2024-10-18SPEEDBOT ROBOTICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410973469.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-10-18
Estimated Expiration
2044-07-19

AI Technical Summary

Technical Problem

In the existing workpiece defect detection technology, the image contains a large number of areas that do not need to be detected, resulting in the loss of defect features, resulting in missed detections and false detections, and low detection accuracy.

Method used

By obtaining the pixel position information of the target area in the workpiece image, the defect detection points are located, and based on these points, the image of the area to be detected is selected for defect detection, so as to reduce the proportion of non-detection pixel areas and improve the focus of detection.

Benefits of technology

The detection accuracy of workpiece defect detection is improved, missed detection caused by the loss of defect features is avoided, and the reliance on significant defect features is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118521576B_ABST
    Figure CN118521576B_ABST
Patent Text Reader

Abstract

The present application relates to a method, device, computer equipment and readable storage medium for workpiece defect detection. The workpiece defect detection method comprises: obtaining pixel position information of a target area in a workpiece image of a workpiece to be detected, wherein the target area refers to a pixel area composed of multiple pixel points that meet the defect detection requirements; locating at least one defect detection point from the target area according to the pixel position information; selecting an image of an area to be detected in the workpiece image according to each of the defect detection points; and performing defect detection on the workpiece to be detected according to the image of the area to be detected. The use of this method can improve the detection accuracy of defect detection on workpieces.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of defect detection, and in particular to a workpiece defect detection method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] With the continuous development of science and technology, the defect detection method for workpieces on the production line has also evolved from the traditional manual detection method to the automated visual detection method. That is, when performing defect detection on a workpiece, the image of the workpiece is captured by a camera and the image is input into the neural network model to complete defect identification. Compared with manual detection, visual detection has significantly improved detection efficiency and accuracy.

[0003] However, the acquisition method of workpiece images is usually fixed, but the areas that need to be inspected for defects in different workpieces and the same workpiece under different processes are different, which leads to the inclusion of a large number of areas in the image that do not require defect detection. When the defect is subsequently identified through a neural network model, defects may be missed due to the loss of defect features. Therefore, the detection accuracy of defect detection on workpieces is low. Summary of the invention

[0004] Based on this, it is necessary to provide a workpiece defect detection method, device, computer equipment, computer-readable storage medium and computer program product that can improve the detection accuracy of workpiece defect detection in response to the above technical problems.

[0005] In a first aspect, the present application provides a workpiece defect detection method, comprising:

[0006] Acquire pixel position information of a target area in a workpiece image of a workpiece to be inspected, wherein the target area refers to a pixel area composed of a plurality of pixel points that meet defect detection requirements;

[0007] Locating at least one defect detection point from the target area according to the pixel position information;

[0008] According to each of the defect detection points, an image of a region to be detected is selected from the workpiece image;

[0009] Defect detection is performed on the workpiece to be inspected according to the image of the area to be inspected.

[0010] In a second aspect, the present application also provides a workpiece defect detection device, comprising:

[0011] An acquisition module, used to acquire pixel position information of a target area in a workpiece image of a workpiece to be inspected, wherein the target area refers to a pixel area composed of a plurality of pixel points that meet the defect detection requirements;

[0012] A positioning module, used for locating at least one defect detection point from the target area according to the pixel position information;

[0013] A selection module, used for selecting an image of a region to be detected in the workpiece image according to each of the defect detection points;

[0014] The detection module is used to perform defect detection on the workpiece to be detected based on the image of the area to be detected.

[0015] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0016] Obtain pixel position information of a target area in a workpiece image of a workpiece to be inspected, wherein the target area refers to a pixel area composed of multiple pixel points that meet defect detection requirements; locate at least one defect detection point from the target area according to the pixel position information; select an image of an area to be inspected in the workpiece image according to each of the defect detection points; and perform defect detection on the workpiece to be inspected according to the image of the area to be inspected.

[0017] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0018] Obtain pixel position information of a target area in a workpiece image of a workpiece to be inspected, wherein the target area refers to a pixel area composed of multiple pixel points that meet defect detection requirements; locate at least one defect detection point from the target area according to the pixel position information; select an image of an area to be inspected in the workpiece image according to each of the defect detection points; and perform defect detection on the workpiece to be inspected according to the image of the area to be inspected.

[0019] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0020] Obtain pixel position information of a target area in a workpiece image of a workpiece to be inspected, wherein the target area refers to a pixel area composed of multiple pixel points that meet defect detection requirements; locate at least one defect detection point from the target area according to the pixel position information; select an image of an area to be inspected in the workpiece image according to each of the defect detection points; and perform defect detection on the workpiece to be inspected according to the image of the area to be inspected.

[0021] The above-mentioned workpiece defect detection method, device, computer equipment, computer-readable storage medium and computer program product first obtain pixel position information of a target area in the workpiece image of the workpiece to be detected. Since the target area is a pixel area composed of multiple pixel points in the workpiece image that meet the defect detection requirements, at least one defect detection point for defect detection can be located from the target area based on the pixel position information; then, the image of the area to be detected is selected in the workpiece image according to each defect detection point, and finally, the defect detection of the workpiece to be detected is completed through the image of the area to be detected. Since the image of the area to be detected is obtained by selecting the workpiece image based on the defect detection point, the proportion of pixel areas that need to be detected in the image of the area to be detected is greater than the proportion of pixel areas that need to be detected in the workpiece image, that is, the image of the area to be detected is relatively focused on the pixel points that need to be detected compared to the workpiece image, thereby ensuring that the image of the area to be detected contains fewer non-detection pixel areas than directly using the workpiece image for defect detection, so that when detecting workpiece defects, it can rely on more significant defect features, and to a certain extent avoid the defect omission caused by the loss of defect features during the workpiece defect detection process, thereby improving the detection accuracy of defect detection of workpieces. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 A schematic diagram of a process flow of manual detection of workpiece defects in a workpiece defect detection method in one embodiment;

[0024] Figure 2 A schematic diagram of a process flow of visual inspection of workpiece defects in a workpiece defect inspection method in one embodiment;

[0025] Figure 3 A schematic diagram of a workpiece defect detection method according to an embodiment;

[0026] Figure 4 is a schematic flow chart of a workpiece defect detection method in another embodiment;

[0027] Figure 5 is a schematic diagram of a workpiece image of a workpiece defect detection method in one embodiment;

[0028] Figure 6 A schematic diagram of a workpiece mask image of a workpiece defect detection method in one embodiment;

[0029] Figure 7 It is a schematic diagram of a process of uniformly sampling defect detection points in a workpiece defect detection method in one embodiment;

[0030] Figure 8 A schematic diagram of an image of a region to be detected in a workpiece defect detection method in one embodiment;

[0031] Fig. 9 A flow chart for generating a data set for a defect detection phase of a workpiece defect detection method in one embodiment;

[0032] Fig.10 is a structural block diagram of a workpiece defect detection device in one embodiment;

[0033] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0035] First of all, it should be understood that in order to ensure the delivery quality of workpieces, workpieces need to be quality inspected in the workpiece production line. Among them, due to the different process stages of the workpiece, different areas of the workpiece need to be inspected. Therefore, the process of defect detection in different areas of the workpiece is crucial. Taking the welding process as an example, it is necessary to detect defects such as pits, uneven grinding and interruptions in different areas. Taking the gluing process as an example, it is necessary to detect defects such as glue holes and glue breaks in different areas. At present, the following two methods are usually used for workpiece defect detection: 1) In the workpiece production line, quality inspectors visually inspect each area of ​​the workpiece for defects, such as Figure 1 As shown, Figure 1 The following is a flow chart showing the manual inspection of workpiece defects. After the workpiece flows in, the quality inspector visually determines whether the workpiece is qualified or unqualified at the manual inspection station. Qualified workpieces flow out normally to the next process, and unqualified workpieces are reworked or treated as waste; 2) In the assembly line of workpiece production, visual inspection is used to detect workpiece defects, such as Figure 2 As shown, Figure 2The following is a flow chart showing the visual inspection of workpiece defects. After the workpiece flows in, the camera takes a picture of the workpiece, and the neural network model of the visual inspection station performs defect recognition. The qualified workpieces flow out normally to the next process, and the unqualified workpieces are reworked or treated as waste. Among them, due to the large number of inspection areas and types of defects for workpiece defect detection, the inspection requirements of the workpieces are complex, so manual inspection is difficult. In addition, since manual inspection relies on the subjective judgment of quality inspectors, the difference in individual recognition experience leads to high false detection and missed detection rates and low detection efficiency. In particular, the workpieces themselves have different shapes and different types of defect detection, which makes manual recognition unable to be applied to all different workpieces. While increasing the difficulty of manual inspection, it is very easy to cause missed detection and false detection of workpieces. In terms of detection efficiency, if a full manual inspection method is adopted, not only will the production demand not be met in terms of beat, but a large number of unqualified parts will also flow out. To solve the above problems, visual inspection is usually used for workpiece inspection. However, visual inspection also has flaws. The principle of visual inspection relies on deep learning. The images collected by the camera are sent to the neural network model to identify defects. The difference in the division of defect detection areas will cause the image to contain a large number of non-detection object areas, which leads to a large overall pixel area size in the image and a small defect pixel area size, which is not conducive to visual inspection. At the same time, the neural network model usually scales the image to a fixed size during training, and because the model architecture is continuously down-sampled to extract features, the pixel area representing the defect may lose some feature information during multiple down-sampling processes, resulting in missed detection and false detection, which leads to low detection accuracy for current workpiece defect detection.

[0036] In one embodiment, Figure 3 As shown, a method for detecting workpiece defects is provided. This embodiment takes the method applied to a terminal as an example. The terminal includes but is not limited to a personal computer, a laptop computer, a smart phone, and a tablet computer. The terminal includes an acquisition module, a positioning module, a selection module, and a detection module. The acquisition module is used to obtain the pixel position information of the target area in the workpiece image of the workpiece to be detected, wherein the target area refers to a pixel area composed of multiple pixel points that meet the defect detection requirements. The positioning module is used to locate multiple defect detection points from the target area according to the pixel position information. The selection module is used to select the image of the area to be detected in the workpiece image through multiple defect detection points. The detection module is used to perform defect detection on the workpiece to be detected through the image of the area to be detected. The terminal implements the workpiece defect detection process through data interaction processing between the acquisition module, the positioning module, the selection module, and the detection module. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps 202 to 208. Among them:

[0037] Step 202 : obtaining pixel position information of a target area in the workpiece image of the workpiece to be inspected, wherein the target area refers to a pixel area composed of a plurality of pixel points that meet the defect detection requirements.

[0038] It should be noted that the workpiece to be inspected refers to the workpiece waiting for defect detection, and the workpiece image refers to the image of the workpiece that has not been preprocessed after being photographed by the camera device. In the shooting stage, the workpiece can be photographed as a whole or partially. The workpiece can be a mechanical part, an electronic component, a metal casting, a plastic part, etc. Taking a robot as an example, the robot can be photographed when it appears completely in the camera lens, or a key component or functional component of the robot can be selected for shooting, such as shooting the top cover, the rearview mirror base, the rear panel glue hole, the wheel eyebrow or the taillight, etc. The size of the workpiece image can be determined by the shooting parameters of the shooting device. For example, the size of the workpiece image is 800*600. The target area is used to represent the pixel area composed of multiple pixels that meet the defect detection requirements. The target area can be either a continuous pixel area or a combination of discontinuous pixel areas. The present embodiment does not specifically limit the shape of the target area, which can be a regular geometric shape, such as a circle or a square, or an irregular geometric shape.

[0039] It should be noted that the target area is composed of a plurality of pixel points that meet the requirements of defect detection, and the pixel position information of the target area in the workpiece image can be determined by locating the plurality of pixel points, wherein the pixel position information can be specifically a pixel point coordinate value, and the pixel point positioning can be performed by using image processing software for positioning, or by programming, pixel positioning based on feature points, pixel positioning based on image matching, or sub-pixel positioning. For example, in one feasible method, after photographing the workpiece, the two-dimensional coordinates of all pixel points in the image are identified by (x, y), and then the two-dimensional coordinate value of a specific pixel point is selected to obtain the pixel position information of the target area.

[0040] As an example, all pixel points of the target area in the workpiece image constituting the workpiece to be inspected are located, and the two-dimensional coordinate values ​​of all pixel points are used as the pixel position information of the target area, wherein the number of all pixel points in the target area is less than the number of all pixel points in the workpiece image.

[0041] Step 204: locate at least one defect detection point in the target area according to the pixel position information.

[0042] It should be noted that the defect detection point can be either a single pixel point or a set of multiple pixel points that make up the target area. After obtaining the position information of all pixel points in the target area, if defect detection is performed on each pixel point, the amount of defect detection will be huge. Based on the pixel position coordinates in the target area, the pixel points for defect detection can be located in the target area for defect detection of the workpiece to be inspected. The defect detection point refers to the pixel point for defect detection. The method for locating the defect detection point can be either a method of randomly selecting pixel points for positioning or a method of clustering to obtain pixel center points for positioning. The clustering algorithm used for clustering positioning can be specifically K-means, DBSCAN or hierarchical clustering, etc.

[0043] As an example, all pixels in the target area are clustered according to pixel position information to obtain at least one pixel cluster, and a target pixel cluster that meets preset defect detection conditions is selected from multiple pixel clusters, and all pixels in the target pixel cluster are used as defect detection points.

[0044] Step 206 : selecting an image of a region to be inspected in the workpiece image according to each defect inspection point.

[0045] It should be noted that when performing workpiece defect detection, detection is usually directly dependent on the workpiece image. For example, in one feasible method, when the workpiece image is input into the neural network model, the neural network model will pre-process the workpiece image and scale the workpiece image to a fixed size, wherein the scaling of the workpiece image can be set in advance by a professional, and the scaling ratio can be 0.8, 1.0 or 1.2, etc. For example, the workpiece image can be scaled at a scaling ratio of 0.8. It can be understood that the image size and resolution of the workpiece image change before and after scaling, and the workpiece image loses image information due to the reduction of image pixels. The image of the area to be detected is used to characterize the area image waiting for defect detection. Since the image of the area to be detected is selected from the workpiece image, and the image of the area to be detected and the workpiece image both contain pixels for defect detection, the pixel ratio of the defect detection point in the image of the area to be detected is greater than the pixel ratio in the image to be detected, which can avoid the defect of a large pixel ratio in the non-detection area in the workpiece image.

[0046] It can be understood that when selecting the image of the area to be detected in the workpiece image, the sizes of the workpiece image and the image of the area to be detected can be the same or different. For example, in one feasible method, a workpiece area image can be framed in the workpiece image based on each defect detection point, and the workpiece area image can be directly used as the image of the area to be detected. For example, in one feasible method, a circular area is generated with the defect detection point as the geometric center and r as the radius as the image of the area to be detected; the framed workpiece area image can also be pre-processed by size transformation or grayscale to obtain the image of the area to be detected. The parameters between different images of the area to be detected can be the same or different, wherein the sizes of the workpiece image and the image of the area to be detected can be the same or different. For example, in one feasible method, after the workpiece image is captured, the original size of the workpiece image is kept unchanged, and after the defect detection points in the target area of ​​the workpiece image are located, the workpiece area image is firstly framed in the workpiece image based on the defect detection points and preset frame selection parameters, and then the size conversion ratio of the workpiece area image is determined according to the size relationship between the original size of the workpiece image and the image size of the workpiece area image, and the workpiece area image is converted with the size conversion ratio to obtain the image of the area to be detected; alternatively, after the workpiece image is captured, the defect detection points in the target area of ​​the workpiece image are directly located, and then the image of the area to be detected is framed based on the defect detection points with the preset frame selection parameters to obtain the image of the area to be detected.

[0047] As an example, for any defect detection point, with the defect detection point as the geometric center, according to the preset selection parameters under the defect detection point, the workpiece area image is selected in the workpiece image, and the workpiece area image is preprocessed to obtain the image of the area to be detected.

[0048] Step 208: perform defect detection on the workpiece to be inspected based on the image of the area to be inspected.

[0049] It should be noted that when workpiece defect detection is performed based on the image of the area to be inspected, it can be performed based on a neural network model, which can be specifically a logistic regression model, a support vector machine model, and a Mask-RCNN model, etc. For example, in one feasible method, the image of the area to be inspected is input into the workpiece defect detection model, and the image of the area to be inspected is detected by the workpiece defect detection model to determine whether there are workpiece defects, so as to obtain a workpiece defect detection result, wherein the preset workpiece defect detection model can specifically be a binary classification model, that is, the workpiece defect detection result output by the preset workpiece defect detection model may include "the presence of workpiece defects" and "the absence of workpiece defects". It can be understood that the workpiece defect detection model can also output specific workpiece defect type detection results, such as weld pit defects, weld interruption defects, and glue break defects.

[0050] As an example, an image of the area to be inspected is input into a workpiece defect detection model, and feature extraction is performed on the image of the area to be inspected by the workpiece defect detection model to obtain workpiece defect features, which are then classified into two categories to obtain a workpiece defect detection result indicating the presence of workpiece defects in the workpiece image or a workpiece defect detection result indicating the absence of workpiece defects.

[0051] In the above-mentioned workpiece defect detection method, firstly, the pixel position information of the target area in the workpiece image of the workpiece to be detected is obtained. Since the target area is a pixel area composed of multiple pixel points in the workpiece image that meet the defect detection requirements, at least one defect detection point for defect detection can be located from the target area based on the pixel position information; then, the image of the area to be detected is selected in the workpiece image according to each defect detection point, and finally, the defect detection of the workpiece to be detected is completed through the image of the area to be detected. Since the image of the area to be detected is obtained by selecting the image of the workpiece based on the defect detection point, the proportion of pixel areas that need to be detected in the image of the area to be detected is greater than the proportion of pixel areas that need to be detected in the workpiece image, that is, the image of the area to be detected is relatively focused on the pixel points that need to be detected compared with the workpiece image, thereby ensuring that the image of the area to be detected contains fewer non-detection pixel areas compared with directly using the workpiece image for defect detection, so that when detecting workpiece defects, it can rely on more significant defect features, and to a certain extent avoid the defect omission caused by the loss of defect features during the workpiece defect detection process, thereby improving the detection accuracy of defect detection on the workpiece.

[0052] In one embodiment, Figure 4 As shown, according to the pixel position information, at least one defect detection point is located from the target area, including:

[0053] Step 302, locating at least one first plane pixel point in the target area according to the pixel position information, and converting each first plane pixel point into a corresponding spatial pixel point;

[0054] It should be noted that the positioning method of locating defect detection points in the target area by random sampling, full sampling or cluster sampling always uses the intervals between different pixel points on the two-dimensional plane for positioning. However, in the process of workpiece defect detection, the area where defect detection is required in the workpiece to be inspected is usually uneven, and then defect detection relies on the defect detection points obtained by interval sampling on the two-dimensional plane, which cannot reflect the actual intervals between different pixel points in the target area, and is prone to poor detection accuracy of workpiece defect detection due to positioning errors of defect sampling points.

[0055] It should be noted that in addition to the above-mentioned defects, different sampling methods also have their own corresponding problems in the defect detection point positioning method on the two-dimensional plane. Using random sampling to extract defect detection points will result in more images of the area to be detected in the specific application scenario, thereby affecting the detection efficiency of workpiece defect detection. Using random sampling to extract defect detection points will introduce noise or cause information loss or deviation due to uneven sampling. Therefore, in order to ensure the accuracy of industrial workpiece defect detection, this embodiment proposes a uniform sampling method, in which, in the process of uniform sampling, the pixel points are first converted between two-dimensional and three-dimensional coordinates, and then the sampling radius parameters are used to perform uniform sampling in three-dimensional space, and finally the two-dimensional pixel points are converted, and the two-dimensional pixel points are used as defect detection points. The conversion between two-dimensional coordinate values ​​and three-dimensional coordinate values ​​can refer to the following steps: dedistortion, normalization, projection and optimization, and can also be obtained by simple calibration. For example, in an implementable method, it is assumed that the two-dimensional coordinate value of the first plane pixel point in the target area is , then the z coordinate of the first plane pixel point in three-dimensional space can be set to a fixed value , then the three-dimensional coordinate value of the spatial pixel point corresponding to the first plane pixel point is .

[0056] As an example, based on pixel position information, at least one first plane pixel point is determined in the target area, and the two-dimensional coordinate values ​​of each first plane pixel point are extracted. For any first plane pixel point, the coordinate value conversion from the two-dimensional coordinate value to the three-dimensional coordinate value is performed under a preset rule to obtain the spatial pixel point corresponding to each first plane pixel point.

[0057] Step 304: Select at least one candidate spatial pixel point from each spatial pixel point according to a preset sampling algorithm.

[0058] It should be noted that, when sampling, the sampling hyperparameters can be set through visualization tools to complete the sampling of defect detection points, such as "whether to sample", "sampling mode", "sampling fill", "sampling width", "sampling height", "sampling radius", "whether to limit sampling" and the number of samples, etc. The preset sampling algorithm can be a random sampling algorithm, a full sampling algorithm or a uniform sampling algorithm, etc., wherein the candidate spatial pixel points refer to the spatial pixel points waiting to be selected as the corresponding defect detection points.

[0059] As an example, by inputting the three-dimensional coordinate value into a preset uniform sampling algorithm, at least one candidate spatial pixel point is selected from each spatial pixel point.

[0060] Step 306: determine at least one defect detection point based on the candidate plane pixel points converted from the candidate spatial pixel points.

[0061] As an example, candidate plane pixel points converted from candidate spatial pixel points are all used as defect detection points.

[0062] Since uniform sampling utilizes the changes in position coordinates in two-dimensional space and three-dimensional space, at least one defect detection point is selected from multiple first-plane pixel points located in the target area. Therefore, in the process of selecting defect detection points, sampling is performed based on the fixed intervals between each spatial pixel point in three-dimensional space. This ensures that the intervals between the sampled target defect detection points are equal, thereby achieving full coverage of different defect detection points. At the same time, the distance between spatial pixel points can truly feedback the actual intervals between different first-plane pixel points in the target area, and the regular distribution of spatial pixel points will also make subsequent data processing and feature extraction processes more convenient. Therefore, the use of uniform sampling algorithm to locate defect detection points has laid a foundation for improving the accuracy of selecting images in the area to be inspected.

[0063] In one embodiment, selecting the image of the area to be inspected in the workpiece image according to each defect detection point may include: for any defect detection point, selecting the defect detection area corresponding to the defect detection point in the workpiece image; respectively detecting the regional overlap between the defect detection areas that intersect, and screening the image of the area to be inspected in each defect detection area according to the regional overlap.

[0064] It should be noted that after obtaining the defect detection point, a defect detection area can be selected in the workpiece image based on the defect detection point as the center. The defect detection area is used to characterize the area where defect detection can be performed. When the image of the area to be detected is selected through the defect detection point, due to the distance between the defect detection points, the difference in workpiece defect detection between the defect detection areas formed with different defect detection points as the center is small. In order to improve the detection efficiency of workpiece defect detection, after obtaining multiple defect detection points and generating multiple defect detection images with different defect detection points as the center, a regional overlap threshold can be set in advance, and a regional overlap comparison can be performed between the selected defect detection areas that intersect, and according to the relationship between the preset regional overlap threshold and the regional overlap, the process of screening the image of the area to be detected in the defect detection image is completed, wherein the preset regional overlap threshold can be 0.5, 0.6 or 0.7, etc.

[0065] As an example, for any defect detection point, a defect detection area with each defect detection point as the geometric center is selected in the workpiece image; a target defect detection area is randomly selected from multiple defect detection areas, and the area overlap between the target defect detection area and another defect detection area that intersects with the target defect detection area is calculated, and it is determined that the area overlap between the target defect detection area and another defect detection area is less than or equal to a preset area overlap threshold, then the target defect detection area is used as the defect detection area, and the execution step is returned: randomly selecting a target defect detection area from multiple defect detection areas until all defect detection areas are traversed, wherein another detection area refers to any defect detection area in each defect detection area that intersects with the target defect detection area except the target defect detection area.

[0066] In one embodiment, before the step of obtaining pixel position information of the target area in the workpiece image of the workpiece to be inspected, the workpiece image of the workpiece to be inspected can also be segmented and masked to obtain a workpiece mask map; and a pixel area composed of at least one pixel point in the workpiece mask map whose pixel value is greater than or equal to a preset pixel threshold is used as the target area.

[0067] It should be noted that the conventional pixel positioning method requires obtaining the pixel position information in the workpiece image, and the determination of the target area requires a combination of multiple pixel position coordinates, which leads to the process of locating the target area in the workpiece image. The process of locating the irregularly shaped target area is relatively cumbersome. Therefore, the present embodiment proposes a method for segmenting foreground and background pixels based on deep learning, thereby locating the target area using the segmented pixels, wherein the preset foreground and background segmentation model can specifically be a CNN model, a Mask-RCNN model, a YOLO model, a Mask-RCNN model, and the like.

[0068] In this embodiment, before locating multiple pixel points that meet the defect detection requirements by using the preset foreground and background segmentation model, the hyperparameters of the model training can be set in advance or in real time based on the visualization tool, and the workpiece mask image obtained after the workpiece image is segmented and masked by the preset foreground and background segmentation model includes a foreground color area and a background color area, wherein the colors of the foreground color area and the background color area are set by themselves, and the colors of the foreground color area and the background color area are different. For example, in one practicable manner, referring to Figure 5 , Figure 5 For a schematic diagram showing a workpiece image, refer to Figure 6 , Figure 6This is a schematic diagram representing the workpiece mask image, wherein the white area is the foreground color area, i.e., the target area, and the black area is the background color area. It can be understood that different areas are composed of multiple pixel points, and one or more pixel points in the target area can be used as defect detection points, i.e., the defect detection point can be either a single pixel point or a set of multiple pixel points that constitute the foreground color area.

[0069] As an example, a workpiece image is input into a preset foreground and background segmentation model, and a segmentation mask is performed on the workpiece image through the preset foreground and background segmentation model to obtain a workpiece mask map; a pixel area composed of at least one pixel point in the workpiece mask map whose pixel value is greater than or equal to a preset pixel threshold is taken as a target area, wherein the preset pixel threshold can be set according to requirements.

[0070] In one feasible method, the traditional CNN model only considers the feature information of the image in a single dimension when performing artifact segmentation masking, and the neural network structure is relatively complex, which leads to a certain degree of flaws in the segmentation efficiency and accuracy of the image foreground and background segmentation.

[0071] Furthermore, when performing workpiece image segmentation masking, the HarDNet-MSEG model can be used. The model adopts the Enconder-Decoder structure and has a relatively simple network architecture. The specific steps of segmenting and masking the workpiece image and obtaining the workpiece mask map are as follows:

[0072] The workpiece image is subjected to feature extraction at different scales to obtain at least one workpiece scale feature; the workpiece scale features are fused to obtain a multi-scale fusion feature of the workpiece; the workpiece image is segmented and masked according to the multi-scale fusion feature of the workpiece to obtain a workpiece mask map.

[0073] For example, in one implementable manner, the model hyperparameters of the HarDNet-MSEG model are set as follows: the iteration period is 200, the batch size is 16, the learning rate is 0.001, the scaling size is 512, the warm-up training is 50, the loss function is the structural loss, the optimizer is the stochastic gradient descent, the learning attenuator is the cosine decay, the data enhancement is False, the Mosaic enhancement is False, the gradient clipping is 0.5, and the backbone network Backbone is hardnet68.

[0074] It can be understood that the image is downsampled to extract features through the Enconder-Decoder structure, and multi-scale feature maps are fused and upsampled to restore the original image size. Finally, the artifact mask map obtained by segmentation is used to determine the target area. Since the artifact image is segmented and masked using the features of the artifact image at different scales, the details and spatial information of the artifact can be captured more accurately. In addition, due to the simple structure of the Enconder-Decoder, the use of the HarDNet-MSEG model for segmentation masking can take into account the segmentation efficiency and accuracy of the image foreground and background segmentation.

[0075] By performing segmentation and masking on the workpiece image to obtain a workpiece mask map, it is possible to locate a large number of pixels that meet the defect detection requirements without relying on the pixel position information in the image, and then use the pixel value as a basis for judgment to obtain a pixel area composed of multiple pixels in the workpiece mask map whose pixel values ​​are greater than or equal to the preset pixel threshold, thereby completing the determination of the target area. In the process of locating the target area, only the initial positioning of the pixel area through the neural network model and the secondary positioning of the image area through the pixel value need to be performed. Benefiting from the characteristics of the neural network model and the convenience of the pixel screening and sampling process, compared with the method of locating the target area in the workpiece image through the pixel position information, it can avoid the human-computer interaction process in the process of locating the target area and improve the automaticity of the target area positioning. Therefore, it lays a foundation for improving the accuracy of selecting the image of the area to be inspected.

[0076] Reference Figure 7 , Figure 7 : is a schematic diagram of a process for uniformly sampling defect detection points, wherein the input may be a workpiece mask map obtained by segmenting a workpiece image through multiple networks, and then the target area in the workpiece image may be determined based on the mask map, so as to extract a plurality of first plane pixel points in the target area through the pixel position information of the target area, that is, extract the two-dimensional coordinate values ​​of all white pixel points in the foreground white area of ​​the mask map, and convert the two-dimensional coordinate values ​​of all white pixel points into three-dimensional coordinate values ​​in three-dimensional space, and then uniformly sample through a preset sampling radius parameter to obtain spatial pixel points in three-dimensional space, and then convert the plurality of spatial pixel points into candidate plane pixel points in two-dimensional space to obtain defect detection points, and then generate a plurality of defect detection areas based on the defect detection points, that is, generate a plurality of patch boxes of preset sizes, so as to complete the screening of defect detection areas depending on the regional overlap between different defect detection areas, and finally use the screened image of the area to be detected as the output, refer to Figure 8 , Figure 8It is a schematic diagram representing the image of the area to be inspected, wherein any quadrilateral selected area is a patch box, and the patch box displayed in a different color is the patch box currently being screened. There is no specific limitation on different patch boxes, and the patch box is generated based on the defect detection points obtained by uniform sampling.

[0077] When selecting the image of the area to be detected in the workpiece image, the workpiece image can be first segmented and masked to obtain the workpiece mask map, and then the target area is located in the workpiece image according to the pixel value of each pixel point in the workpiece mask map, and the positioning of multiple pixel points that meet the defect detection requirements is completed based on the pixel position information of the target area, and then multiple pixel points that meet the defect detection requirements are uniformly sampled to obtain multiple candidate plane pixel points, and finally multiple defect detection areas are generated with different candidate plane pixel points as geometric centers, and then the multiple defect detection areas are screened by comparing the size relationship between the area overlap between any two defect detection areas that intersect in the multiple defect detection areas and the preset area overlap threshold, and finally the image of the area to be detected waiting for defect detection is screened. Since the different images of the area to be detected obtained after screening can objectively represent the defect conditions of the workpiece at different positions, the screening of the defect detection area based on the area overlap can improve the rhythm of the workpiece defect detection. At the same time, the uniform sampling in three-dimensional space can ensure the positioning accuracy of the defect detection point. Therefore, the use of the image of the area to be detected to perform defect detection on the workpiece to be detected takes into account both detection accuracy and detection efficiency.

[0078] In one embodiment, each defect detection area includes at least one first defect detection area and at least one second defect detection area; for any defect detection point, a defect detection area corresponding to the defect detection point is selected in the workpiece image, including: for any defect detection point, a first defect detection area is selected in the workpiece image with the defect detection point as the center; if it is determined that the number of areas of all first defect detection areas is less than a preset area number threshold, at least one second plane pixel point is collected in the target area; for any second plane pixel point, a second defect detection area is selected in the workpiece image with the second plane pixel point as the geometric center.

[0079] It should be noted that since uniform sampling always relies on a certain interval between pixel points for sampling, when the interval between the uniformly sampled defect detection points is large, the number of images of the area to be inspected waiting for defect detection will be small. In order to further improve the detection accuracy of workpiece defect detection, the defect detection points can be expanded in the target area again to expand the defect detection area, thereby achieving the purpose of expanding the image of the area to be inspected, wherein the first defect detection area refers to the defect detection area selected in the workpiece image according to the first plane pixel points, and the second defect detection area refers to the defect detection area selected in the workpiece image according to the second plane pixel points.

[0080] As an example, for any defect detection point, a first defect detection area is selected in the workpiece image with the defect detection point as the center; it is determined whether the area number of all first defect detection areas is less than the preset area number threshold; if it is determined that the area number of all first defect detection areas is less than the preset area number threshold, second plane pixel points are collected in the target area, wherein the method for collecting the second plane pixel points can refer to the method for collecting defective pixel points that depends on the first plane pixel points, and this embodiment will not be repeated here; for any second plane pixel point, a second defect detection area is selected in the workpiece image with the second plane pixel point as the geometric center.

[0081] When the first defect detection area (i.e., the negative sample defect detection area) is insufficient, sampling can be performed again in the target area to expand the number of defect detection areas. That is, a combination of multiple sampling methods is used to locate the defect detection points in the target area, and then the defect detection of the workpiece to be inspected is completed through the defect detection areas with the expanded number. Therefore, the foundation is laid for further improving the defect detection efficiency of the workpiece to be inspected.

[0082] In one embodiment, the step of performing defect detection on the workpiece to be inspected according to the image of the area to be inspected is executed by the workpiece defect detection model and may also include: obtaining a training sample image and an object annotation file; when annotating the first annotated pixel point of the training sample image according to the first current annotated object in the object annotation file, executing a loop process until all first annotated objects in the object annotation file are traversed; the loop process includes: determining that the first annotated pixel point is a foreground pixel point, then selecting at least one positive sample detection point in the training sample image; for any positive sample detection point, selecting a positive sample area image corresponding to the positive sample detection point in the training sample image; determining that the first annotated pixel point is a background pixel point, then obtaining a new first annotated object in the object annotation file as the first current annotated object.

[0083] It should be noted that, in the workpiece defect detection method of the present embodiment, the defect features are more significant due to the enlargement of the pixel area for defect detection, and the accuracy of workpiece defect detection will be improved to a certain extent in manual detection compared with the traditional manual detection method. The use of a neural network model for visual detection can improve the detection accuracy more significantly, and can reasonably avoid the technical problems of different shapes of workpiece objects, a large number of non-detection object areas in the image, and a large image pixel size and a small defect pixel size. Among them, the workpiece defect detection model is used to characterize the trained neural network model, which can be specifically Mask-RCNN. The training hyperparameters of Mask-RCNN can be set as follows: the iteration cycle is 20,000, the batch size is 16, the learning rate is 0.0025, the maximum zoom size and the minimum zoom size are both set to 512, and the basic configuration is mask_rcnn_R_50_FPN_3x. The detection process can be understood as: the Mask-RCNN detection frame is coarsely positioned and the detection object frame is finely positioned, and the sampling pyramid multi-scale downsampling is used to extract features, which can ensure the detection accuracy to a certain extent.

[0084] It should be noted that the workpiece defect detection model can be used to extract workpiece defect features to complete workpiece defect detection. The workpiece defect features can be image features at a single scale or at multiple scales. The object annotation file is used to annotate the detection object. The training sample image can be collected by professionals before the workpiece defect detection model is trained. It can be understood that the training sample image includes positive sample detection points and negative sample detection points. The positive sample detection point refers to the defect-free training sample image detection point, and the negative sample detection point refers to the defective training sample image detection point, which can be obtained by performing segmentation mask acquisition on the training sample image, and the training sample image is detected foreground and background and the presence or absence of defects through the object annotation file, and then classified to obtain the sample area image used for training the workpiece defect detection model, and the training of the workpiece defect detection model is completed based on the sample area image, wherein the sample area image includes the positive sample area image and the negative sample area image, wherein the foreground pixel point can be set according to the needs, and can be black or white, etc.

[0085] As an example, a training sample image and an object annotation file are obtained; if it is determined that the first annotated pixel point of the first annotated object in the object annotation file in the training sample image is a foreground pixel point, the training sample image is segmented into foreground and background to obtain a training sample mask map, wherein the first annotated object refers to any foreground annotated object in the object annotation file, and the training sample mask map includes at least one positive sample detection point and at least one negative sample detection point; each positive sample detection point and each negative sample detection point are sampled to obtain at least one target positive sample detection point and at least one target negative sample detection point respectively corresponding to each other; according to each target positive sample detection point, a positive sample area image is selected in the training sample image, and according to each target negative sample detection point, a negative sample area image is selected in the training sample image, wherein the positive sample area image and the negative sample area image are used to train a workpiece defect detection model; if it is determined that the first annotated pixel point of the first annotated object in the object annotation file in the training sample image is a background pixel point, the step of determining whether the first annotated pixel point is a foreground pixel point and subsequent steps are returned to execute until all first annotated objects in the object annotation file are traversed.

[0086] It should be noted that, in the process of selecting positive sample region images from training sample images, both region images with defect annotations and region images with high overlap between region images without defect annotations are filtered out.

[0087] In one embodiment, when it is determined that the first annotated pixel point is a foreground pixel point, before the step of selecting at least one sample detection point in the training sample image, the training sample image can also be segmented into foreground and background according to the first annotated pixel point to obtain a training sample mask image; when the second annotated pixel point of the training sample mask image is annotated according to the second current annotated object in the object annotation file; a loop process is executed until all second annotated objects in the object annotation file are traversed; the loop process includes: when it is determined that the second annotated pixel point is a defective pixel point, at least one negative sample detection point is selected in the training sample image; for any negative sample detection point, a negative sample area image corresponding to the negative sample detection point is selected in the training sample image; when it is determined that the second annotated pixel point is not a defective pixel point, a new second annotated object is obtained in the object annotation file as the second current annotated object, wherein both the positive sample area image and the negative sample area image are used to train to obtain a workpiece defect detection model.

[0088] It should be noted that, since the acquisition of the positive sample image only requires determining whether the first annotated pixel is a foreground pixel, it is possible to distinguish whether the pixel is a pixel that needs to be detected. Therefore, when acquiring the positive sample area image, a single logical process that relies on detecting whether the first annotated object is a foreground pixel can be completed. When the first annotated pixel is not a background pixel, it relies on determining whether the second annotated pixel of the second annotated object in the training sample image is a defective pixel, thereby realizing the acquisition of the negative sample area image under the iterative logic.

[0089] As an example, based on the first annotated pixel point, the training sample image is segmented into foreground and background to obtain a training sample mask map; if it is determined that the second annotated pixel point of the second annotated object in the object annotation file in the training sample mask map is a defective pixel point, then based on the second annotated pixel point, the training sample image is segmented into foreground and background to obtain a negative sample mask map, at least one negative sample detection point is selected from the negative sample mask map, and a negative sample area image is selected in the training sample image with each negative sample detection point as the geometric center; if it is determined that the second annotated pixel point is not a defective pixel point, then the step of determining whether the second annotated pixel point is a defective pixel point and subsequent steps are returned, wherein the second annotated object refers to any defective annotated object in the object annotation file.

[0090] In one embodiment, during the training of the workpiece defect detection model, the following steps may also be performed:

[0091] When the number of image areas of the negative sample area image is less than or equal to a preset image area number threshold, increase the positioning parameters of the negative sample area image; and / or obtain the preset image enhancement parameters, and locate the negative sample area image whose size is smaller than the workpiece image in the training sample image according to the image enhancement parameters and each target negative sample detection point.

[0092] It should be noted that in the process of model training, there will be a problem of too few defective samples. In the data processing stage, the offline data enhancement method can be sampled to enhance the two-stage data set, wherein the positioning parameter is used to increase the number of times the negative sample area image is selected, that is, the number of times the defective samples are generated. For example, in an implementable method, the number of times the positive sample area image and the negative sample area image are generated is 1, then the number of times the negative sample area image is generated can be increased to 8, and the training sample data can be enhanced by setting the image enhancement parameters, so that the sample images are not repeated, wherein the image enhancement parameters It is determined by the image enhancement strategy, which includes random translation, rotation, noise and hue. For example, in an implementable manner, the hyperparameters set for the workpiece defect detection model for positive and negative sample image training can be as follows: number of negative sample generation: 8; sampling padding: 0; sampling width: 512; sampling height: 512; sampling radius: 320; sampling IOU filtering threshold: 0.5; random width translation factor: 0~sampling width / 3; random height translation factor: 0~sampling height / 3; random rotation factor: 0°~30°; noise factor: (mean: 0), (variance distribution: (10, 100)); hue factor: (brightness: 0.2), contrast: (0.2), saturation: 0.2), among which the random factor, hue factor and noise factor are all image enhancement parameters.

[0093] In one practicable manner, referring to Fig. 9 , Fig. 9 A flow chart is generated for the dataset representing the defect detection stage, where the original image can be understood as a training sample image, and the annotation file is the annotation object file. The process of workpiece defect detection is as follows:

[0094] Firstly, pixel points are selected in the training sample image by using the annotation of the first annotation object in the object annotation file, and the positive sample area image is finally obtained by uniform sampling and filtering of the pixel area. Also, pixel points are selected in the training sample image by using the annotation of the second annotation object in the object annotation file, and the negative sample area image is finally obtained by uniform sampling and filtering of the pixel area, so as to integrate the training to obtain the workpiece defect detection model, wherein the sampling parameters, positioning parameters and image enhancement parameters can be set based on the visualization tool during the training process.

[0095] Furthermore, multiple pixel points that meet the defect detection requirements in the target area are extracted from the workpiece mask map obtained by segmenting and masking the workpiece image, that is, all white pixel points in the foreground white area of ​​the mask map are extracted, and the two-dimensional coordinate values ​​of all white pixel points are extracted, and the two-dimensional coordinate values ​​of all white pixel points are converted into three-dimensional coordinate values ​​in three-dimensional space, and then uniform sampling is performed through a preset sampling radius parameter to obtain multiple spatial pixel points in three-dimensional space, and then the multiple spatial pixel points are converted into candidate plane pixel points in two-dimensional space, and finally defect detection points are determined based on multiple candidate plane pixel points, and then multiple defect detection areas are selected in the workpiece image based on the multiple defect detection points, that is, multiple patch boxes of preset sizes are selected, so as to complete the screening of defect detection areas depending on the regional overlap between different defect detection areas, and finally the screened defect detection areas are used as the output image of the area to be detected, and finally the workpiece defect detection is completed by inputting the image of the area to be detected into the trained workpiece defect detection model.

[0096] Since the image of the area to be inspected enlarges the pixel area that needs to be detected for defects relative to the workpiece image, the proportion of the pixel area that needs to be detected in the image of the area to be inspected is greater than the proportion of the pixel area that needs to be detected in the workpiece image. Therefore, when detecting workpiece defects, more significant defect features can be relied upon, which to a certain extent avoids the defect omission caused by the loss of defect features during the workpiece defect detection process, thereby solving the problems existing in visual inspection, such as "the shapes of the inspection objects are different, and the image contains a large number of non-inspection object areas" and "the image pixel size is large, and the defect pixel size is small". At the same time, since the relevant parameters can be adjusted based on the number of defect image samples using visualization tools during the training stage, the problem of "too few defect samples" in visual inspection can be avoided simultaneously, thereby improving the detection accuracy of defect detection on workpieces.

[0097] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0098] Based on the same inventive concept, the embodiment of the present application also provides a workpiece defect detection device for implementing the workpiece defect detection method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more workpiece defect detection device embodiments provided below can refer to the limitations of the workpiece defect detection method above, and will not be repeated here.

[0099] In an exemplary embodiment, Fig.10 As shown, a workpiece defect detection device is provided, including: an acquisition module 401, a positioning module 402, a selection module 403 and a detection module 404, wherein:

[0100] An acquisition module 401 is used to acquire pixel position information of a target area in a workpiece image of a workpiece to be inspected, wherein the target area refers to a pixel area composed of a plurality of pixel points that meet the defect detection requirements;

[0101] A positioning module 402, configured to locate at least one defect detection point from the target area according to the pixel position information;

[0102] A selection module 403 is used to select an image of a region to be detected in the workpiece image according to each of the defect detection points;

[0103] The detection module 404 is used to perform defect detection on the workpiece to be detected according to the image of the area to be detected.

[0104] In one embodiment, the positioning module 402 is further configured to:

[0105] According to the pixel position information, at least one first plane pixel point is located in the target area, and each of the first plane pixel points is converted into a corresponding spatial pixel point; according to a preset sampling algorithm, at least one candidate spatial pixel point is selected from each of the spatial pixel points; and according to the candidate plane pixel points obtained by converting each of the candidate spatial pixel points, at least one defect detection point is determined.

[0106] In one embodiment, the selection module 403 is further used for:

[0107] For any of the defect detection points, a defect detection area corresponding to the defect detection point is selected in the workpiece image; the regional overlap between the intersecting defect detection areas is detected respectively, and based on the regional overlap, the image of the area to be detected is screened in each of the defect detection areas.

[0108] In one embodiment, each of the defect detection areas includes at least one first defect detection area and at least one second defect detection area; the selection module 403 is further used to:

[0109] For any of the defect detection points, the first defect detection area is selected in the workpiece image with the defect detection point as the center; if it is determined that the area number of all first defect detection areas is less than a preset area number threshold, at least one second plane pixel point is collected in the target area; for any of the second plane pixel points, a second defect detection area is selected in the workpiece image with the second plane pixel point as the geometric center.

[0110] In one of the embodiments, the workpiece defect detection device also includes a target area determination module; the target area determination module is used to perform segmentation masking on the workpiece image of the workpiece to be inspected to obtain a workpiece mask map; and a pixel area composed of at least one pixel point in the workpiece mask map whose pixel value is greater than or equal to a preset pixel threshold is used as the target area.

[0111] In one of the embodiments, the step of performing defect detection on the workpiece to be inspected based on the image of the area to be inspected is performed by a workpiece defect detection model; the workpiece defect detection device also includes a first labeling module, which is used to obtain a training sample image and an object labeling file; when labeling the first labeled pixel point of the training sample image according to the first current labeled object of the object labeling file, a loop process is executed until all first labeled objects in the object labeling file are traversed; the loop process includes: determining that the first labeled pixel point is a foreground pixel point, then selecting at least one positive sample detection point in the training sample image; for any of the positive sample detection points, selecting a positive sample area image corresponding to the positive sample detection point in the training sample image; determining that the first labeled pixel point is a background pixel point, then obtaining a new first labeled object in the object labeling file as the first current labeled object.

[0112] In one embodiment, the workpiece defect detection device also includes a second labeling module; the second labeling module is used to perform foreground and background segmentation on the training sample image according to the first labeled pixel point to obtain a training sample mask image; when the second labeled pixel point of the training sample mask image is labeled according to the second current labeled object of the object labeling file; a loop process is executed until all second labeled objects in the object labeling file are traversed; the loop process includes: determining that the second labeled pixel point is a defective pixel point, then selecting at least one negative sample detection point in the training sample image; for any of the negative sample detection points, selecting a negative sample area image corresponding to the negative sample detection point in the training sample image; determining that the second labeled pixel point is not the defective pixel point, then obtaining a new second labeled object in the object labeling file as the second current labeled object, wherein the positive sample area image and the negative sample area image are both used to train to obtain the workpiece defect detection model.

[0113] Each module in the above workpiece defect detection device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.

[0114] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig.11 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a workpiece defect detection method is implemented. Those skilled in the art can understand that Fig.11The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0115] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0116] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0117] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0118] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0119] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0120] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A workpiece defect detection method, characterized in that: The method comprises: Obtaining pixel position information of a target area in a workpiece image of the workpiece to be detected, wherein the target area refers to a pixel area composed of at least one pixel point in a workpiece mask image obtained by performing segmentation masking on the workpiece image, the pixel value of which is greater than or equal to a preset pixel threshold; Locating at least one defect detection point from the target area according to the pixel position information; According to each of the defect detection points, an image of a region to be detected is selected from the workpiece image; According to the image of the area to be inspected, defect detection is performed on the workpiece to be inspected, wherein, according to the pixel position information, at least one defect detection point is located from the target area, comprising: Locating at least one first plane pixel point in the target area according to the pixel position information, and converting each of the first plane pixel points into a corresponding spatial pixel point; Selecting at least one candidate spatial pixel point from each of the spatial pixel points according to a preset sampling algorithm; At least one of the defect detection points is determined based on the candidate plane pixel points converted from the candidate space pixel points.

2. The method according to claim 1, characterized in that The step of selecting an image of a region to be detected in the workpiece image according to each of the defect detection points comprises: For any of the defect detection points, selecting a defect detection area corresponding to the defect detection point in the workpiece image; A target defect detection area is randomly selected from each of the defect detection areas, and the area overlap between the target defect detection area and another defect detection area is calculated. If it is determined that the area overlap is less than or equal to a preset area overlap threshold, the target defect detection area is used as the image of the area to be detected, and the execution step is returned to: a target defect detection area is randomly selected from each of the defect detection areas until all defect detection areas are traversed, wherein the other defect detection area refers to any defect detection area in each of the defect detection areas that intersects with the target defect detection area except the target defect detection area.

3. The method according to claim 2, characterized in that Each of the defect detection areas includes at least one first defect detection area and at least one second defect detection area; For any of the defect detection points, selecting a defect detection area corresponding to the defect detection point in the workpiece image includes: For any of the defect detection points, taking the defect detection point as the center, selecting the first defect detection area in the workpiece image; Determining that the number of regions of all first defect detection regions is less than a preset region number threshold, collecting at least one second plane pixel point in the target region; For any pixel point on the second plane, a second defect detection area is selected in the workpiece image with the pixel point on the second plane as the geometric center.

4. The method according to claim 1, characterized in that Before the step of obtaining pixel position information of a target area in the workpiece image of the workpiece to be detected, the method further includes: Inputting the workpiece image into a preset foreground and background segmentation model, performing segmentation masking on the workpiece image by using the preset foreground and background segmentation model, and obtaining the workpiece mask map; A pixel area formed by at least one pixel point in the workpiece mask image whose pixel value is greater than or equal to a preset pixel threshold is used as a target area.

5. The method according to claim 1, characterized in that The step of performing defect detection on the workpiece to be detected based on the image of the area to be detected is performed by a workpiece defect detection model; the method further includes: Obtain training sample images and object annotation files; When annotating the first annotated pixel point of the training sample image according to the first current annotated object of the object annotating file, a loop process is performed until all the first annotated objects in the object annotating file are traversed; the loop process includes: Determining that the first annotated pixel point is a foreground pixel point, selecting at least one positive sample detection point in the training sample image; for any of the positive sample detection points, selecting a positive sample area image corresponding to the positive sample detection point in the training sample image; It is determined that the first annotated pixel point is a background pixel point, and a new first annotated object is obtained from the object annotating file as the first current annotated object.

6. The method according to claim 5, characterized in that Before the step of determining that the first annotated pixel point is a foreground pixel point, selecting at least one positive sample detection point in the training sample image, the method further includes: According to the first annotated pixel points, the training sample image is segmented into foreground and background to obtain a training sample mask image; When the second annotated pixel point of the training sample mask image is annotated according to the second current annotated object of the object annotating file; a loop process is performed until all the second annotated objects in the object annotating file are traversed; the loop process includes: Determining that the second annotated pixel point is a defective pixel point, selecting at least one negative sample detection point in the training sample image; for any of the negative sample detection points, selecting a negative sample area image corresponding to the negative sample detection point in the training sample image; If it is determined that the second annotated pixel point is not the defective pixel point, a new second annotated object is obtained in the object annotation file as the second current annotated object, wherein both the positive sample area image and the negative sample area image are used to train the workpiece defect detection model.

7. A workpiece defect detection device, characterized in that: The device comprises: An acquisition module is used to acquire pixel position information of a target area in a workpiece image of a workpiece to be detected, wherein the target area refers to a pixel area composed of at least one pixel point whose pixel value is greater than or equal to a preset pixel threshold in a workpiece mask image obtained by performing segmentation masking on the workpiece image; A positioning module, used for locating at least one defect detection point from the target area according to the pixel position information; A selection module, used for selecting an image of a region to be detected in the workpiece image according to each of the defect detection points; A detection module is used to perform defect detection on the workpiece to be inspected based on the image of the area to be inspected, wherein the positioning module is also used to locate at least one first plane pixel point in the target area based on the pixel position information, and convert each of the first plane pixel points into a corresponding space pixel point; select at least one candidate space pixel point from each of the space pixel points according to a preset sampling algorithm; and determine at least one of the defect detection points based on the candidate plane pixel points converted from each of the candidate space pixel points.

8. The device according to claim 7, characterized in that The selection module is also used for: For any of the defect detection points, a defect detection area corresponding to the defect detection point is selected in the workpiece image; a target defect detection area is randomly selected from each of the defect detection areas, and the area overlap between the target defect detection area and another defect detection area is calculated; if it is determined that the area overlap is less than or equal to a preset area overlap threshold, the target defect detection area is used as the image of the area to be detected, and the execution step is returned to: a target defect detection area is randomly selected from each of the defect detection areas until all defect detection areas are traversed, wherein the other defect detection area refers to any defect detection area in each of the defect detection areas that intersects with the target defect detection area except the target defect detection area.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Defect detection method and device, electronic equipment and storage medium

    CN117218062A

  • Neural network model training method, product defect detection method and related device

    CN117809154A