An Injection Molding Part Defect Detection Method Based on OpenCV

Through OpenCV's multi-scale template matching and threshold processing, combined with the Sobel operator to detect the edge of the injection molded part, the problems of low manual detection efficiency and insufficient accuracy in the defect detection of injection molded parts are solved, and fast and accurate defect detection is achieved.

CN116128861BActive Publication Date: 2025-07-29DONGGUAN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310177356.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-28
Publication Date
2025-07-29
Estimated Expiration
2043-02-28

AI Technical Summary

Technical Problem

In the defect detection of existing injection molded parts, the manual inspection efficiency is low, the accuracy is insufficient, and the computing power requirements of the defect detection algorithm are too high, resulting in insufficient detection efficiency and accuracy.

Method used

Using OpenCV-based injection molded parts defect detection method, the surface image of the injection molded tape was taken by the camera, and multi-scale template matching, threshold processing and contour extraction were used, and the edges were detected by Sobel operator, feature points were located and defects of the injection molded parts were judged.

Benefits of technology

It realizes fast and accurate defect detection of injection molded parts, reduces computing resource consumption, is suitable for different injection molded parts detection systems, and has good detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116128861B_ABST
    Figure CN116128861B_ABST
Patent Text Reader

Abstract

The present invention relates to a method for detecting defects of injection molded parts based on OpenCV, comprising the following steps: First, collect the surface image of the entire injection molded tape; Second, use the multi-scale template matching algorithm to obtain the circumscribed rectangle on the test picture and draw a rectangular frame; Third, according to the rectangular frame, cut out each injection molded part on the injection molded tape from the overall image respectively to obtain the injection molded part image; Fourth, perform threshold processing on the extracted injection molded part image; Fifth, use the method of hollowing out internal points for each injection molded part to adjust and delete the points inside the contour, leaving only the contour of the injection molded part, and use the Sobel operator according to the gray-weighted difference of the upper and lower, left and right adjacent points of the pixel points; Sixth, locate the feature points, extract the corresponding contour and then take the minimum circumscribed rectangle, judge the length and width of the rectangle, if the length and width do not meet the requirements, then the injection molded part has defects, otherwise there are no defects. It is simple to operate, has a small amount of calculation, and has a good defect detection effect, and is applicable to different injection molded part defect detection systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of product quality inspection, and particularly relates to a defect detection for injection molded parts. Background Art

[0002] Plastics have been widely used in industries such as agriculture, food, manufacturing, automotive, electronics, hardware consumables, medical devices, pharmaceuticals, portable devices, chemical machinery, and protective products due to their excellent physical and chemical properties such as light weight, high specific strength, good insulation, excellent optical properties, and strong comprehensive protection ability. They are one of the important materials in daily life and industrial production. Injection molding is one of the most important plastic molding methods in industrial production. This molding method is not only suitable for processing various products with complex structures or fine dimensions, but also has the characteristics of short production cycle, low production cost, strong adaptability, easy integration, and high automation. Generally, the injection molding process is a complex multi-stage material molding process. The setting and adjustment of process parameters in each stage of the molding process have an important impact on the final molding quality of the injection molded parts. In the normal continuous injection molding production process, due to factors such as fluctuations in the production state of the injection molding machine, uncertainties in process parameter settings, and lags in the measurement of key parameters, there may be significant differences in the molding quality of injection molded parts produced successively by the same injection molding machine. At the same time, for different batches of plastic raw materials, different injection molding machines, and different production molds, the injection molding process has different production conditions and production environments, directly resulting in the inability to accurately evaluate the molding quality of the injection molded parts after production. Therefore, it is necessary to detect the molding quality of the injection molded parts after production to ensure that the molding quality of the injection molded parts meets the production requirements. As an essential step in the production and manufacturing process, surface defect detection is widely used in various industrial fields, including 3C, semiconductor and electronics, automotive, chemical, pharmaceutical, light industry, military, etc., giving rise to numerous upstream and downstream enterprises. Since the 20th century, surface defect detection has roughly gone through three stages, namely manual visual inspection, single electromechanical or optical technology inspection, and machine vision inspection. Manual visual inspection has the earliest origin and the widest application. Although advanced detection technologies such as artificial intelligence and machine vision have gradually matured, defect detection relying on the naked eye still accounts for a large proportion and is widely present in small and medium-sized enterprises. However, with the disappearance of the demographic dividend, as well as the boring work, low freedom, and low salary, fewer and fewer people are willing to engage in quality inspection, and the problem of difficult employment has become increasingly prominent. Therefore, the defect detection algorithm using machine vision to detect the surface defects of each injection molded part on the same injection molding belt is of great significance. Summary of the Invention

