Injection molded parts appearance defect detection method, device, electronic equipment and storage medium

By stepping through preset detection points to search for gray value mutation points and segmenting images, the problem of insufficient processing capabilities of the injection molded part appearance detection model for complex backgrounds is solved, the detection precision and accuracy are improved, and it is suitable for detection tasks in complex environments.

CN118096751BActive Publication Date: 2024-08-27GD MIDEA AIR CONDITIONING EQUIP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410504142.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-25
Publication Date
2024-08-27
Estimated Expiration
2044-04-25

AI Technical Summary

Technical Problem

The appearance detection model of injection molded parts in the existing technology has insufficient processing capabilities for complex background images, resulting in a decrease in detection accuracy, inability to effectively remove background interference, and affecting detection results.

Method used

Use preset detection points to stepwise search for gray value mutation points, determine effective gray value mutation points to separate the foreground boundary lines, remove the background, segment the image into sub-images and input the detection model to improve image quality and detection accuracy.

Benefits of technology

By removing background interference, the precision and accuracy of appearance defect detection of injection molded parts are improved, making it suitable for detection tasks in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118096751B
    Figure CN118096751B
Patent Text Reader

Abstract

The present invention provides a method, device, electronic device and storage medium for detecting appearance defects of injection molded parts, belonging to the field of intelligent detection technology. The method comprises: determining a plurality of preset detection points for step-by-step searching of gray value mutation points on the appearance binary image of the injection molded part to be detected, and selecting at least two valid points from the gray value mutation points to determine the foreground separation boundary line, and then inputting the image with the background removed into the appearance defect detection model. Before inputting the injection molded part image into the detection model, the present invention uses the preset detection points to step-by-step search for the pixel points with gray value mutation in the image, and excludes the gray value mutation points affected by the water outlet or appearance defects, and determines the foreground separation boundary line in the image according to at least two valid gray value mutation points, thereby pre-processing the appearance binary image to remove the background, so that the image input into the model is more effective and has fewer interference factors, and can improve the accuracy of injection molded part appearance defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent detection technology, and in particular to a method, device, electronic equipment and storage medium for detecting appearance defects of injection molded parts. Background Art

[0002] Detecting defects on the appearance of injection molded parts is an indispensable part of the product production process. The use of machine vision inspection technology for appearance inspection has also been widely used in precision manufacturing production lines, online automated inspection of industrial product quality and other fields.

[0003] At present, when machine vision inspection technology is used to inspect the appearance of injection molded parts, the original image taken is often directly input into the inspection model to obtain the appearance defect detection results output by the inspection model.

[0004] However, since the original images have not been properly preprocessed, the practice of directly inputting the original images into the detection model is only applicable to simple and variable controllable environments such as laboratories. Once the detection background in the original image becomes complex, the performance of the detection model will be seriously affected. Summary of the invention

[0005] The present invention provides a method, a device, an electronic device and a storage medium for detecting appearance defects of injection molded parts, which are used to solve the defect of not properly preprocessing the original image in the prior art.

[0006] In a first aspect, the present invention provides a method for detecting appearance defects of injection molded parts, comprising:

[0007] Binarization is performed on the photographed image of the injection molded part to be inspected to obtain a binary image of the appearance;

[0008] Determine a plurality of preset detection points on the appearance binary image, and use the preset detection points to stepwise search for gray value mutation points;

[0009] Selecting at least two valid gray value mutation points from all gray value mutation points to determine a foreground separation boundary line based on the valid gray value mutation points;

[0010] According to the foreground separation boundary line, the background in the appearance binary image is removed to obtain a detection binary image;

[0011] The detected binary image is input into an appearance defect detection model to obtain an appearance defect detection result output by the appearance defect detection model.

[0012] According to a method for detecting appearance defects of injection molded parts provided by the present invention, the step of determining a plurality of preset detection points on the appearance binary image comprises:

[0013] Determining the number of the preset inspection points according to the specification parameters of the injection molded part to be inspected;

[0014] The distribution of the preset detection points is determined according to the position of the injection molded part to be detected on the appearance binary image.

[0015] According to a method for detecting appearance defects of injection molded parts provided by the present invention, the plurality of preset detection points at least include a first search point set and a second search point set;

[0016] The first search point set and the second search point set each include at least two of the preset detection points;

[0017] When using the preset detection points to stepwise search for grayscale value mutation points, the moving direction of all preset detection points in the first search point set is a first direction, and the moving direction of all preset detection points in the second search point set is a second direction, and the first direction and the second direction are opposite to each other.

[0018] According to a method for detecting appearance defects of injection molded parts provided by the present invention, the arrangement directions of the first search point set and the second search point set are both perpendicular to the width direction or the length direction of the appearance binary image;

[0019] In the case where the arrangement direction is perpendicular to the width direction of the appearance binary image, the first direction and the second direction are respectively toward two side edges of the appearance binary image in the width direction;

[0020] In a case where the arrangement direction is perpendicular to the length direction of the appearance binary image, the first direction and the second direction are respectively oriented toward two side edges of the appearance binary image in the length direction.

[0021] According to a method for detecting appearance defects of injection molded parts provided by the present invention, for any preset detection point, a search point set to which the any preset detection point belongs is determined to determine a step direction when stepping and searching for a gray value mutation point, and the stepping and searching for a gray value mutation point using the preset detection point comprises:

[0022] When the gray value of the pixel point where any of the preset detection points is located is 1, controlling any of the preset detection points to perform step search in the step direction with a step length of one pixel;

[0023] Determine whether the grayscale value of the pixel point where any preset detection point is located after each step search has a sudden change;

[0024] If no mutation occurs, controlling any of the preset detection points to continue stepping search until the grayscale value of the pixel point where the preset detection point is located undergoes a mutation;

[0025] The pixel point where the grayscale value suddenly changes after the step search of any preset detection point is taken as the grayscale value sudden change point.

[0026] According to a method for detecting appearance defects of injection molded parts provided by the present invention, the step of selecting at least two valid gray value mutation points from all gray value mutation points comprises:

[0027] Calculating the first slope and the second slope between each gray value mutation point and two adjacent gray value mutation points;

[0028] If the directions of the first slope and the second slope are inconsistent, the gray value mutation point is regarded as an invalid gray value mutation point;

[0029] The invalid gray value mutation points among all gray value mutation points are removed to obtain the valid gray value mutation points.

[0030] According to a method for detecting appearance defects of injection molded parts provided by the present invention, the foreground separation boundary line is determined based on the effective gray value mutation point, including:

[0031] Perform straight line fitting on all the effective gray value mutation points based on the least square method to obtain a fitting straight line;

[0032] The straight line where the two effective gray value mutation points with the shortest vertical distance to the fitting straight line are located is used as the foreground separation boundary line.

[0033] According to a method for detecting appearance defects of injection molded parts provided by the present invention, the step of inputting the detection binary image into an appearance defect detection model to obtain an appearance defect detection result output by the appearance defect detection model comprises:

[0034] Using a sliding window to divide the detection binary image into a plurality of sub-images;

[0035] Input each of the sub-images into the appearance defect detection model in turn to obtain an appearance defect detection result output by the appearance defect detection model; the appearance defect detection result includes a detection result corresponding to each of the sub-images.

[0036] According to a method for detecting appearance defects of injection molded parts provided by the present invention, the method of segmenting the detection binary image into a plurality of sub-images using a sliding window comprises:

[0037] Controlling the sliding window to move stepwise on the detection binary image according to a preset step length to preliminarily define the segmentation lines of the plurality of sub-images;

[0038] The detected binary image is divided according to the dividing line to obtain a plurality of sub-images.

[0039] According to a method for detecting appearance defects of injection molded parts provided by the present invention, after preliminarily defining the segmentation lines of a plurality of sub-images, the method further comprises:

