Headset injection mold defect detection method based on machine vision

By applying the combination method of blind deconvolution recovery algorithm and random forest algorithm in injection mold detection, the problems of low image clarity and low detection efficiency of industrial cameras are solved, and efficient and real-time detection of injection mold defects are achieved.

CN119887714AInactive Publication Date: 2025-04-25DONGGUAN YINGJI ELECTRONIC TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411979750.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-25
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, industrial cameras are prone to light changes, motion blur and environmental interference when shooting injection molds, resulting in low image clarity and difficult to accurately reflect the true state of the mold surface. In addition, the existing mold defect detection mainly relies on manual visual inspection, which is inefficient in detection and time-consuming, making it impossible to realize real-time detection of mold defects.

Method used

The defect detection method of headset injection molds based on machine vision is adopted, and the initial image is restored through a blind deconvolution recovery algorithm to generate a clear target image. Then, image features are extracted and a mold defect detection model based on a random forest algorithm is constructed to realize automated detection of mold defects.

Benefits of technology

This method can effectively avoid the impact of light changes, motion blur and environmental interference on image quality, and improve the clarity and detection accuracy of mold images. At the same time, through automated inspection, the detection efficiency is significantly improved and real-time detection of mold defects is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119887714A_ABST
    Figure CN119887714A_ABST
Patent Text Reader

Abstract

The invention provides a headphone injection mold defect detection method based on machine vision, and relates to the technical field of image data processing, and the method comprises the steps: obtaining an initial image of a headphone injection mold; performing recovery processing on the initial image through a blind deconvolution recovery algorithm, and determining a recovery image of the headset injection mold; the restored image is preprocessed, and a target image of the headset injection mold is determined; extracting a plurality of image features of the target image; constructing a mold defect detection model based on a random forest algorithm; inputting each image feature into the mold defect detection model based on the random forest algorithm for defect detection; when the headphone injection mold is detected to have defects, sending out an early warning signal; and when the headphone injection mold is not detected to have defects, returning to S1. The method is high in detection efficiency and short in time consumption, and can realize real-time detection of mold defects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image data processing, and in particular to a method for detecting defects of a headphone injection mold based on machine vision. Background Art

[0002] With the widespread application of injection molds in industrial production, mold quality has become a key factor affecting product appearance, performance and market competitiveness. In the production process of headphones, the processing accuracy and operating status of the injection mold directly determine the quality and stability of the product.

[0003] However, in the long-term use, injection molds may have defects such as flash, shrinkage marks, cracks, etc. due to mold fatigue, processing defects or improper operation. These problems will not only seriously affect the appearance of the headphone products, but may also lead to performance degradation and shortened service life. In order to ensure the normal operation of the mold and the high-quality output of the product, timely detection and accurate positioning of mold defects has become an indispensable and important part of the production process.

[0004] In the prior art, since industrial cameras are often affected by lighting changes, motion blur and environmental interference during the shooting process, the captured mold images are not clear and it is difficult to accurately reflect the true state of the mold surface.

[0005] In addition, the existing mold defect detection mainly relies on manual visual inspection, which is inefficient, time-consuming, and unable to achieve real-time detection of mold defects. Summary of the invention

[0006] In order to solve the technical problems that traditional industrial cameras are often affected by lighting changes, motion blur and environmental interference during the shooting process, resulting in the collected mold images having low clarity and difficulty in accurately reflecting the true state of the mold surface, and the existing mold defect detection mainly relies on manual visual inspection, with low detection efficiency and long detection time, and cannot realize real-time detection of mold defects, the present invention provides a headphone injection mold defect detection method based on machine vision.

[0007] The technical solution provided by the embodiment of the present invention is as follows:

[0008] First aspect:

[0009] An embodiment of the present invention provides a method for detecting defects of a headphone injection mold based on machine vision, comprising:

[0010] S1: Acquire the initial image of the headphone injection mold;

[0011] S2: restoring the initial image by a blind deconvolution restoration algorithm to determine a restored image of the headphone injection mold;

[0012] S3: preprocessing the restored image to determine a target image of the headphone injection mold;

[0013] S4: extracting multiple image features of the target image;

[0014] S5: Build a mold defect detection model based on random forest algorithm;

[0015] S6: inputting each of the image features into the mold defect detection model based on the random forest algorithm to perform defect detection;

[0016] S7: When the headphone injection mold is detected to have defects, an early warning signal is issued;

[0017] S8: When no defect is detected in the headphone injection mold, return to S1.

[0018] Second aspect:

[0019] An embodiment of the present invention provides a machine vision-based headphone injection mold defect detection system, comprising: a memory and one or more processors;

[0020] One or more application programs are stored in the memory, and the one or more application programs are suitable for being executed by the one or more processors to implement the above-mentioned method for detecting defects of a headphone injection mold based on machine vision.

[0021] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0022] In the present invention, the initial image of the headphone injection mold is restored through a blind deconvolution restoration algorithm to determine the restored image of the headphone injection mold, thereby avoiding the problem of low clarity of the acquired mold image caused by the influence of illumination changes, motion blur and environmental interference during the shooting process of industrial cameras. The real state of the mold surface can be accurately reflected. The restored image is preprocessed to determine the target image of the headphone injection mold, and multiple image features extracted from the target image are input into a mold defect detection model based on a random forest algorithm for defect detection. Manual visual inspection is no longer relied on, and the detection efficiency is high and the time consumption is short, so real-time detection of mold defects can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0024] Figure 1 A schematic flow chart of a method for detecting defects of a headphone injection mold based on machine vision provided by an embodiment of the present invention;