[0003] The purpose of the present invention is to solve the problems in the existing defect detection of injection molded parts, such as low efficiency of manual detection, insufficient accuracy, and excessive computing power requirements for defect detection algorithms. A method for defect detection of injection molded parts based on OpenCV is proposed. After the injection molded tape is photographed by a camera and multi-scale template matching is performed to obtain a single injection molded part, the clear and smooth contour edge of the injection molded part is obtained through threshold processing and contour extraction, and the defect condition of the injection molded part is judged by the distance between feature points.

[0004] To achieve the above object, the technical solution adopted by the present invention is as follows:

[0005] A method for defect detection of injection molded parts based on OpenCV, which includes the following steps:

[0006] Step 1: Use a camera to photograph all injection molded parts on the injection molded tape to collect the overall surface image of the injection molded tape;

[0007] Step 2: Use the multi-scale template matching algorithm to read the template image and perform grayscale conversion and edge detection processing in sequence; read the test image, traverse the entire scale space, and perform cropping of the test image; obtain the bounding rectangle on the test image and draw the rectangle frame;

[0008] Step 3: According to the rectangle frame, cut out each injection molded part on the injection molded tape from the overall image to obtain the injection molded part image;

[0009] Step 4: Perform threshold processing on the extracted injection molded part image, process the pixel points with pixel values greater than the threshold to 255, and process the pixel points with pixel values less than the threshold to 0, so that the image becomes a black-and-white image, and in this case, it is very convenient to extract the ROI region;

[0010] Step 5: Use the method of hollowing out internal points to adjust and delete the points inside the contour of each injection molded part image. After adjustment, only the contour of the injection molded part remains on the injection molded part image. At the same time, use the Sobel operator to detect the edge according to the phenomenon that the weighted difference of the gray levels of the upper, lower, left, and right adjacent points of the pixel points reaches an extreme value at the edge;

[0011] Step 6: Locate the feature points, take the minimum bounding rectangle after extracting the corresponding injection molded part contour, judge the length and width of the rectangle. If the length and width do not meet the requirements, the injection molded part has defects, otherwise it has no defects.

[0012] Further, the principle of the multi-scale template matching algorithm in step 2 is as follows:

[0013] 1. Read the template image and perform grayscale conversion and edge detection processing in sequence; 2. Read the test image, traverse the entire scale space, and perform cropping of the test image; 3. Perform edge detection and template matching in sequence to obtain the bounding rectangle; 4. Update the position of the template in the test image according to the result; 5. Perform position conversion, then draw a rectangle frame, and finally display the template matching result.

[0014] Further, for the above solution, the principle of the threshold processing and ROI region extraction in step 4 is as follows:

[0015] Threshold processing is a process of setting a certain threshold and then uniformly processing pixels greater than or less than the threshold;

[0016] During the threshold processing of the extracted injection molded part image, pixels with pixel values greater than the threshold are processed as 255, and pixels with pixel values less than the threshold are processed as 0, so that the image becomes a black-and-white image; in OpenCV, after setting the image object, threshold, maximum value, and threshold processing type using the cv2.threshold() function, the threshold and the processed result image can be returned; after extracting the irregular region using the mask of OpenCV, the ROI region of the injection molded part can be extracted by calling the API function bitwise_and.

[0017] Compared with the prior art, the present invention has the following beneficial effects:

[0018] 1. The defect detection method of the present invention adopts the multi-scale template matching method during template matching, and by continuously changing the scale size of the image and matching the template, the computational resources consumed during matching can be reduced.

[0019] 2. The present invention locates the feature points, extracts the corresponding contour and then takes the minimum bounding rectangle, and judges whether the injection molded part has defects by judging the length and width of the rectangle, which can quickly judge product defects;