[0040] If it is determined that there is an abnormal pixel point on the segmentation line, the abnormal pixel point is a pixel point with a gray value of 0;

[0041] then steppingly adjusting the position of the segmentation line in a direction perpendicular to the segmentation line until the abnormal pixel point no longer exists on the segmentation line;

[0042] The new sub-image obtained by segmentation after stepwise adjustment of the position of the segmentation line is preprocessed so that the size of the new sub-image is the same as the size of the sub-image obtained by segmentation before stepwise adjustment of the position of the segmentation line.

[0043] According to a method for detecting appearance defects of injection molded parts provided by the present invention, the preset step size is smaller than the size of the sliding window.

[0044] According to a method for detecting appearance defects of injection molded parts provided by the present invention, the appearance defect detection result is a result image obtained by marking the appearance defects existing in the appearance binary image with a target frame;

[0045] Accordingly, after obtaining the appearance defect detection result output by the appearance defect detection model, the method further includes:

[0046] If the area of ​​the appearance defect is larger than the first preset area, the injection molded part to be inspected is determined to be unqualified;

[0047] If the area of ​​the appearance defect is less than or equal to the first preset area but greater than the second preset area, and there are other appearance defects within the preset range of the appearance defect, then the injection molded part to be inspected is determined to be unqualified;

[0048] If the area of ​​the appearance defect is less than or equal to the second preset area, it is confirmed that the injection molded part to be inspected is qualified.

[0049] In a second aspect, the present invention further provides an injection molded part appearance defect detection device, comprising:

[0050] A binarization processing unit is used to perform binarization processing on the photographed image of the injection molded part to be inspected to obtain a binarized image of the appearance;

[0051] A mutation point search unit, used for determining a plurality of preset detection points on the appearance binary image, so as to stepwise search for gray value mutation points using the preset detection points;

[0052] A boundary line determination unit, used to select at least two valid gray value mutation points from all gray value mutation points, so as to determine a foreground separation boundary line based on the valid gray value mutation points;

[0053] A background removal unit, used to remove the background in the appearance binary image according to the foreground separation boundary line to obtain a detection binary image;

[0054] The defect detection unit is used to input the detection binary image into the appearance defect detection model to obtain the appearance defect detection result output by the appearance defect detection model.

[0055] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements any one of the above-described methods for detecting appearance defects of injection molded parts.

[0056] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described methods for detecting appearance defects of injection molded parts.

[0057] The method, device, electronic device and storage medium for detecting appearance defects of injection molded parts provided by the present invention use preset detection points to step-search for pixel points with sudden grayscale value changes in the image before inputting the image of the injection molded part into the detection model, and exclude grayscale value mutation points affected by the water outlet or appearance defects, and determine the foreground separation boundary line in the image based on at least two valid grayscale value mutation points, thereby preprocessing the appearance binary image to remove the background, so that the image input into the model is more effective and has fewer interference factors, which can improve the accuracy of injection molded part appearance defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0059] Figure 1 This is one of the flow diagrams of the method for detecting appearance defects of injection molded parts provided by the present invention;

[0060] Figure 2 This is one of the schematic diagrams of the preset detection point stepwise search for gray value mutation points provided by the present invention;

[0061] Figure 3 This is the second schematic diagram of the preset detection point stepwise search for the gray value mutation point provided by the present invention;

[0062] Figure 4This is the third schematic diagram of the preset detection point stepwise search for gray value mutation point provided by the present invention;

[0063] Figure 5 This is the fourth schematic diagram of the preset detection point stepwise search for the gray value mutation point provided by the present invention;

[0064] Figure 6 This is the second flow chart of the method for detecting appearance defects of injection molded parts provided by the present invention;

[0065] Figure 7 It is a schematic diagram of the flow of the air conditioner panel appearance detection method provided by the present invention;

[0066] Figure 8 It is a structural schematic diagram of the device for detecting appearance defects of injection molded parts provided by the present invention;

[0067] Fig. 9 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0068] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0069] It should be noted that, in the description of the present invention, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "includes a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances.

[0070] The terms "first", "second", etc. in the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more.

[0071] Combine the following Figure 1-Figure 9 The invention describes the method, device, electronic device and storage medium for detecting appearance defects of injection molded parts.

[0072] It should be noted that the executor of the injection molded part appearance defect detection method provided by the present invention is the corresponding injection molded part appearance detection device, which includes or is connected to a server or computer equipment, and the specific forms include but are not limited to mobile phones, tablet computers, laptop computers, PDAs, vehicle-mounted electronic devices, wearable devices, ultra-mobile personal computers (Ultra-Mobile Personal Computer, UMPC), netbooks or personal digital assistants (Personal Digital Assistant, PDA) and other devices.

[0073] Figure 1 FIG. 1 is one of the flow charts of the method for detecting appearance defects of injection molded parts provided by the present invention, such as Figure 1 As shown, including but not limited to the following steps:

[0074] Step 110: binarizing the image of the injection molded part to be inspected to obtain a binary image of the appearance.

[0075] The binarization process refers to the process of converting the captured image of the injection molded part to be inspected into a binary image containing only two pixel values.

[0076] For example, the captured image of the injection molded part to be inspected is converted into a binary image containing only two pixel values: the minimum grayscale value (0, representing black) and the maximum grayscale value (1 or 255, representing white).

[0077] Before performing binarization processing on the photographed image of the injection molded part to be inspected, it is first necessary to obtain the photographed image of the injection molded part to be inspected.

[0078] For example, the camera is installed directly above the conveyor belt, with the side of the injection molded part to be inspected facing directly above the conveyor belt. When the injection molded part to be inspected is transported through the conveyor belt, the camera is used to photograph the injection molded part to be inspected, so as to obtain the image of the injection molded part to be inspected. The camera can also be installed directly in front of the conveyor belt, with the side of the injection molded part to be inspected facing directly in front of the conveyor belt, and the camera can also be used to obtain the image of the injection molded part to be inspected.

[0079] After obtaining the captured image of the injection molded part to be inspected, the captured original image is not directly input into the appearance defect detection model. Instead, the captured image of the injection molded part to be inspected is first binarized to simplify the information in the captured image and highlight the target contour and features of the injection molded part to be inspected, thereby obtaining a binary appearance image that is convenient for subsequent processing and analysis.

[0080] Optionally, the photographing device for photographing the injection molded parts to be inspected is an 8K line scan camera and a large depth of field lens.

[0081] Optionally, the injection molded part to be inspected is photographed using tunnel light imaging technology.

[0082] Step 120: determining a plurality of preset detection points on the appearance binary image, and using the preset detection points to stepwise search for grayscale value mutation points.

[0083] Specifically, after binarizing the captured image to obtain an appearance binary image, multiple preset detection points are selected on the appearance binary image, and the selected multiple preset detection points are respectively moved stepwise on the appearance binary image, thereby searching for grayscale value mutation points on the appearance binary image.

[0084] The grayscale value mutation point refers to a point where the grayscale value of the pixel at which the preset detection point is located suddenly changes during the stepping process of any preset detection point. Generally, the grayscale value of the pixel at which the preset detection point is located changes from the maximum grayscale value (1 or 255) to the minimum grayscale value (0). In this case, the pixel at which the preset detection point is located before the grayscale value mutation or the pixel at which the preset detection point is located after the grayscale value mutation can be determined as the grayscale value mutation point.

[0085] In one embodiment, the step of determining a plurality of preset inspection points on the appearance binary image includes: determining the number of the preset inspection points according to specification parameters of the injection molded part to be inspected; and determining the distribution of the preset inspection points according to the position of the injection molded part to be inspected on the appearance binary image.

[0086] For example, when the specification parameters of the injection molded parts to be inspected are relatively small, 5 to 8 preset inspection points can be selected on the appearance binary image; when the specification parameters of the injection molded parts to be inspected are relatively large, 8 to 16 preset inspection points can be selected on the appearance binary image.