[0025] Figure 2 A schematic structural diagram of a headphone injection mold defect detection system based on machine vision provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The technical solution of the present invention is described below in conjunction with the accompanying drawings.

[0027] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "example" in the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "example" is intended to present the concept in a specific way. In addition, in the embodiments of the present invention, the meaning expressed by "and / or" can be both, or it can be either of the two.

[0028] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.

[0029] Reference Manual Attached Figure 1 , showing a flow chart of a method for detecting defects in a headphone injection mold based on machine vision provided by an embodiment of the present invention.

[0030] The embodiment of the present invention provides a method for detecting defects in a headset injection mold based on machine vision. The method can be implemented by a headset injection mold defect detection device based on machine vision. The headset injection mold defect detection device based on machine vision can be a terminal or a server. The processing flow of the method for detecting defects in a headset injection mold based on machine vision can include the following steps:

[0031] S1: Acquire the initial image of the headphone injection mold.

[0032] Specifically, an industrial camera is installed on the injection molding production line to photograph the headphone injection mold, thereby obtaining an initial image of the headphone injection mold in real time.

[0033] It should be noted that, on the one hand, due to the inertial motion of the injection molding machine, there is a relative motion between the camera and the target image during a very short exposure time. This motion blur causes pixel drift in the captured image. On the other hand, the environment of the injection molding workshop (such as light and shadow changes, dust, etc.) will also interfere with the image quality and aggravate the motion blur of the image. Therefore, the initial image is often a blurred image, and the acquired blurred image needs to be further restored to obtain a clear image of the headphone injection mold.

[0034] In the present invention, by installing an industrial camera on the injection molding production line, mold images can be collected in real time to ensure the timeliness of defect detection and avoid the accumulation of defective products caused by delays.

[0035] S2: The initial image is restored by a blind deconvolution restoration algorithm to determine a restored image of the headphone injection mold.

[0036] It should be noted that the blind deconvolution restoration algorithm is a technology that restores a clear image when the cause of blur is unknown. It establishes an image degradation model and regards the blurred image as the result of a clear image being blurred. The algorithm does not need to know the specific blur form in advance, but gradually restores the clarity and details of the image through iterative calculation. Blind deconvolution is widely used in image quality problems caused by motion blur or optical system distortion, and can effectively improve the usability of the image.

[0037] In the present invention, the blind deconvolution algorithm does not need to clarify the specific cause of blur or blur model (such as motion blur, focal blur, etc.) in advance, and restores the clarity of the image through an adaptive optimization method, so that it can cope with various complex blur scenes and has a wide range of applicability. By restoring the blurred image to a clear image, the problem of detail loss and misjudgment caused by blur is reduced, thereby significantly improving the accuracy and reliability of defect detection and avoiding detection errors caused by image blur. Through the automated processing of the blind deconvolution algorithm, the reliance on manual judgment is reduced, the intelligence level of the system is improved, and human errors and labor costs are reduced.

[0038] In a possible implementation, S2 specifically includes sub-steps S201 to S203:

[0039] S201: restore the initial image using a blind deconvolution restoration algorithm:

[0040] ||h×fg|| 2 =E[∫(h×fg) 2 dx]=E(∫n 2 dx)=σ 2 E(e)

[0041] Among them, || || represents the second norm, h represents the point spread function, f represents the restored image, g represents the initial image, E represents the expected value, e represents the random variable, n represents the noise, σ 2 represents the variance of the noise.

[0042] S202: Convert the solution process of blind deconvolution recovery processing into a Lagrangian optimization problem:

[0043] min L(f,h)=min[||h×fg|| 2 +α 1 r(f)+α 2 r(h)]

[0044] Among them, min means taking the minimum value, L means the Lagrangian function, α 1 represents the weight coefficient of the regularization term of the restored image, r(f) represents the regularization term of the restored image, α 2 represents the weight coefficient of the regularization term of the point spread function, and r(h) represents the regularization term of the point spread function.

[0045] S203: Solve the Lagrangian optimization problem to determine a restored image of the headphone injection mold.

[0046] In the present invention, the blurred initial image can be restored to a clearer image through the blind deconvolution algorithm. This provides high-quality input for subsequent defect detection and avoids inaccurate detection results caused by blurred images. The blind deconvolution restoration process is converted into a Lagrangian optimization problem, and the restored image and point spread function can be solved simultaneously through optimization theory. This two-variable optimization method not only improves the accuracy of the restoration result, but also solves the noise amplification and overfitting problems through regularization constraints. The clear image provides a more reliable basis for the subsequent texture and edge feature extraction, significantly improves the accuracy and robustness of the defect detection algorithm, and reduces misjudgment and missed detection.

[0047] Optionally, the Lagrangian optimization problem is solved by an alternating optimization method to determine a restored image of the headphone injection mold.

[0048] It should be noted that the alternating optimization method is a commonly used technique in optimization problems, especially for optimization tasks involving multiple variables. In the alternating optimization method, the optimization problem is decomposed into multiple sub-problems. Each time the optimization is performed, a part of the variables is fixed and the other variables are optimized. By repeatedly performing this local optimization, the global or approximately global optimal solution can be obtained.

[0049] In a possible implementation, S203 specifically includes sub-steps S2031 to S2035:

[0050] S2031: Initialize the restored image and the initial value of the point spread function.

[0051] Optionally, the initial value of the restored image can be obtained by performing simple filtering or smoothing on the blurred image, such as Gaussian filtering or mean filtering.