[0020] 3. The method proposed by the present invention is simple to operate, has a small amount of calculation, and has a good defect detection effect, and is applicable to different injection molded part defect detection systems. Description of the Drawings

[0021] Figure 1 It is the original image of two pairs of injection molded parts on an injection molding belt in one embodiment of the present invention;

[0022] Figure 2 It is the result image after multi-scale template matching;

[0023] Figure 3 It is the image of a single injection molded part cut out from the injection molding belt;

[0024] Figure 4Effect diagram of extracting ROI region for the injection molded part with the triangular position facing up;

[0025] Figure 5 Effect diagram of extracting ROI region for the injection molded part with the triangular position facing down;

[0026] Figure 6 Effect diagram after threshold processing;

[0027] Figure 7 Effect diagram after contour extraction;

[0028] Figure 8 Effect diagram after edge extraction using sobel operator;

[0029] Figure 9 Result diagram of extracting and judging the width of the triangular position at the upper part of the injection molded part;

[0030] Figure 10 Result diagram of extracting and judging the width of the triangular position at the lower part of the injection molded part;

[0031] Figure 11 Result diagram of judging the existence of unfilled defects at the bottom of the injection molded part;

[0032] Figure 12 Result diagram of detecting the injection molded part without defects on the injection molding belt;

[0033] Figure 13 Result diagram of detecting the injection molded part with defects on the injection molding belt. Specific implementation mode

[0034] The following will further illustrate the concept, specific structure and technical effects of the present invention in conjunction with the drawings to fully understand the purpose, features and effects of the present invention.

[0035] It should be noted that in the description of the present invention, the terms indicating directions or position relationships such as "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. are based on the directions or position relationships shown in the drawings. This is only for convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation, so it cannot be understood as a limitation to the present invention. Embodiment

[0036] As Figures 1 to 13 shown, in the embodiment, an injection molded part defect detection method based on OpenCV is adopted, which is specifically applied to the defect detection algorithm based on OpenCV and includes the following steps:

[0037] Step 1: Use a camera to take pictures of all injection molded parts on the injection molding belt to collect the overall surface image of the injection molding belt and transmit it to the computer;

[0038] Step 2: Apply the multi-scale template matching algorithm. Read the template image, and sequentially perform grayscale conversion and edge detection processing. The template image is pre-saved in the computer for reference. Read the test image, traverse the entire scale space, and perform cropping on the test image. Obtain the bounding rectangle on the test image and draw the rectangle frame. The principle of this multi-scale template matching algorithm is as follows: First, read the template image and sequentially perform grayscale conversion and edge detection processing; Second, read the test image, traverse the entire scale space, and perform cropping on the test image; Third, sequentially perform edge detection and template matching to obtain the bounding rectangle; Fourth, update the position of the template in the test image according to the result; Fifth, perform position conversion, then draw the rectangle frame, and finally display the template matching result.

[0039] Step 3: According to the rectangle frame, crop each injection molded part from the surface image of the entire injection molded tape to obtain the injection molded part image.

[0040] Step 4: Perform threshold processing on the extracted injection molded part image. Process the pixel points with pixel values greater than the threshold to 255, and process the pixel points with pixel values less than the threshold to 0, so that the image becomes a black-and-white image. In this case, it will be very convenient to extract the ROI region. The principles of threshold processing and ROI region extraction are as follows:

[0041] Threshold processing is the process of setting a certain threshold and then uniformly processing the pixels greater than or less than the threshold;

[0042] During the threshold processing of the extracted injection molded part image, process the pixel points with pixel values greater than the threshold to 255, and process the pixel points with pixel values less than the threshold to 0, so that the image becomes a black-and-white image; After setting the image object, threshold, maximum value, and threshold processing type using the cv2.threshold() function in OpenCV, the threshold and the processed result image can be returned; After extracting the irregular region using the mask of OpenCV, call the API function bitwise_and to extract the ROI region of the injection molded part.

[0043] Step 5: Use the method of hollowing out internal points to adjust and delete the points inside the contour for each injection molded part image. After adjustment, only the contour of the injection molded part remains on the injection molded part image. At the same time, use the Sobel operator to detect the edge according to the phenomenon that the weighted difference of the gray levels of the upper, lower, left, and right adjacent points of the pixel points reaches an extreme value at the edge. Since the Sobel operator has a smoothing effect on noise and can provide more accurate edge direction information, the contour extracted by this algorithm can be more accurate.