[0087] Furthermore, after the number of preset detection points is determined, the distribution of the preset detection points is determined according to the position of the injection molded part to be detected on the appearance binary image.

[0088] For example, when the upper and / or lower boundaries of the injection molded part to be inspected coincide with the upper and / or lower boundaries of the appearance binary image, respectively, the preset detection points are arranged and distributed longitudinally at equal or unequal intervals in a direction perpendicular to the upper and / or lower boundaries of the appearance binary image; when the left and / or right boundaries of the injection molded part to be inspected coincide with the left and / or right boundaries of the appearance binary image, the preset detection points are arranged and distributed transversely at equal or unequal intervals in a direction perpendicular to the left and / or right boundaries of the appearance binary image. It can be understood that the upper, lower, left, and right used here are to clearly describe the distribution of the preset detection points on the appearance binary image and should not be regarded as a limitation to the present invention.

[0089] Step 130: Select at least two valid gray value mutation points from all gray value mutation points to determine a foreground separation boundary line based on the valid gray value mutation points.

[0090] The foreground separation boundary line refers to the boundary line between the injection molded part to be detected (foreground) and the environment (background) such as the conveyor belt and the production workshop in the appearance binary image.

[0091] Specifically, after the grayscale value mutation point on the appearance binary image is searched step by step using the preset detection points, the searched grayscale value mutation point may be any intersection point on the boundary line between the foreground and the background in the appearance binary image, or it may be any point on the boundary of the appearance defect, sprue, etc. in the injection molded part to be detected in the appearance binary image.

[0092] Therefore, in order to better determine the boundary line between the injection molded part to be inspected and the environmental background in the appearance binary image, it is necessary to eliminate the interference of grayscale value mutation points located on the boundaries of appearance defects, water outlets, etc., and select at least two valid grayscale value mutation points located on the dividing line between the foreground and the background from the grayscale value mutation points searched step by step from multiple preset detection points, and determine the foreground separation boundary line based on the selected valid grayscale value mutation points.

[0093] Step 140: removing the background in the appearance binary image according to the foreground separation boundary line to obtain a detection binary image.

[0094] Specifically, after determining the foreground separation boundary line through the effective gray value mutation points searched by the preset detection point step, the appearance binary image and the environmental background such as the conveyor belt and the production workshop are cropped according to the foreground separation boundary line, the background in the appearance binary image is removed, and the foreground composed of the injection molded parts to be inspected in the appearance binary image is retained to obtain the detection binary image.

[0095] Step 150: inputting the detected binary image into an appearance defect detection model to obtain an appearance defect detection result output by the appearance defect detection model.

[0096] Among them, the appearance defect detection result refers to the result of judging whether any of the appearance defects such as color noise, material flower, clamping line, black spot, scratch, top white, air mark, bubble, diffusion mark, oil stain, mold dust, bulge, etc. are detected on the inspection binary image corresponding to the injection molded part to be inspected.

[0097] Specifically, the detection binary image after removing the background is input into the trained appearance defect detection model to obtain the appearance defect detection result output by the appearance defect detection model, indicating whether there is an appearance defect on the injection molded part to be detected.

[0098] It should be noted that the appearance defect detection model can be obtained by training a plurality of historical inspection binary images in the production process and a plurality of corresponding labels annotated with the appearance defect detection results to any machine vision algorithm such as Convolutional Neural Networks (CNN), Generative Adversarial Networks (GAN), Multi-Scale Convolutional Neural Networks (MS-CNN) or Support Vector Machine (SVM), and the present invention does not impose any limitation on this.

[0099] Whether it is the photographed image of the injection molded part to be inspected or the appearance binary image, the environmental background therein will not contain the appearance defects of the injection molded part. Due to the limitations of photographic imaging, there is often an environmental background in the photographed image of the injection molded part to be inspected. After the photographed image is binarized, if the appearance binary image is not preprocessed to remove the background and retain the foreground, but the appearance binary image containing the background is used to train the appearance defect detection model, or is used to actually detect the appearance defects of the injection molded part, it will greatly affect the accuracy of the appearance defect detection model.

[0100] The method for detecting appearance defects of injection molded parts provided by the present invention uses preset detection points to step-search for pixel points with sudden grayscale value changes in the image before inputting the injection molded part image into the detection model, and excludes grayscale value mutation points affected by the water outlet or appearance defects, and determines the foreground separation boundary line in the image according to at least two valid grayscale value mutation points, thereby performing preprocessing on the appearance binary image to remove the background, so that the image input into the model is more effective and has fewer interference factors, and can improve the accuracy of injection molded part appearance defect detection.

[0101] Based on the above embodiment, as an optional embodiment, the multiple preset detection points include at least a first search point set and a second search point set;

[0102] The first search point set and the second search point set each include at least two of the preset detection points;

[0103] When using the preset detection points to stepwise search for grayscale value mutation points, the moving direction of all preset detection points in the first search point set is a first direction, and the moving direction of all preset detection points in the second search point set is a second direction, and the first direction and the second direction are opposite to each other.

[0104] Specifically, the plurality of preset detection points determined on the appearance binary image at least include a first search point set and a second search point set, and the first search point set and the second search point set each include at least two preset detection points. Furthermore, the moving direction of all the preset detection points in the first search point set when stepping and searching for gray value mutation points is a first direction, and the moving direction of all the preset detection points in the second search point set when stepping and searching for gray value mutation points is a second direction opposite to the first direction.

[0105] Therefore, when the gray value mutation point is searched step by step using the preset detection points, there are two sets of preset detection points for stepping the pixel values ​​of the gray value mutation, and the movement search directions of the two sets of preset detection points are opposite. As the two sets of preset detection points continue to move step by step, at least two relative boundaries of the injection molded part to be detected in the appearance binary image will be searched.

[0106] The method for detecting appearance defects of injection molded parts provided by the present invention can perform step-by-step search on grayscale value mutation points in an appearance binary image from two directions by dividing multiple preset detection points into a first search point set and a second search point set, so as to search for at least two relative boundaries of the injection molded parts to be detected in the appearance binary image.

[0107] Based on the above embodiment, as an optional embodiment, the arrangement direction of the first search point set and the second search point set are both perpendicular to the width direction or the length direction of the appearance binary image;

[0108] In the case where the arrangement direction is perpendicular to the width direction of the appearance binary image, the first direction and the second direction are respectively toward two side edges of the appearance binary image in the width direction;

[0109] In a case where the arrangement direction is perpendicular to the length direction of the appearance binary image, the first direction and the second direction are respectively oriented toward two side edges of the appearance binary image in the length direction.

[0110] Figure 2 FIG. 1 is one of the schematic diagrams of the preset detection point stepwise search for gray value mutation points provided by the present invention, such as Figure 2As shown, the multiple preset detection points include a first search point set and a second search point set. The first search point set consists of five preset detection points on the left that are arranged in a width direction perpendicular to the appearance binary image, and the second search point set consists of five preset detection points on the right that are also arranged in a width direction perpendicular to the appearance binary image.

[0111] Correspondingly, the direction in which the five preset detection points in the first search point set step by step search for the grayscale value mutation point is parallel to the left direction of the width direction of the appearance binary image, and the direction in which the five preset detection points in the second search point set step by step search for the grayscale value mutation point is parallel to the right direction of the width direction of the appearance binary image.

[0112] Optionally, the arrangement directions of the first search point set and the second search point set are both perpendicular to the length direction of the appearance binary image. Accordingly, the direction in which all preset detection points in the first search point set step by step search for grayscale value mutation points is an upward direction parallel to the length direction of the appearance binary image; the direction in which all preset detection points in the second search point set step by step search for grayscale value mutation points is a downward direction parallel to the length direction of the appearance binary image.

[0113] It can be understood that the width direction and the length direction of the appearance binary image are relative.