[0052] Optionally, the initial value of the PSF can be assumed to be a Gaussian blur function, or other simple models (such as linear motion blur) can be selected according to the actual blur type.

[0053] S2032: Set the maximum number of iterations Q of the gradient descent method.

[0054] It should be noted that the gradient descent method is a commonly used optimization algorithm, which is used to find the minimum value of the objective function in an iterative manner. The core idea is to calculate the gradient of the objective function (i.e., the rate of change of the function value to the variable), and update the variable value in the direction of gradient descent so that the function value gradually decreases. The step size of each update is determined by the learning rate, and the size of the learning rate affects the convergence speed and stability. The gradient descent method is widely used in machine learning, deep learning, and other fields that require optimization to optimize model parameters or solve nonlinear optimization problems.

[0055] S2033: Fixed point spread function, optimized and restored image by gradient descent method.

[0056] It should be noted that when the point spread function is fixed, the goal of optimizing the restored image is to reduce the difference between the restored image and the blurred image by minimizing the part of the objective function related to the restored image while satisfying the regularization constraint.

[0057] Specifically, this process calculates the gradient direction of the restored image and continuously updates the image through the gradient descent method, so that the restored image gradually approaches the optimal solution, and finally obtains a clear restored result that is closer to the real image:

[0058] 1. Calculate the update direction of the restored image by gradient descent method:

[0059]

[0060] in, represents the gradient operator and T represents the transpose operation.

[0061] 2. Update recovery image:

[0062]

[0063] Among them, q represents the current iteration number and η represents the learning rate.

[0064] S2034: Fix the restored image and optimize the point spread function by gradient descent method.

[0065] It should be noted that when the restored image is fixed, the goal of optimizing the point spread function is to reduce the error between the point spread function and the blurring process by minimizing the part of the objective function related to the point spread function while satisfying the regularization constraint.

[0066] Specifically, this process fixes the restored image, calculates the gradient direction of the point spread function, and gradually adjusts the point spread function through the gradient descent method to make it more accurately describe the blurring process, thereby improving the restoration quality and improving the convergence effect of the model:

[0067] 1. Calculate the update direction of the point spread function by gradient descent method:

[0069]

[0070] 2. Update the point spread function:

[0071]

[0072] S2035: Repeat sub-steps S2033 to S2034 to alternately optimize the restored image and the point spread function until a maximum number of iterations is reached to determine the restored image of the headphone injection mold.

[0073] In the present invention, the alternating optimization method gradually approaches the optimal solution of the objective function by alternately optimizing the gradient descent method of the restored image and the point spread function. Before reaching the maximum number of iterations or satisfying the convergence condition, the algorithm can steadily reduce the error and improve the overall convergence effect. The alternating optimization method combined with the gradient descent method can effectively deal with the problems of noise and blur model uncertainty in the blurred image. Through the constraints of the regularization term, noise interference can be effectively suppressed to ensure the stability and robustness of the restored image and the point spread function.

[0074] S3: Preprocess the restored image to determine a target image of the headphone injection mold.

[0075] In the present invention, the restored image may still have certain noise, contrast problems or local uneven brightness. Through preprocessing, the image quality can be further improved, providing a more stable and clear image basis for subsequent feature extraction and defect detection.

[0076] In a possible implementation, S3 specifically includes sub-steps S301 and S302:

[0077] S301: grayscale processing of the restored image through gamma transformation:

[0078]

[0079] Among them, V out represents the grayscale value of the restored image of the headphone injection mold after grayscale processing, A represents the proportional coefficient used to adjust the gamma transform intensity, V in represents the grayscale value of the restored image of the headphone injection mold, and r represents the gamma value.

[0080] It should be noted that gamma transform is a nonlinear image grayscale processing method that adjusts the contrast and brightness of an image by exponentially changing the grayscale value of the image. Its core is to enhance the high grayscale or low grayscale areas of the image by adjusting the gamma value, so that the brightness distribution of the image is more in line with visual perception requirements. Gamma transform is widely used in image preprocessing, which can effectively improve image exposure problems, enhance details, and reduce brightness distortion in certain scenes.

[0081] S302: Denoising the restored image after grayscale processing by median filtering to determine the target image of the headphone injection mold:

[0082] l median (x,y)=median[j(b,d)] (b,d)∈N(x,y)

[0083] Among them, l median (x,y) represents the pixel value of the pixel with horizontal coordinate x and vertical coordinate y in the target image, median represents the median, j(b,d) represents the pixel value of the pixel with horizontal coordinate b and vertical coordinate d in the neighborhood, and N(x,y) represents the neighborhood range of the pixel with horizontal coordinate x and vertical coordinate y in the restored image after grayscale processing.

[0084] Specifically, through median filtering, all pixels in the restored image after grayscale processing are traversed, and the neighborhood range is determined with each pixel as the center. The grayscale values ​​of all pixels in the neighborhood are sorted, and the middle value is taken as the final grayscale value of the current pixel. In this way, median filtering effectively removes salt and pepper noise and speckle noise in the image, while retaining the edge and texture information of the image, avoiding image blur caused by filtering.

[0085] It should be noted that median filtering is a commonly used image denoising method that reduces noise by replacing the value of the central pixel with the median value in the pixel neighborhood. This method is particularly effective for salt and pepper noise and speckle noise because it can preserve the edges and details of the image without introducing blur. The core idea of ​​median filtering is to traverse the image matrix, sort the pixel values ​​in the neighborhood of each pixel, and take the middle value, thereby filtering out extreme noise points while maintaining the structural characteristics of the image.