[0044] Step 6: Locate the feature points, extract the corresponding injection molded part contour, and then take the minimum bounding rectangle. Judge the length and width of this rectangle. If the length and width do not meet the requirements, then the injection molded part is defective; otherwise, it is defect-free.

[0045] The defect detection method of the present invention adopts a multi-scale template matching method when performing template matching. By continuously changing the scale of the image and matching the template, the computing resources consumed during matching can be reduced. And by locating the feature points, extracting the corresponding contour and then taking the minimum bounding rectangle, and judging whether the injection molded part is defective by judging the length and width of this rectangle, the product defect can be quickly judged. The algorithm proposed by the present invention is simple to operate, has a small amount of calculation, and has a good defect detection effect, and is applicable to different injection molded part defect detection systems.

[0046] Although the preferred specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, the present invention should not be limited to the exact same structure and operation as described above and shown in the drawings. For those skilled in the art of this technology, without departing from the concept and scope of the present invention, many equivalent improvements and changes can still be made to the above embodiments through logical analysis, reasoning or limited experiments, but these improvements and changes should all fall within the scope of protection required by the present invention.

Claims

1. An injection molding part defect detection method based on OpenCV, characterized in that It includes the following steps: Step 1: Use a camera to take pictures of all injection-molded parts on the injection tape to collect the surface image of the entire injection tape; Step 2: Use the multi-scale template matching algorithm to read the template image and sequentially perform grayscale conversion and edge detection processing; read the test image, traverse the entire scale space, and perform test image cropping; obtain the circumscribed rectangle on the test image and draw a rectangle frame; Step 3: According to the rectangle frame, crop each injection-molded part on the injection tape from the overall image to obtain the injection-molded part image; Step 4: Perform threshold processing on the extracted injection-molded part image, process the pixel points with pixel values greater than the threshold to 255, and process the pixel points with pixel values less than the threshold to 0, so that the picture becomes a picture with only black and white. In this case, it will be very convenient to extract the ROI region; Step 5: Use the method of hollowing out internal points to adjust and delete the points inside the contour of each injection-molded part image. After adjustment, only the contour of the injection-molded part remains on the injection-molded part image. At the same time, use the Sobel operator to detect the edge according to the phenomenon that the weighted difference of the gray levels of the upper, lower, left, and right neighboring points of the pixel point reaches an extreme value at the edge; Step 6: Locate the feature points, take the minimum circumscribed rectangle after extracting the corresponding injection-molded part contour, and judge the length and width of the rectangle. If the length and width do not meet the requirements, the injection-molded part has defects, otherwise it has no defects.

2. The method for detecting defects of injection molded parts based on OpenCV according to claim 1, characterized in that The principle of the multi-scale template matching algorithm in Step 2 is as follows:

1. Read the template image and sequentially perform grayscale conversion and edge detection processing; 2. Read the test image, traverse the entire scale space, and perform test image cropping; 3. Sequentially perform edge detection and template matching to obtain the circumscribed rectangle; 4. Update the position of the template in the test image according to the result; 5. Perform position conversion, then draw a rectangle frame, and finally display the template matching result.

3. The method for detecting defects of injection molded parts based on OpenCV according to claim 1, characterized in that, The principle of the threshold processing and ROI region extraction of the image in Step 4 is as follows: Threshold processing is a process of setting a certain threshold and then uniformly processing the pixels greater than the threshold or less than the threshold; During the threshold processing of the extracted injection-molded part image, the pixel points with pixel values greater than the threshold are processed to 255, and the pixel points with pixel values less than the threshold are processed to 0, so that the picture becomes a picture with only black and white; in OpenCV, after setting the picture object, threshold, maximum value, and threshold processing type using the cv2.threshold() function, the threshold and the processed result image can be returned; after using the mask of OpenCV to extract the irregular region, the API function bitwise_and can be called to extract the ROI region of the injection-molded part.

Citation Information

Patent Citations

  • A complex injection molding product flash defect identification method based on multi-template low-rank decomposition

    CN109816648A

  • Mechanism, system and method for detecting defects of injection molded part products

    CN114235845A