[0114] The method for detecting appearance defects of injection molded parts provided by the present invention arranges multiple preset detection points in the first search point set or the second search point set side by side, and the arrangement directions are perpendicular to the width / length direction of the appearance binary image, so that the preset detection points can accurately search for the grayscale value mutation points of the foreground and background in the appearance binary image in the width / length direction to the greatest extent when stepping to search for the grayscale value mutation points, thereby accurately determining the foreground separation boundary line, so as to more accurately remove the background of the appearance binary image.

[0115] Based on the above embodiment, as an optional embodiment, for any preset detection point, determining the search point set to which the any preset detection point belongs, so as to determine the stepping direction when stepping and searching for the gray value mutation point, the stepping and searching for the gray value mutation point using the preset detection point includes:

[0116] When the gray value of the pixel point where any of the preset detection points is located is 1, controlling any of the preset detection points to perform step search in the step direction with a step length of one pixel;

[0117] Determine whether the grayscale value of the pixel point where any preset detection point is located after each step search has a sudden change;

[0118] If no mutation occurs, controlling any of the preset detection points to continue stepping search until the grayscale value of the pixel point where the preset detection point is located undergoes a mutation;

[0119] The pixel point where the grayscale value suddenly changes after the step search of any preset detection point is taken as the grayscale value sudden change point.

[0120] Specifically, Figure 2 As shown, the first preset detection point A in the first search point set is taken as an example.

[0121] When using the preset detection point A to stepwise search for the grayscale value mutation point, first determine the search point set to which the preset detection point A belongs. If the preset detection point A belongs to the first search point set, then the stepping direction of the preset detection point A when stepping search for the grayscale value mutation point is the first direction, that is, the left direction parallel to the width direction of the appearance binary image.

[0122] After determining the preset detection point A on the appearance binary image, first obtain the grayscale value of the pixel where the preset detection point A is located. If the grayscale value of the pixel where the preset detection point A is located is 1, control the preset detection point A to perform a step search in the left stepping direction with a step length of one pixel, and determine whether the grayscale value of the pixel where the preset detection point A is located has a sudden change.

[0123] The grayscale value of the pixel where the preset detection point A is located in the previous step is 1. After moving one pixel in a step, if the grayscale value of the pixel where the preset detection point A is located is 0, it means that the grayscale value has undergone a mutation. If the grayscale value remains at 1, it means that the grayscale value has not undergone a mutation.

[0124] If the grayscale value of the pixel where the preset detection point A is located does not suddenly change, the preset detection point A is controlled to continue to step leftward until the grayscale value of the pixel where the preset detection point A is located suddenly changes.

[0125] If the gray value of the pixel point where the preset detection point A is located changes suddenly, the preset detection point A is controlled to end the step search, and the pixel point whose gray value changes suddenly after the step search ends is used as the gray value mutation point.

[0126] It is understandable that for each preset detection point, a step search can be performed on the appearance binary image according to the above steps to search for multiple gray value mutation points.

[0127] The method for detecting appearance defects of injection molded parts provided by the present invention controls the preset detection point to perform a fine search with a step size of 1 pixel when the grayscale value of the pixel point where the preset detection point is located is 1, and controls the grayscale value of the pixel point where the preset detection point is located to continuously perform a step search when no mutation occurs, until a pixel point with a mutation occurs in the grayscale value is searched, thereby accurately determining the foreground separation boundary line to perform more accurate background removal on the appearance binary image.

[0128] Based on the above embodiment, as an optional embodiment, selecting at least two valid gray value mutation points from all gray value mutation points includes:

[0129] Calculating the first slope and the second slope between each gray value mutation point and two adjacent gray value mutation points;

[0130] If the directions of the first slope and the second slope are inconsistent, the gray value mutation point is regarded as an invalid gray value mutation point;

[0131] The invalid gray value mutation points among all gray value mutation points are removed to obtain the valid gray value mutation points.

[0132] Among them, if the gray value mutation point searched by the preset detection point step is a valid gray value mutation point, it means that the gray value mutation point is exactly located at the boundary between the foreground and the background in the appearance binary image. Correspondingly, the gray value mutation point located at the boundary of the appearance defect, water outlet, etc. on the injection molded part is an invalid gray value mutation point and needs to be excluded in the process of determining the foreground separation boundary line.

[0133] Specifically, Figure 3 2 is a schematic diagram of the preset detection point stepwise search for gray value mutation point provided by the present invention, such as Figure 2 and Figure 3 As shown, the first search point set includes five preset detection points A, B, C, D, and E. After the five preset detection points are step-wise searched, the obtained gray value mutation points a, c, d, and e are relatively located on the same straight line, while the gray value mutation point b is located at a large position different from the other gray value mutation points.

[0134] Furthermore, the first slope between the gray value mutation point b and the gray value mutation point a is calculated, and the second slope between the gray value mutation point b and the gray value mutation point c is also calculated. It can be obtained that the directions of the first slope and the second slope are inconsistent, so the gray value mutation point b is regarded as an invalid gray value mutation point.

[0135] Using the same method, the first slope between the gray value mutation point c and the gray value mutation point b is calculated, and the second slope between the gray value mutation point c and the gray value mutation point d is also calculated. At this time, the directions of the first slope and the second slope are consistent, and the gray value mutation point c is not regarded as an invalid gray value mutation point. Similarly, after the gray value mutation point d is calculated, the first slope and the second slope are the same, and the gray value mutation point d is not an invalid gray value mutation point.

[0136] After all invalid gray value mutation points among the gray value mutation points are determined, the invalid gray value mutation points are removed, and the remaining gray value mutation points are valid gray value mutation points.

[0137] In this embodiment, when performing a step search on a boundary line between the foreground and the background on the appearance binary image, a total of 5 preset detection points are selected. Among the grayscale value mutation points obtained after the step search, the grayscale value mutation point b is affected by the sprue or appearance defects on the injection molded part to be detected, resulting in it being not on the same straight line as other grayscale value mutation points.

[0138] The method for detecting appearance defects of injection molded parts provided by the present invention first calculates the slope between adjacent gray value mutation points, and determines whether the slope between any gray value mutation point and two adjacent gray value mutation points is consistent, thereby determining whether the preset detection point is affected by the sprue or appearance defects during the step search process, and eliminating the affected gray value mutation points, effectively eliminating the interference and adverse effects of the sprue or appearance defects on the accurate determination of the foreground separation boundary line.

[0139] Based on the above embodiment, as an optional embodiment, determining the foreground separation boundary line based on the effective gray value mutation point includes:

[0140] Perform straight line fitting on all the effective gray value mutation points based on the least square method to obtain a fitting straight line;

[0141] The straight line where the two effective gray value mutation points with the shortest vertical distance to the fitting straight line are located is used as the foreground separation boundary line.

[0142] Among them, the least square method refers to a method of finding the best matching function for data by minimizing the sum of squares of errors.

[0143] Specifically, after selecting at least two valid gray value mutation points from all gray value mutation points, the least squares method is used to perform straight line fitting on all valid gray value mutation points to obtain a fitting straight line, and the straight lines where the two valid gray value mutation points with the shortest and second shortest vertical distances to the fitting straight line are located are used as foreground separation boundary lines.

[0144] Figure 4 This is the third schematic diagram of the preset detection point step search gray value mutation point provided by the present invention, Figure 5 FIG. 4 is a schematic diagram of the preset detection point stepwise search for gray value mutation point provided by the present invention, such as Figure 4 and Figure 5 As shown in the figure, all gray value mutation points except gray value mutation point b are valid gray value mutation points. Then, based on the least squares method, a, c, d, and e are fitted with a straight line to obtain the fitting straight line. i .