[0086] In the present invention, gamma transform can enhance the high grayscale or low grayscale area of ​​the image by nonlinearly adjusting the grayscale value, thereby making the brightness distribution more uniform, solving the exposure problem in the restored image, and improving the overall visibility of the image. Median filtering can remove salt and pepper noise and speckle noise in the image while maintaining the edge and texture information of the image, avoiding the blurring phenomenon introduced by traditional filtering methods. The combination of gamma transform and median filtering can improve the brightness and contrast of the image while removing noise and retaining key features, thereby generating a clear and high-quality target image.

[0087] S4: Extract multiple image features of the target image.

[0088] Optionally, S4 is specifically:

[0089] Multiple image features of the target image are extracted through the local binary pattern algorithm.

[0090] It should be noted that the Local Binary Patterns (LBP) algorithm is a texture feature extraction method used to describe the local texture information of an image. The core idea is to compare the grayscale value of each pixel with that of the surrounding neighboring pixels, mark the neighboring pixels that are larger than the central pixel as 1, and those that are smaller as 0, thereby generating a binary pattern. The LBP algorithm has the characteristics of simple calculation and strong robustness to illumination changes. It is particularly suitable for scenes such as texture classification and image feature extraction, and is an effective image analysis tool.

[0091] In the present invention, the LBP algorithm is a feature extraction method that focuses on texture information. It generates a binary pattern by comparing the grayscale values ​​of neighboring pixels and central pixels, and can efficiently capture the local texture features of the image. This is crucial for mold defect detection and can help identify texture anomalies caused by defects. Mold images may be affected by changes in lighting in a production environment. The LBP algorithm is based on relative comparison of grayscale values ​​and is not affected by absolute brightness. Therefore, it has strong lighting robustness and can stably extract image features under complex lighting conditions.

[0092] In a possible implementation, S4 specifically includes sub-steps S401 to S405:

[0093] S401: Setting a pixel point in the target image as a central pixel point.

[0094] S402: Determine a neighborhood range of a central pixel point, where the neighborhood range of the central pixel point includes a plurality of neighboring pixel points.

[0095] Optionally, neighborhood ranges of different sizes are selected according to actual application requirements, such as a 3×3, 5×5 or larger rectangular window centered on the central pixel.

[0096] S403: Compare the difference between the grayscale values ​​of each neighborhood pixel and the central pixel, and generate a binary code:

[0097]

[0098] Among them, sign represents the sign function, G i represents the i-th neighborhood pixel, G c Represents the cth central pixel.

[0099] Specifically, according to the order of the neighborhood pixels in the window, the differences between the grayscale values ​​of each neighborhood pixel and the center pixel are compared in turn. For each neighborhood pixel, if its grayscale value is greater than or equal to the grayscale value of the center pixel, it is marked as 1. If it is less than the grayscale value of the center pixel, it is marked as 0. The comparison results are arranged in a fixed order of the neighborhood pixels in the window, and finally a binary string is generated as the local pattern code of the center pixel.

[0100] S404: Convert the binary code into a decimal number to obtain the LBP value of the central pixel:

[0101]

[0102] Among them, LBP represents the LBP value of the central pixel, and I represents the total number of neighborhood pixels.

[0103] S405: Repeat sub-steps S401 to S403, traverse all pixels in the target image, and calculate the LBP value of each pixel to obtain multiple image features based on the LBP value.

[0104] Specifically, the LBP algorithm processes each pixel in the target image, sets it as the central pixel one by one, and generates the corresponding LBP value according to the gray value distribution of other pixels in the neighborhood of the pixel. During the processing, all pixels in the image are traversed, and the LBP value of each pixel is calculated and stored. These LBP values ​​effectively capture the local texture features of the image and reflect the structural information of the image through the overall features.

[0105] In the present invention, the LBP algorithm generates a binary code that can reflect the local texture features by comparing the grayscale values ​​of the central pixel and the neighboring pixel, and can accurately capture the slight texture changes on the mold surface. The LBP value can effectively reflect the subtle differences in the local texture features in the image. By traversing all the pixels of the image to calculate the LBP value, the texture anomalies that may be caused by defects can be captured, the detection accuracy can be improved, and the probability of false detection and missed detection can be reduced. By extracting the image features based on LBP, the system can more robustly adapt to the detection tasks of different mold types and different environments, has a strong generalization ability, and is suitable for promotion and application in a variety of mold defect detection scenarios.

[0106] S5: Build a mold defect detection model based on random forest algorithm.

[0107] It should be noted that the random forest algorithm is an ensemble learning method based on decision trees, which completes classification or regression tasks by constructing and combining multiple decision trees. It generates each decision tree by random sampling and feature selection, thereby reducing the model's dependence on a single tree, and improving the overall prediction accuracy and stability by integrating the results of multiple trees. Random forests have strong resistance to overfitting, robustness to missing data, and good generalization performance, and are widely used in data mining, feature selection, and model prediction. Through majority voting or average calculation, random forests can effectively handle high-dimensional data and nonlinear problems.

[0108] In the present invention, random forest reduces the error that may be caused by a single decision tree by combining the results of multiple decision trees, and can effectively capture the complex patterns of mold defect features, thereby improving the accuracy of defect detection. The feature data of mold images may have high dimensions. Random forest can reduce the computational complexity through random feature selection, retain important information, and ensure efficient processing of high-dimensional feature data.

[0109] S6: Input each image feature into a mold defect detection model based on a random forest algorithm to perform defect detection.