[0145] Furthermore, the effective gray value mutation points a and c have the shortest vertical distance from the fitting line, so the straight line where the effective gray value mutation points a and c are located is used as the foreground separation boundary line l , which is used to remove the background in the appearance binary image according to the foreground separation boundary line to obtain the detection binary image.

[0146] Optionally, when two valid gray value mutation points are selected from all gray value mutation points, the fitting straight line is the straight line where the two valid gray value mutation points are located, that is, the foreground separation boundary line.

[0147] In another embodiment, straight line fitting is performed on all the gray value mutation points based on the least square method to obtain a fitting straight line; the straight line where the two valid gray value mutation points with the shortest vertical distance to the fitting straight line are located is used as the foreground separation boundary line.

[0148] Generally speaking, there are two methods to separate the foreground and background in an image: (1) Threshold segmentation method: the pixels in the image are classified according to their grayscale values ​​and the preset threshold value, so as to separate the foreground and background. It has the advantage of being simple and easy to understand, but it is not effective for complex image scenes; (2) Image processing technology method: it mainly uses image processing techniques such as filtering and morphological operations to separate the foreground and background. It has the advantage of being effective, but it requires targeted processing for complex image scenes.

[0149] In summary, the above two foreground-background separation methods can be applied to laboratory scenes, but cannot perform well in complex environments.

[0150] First, the injection molded parts to be inspected will have sprues attached after passing through the injection molding machine, which is determined by the injection molding process. At the same time, sprues do not belong to the scope of appearance defect detection. Generally, only the front of the injection molded parts is detected during the inspection. However, the above two foreground and background separation methods both adopt the idea of ​​removing the edges of objects, and cannot deduct a certain part of the object alone. In addition, there are many types of injection molded parts, and the sprue position of each model is not fixed, which makes it impossible to deduct at a fixed point, thus affecting the accuracy of foreground and background separation, affecting the effectiveness of the image input to the appearance defect detection model, and having a greater impact on the accuracy of the appearance defect detection model.

[0151] Secondly, many injection molded parts to be inspected (such as air conditioning panels) are different from normal material parts. Their edges are curved to a certain extent. The images obtained after shooting are different in imaging, causing the grayscale of the edge to jump as the curvature increases. In addition, slight angles will cause large fluctuations in grayscale, making traditional methods such as threshold segmentation less effective in distinguishing panels from conveyor belts, because the grayscale gradient at the edge position varies greatly, making it impossible to select a suitable threshold for segmentation. Either too many segmentations will cause the background to be framed, or too few segmentations will cause part of the panel image to be removed as the background, that is, the accuracy of foreground and background separation is low.

[0152] The method for detecting appearance defects of injection molded parts provided by the present invention generally adopts an N-point stepping foreground-background separation method, and determines the gray value mutation point with pixel accuracy by stepping through each pixel point on the binary image. By judging whether the slope between each gray value mutation point and the adjacent gray value mutation point is consistent, the invalid gray value mutation points affected by the water outlet, appearance defects, etc. on the injection molded part to be detected are eliminated, and the foreground separation boundary line is determined by using the valid gray value mutation points. The background can be accurately removed in a real shooting environment that is much more complicated than that in a laboratory, and a more effective detection binary image can be obtained, thereby improving the accuracy of injection molded part appearance defect detection.

[0153] Based on the above embodiment, as an optional embodiment, the step of inputting the detection binary image into an appearance defect detection model to obtain an appearance defect detection result output by the appearance defect detection model includes:

[0154] Using a sliding window to divide the detection binary image into a plurality of sub-images;

[0155] Input each of the sub-images into the appearance defect detection model in turn to obtain an appearance defect detection result output by the appearance defect detection model; the appearance defect detection result includes a detection result corresponding to each of the sub-images.

[0156] The sliding window means defining a window of a fixed size, sliding it horizontally and vertically with a fixed stride starting from the upper left corner of the detection binary image, and traversing the entire detection binary image in sequence.

[0157] Specifically, the detection binary image obtained after removing the background is traversed by the sliding window, so as to divide the detection binary image into multiple sub-images of the same size as the sliding window. Then, each sub-image is input into the appearance defect detection model in turn to obtain the appearance defect detection result output by the appearance defect detection model, wherein the appearance defect detection result includes the detection result corresponding to each sub-image.

[0158] It can be understood that the appearance defect detection model for sub-image detection here can be obtained by inputting multiple historical sub-images in the production process and corresponding multiple labels marked with detection results into any machine vision algorithm such as CNN convolutional neural network, GAN generative adversarial network, MS-CNN multi-scale convolutional neural network or SVM support vector machine for training, and the present invention is not limited to this.

[0159] In one embodiment, before the detection binary image is divided into a plurality of sub-images using a sliding window, a resizing operation is performed on the detection binary image.

[0160] For example, assuming the size of the sliding window is 1000px×1000px, the detection binary image after removing the background Size is 2500px×1500px. Then, we use the sliding window to detect the binary image. Before being divided into multiple sub-images, the bilinear interpolation function is used The size of the detection binary image is reset to 8000px × 4000px. Then, the resized detection binary image is cropped into 32 sub-images using a sliding window with a step size of 1000px.

[0161] When it comes to appearance defect detection of injection molded parts, there are often problems such as the defect area being too small and the sample being unbalanced, making the appearance defects difficult to detect.

[0162] Taking the air-conditioning panel as an example, the mainstream inspection method on the market is to use an area array camera to shoot, inspect and splice. This method is not completely applicable to the air-conditioning panel scenario, because there are many types of defects in the air-conditioning panel, the smallest of which is 0.2mm-0.5mm, and the size of the air-conditioning panel is very large.

[0163] If the entire inspection binary image of the air conditioner panel is directly input, the appearance defect will be difficult to be detected by the appearance defect detection model because the area of ​​the appearance defect is too small and the inspection binary image is too large.

[0164] The method for detecting appearance defects of injection molded parts provided by the present invention utilizes a sliding window to crop a detection binary image into multiple sub-images, which significantly increases the size ratio of appearance defects relative to the image input into the detection model, amplifies the effective information in the image, and avoids from the image level the decrease in the accuracy of the appearance defect detection model caused by the imbalance problem that the area of ​​the appearance defect is too small and the detection binary image is too large.

[0165] Based on the above embodiment, as an optional embodiment, the step of dividing the detection binary image into a plurality of sub-images by using a sliding window includes:

[0166] Controlling the sliding window to move stepwise on the detection binary image according to a preset step length to preliminarily define the segmentation lines of the plurality of sub-images;

[0167] The detected binary image is divided according to the dividing line to obtain a plurality of sub-images.

[0168] The preset step size may be set to 900px, 1000px, or 1500px, etc., and the present invention does not impose any limitation on this.

[0169] Specifically, when the detection binary image is divided into a plurality of sub-images by using a sliding window, the sliding window is controlled to move stepwise on the detection binary image according to a preset step length, so as to preliminarily define the dividing lines of the plurality of sub-images according to the sliding window. At this time, the detection binary image can be directly divided according to the preliminarily defined dividing lines, so as to obtain a plurality of sub-images having the same size as the sliding window.

[0170] Based on the above embodiment, as an optional embodiment, after preliminarily defining the segmentation lines of the plurality of sub-images, the method further includes:

[0171] If it is determined that there is an abnormal pixel point on the segmentation line, the abnormal pixel point is a pixel point with a gray value of 0;

[0172] then steppingly adjusting the position of the segmentation line in a direction perpendicular to the segmentation line until the abnormal pixel point no longer exists on the segmentation line;

[0173] The new sub-image obtained by segmentation after stepwise adjustment of the position of the segmentation line is preprocessed so that the size of the new sub-image is the same as the size of the sub-image obtained by segmentation before stepwise adjustment of the position of the segmentation line.

[0174] Specifically, after controlling the sliding window to step on the detection binary image according to a preset step length to preliminarily define the segmentation lines of multiple sub-images according to the sliding window, it is also determined whether there are abnormal pixels with a gray value of 0 on the preliminarily defined segmentation lines.