[0110] In the present invention, the random forest model can combine multiple image features and accurately identify the defect type on the mold surface by integrating the classification results of multiple decision trees, thereby improving the accuracy of defect detection and reducing the occurrence of false detection and missed detection. By directly inputting image features into the random forest model, an automated defect detection process can be achieved without the need for manual participation in feature classification and judgment, greatly improving detection efficiency and meeting the real-time detection requirements of industrial production lines. There may be complex nonlinear relationships between mold defect features. The random forest model can flexibly capture these complex relationships by constructing multiple nonlinear decision trees, thereby improving the sensitivity and adaptability of defect detection.

[0111] In a possible implementation, S6 specifically includes sub-steps S601 to S606:

[0112] S601: construct an initial forest consisting of multiple decision trees, where the decision tree includes multiple nodes.

[0113] S602: Calculate the information gain and Gini index of the current node of each decision tree:

[0114]

[0115] Where Gain() represents information gain, M represents the number of image features in the current node, a represents the attribute of the image feature, Ent() represents the entropy of the image feature set, V represents the number of child nodes generated after node division, || represents taking the absolute value, and M v represents the number of image features in the vth child node after node division, K represents the number of categories, and p k It represents the probability that the image feature belongs to the kth category, and Gini() represents the Gini index.

[0116] S603: Dynamically determine the node division rule based on the information gain and Gini index of the current node:

[0117]

[0118] Among them, O represents the node division rule, min represents the minimum value, W{} represents the comprehensive function, ρ represents the weight coefficient of the Gini index, τ represents the weight coefficient of the information gain, and R represents the domain of the weight coefficient.

[0119] S604: According to the node division rule, use various image features to perform node division on the current node.

[0120] S605: When the number of image features in the current node is less than a preset number, node division is stopped to obtain multiple defect categories output by multiple decision trees.

[0121] It should be noted that those skilled in the art can set the size of the preset number according to actual needs, and the present invention is not limited thereto.

[0122] S606: According to each defect category, through a voting mechanism, it is determined that the defect category with the most votes is the defect category of the headphone injection mold.

[0123] In the present invention, by constructing multiple randomly generated decision trees, a powerful integrated model is formed, which can fully learn the relationship between image features and defect categories in the initial stage, providing a basis for subsequent classification. By comprehensively considering information gain and Gini index, and dynamically adjusting the node division criteria according to the weight, the optimal splitting is achieved. Using the optimal feature splitting node, the image feature space is gradually divided into finer areas, making each area more homogeneous. By dividing the feature space by multiple decision trees, the defect information of the mold surface can be captured from multiple dimensions, improving the accuracy of classification.

[0124] S7: When defects are detected in the headphone injection mold, an early warning signal is issued.

[0125] In the present invention, through real-time early warning, the operator can quickly take measures, such as adjusting injection molding process parameters or replacing molds, thereby reducing production downtime and improving production efficiency. By automatically detecting and issuing early warning signals by the system, there is no need to rely on manual frequent inspections of molds, reducing labor costs and improving the efficiency and consistency of detection.

[0126] In a possible implementation, S7 specifically includes sub-steps S701 to S703:

[0127] S701: When the headphone injection mold is detected to have flash defects, a first-level warning signal is issued.

[0128] It should be noted that flash refers to the excess flakes or burrs formed when plastic material overflows from the parting surface, insert joint surface or core mating surface of the mold during the injection molding process. This defect is usually caused by insufficient mold manufacturing accuracy, non-parallel mold parts, insufficient clamping force or excessive injection pressure, which seriously affects the appearance and dimensional accuracy of the product.

[0129] Specifically, when a flash defect is detected in the mold, a first-level warning signal is triggered. At this time, the system issues a lower-level alarm, usually in the form of a visual prompt (such as a flashing indicator light) or an audio prompt (such as a short beep), to remind the operator to pay attention to the mold operation status and conduct timely inspections to prevent further problems from affecting product quality.

[0130] S702: When the headphone injection mold is detected to have a shrinkage defect, a secondary warning signal is issued.

[0131] It should be noted that shrinkage marks refer to the depressions or shrinkage marks that appear in the area of ​​plastic products with larger wall thickness due to uneven cooling shrinkage. This defect is mainly caused by unreasonable design of mold cooling system, insufficient injection pressure or poor material fluidity, which will affect the appearance quality and mechanical properties of the product.

[0132] Specifically, when a mold sink mark defect is detected, a secondary warning signal is triggered. The system issues an alarm in a more obvious way, such as a continuous beep or a specific error message displayed on the screen, prompting the operator that there may be a more serious problem with the mold and that the injection molding parameters or mold cooling system need to be adjusted immediately.

[0133] S703: When the headphone injection mold is detected to have cracking defects, a third-level warning signal is issued.

[0134] It should be noted that cracking refers to crack defects caused by internal stress concentration or external force during demoulding or use of plastic products. The causes include improper mold design, uneven ejection, insufficient or excessive plasticization of materials, and unreasonable design of product wall thickness. This defect will weaken the structural strength of the product and affect its service life.

[0135] Specifically, when cracking defects are detected in the mold, the highest level three warning signal will be triggered. The system will issue a strong and continuous alarm, such as a high-frequency sound alarm and a red warning light, and may even automatically suspend equipment operation to avoid serious damage to the mold or production accidents, requiring the operator to take immediate measures to repair the problem.

[0136] In the present invention, through the first, second and third level warning signals, the system can trigger the corresponding level of alarm according to the severity of the defect, so that the operator can give priority to more urgent problems, thereby avoiding the impact of the expansion of serious defects on production. The system automatically classifies warnings according to the defect type, reduces dependence on manual experience, improves the level of intelligence, and promotes the transformation of mold production lines to full automation and intelligence. Different warning signal intensities guide operators to respond quickly, effectively shortening the time from defect detection to processing.

[0137] S8: When no defect is detected in the headphone injection mold, return to S1.

[0138] In the present invention, for molds that have not been detected with defects, the system directly enters the next round of inspection process, reducing unnecessary waiting time, improving inspection efficiency, and meeting the needs of high-speed production lines. Through cyclic inspection, potential mold problems can be quickly discovered and responded to, preventing defects from gradually developing into more serious problems, and improving the predictability of inspection and the reliability of the system.

[0139] In a possible implementation, the method for detecting defects in a headphone injection mold based on machine vision further includes:

[0140] S9: With the goal of minimizing the mean square error loss function, the mold defect detection model based on the random forest algorithm is optimized through the krill swarm optimization algorithm to determine the optimal parameter set of the mold defect detection model based on the random forest algorithm.

[0141] It should be noted that the mean square error loss function is an indicator used to evaluate the difference between the predicted result and the true value. It measures the accuracy of the model prediction by calculating the square average of the error between the predicted value and the true value. The smaller the loss value, the closer the predicted result is to the true value, and the better the performance of the model. Since this method will amplify large errors, it is more sensitive to outliers and is suitable for scenarios that require high-precision predictions.

[0142] It should be noted that the krill swarm optimization algorithm is an intelligent optimization algorithm that simulates the foraging and migration behavior of krill groups in nature. The algorithm finds the optimal solution to the problem by simulating the mutual cooperation, foraging movement and random diffusion of krill individuals in the group. Each krill individual adjusts its position according to its own position, interaction with its neighbors and the attractiveness of the target environment, thereby gradually approaching the optimal solution. The krill swarm optimization algorithm has the characteristics of strong global search ability and high adaptability, and is widely used in solving complex optimization problems.

[0143] In the present invention, through parameter optimization, the random forest model can better adapt to different mold types and defect scenarios, enhance the generalization ability of new data, and ensure the stability and robustness of the detection system.

[0144] In a possible implementation, S9 specifically includes sub-steps S901 to S902:

[0145] S901: With the goal of minimizing the mean square error loss function, construct the objective function:

[0146]

[0147] Wherein, min represents the minimum value, MSE represents the objective function, θ represents the parameter set of the mold defect detection model based on the random forest algorithm, S represents the total number of initial images of the headphone injection mold, and Y s represents the true diagnosis result of the initial image of the s-th headphone injection mold, represents the actual diagnosis result of the initial image of the s-th headphone injection mold.

[0148] S902: According to the objective function, the mold defect detection model based on the random forest algorithm is optimized by using the krill swarm optimization algorithm to determine the optimal parameter set of the mold defect detection model based on the random forest algorithm.

[0149] In the present invention, the goal is to minimize the mean square error loss function, which can significantly reduce the error between the predicted value and the true value, improve the prediction accuracy of the random forest model, and ensure the accuracy of the mold defect detection results. The parameters of the random forest model are automatically adjusted by the krill swarm optimization algorithm to avoid the complexity and inefficiency of manual parameter adjustment, greatly improving the optimization efficiency. By automatically optimizing the parameters, the random forest model can adapt to the characteristic patterns of different mold defects and enhance the classification ability of diversified defect scenarios.

[0150] In a possible implementation, S902 specifically includes sub-steps S9021 to S9028:

[0151] S9021: Initialize parameters and set the maximum number of iterations of the krill swarm optimization algorithm.

[0152] S9022: Generate an initial population through Logistic chaos mapping. The initial population includes multiple krill individuals. Each krill individual represents a feasible parameter set of a mold defect detection model based on the random forest algorithm:

[0153] X z (t+1)=γX z (t)·(1-X z (t))

[0154] Among them, X z (t+1) represents the position of the zth krill individual at the t+1 iteration, γ represents the branching coefficient with a value of 3.95, and X z (t) represents the position of the z-th krill individual at the tth iteration.

[0155] It should be noted that Logistic chaos mapping is a classic nonlinear dynamic system model, which is widely used to study chaotic phenomena and their applications. It simulates complex nonlinear behaviors through simple mathematical expressions and shows high sensitivity to initial conditions. Logistic chaos mapping is usually used to generate chaotic sequences, and is often used in fields such as image encryption, random number generation and optimization algorithms. Its chaotic characteristics give it significant advantages in exploring the solution space of problems and avoiding local optimality.

[0156] S9023: Taking the objective function as the fitness function, calculating the fitness value of each krill individual, and taking the krill individual with the maximum fitness value as the current krill individual.

[0157] S9024: Adaptively adjust the inertia weight of foraging motion and induced motion through cosine control factors:

[0158]

[0159] Among them, ω1 represents the inertia weight of the foraging motion after adaptive adjustment, ω 2 represents the inertia weight of the induced motion after adaptive adjustment, ω max represents the maximum value of the inertia weight, ω min represents the minimum value of the inertia weight, T represents the maximum number of iterations, and P represents a random number in the range of (0,1).