[0175] When there are abnormal pixels with a grayscale value of 0 on the initially drawn segmentation line, if the inspection binary image is segmented according to the initially drawn segmentation line, it is very likely that the appearance defects in the inspection binary image will be segmented, which will lead to misjudgment when calculating the area of ​​the appearance defects, and even cause unqualified injection molded parts to be misjudged as qualified injection molded parts.

[0176] Therefore, when it is determined that there are abnormal pixels with a grayscale value of 0 on the initially drawn segmentation line, the position of the segmentation line is stepwise adjusted in a direction perpendicular to the initially drawn segmentation line until there are no abnormal pixels on the segmentation line, and then the detection binary image is segmented according to the adjusted segmentation line.

[0177] Furthermore, since the new sub-image obtained after segmentation according to the step adjustment of the position of the dividing line is not the same size as the sub-image obtained before segmentation according to the step adjustment of the position of the dividing line, and does not meet the input requirements of the appearance defect detection model, the new sub-image obtained after segmentation according to the step adjustment of the position of the dividing line must be preprocessed so that the size of the new sub-image is the same as the size of the sub-image obtained before segmentation according to the step adjustment of the position of the dividing line.

[0178] In one embodiment, the preprocessing of the new sub-image obtained by segmentation after stepping and adjusting the position of the dividing line includes: using pixels with a grayscale value of 1 to fill the new sub-image with a filling sub-image of equal length and width, if the size of the filling sub-image is different from the size of the sub-image obtained by segmentation before the position of the dividing line is step-adjusted, then the size of the filling sub-image is uniformly adjusted to the size of the sub-image obtained by segmentation before the position of the dividing line is step-adjusted, to obtain a preprocessed sub-image.

[0179] For example, assuming that the size of the sliding window is 1000px×1000px, the size of the sub-image obtained by segmentation before the stepwise adjustment of the position of the segmentation line is 1000px×1000px. If the size of the new sub-image obtained by segmentation after the stepwise adjustment of the position of the segmentation line is 1020px×1000px, the new sub-image is filled with pixels with a gray value of 1 to fill it into a 1020px×1020px filled sub-image, and the 1020px×1020px filled sub-image is uniformly reduced to a sub-image of size 1000px×1000px, and the pre-processed sub-image is obtained as the input of the appearance defect detection model.

[0180] If the size of the new sub-image obtained after stepping and adjusting the position of the segmentation line is 980px×1000px, the new sub-image is filled with pixels with a grayscale value of 1 to fill it into a filled sub-image of 1000px×1000px, and the preprocessed sub-image is obtained as the input of the appearance defect detection model.

[0181] In one embodiment, when the position of the dividing line is adjusted stepwise, the position of the dividing line is adjusted stepwise outward based on the principle of enlarging the size of the sub-image, so as to avoid missing the appearance defect features on the image in the cropped sub-image.

[0182] The method for detecting appearance defects of injection molded parts provided by the present invention adopts an adaptive fine-tuning method as a whole. For special circumstances in which some appearance defects may be divided into two halves when a sliding window is used to divide a sub-image, thus affecting the final determination of product qualification, after the sliding window is used to preliminarily define a dividing line, it is first determined whether a grayscale transition exists on the dividing line in a boundary box of the sliding window. If so, the size of the window is adaptively adjusted until there is no grayscale transition on the dividing line. The adjustment is then stopped, and the dividing line without grayscale transition is used to divide the detection binary image, which can effectively avoid the misjudgment caused by long strip defects being cut into two halves.

[0183] Based on the above embodiment, as an optional embodiment, the preset step size is smaller than the size of the sliding window.

[0184] Specifically, since the preset step size of the sliding window is smaller than the size of the sliding window, after the detection binary image is cropped and divided into multiple sub-images using the sliding window, the multiple sub-images obtained all contain repeated areas, which can effectively avoid the situation where the cropped sub-images miss the appearance defect features on the detection binary image to a considerable extent.

[0185] The method for detecting appearance defects of injection molded parts provided by the present invention introduces a sliding window segmentation method with overlapping steps for some appearance defects (such as black spots) with small areas that are easily overlooked in the process of segmenting and detecting binary images. This method ensures that image information loss will not occur regardless of the size of the image being cropped. This method can adapt to more production and appearance defect detection scenarios and improve the accuracy of appearance defect detection.

[0186] The aforementioned N-point step-by-step foreground-background separation method and sliding window segmentation method both belong to the data enhancement algorithm provided by the present invention for enhancing the image input to the appearance defect detection model, which can eliminate irrelevant image information of the appearance defect detection model during the training process and the actual detection process, and increase the area ratio of the appearance defect area in the detection image, thereby improving the accuracy of injection molded parts appearance defect detection.

[0187] Based on the above embodiment, as an optional embodiment, the appearance defect detection result is a result image after the appearance defects existing in the appearance binary image are marked by using a target frame;

[0188] Accordingly, after obtaining the appearance defect detection result output by the appearance defect detection model, the method further includes:

[0189] If the area of ​​the appearance defect is larger than the first preset area, the injection molded part to be inspected is determined to be unqualified;

[0190] If the area of ​​the appearance defect is less than or equal to the first preset area but greater than the second preset area, and there are other appearance defects within the preset range of the appearance defect, then the injection molded part to be inspected is determined to be unqualified;

[0191] If the area of ​​the appearance defect is less than or equal to the second preset area, it is confirmed that the injection molded part to be inspected is qualified.

[0192] The appearance defect detection result includes at least one target frame for marking the existing appearance defects. If there are multiple appearance defects, the appearance defect detection result will correspondingly include multiple target frames for marking the appearance defects.

[0193] Specifically, after the detection binary image or multiple images segmented from the detection binary image are input into the appearance defect detection model, the appearance defect detection model detects the appearance defects in the image, annotates the detected appearance defects with a target box, and outputs a result image in which the appearance defects in the appearance binary image are annotated by the target box.

[0194] After obtaining the appearance defect detection result, the appearance defects detected by the appearance defect detection model are judged and screened one by one to determine whether the appearance detection result of the injection molded part to be detected is qualified or unqualified.

[0195] If the area of ​​any appearance defect in the appearance defect detection result is larger than the preset area, the injection molded part to be detected is determined to be unqualified.

[0196] If the area of ​​any appearance defect in the appearance defect detection result is less than or equal to the first preset area but greater than the second preset area, and there are other appearance defects with unlimited areas within the preset range of the appearance defect, the injection molded part to be tested is determined to be unqualified.

[0197] If the areas of all appearance defects in the appearance defect detection result are less than or equal to the second preset area, it is confirmed that the injection molded part to be tested is qualified.

[0198] It can be understood that the second preset area is smaller than the first preset area.

[0199] For example, assuming that the injection molded part to be inspected is an air conditioning panel, the first preset area is 1 , the second preset area is 0.5 , the default range is 10 .

[0200] For any black spot detected, if the calculated black spot area is greater than 1 , the air conditioner panel is directly judged as a substandard product; if the calculated black spot area is less than or equal to 1 But greater than 0.5 , then further determine that in the 10 Whether there are other appearance defects within the range, if there are other appearance defects, regardless of the area of ​​other appearance defects, the air conditioner panel is judged as a non-conforming product; if the calculated area of ​​each appearance defect is less than or equal to 0.5 , the air conditioning panel is judged to be a qualified product.

[0201] It should be noted that the specific settings of the first preset area, the second preset area and the preset range can be determined comprehensively based on factors such as the specification parameters of the injection molded parts to be inspected, the manufacturing process of the injection molded parts to be inspected, the accuracy requirements of the appearance inspection, etc., and the present invention is not limited to this.

[0202] It can be understood that if the detection binary image or sub-image input into the appearance defect detection model has undergone preprocessing such as resizing that affects the calculation of the true area of ​​the appearance defect, then when calculating the true area of ​​the appearance defect, a corresponding recovery operation will be performed so that the calculated area is consistent with the true area of ​​the appearance defect on the injection molded part.

[0203] In one embodiment, the area of ​​the appearance defect in a target frame is calculated by traversing each pixel in the target frame, counting the number of pixels in the target frame whose grayscale value is the minimum grayscale value, and determining the area of ​​the appearance defect based on this number.

[0204] Generally speaking, due to the single environment of the laboratory, many manufacturers do not perform secondary filtering and selection after obtaining the test results after choosing the current mainstream testing methods, that is, they do not perform post-processing. This will introduce a lot of errors and cause the detection effect to deteriorate.

[0205] Moreover, in the production process of injection molded parts, there are many different models and specifications of injection molded parts, and different models and specifications of injection molded parts have different acceptance of appearance defects. If the appearance defect detection results are not screened for the second time, it will not be able to adapt to the production of multiple models of injection molded parts.

[0206] The method for detecting appearance defects of injection molded parts provided by the present invention, after obtaining the appearance defect detection results output by the appearance defect detection model, also sets a suitable first preset area, a second preset area and a preset range according to the different acceptance of appearance defects of injection molded parts of different models and specifications, so as to perform a secondary screening of the appearance defect detection results, and obtain the final qualified results of the injection molded part appearance defect detection. The method can also adapt to complex non-laboratory environments and improve the accuracy of injection molded part appearance defect detection.

[0207] In one embodiment, during pre-training of the appearance defect detection model, the data sample set is first divided into a training set and a validation set.

[0208] For the data in the data sample set, the images are enhanced by separating the foreground and background and segmenting the area with sliding windows. The network can also be prevented from overfitting by random horizontal and vertical flipping, random enhancement of brightness and lightness, etc. The enhanced images are then output to the appearance defect detection model based on the BP algorithm for training, and the model weight parameters are saved.

[0209] Then calculate the false detection rate, missed detection rate and accuracy of the appearance defect detection model. The formula is as follows:

[0210] ;

[0211] ;

[0212] ;

[0213] in, is the number of defective images correctly identified, is the number of falsely identified defect images, is the number of correctly identified non-defective images, is the number of incorrectly identified non-defective images.

[0214] Optionally, the appearance defect detection model is deployed to the injection molded part appearance defect detection device through C++ language to realize model reasoning.

[0215] In order to better demonstrate the method for detecting appearance defects of injection molded parts provided by the present invention, an embodiment in which the injection molded part is an air conditioner panel is provided below to illustrate the complete process of the present invention in detecting appearance defects of injection molded parts. It should be noted that this embodiment is only an illustration of the method for detecting appearance defects of injection molded parts provided by the present invention and should not be regarded as a limitation of the present invention.

[0216] Figure 6 This is the second flow chart of the method for detecting appearance defects of injection molded parts provided by the present invention. Figure 7 FIG. 1 is a flow chart of the air conditioner panel appearance detection method provided by the present invention, such as Figure 6 and Figure 7 As shown in the figure, when the conveyor belt transports the air conditioning panel to be inspected to the preset inspection position, the position sensor senses the incoming material, and the injection molded part appearance inspection device turns on the shooting device to shoot the air conditioning panel, collect the image of the air conditioning panel, and transmit it to the inspection system. After receiving the captured image, the inspection system stores the captured image in the Bitmap.

[0217] Before the back-end inspection system performs appearance defect inspection on the captured image, it first pre-processes the image, including:

[0218] (1) Binarize the captured image to obtain an appearance binary image;

[0219] (2) Determine a plurality of preset detection points on the appearance binary image, use the predicted detection points to step-by-step search for the grayscale value mutation points of the air conditioner panel on the appearance binary image, and determine the foreground separation boundary line for separating the foreground and the background according to the effective grayscale value mutation points among the grayscale value mutation points, and crop the appearance binary image according to the foreground separation boundary line to remove the background part in the appearance binary image, thereby obtaining a detection binary image;

[0220] (3) Using a sliding window with a preset step size smaller than the sliding window size to move on the detection binary image, to preliminarily define the segmentation lines of multiple sub-images; judging whether there is a grayscale transition on the segmentation line, if there is a grayscale transition, appropriately adjusting the position of the segmentation line until there is no grayscale transition on the segmentation line; using the adjusted segmentation line to segment the detection binary image to obtain multiple sub-images, and preprocessing the sub-images;

[0221] (4) The preprocessed multiple sub-images are sequentially input into the appearance defect detection model to obtain an appearance defect detection result, which is a result image obtained after the appearance defects are marked with a target frame.

[0222] After detecting the appearance defect detection results, the back-end inspection system controls the front-end display device to display the appearance defect detection results, and screens the appearance defect detection results to display whether the air-conditioning panel is qualified, so that the staff can monitor the appearance inspection process of the air-conditioning panel in real time in the inspection workshop.

[0223] In addition to displaying the appearance defect inspection results of a single air-conditioning panel, the front-end display device also displays the number of air-conditioning panels with qualified inspection results, the number of air-conditioning panels with unqualified inspection results, the total number of air-conditioning panels inspected, and the pass rate. The pass rate refers to the ratio of the number of air-conditioning panels that have passed the inspection per unit time to the total number of air-conditioning panels produced.

[0224] Figure 8Schematic diagram of the structure of the device for detecting appearance defects of injection molded parts provided by the present invention. Figure 8 As shown, including but not limited to:

[0225] A binarization processing unit 801 is used to perform binarization processing on the photographed image of the injection molded part to be inspected to obtain a binarized image of the appearance;

[0226] A mutation point search unit 802 is used to determine a plurality of preset detection points on the appearance binary image, so as to stepwise search for gray value mutation points using the preset detection points;

[0227] The boundary line determination unit 803 is used to select at least two valid gray value mutation points from all gray value mutation points, so as to determine the foreground separation boundary line based on the valid gray value mutation points;

[0228] A background removal unit 804 is used to remove the background in the appearance binary image according to the foreground separation boundary line to obtain a detection binary image;

[0229] The defect detection unit 805 is used to input the detection binary image into the appearance defect detection model to obtain the appearance defect detection result output by the appearance defect detection model.

[0230] It should be noted that the device for detecting appearance defects of injection molded parts provided by the present invention can execute the method for detecting appearance defects of injection molded parts described in any of the above embodiments during specific operation, which will not be elaborated in this embodiment.

[0231] The device for detecting appearance defects of injection molded parts provided by the present invention uses preset detection points to step-search for pixel points with sudden grayscale value changes in the image before inputting the image of the injection molded part into the detection model, and excludes grayscale value mutation points affected by the water outlet or appearance defects, and determines the foreground separation boundary line in the image according to at least two valid grayscale value mutation points, thereby performing preprocessing on the appearance binary image to remove the background, so that the image input into the model is more effective and has fewer interference factors, and can improve the accuracy of injection molded part appearance defect detection.

[0232] Fig. 9 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Fig. 9As shown, the electronic device may include: a processor (Processor) 910, a communication interface (Communications Interface) 920, a memory (Memory) 930 and a communication bus 940, wherein the processor 910, the communication interface 920, and the memory 930 complete mutual communication through the communication bus 940. The processor 910 may call the logic instructions in the memory 930 to execute the injection molded part appearance defect detection method, which method includes but is not limited to: binarizing the photographed image of the injection molded part to be detected to obtain an appearance binary image; determining a plurality of preset detection points on the appearance binary image to use the preset detection points to stepwise search for gray value mutation points; selecting at least two valid gray value mutation points from all gray value mutation points to determine a foreground separation boundary line based on the valid gray value mutation points; removing the background in the appearance binary image according to the foreground separation boundary line to obtain a detection binary image; inputting the detection binary image into the appearance defect detection model to obtain the appearance defect detection result output by the appearance defect detection model.