[0160] It should be noted that the cosine control factor is a method used to dynamically adjust parameters in optimization algorithms. The control factor is usually decreased or increased by the change law of the cosine function. It can smoothly adjust the search range during the optimization process, thereby maintaining a large exploration capability in the early stage and gradually transitioning to a fine search in the later stage. The cosine control factor is widely used in optimization algorithms, for example, to adjust weights, step sizes or probabilities to improve the global search capability and convergence speed of the algorithm. It is characterized by smooth changes and can effectively balance the needs of global search and local convergence.

[0161] S9025: Adaptively adjust the foraging motion and the induced motion according to the inertia weights of the adaptively adjusted foraging motion and the induced motion:

[0162]

[0163] Among them, F' z represents the foraging movement of the zth krill individual after adaptive adjustment, F z represents the foraging movement of the zth krill individual, S f represents the foraging speed, β z represents the foraging direction of the z-th krill individual, represents the last foraging movement of the z-th krill individual, represents the current best foraging direction to attract the z-th krill individual, represents the historical best foraging direction to attract the z-th krill individual, G' z represents the induced motion of the zth krill individual after adaptive adjustment, G z represents the induced motion of the zth krill individual, G max represents the maximum induced velocity, b z represents the induction factor of the zth krill individual, represents the last induced movement of the z-th krill individual.

[0164] S9026: Update the current position of the krill individual according to the adaptively adjusted foraging movement and induced movement:

[0165] X z (t+Δt)=X z (t)+Δt(F'z +G' z +U z )

[0166] U z =U max ξ

[0167] Among them, X z (t+Δt) represents the position of the z-th krill individual at the t+Δt-th iteration, Δt represents the step length when the krill individual is updated, and U z represents the random diffusion rate of the zth krill individual, U max represents the maximum diffusion rate, ξ represents the random disturbance factor with a value range of [-1,1].

[0168] S9027: Update the position of the current krill individual through the Cauchy mutation operation:

[0169]

[0170] in, represents the position of krill individuals after Cauchy mutation, represents the position of the z-th krill individual after Cauchy mutation at the t-th iteration, and C(0,1) represents a Cauchy distribution random variable.

[0171] It should be noted that the Cauchy mutation operation is a commonly used mutation method in intelligent optimization algorithms. It generates random numbers based on the Cauchy distribution and is used to update the individual solution or position. Unlike the traditional normal distribution mutation, the Cauchy mutation has a longer tail and can produce a larger step size change, so it has a stronger global search capability during the exploration process. It can effectively prevent the algorithm from falling into the local optimal solution, improve the exploration efficiency of the solution space, and maintain a certain degree of search randomness. The Cauchy mutation operation is widely used in optimization algorithms such as genetic algorithms and particle swarm optimization to enhance the robustness and diversity of the algorithm.

[0172] S9028: Repeat sub-steps S9024 to S9027. When the maximum number of iterations is reached, the algorithm stops and the optimal parameter set of the mold defect detection model based on the random forest algorithm is output.

[0173] In the present invention, the krill swarm optimization algorithm is combined with the Logistic chaos map and the Cauchy mutation operation, which can fully explore the entire solution space and effectively avoid falling into the local optimal solution. Through the global search capability, it is ensured that the optimal parameter set of the random forest model is found, and the accuracy and stability of mold defect detection are improved. The inertia weights of foraging motion and induced motion are dynamically adjusted through the cosine control factor, and a large search range is maintained in the early stage of optimization to improve the global exploration capability. In the later stage of optimization, it gradually focuses on fine search to improve the local convergence ability, thereby achieving a balance between search efficiency and optimization effect.

[0174] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0175] In the present invention, the initial image of the headphone injection mold is restored through a blind deconvolution restoration algorithm to determine the restored image of the headphone injection mold, thereby avoiding the problem of low clarity of the acquired mold image caused by the influence of illumination changes, motion blur and environmental interference during the shooting process of industrial cameras. The real state of the mold surface can be accurately reflected. The restored image is preprocessed to determine the target image of the headphone injection mold, and multiple image features extracted from the target image are input into a mold defect detection model based on a random forest algorithm for defect detection. Manual visual inspection is no longer relied on, and the detection efficiency is high and the time consumption is short, so real-time detection of mold defects can be achieved.

[0176] Reference Manual Attached Figure 2 , showing a structural schematic diagram of a headphone injection mold defect detection system based on machine vision provided by the present invention.

[0177] The present invention further provides a machine vision-based headphone injection mold defect detection system 30 , comprising: a memory 303 and one or more processors 301 .

[0178] One or more application programs are stored in the memory 303 , and the one or more application programs are suitable for being executed by the one or more processors 301 to implement the method for detecting defects of a headphone injection mold based on machine vision described in the method embodiment.

[0179] The headphone injection mold defect detection system 30 based on machine vision includes: a processor 301 and a memory 303. The processor 301 and the memory 303 are connected, for example, through a bus 302.

[0180] The structure of the machine vision-based headphone injection mold defect detection system 30 does not constitute a limitation on the embodiment of the present invention.

[0181] The processor 301 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA or other programmable logic device, a transistor logic device, a hardware component or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present invention. The processor 301 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0182] The bus 302 may include a path to transmit information between the above components. The bus 302 may be a PCI bus or an EISA bus, etc. The bus 302 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0183] The memory 303 can be a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, or an EEPROM, a CD-ROM or other optical disk storage, an optical disk storage (including a compressed optical disk, a laser disk, an optical disk, a digital versatile disk, a Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.

[0184] It should be noted that the headphone injection mold defect detection system 30 based on machine vision can implement the above-mentioned headphone injection mold defect detection method based on machine vision, and can achieve the same or similar technical effects. To avoid repetition, the present invention will not go into details.

[0185] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0186] In the present invention, the initial image of the headphone injection mold is restored through a blind deconvolution restoration algorithm to determine the restored image of the headphone injection mold, thereby avoiding the problem of low clarity of the acquired mold image caused by the influence of illumination changes, motion blur and environmental interference during the shooting process of industrial cameras. The real state of the mold surface can be accurately reflected. The restored image is preprocessed to determine the target image of the headphone injection mold, and multiple image features extracted from the target image are input into a mold defect detection model based on a random forest algorithm for defect detection. Manual visual inspection is no longer relied on, and the detection efficiency is high and the time consumption is short, so real-time detection of mold defects can be achieved.