[0233] In addition, the logic instructions in the above-mentioned memory 930 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0234] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the injection molded part appearance defect detection method provided in the above-mentioned embodiments, the method including but not limited to the following steps: binarizing the captured image of the injection molded part to be inspected to obtain an appearance binary image; determining a plurality of preset detection points on the appearance binary image to use the preset detection points to stepwise search for grayscale value mutation points; selecting at least two valid grayscale value mutation points from all grayscale value mutation points to determine a foreground separation boundary line based on the valid grayscale value mutation points; removing the background in the appearance binary image according to the foreground separation boundary line to obtain a detection binary image; inputting the detection binary image into an appearance defect detection model to obtain an appearance defect detection result output by the appearance defect detection model.

[0235] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0236] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0237] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting appearance defects of injection molded parts, characterized in that: include: Binarization is performed on the photographed image of the injection molded part to be inspected to obtain a binary image of the appearance; Determine a plurality of preset detection points on the appearance binary image, and use the preset detection points to stepwise search for gray value mutation points; Selecting at least two valid gray value mutation points from all gray value mutation points, including: calculating a first slope and a second slope between each gray value mutation point and two adjacent gray value mutation points; if the directions of the first slope and the second slope are inconsistent, taking the gray value mutation point as an invalid gray value mutation point; removing the invalid gray value mutation point from all gray value mutation points to obtain the valid gray value mutation point; and determining a foreground separation boundary line based on the valid gray value mutation point; According to the foreground separation boundary line, the background in the appearance binary image is removed to obtain a detection binary image; The detected binary image is input into an appearance defect detection model to obtain an appearance defect detection result output by the appearance defect detection model.

2. The method for detecting appearance defects of injection molded parts according to claim 1, characterized in that: The step of determining a plurality of preset detection points on the appearance binary image comprises: Determining the number of the preset inspection points according to the specification parameters of the injection molded part to be inspected; The distribution of the preset detection points is determined according to the position of the injection molded part to be detected on the appearance binary image.

3. The method for detecting appearance defects of injection molded parts according to claim 2, characterized in that: The plurality of preset detection points at least include a first search point set and a second search point set; The first search point set and the second search point set each include at least two of the preset detection points; When using the preset detection points to stepwise search for grayscale value mutation points, the moving direction of all preset detection points in the first search point set is a first direction, and the moving direction of all preset detection points in the second search point set is a second direction, and the first direction and the second direction are opposite to each other.

4. The method for detecting appearance defects of injection molded parts according to claim 3, characterized in that: The arrangement directions of the first search point set and the second search point set are both perpendicular to the width direction or the length direction of the appearance binary image; In the case where the arrangement direction is perpendicular to the width direction of the appearance binary image, the first direction and the second direction are respectively toward two side edges of the appearance binary image in the width direction; In a case where the arrangement direction is perpendicular to the length direction of the appearance binary image, the first direction and the second direction are respectively oriented toward two side edges of the appearance binary image in the length direction.

5. The method for detecting appearance defects of injection molded parts according to claim 3, characterized in that: For any preset detection point, determining the search point set to which the preset detection point belongs, so as to determine the stepping direction when stepping and searching for the gray value mutation point, wherein the stepping and searching for the gray value mutation point by using the preset detection point comprises: When the gray value of the pixel point where any of the preset detection points is located is 1, controlling any of the preset detection points to perform step search in the step direction with a step length of one pixel; Determine whether the grayscale value of the pixel point where any preset detection point is located after each step search has a sudden change; If no mutation occurs, controlling any of the preset detection points to continue stepping search until the grayscale value of the pixel point where the preset detection point is located undergoes a mutation; The pixel point where the grayscale value suddenly changes after the step search of any preset detection point is taken as the grayscale value sudden change point.

6. The method for detecting appearance defects of injection molded parts according to claim 5, characterized in that: The step of determining the foreground separation boundary line based on the effective gray value mutation point comprises: Perform straight line fitting on all the effective gray value mutation points based on the least square method to obtain a fitting straight line; The straight line where the two effective gray value mutation points with the shortest vertical distance to the fitting straight line are located is used as the foreground separation boundary line.

7. The method for detecting appearance defects of injection molded parts according to claim 1, characterized in that: The step of inputting the detected binary image into an appearance defect detection model to obtain an appearance defect detection result output by the appearance defect detection model includes: Using a sliding window to divide the detection binary image into a plurality of sub-images; Input each of the sub-images into the appearance defect detection model in turn to obtain an appearance defect detection result output by the appearance defect detection model; the appearance defect detection result includes a detection result corresponding to each of the sub-images.

8. The method for detecting appearance defects of injection molded parts according to claim 7, characterized in that: The method of dividing the detected binary image into a plurality of sub-images by using a sliding window comprises: Controlling the sliding window to move stepwise on the detection binary image according to a preset step length to preliminarily define the segmentation lines of the plurality of sub-images; The detected binary image is divided according to the dividing line to obtain a plurality of sub-images.

9. The method for detecting appearance defects of injection molded parts according to claim 8, characterized in that: After initially defining the dividing lines of multiple sub-images, it also includes: If it is determined that there is an abnormal pixel point on the segmentation line, the abnormal pixel point is a pixel point with a gray value of 0; then steppingly adjusting the position of the segmentation line in a direction perpendicular to the segmentation line until the abnormal pixel point no longer exists on the segmentation line; The new sub-image obtained by segmentation after stepwise adjustment of the position of the segmentation line is preprocessed so that the size of the new sub-image is the same as the size of the sub-image obtained by segmentation before stepwise adjustment of the position of the segmentation line.

10. The method for detecting appearance defects of injection molded parts according to claim 8 or 9, characterized in that: The preset step size is smaller than the size of the sliding window.

11. The method for detecting appearance defects of injection molded parts according to claim 1, characterized in that: The appearance defect detection result is a result image obtained by marking the appearance defects existing in the appearance binary image using a target frame; Accordingly, after obtaining the appearance defect detection result output by the appearance defect detection model, the method further includes: If the area of ​​the appearance defect is larger than the first preset area, the injection molded part to be inspected is determined to be unqualified; If the area of ​​the appearance defect is less than or equal to the first preset area but greater than the second preset area, and there are other appearance defects within the preset range of the appearance defect, then the injection molded part to be inspected is determined to be unqualified; If the area of ​​the appearance defect is less than or equal to the second preset area, it is confirmed that the injection molded part to be inspected is qualified.

12. An injection molded part appearance defect detection device, characterized in that: include: A binarization processing unit is used to perform binarization processing on the photographed image of the injection molded part to be inspected to obtain a binarized image of the appearance; A mutation point search unit, used to determine a plurality of preset detection points on the appearance binary image, so as to stepwise search for gray value mutation points using the preset detection points; A boundary line determination unit, used to select at least two valid gray value mutation points from all gray value mutation points, so as to determine a foreground separation boundary line based on the valid gray value mutation points; A background removal unit, used to remove the background in the appearance binary image according to the foreground separation boundary line to obtain a detection binary image; A defect detection unit, used for inputting the detection binary image into an appearance defect detection model to obtain an appearance defect detection result output by the appearance defect detection model; The step of selecting at least two valid grayscale value mutation points from all grayscale value mutation points comprises: Calculate the first slope and the second slope between each gray value mutation point and two adjacent gray value mutation points; if the directions of the first slope and the second slope are inconsistent, take the gray value mutation point as an invalid gray value mutation point; remove the invalid gray value mutation points from all gray value mutation points to obtain the valid gray value mutation point.

13. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for detecting appearance defects of injection molded parts as described in any one of claims 1 to 11 is implemented.

14. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting appearance defects of injection molded parts as claimed in any one of claims 1 to 11 is implemented.