[0187] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

[0188] There are a few points to note:

[0189] (1) The drawings of the embodiments of the present invention only relate to the structures related to the embodiments of the present invention, and other structures may refer to the general design.

[0190] (2) For the sake of clarity, in the drawings used to describe the embodiments of the present invention, the thickness of the layers or regions is exaggerated or reduced, that is, these drawings are not drawn according to the actual scale. It is understood that when an element such as a layer, film, region or substrate is referred to as being "on" or "under" another element, the element may be "directly" "on" or "under" the other element or there may be intermediate elements.

[0191] (3) In the absence of conflict, the embodiments of the present invention and the features therein may be combined with each other to obtain new embodiments.

[0192] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. The protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for detecting defects in headphone injection molds based on machine vision, characterized in that: include: S1: Acquire the initial image of the headphone injection mold; S2: restoring the initial image by a blind deconvolution restoration algorithm to determine a restored image of the headphone injection mold; S3: preprocessing the restored image to determine a target image of the headphone injection mold; S4: extracting multiple image features of the target image; S5: Build a mold defect detection model based on random forest algorithm; S6: inputting each of the image features into the mold defect detection model based on the random forest algorithm to perform defect detection; S7: When the headphone injection mold is detected to have defects, an early warning signal is issued; S8: When no defect is detected in the headphone injection mold, return to S1.

2. The headphone injection mold defect detection method based on machine vision according to claim 1, characterized in that: The S2 specifically includes: S201: Restoring the initial image using a blind deconvolution restoration algorithm; S202: converting the solution process of blind deconvolution restoration into a Lagrangian optimization problem; S203: Solving the Lagrangian optimization problem to determine a restored image of the headphone injection mold.

3. The method for detecting defects of headphone injection molds based on machine vision according to claim 1, characterized in that: The S3 specifically includes: S301: performing grayscale processing on the restored image through gamma transformation; S302: performing denoising on the restored image after grayscale processing by median filtering to determine a target image of the headphone injection mold.

4. The method for detecting defects of headphone injection molds based on machine vision according to claim 1, characterized in that: The S4 is specifically: A plurality of image features of the target image are extracted by a local binary pattern algorithm.

5. The method for detecting defects of headphone injection molds based on machine vision according to claim 4, characterized in that: The S4 specifically includes: S401: Setting a pixel point in the target image as a central pixel point; S402: Determine a neighborhood range of the central pixel point, where the neighborhood range of the central pixel point includes a plurality of neighboring pixel points; S403: Compare the difference between the grayscale value of each of the neighborhood pixels and the central pixel to generate a binary code; S404: Convert the binary code into a decimal number to obtain the LBP value of the central pixel. S405: Repeat sub-steps S401 to S403, traverse all pixel points in the target image, and calculate the LBP value of each pixel point to obtain multiple image features based on the LBP value.

6. The method for detecting defects of headphone injection molds based on machine vision according to claim 1, characterized in that: The S6 specifically includes: S601: constructing an initial forest consisting of a plurality of decision trees, wherein the decision trees include a plurality of nodes; S602: Calculate the information gain and Gini index of the current node of each decision tree; S603: Dynamically determine the node division rule based on the information gain and Gini index of the current node; S604: performing node division on the current node using each of the image features according to the node division rule; S605: When the number of image features in the current node is less than a preset number, stop node division to obtain multiple defect categories output by multiple decision trees; S606: According to each of the defect categories, a voting mechanism is used to determine that the defect category with the largest number of votes is the defect category of the headphone injection mold.

7. The method for detecting defects of headphone injection molds based on machine vision according to claim 6, characterized in that: The S7 specifically includes: S701: When the headphone injection mold is detected to have a flash defect, a first-level warning signal is issued; S702: When the headphone injection mold is detected to have a shrinkage defect, a secondary warning signal is issued; S703: When the headphone injection mold is detected to have a crack defect, a third-level warning signal is issued.

8. The method for detecting defects of headphone injection molds based on machine vision according to claim 1, characterized in that: Also includes: S9: With the goal of minimizing the mean square error loss function, the mold defect detection model based on the random forest algorithm is optimized by using a krill swarm optimization algorithm to determine an optimal parameter set of the mold defect detection model based on the random forest algorithm.

9. The method for detecting defects of headphone injection molds based on machine vision according to claim 8, characterized in that: The S9 specifically includes: S901: construct an objective function with the goal of minimizing the mean square error loss function; S902: According to the objective function, the mold defect detection model based on the random forest algorithm is optimized by using a krill swarm optimization algorithm to determine an optimal parameter set of the mold defect detection model based on the random forest algorithm.

10. A headphone injection mold defect detection system based on machine vision, characterized in that: include: memory and one or more processors; One or more applications are stored in the memory, and the one or more applications are suitable for being executed by the one or more processors to implement the machine vision-based headphone injection mold defect detection method according to any one of claims 1 to 9.