In-mold foreign matter detection method and device, electronic equipment and storage medium
By analyzing image texture feature parameters, ambient light interference can be distinguished from real foreign objects, enabling adaptive template updates. This solves the problem of frequent false alarms in mold detection systems and improves detection accuracy and automation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GD MIDEA AIR CONDITIONING EQUIP CO LTD
- Filing Date
- 2026-03-26
- Publication Date
- 2026-07-03
AI Technical Summary
In existing mold detection systems, false alarms occur frequently due to changes in ambient light, affecting production efficiency and increasing manual intervention costs. Furthermore, these systems cannot effectively distinguish between changes in ambient light and actual foreign objects.
By analyzing image texture feature parameters, ambient light interference and real foreign objects are distinguished, enabling adaptive template updates. Multi-scale consistency, spatial continuity and temporal context features are used for weighted fusion to determine the authenticity of the difference regions.
It effectively reduces false alarm rate, improves detection accuracy, reduces manual maintenance costs, and enhances the automation level of the system.
Smart Images

Figure CN121893494B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent manufacturing technology, and in particular to a method, device, electronic device, and storage medium for detecting foreign objects inside a mold. Background Technology
[0002] In injection molding, the cleanliness of the mold's interior directly affects product quality and production safety. If foreign objects remain in the mold cavity, such as plastic debris, broken ejector pins, or incompletely detached parts, they can easily cause mold damage or product defects during the next mold closing, resulting in high maintenance costs and production stoppages. Therefore, reliable and efficient inspection of the mold's interior before each mold closing is a key technical requirement for ensuring the stable operation of automated production.
[0003] To meet the above requirements, existing technologies commonly employ a machine vision-based mold monitoring solution. This solution typically involves installing an industrial camera on the injection molding machine. First, an image is captured when the mold is clean and free of foreign objects, and this image is defined as a standard template image. In each subsequent production cycle, the system captures a real-time image to be inspected before mold closing and compares this real-time image with the pre-stored standard template image at the pixel level. When the difference in the comparison results exceeds a preset threshold, it is determined that a foreign object exists within the mold, and an alarm signal is immediately output to prevent the injection molding machine from closing the mold, thereby protecting the mold.
[0004] The aforementioned existing technical solutions have significant shortcomings in practical applications. Because the judgment logic of this solution relies on a simple difference comparison between the real-time image to be inspected and a fixed standard template image, it is prone to misjudgments due to factors such as ambient light, leading to numerous false alarms and severely disrupting normal production rhythms. To eliminate these false alarms, operators must frequently pause the production line, manually confirm the mold status, and then manually re-acquire a new standard template image. This not only significantly increases the cost of manual intervention but also significantly reduces the automation level and overall operating efficiency of the production line. Summary of the Invention
[0005] This invention provides a method, device, electronic device, and storage medium for detecting foreign objects inside a mold, which solves the problem in the prior art that the detection system cannot distinguish between changes in ambient light and real foreign objects, resulting in a high false alarm rate and the need for frequent manual intervention. It achieves intelligent recognition and adaptation to changes in ambient light, thereby improving the automation level and accuracy of mold detection.
[0006] This invention provides a method for detecting in-mold foreign objects, comprising:
[0007] In response to the detection trigger signal of the current detection cycle, a real-time image of the mold area is acquired as the image to be detected;
[0008] Determine the region of interest (ROI) image corresponding to the preset detection region in the image to be detected;
[0009] The region of interest image is compared with the template images in the template image set, and the difference region is extracted from the region of interest image;
[0010] Obtain the image texture feature parameters of the difference region;
[0011] Based on the image texture feature parameters, it is determined whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object.
[0012] If the discrepancy is determined to be false, the region of interest image is updated to the template image set and used as a comparison benchmark for subsequent detection.
[0013] If the discrepancy is determined to be genuine, an abnormal foreign object detection signal is output.
[0014] According to the present invention, an intramural foreign object detection method is provided, wherein obtaining the image texture feature parameters of the difference region includes:
[0015] Extract the grayscale image of the difference region and its surrounding neighborhood;
[0016] The grayscale image is traversed using a sliding window of a preset size, and the local entropy value within each sliding window is calculated to generate the current local entropy map;
[0017] The rate of change matrix of the current local entropy map relative to the reference local entropy map of the previous detection period is calculated and used as the image texture feature parameter.
[0018] According to the present invention, a method for detecting in-mold foreign objects, wherein determining whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object based on the image texture feature parameters includes:
[0019] Based on the rate of change matrix, the multi-scale consistency characteristics of the difference region are determined, wherein the multi-scale consistency characteristics are determined based on the sign of the change direction of the difference region at multiple scales;
[0020] The spatial continuity features of the differential regions are extracted, and these features are determined based on the proportion of connected domain area and the degree of discretization of the differential regions.
[0021] Extract the temporal context features of the difference region, which are determined based on the variance of the feature changes of the difference region in multiple consecutive historical detection periods;
[0022] The multi-scale consistency feature, the spatial continuity feature, and the temporal context feature are weighted and fused to obtain a weighted comprehensive score;
[0023] If the weighted composite score is greater than the preset ambient light interference judgment threshold, it is determined to be a false difference;
[0024] Otherwise, it is determined to be a genuine difference.
[0025] According to the present invention, an intramural foreign object detection method further includes, before determining the region of interest image corresponding to a preset detection region in the image to be detected:
[0026] Acquire a first reference image when the mold is fully open and contains the injection molded product, and a second reference image when the mold is closed and does not contain the injection molded product;
[0027] Perform a difference operation on the first reference image and the second reference image to extract the contour feature region;
[0028] The region within the outer polygon boundary of the contour feature region is set as the preset detection region.
[0029] According to the present invention, an intramural foreign object detection method is provided, wherein performing a difference operation on the first reference image and the second reference image to extract the contour feature region includes:
[0030] The first reference image and the second reference image are filtered respectively;
[0031] An initial difference image is obtained by performing a difference operation on the filtered first reference image and the second reference image;
[0032] After binarizing the initial difference image, morphological processing and connected component analysis are performed to extract the contour feature region.
[0033] According to the present invention, an in-mold foreign object detection method, wherein the step of acquiring a real-time image of the mold area as the image to be detected in response to a detection trigger signal of the current detection cycle includes:
[0034] Upon receiving the detection trigger signal, continuous video frame acquisition of the mold area is initiated;
[0035] Calculate the global pixel difference between adjacent video frames sequentially;
[0036] The video frame in which the global pixel difference is detected to be below a preset steady-state threshold for N consecutive frames is taken as the image to be detected, where N is a natural number greater than 1.
[0037] According to the present invention, an in-mold foreign object detection method is provided, wherein if the difference is determined to be a real difference, an abnormal foreign object detection signal is output, comprising:
[0038] If the difference is determined to be a real difference, the difference region is segmented by high and low thresholds to extract the bright sub-region and the dark sub-region respectively.
[0039] Calculate the shadow correlation vector formed between the centroid of the bright sub-region and the centroid of the dark sub-region;
[0040] If the angle between the shadow association vector and the preset ambient light source direction vector is within the preset parallel tolerance range, the output foreign object detection anomaly signal is determined to include the difference region as a solid foreign object with three-dimensional height;
[0041] If the included angle exceeds the parallel tolerance range, the output foreign object detection abnormal signal is determined to include the difference area as two-dimensional interference caused by surface oil or reflection.
[0042] According to the present invention, an in-mold foreign object detection method, after determining that the output foreign object detection anomaly signal includes the difference region as a solid foreign object with three-dimensional height, further includes:
[0043] Extract the geometric shape features and physical coordinate information of the difference region;
[0044] The geometric features and physical coordinate information are input into a preset fault knowledge base for matching to identify the current type of foreign object;
[0045] If the foreign object is identified as unremoved product residue, a linkage control signal is generated and output to trigger the injection molding machine to perform a secondary ejection action.
[0046] If the foreign object is identified as a damaged metal component of the mold, a shutdown alarm signal is generated and output to force the mold closing action to be locked.
[0047] According to the present invention, an in-mold foreign object detection method, when the mold to be detected has multiple repeating cavities, further includes, after determining the region of interest image corresponding to the preset detection area in the image to be detected, the method further includes:
[0048] In the region of interest image, periodic sub-regions corresponding to each cavity are divided;
[0049] Calculate the image similarity between each periodic sub-region in the image to be detected;
[0050] Calculate the average image similarity between each periodic sub-region and all other periodic sub-regions;
[0051] If the average similarity of the image in any periodic sub-region is lower than a preset consistency threshold, then it is directly determined that there is a real difference in any periodic sub-region, and the foreign object detection abnormal signal is output.
[0052] If the average similarity of the images is not lower than the consistency threshold, then the step of comparing the region of interest image with the template images in the template image set continues.
[0053] According to the present invention, an intramural foreign object detection method includes comparing the region of interest image with template images in a template image set and extracting the difference region from the region of interest image, comprising:
[0054] The region of interest image and the template image are filtered respectively;
[0055] A difference operation is performed on the filtered region of interest image and the template image to obtain a comparison difference image;
[0056] After binarizing the comparison difference image, morphological processing and connected component analysis are performed to extract abnormal regions;
[0057] The polygonal boundary of the abnormal region is taken as the difference region.
[0058] According to the present invention, an intramural foreign object detection method further includes, after comparing the region of interest image with template images in a template image set:
[0059] Extract small difference regions where the pixel difference value is lower than the alarm threshold but higher than the floor noise threshold, wherein the alarm threshold is the pixel difference threshold for extracting the abnormal region;
[0060] Record the coordinates of the occurrence of the minute difference regions and their frequency of occurrence in multiple consecutive detection cycles;
[0061] If the frequency of occurrence of the small difference area at the same coordinate is increasing, or the area of the small difference area at the same coordinate is expanding cumulatively, a predictive maintenance warning signal is output indicating that the mold has chronic wear or residue accumulation at the same coordinate.
[0062] The present invention also provides an in-mold foreign object detection device, comprising the following modules:
[0063] The image acquisition module is used to acquire real-time images of the mold area as the images to be detected in response to the detection trigger signal of the current detection cycle;
[0064] The region determination module is used to determine the region of interest image corresponding to the preset detection region in the image to be detected;
[0065] The difference extraction module is used to compare the region of interest image with the template images in the template image set, and extract the difference region from the region of interest image;
[0066] The feature acquisition module is used to acquire image texture feature parameters of the difference region;
[0067] An anomaly determination module is used to determine, based on the image texture feature parameters, whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object; if it is determined to be a false difference, the region of interest image is updated to the template image set as a comparison benchmark for subsequent detection; if it is determined to be a real difference, a foreign object detection anomaly signal is output.
[0068] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement any of the above-described methods for detecting foreign objects in a mold.
[0069] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the intramold foreign object detection method as described above.
[0070] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements any of the above-described methods for detecting foreign objects within a mold.
[0071] The method, apparatus, electronic device, and storage medium for detecting in-mold foreign objects provided by this invention analyze image texture features to determine the physical properties of differences, effectively distinguish between light interference and real foreign objects, and realize adaptive template updates under changes in ambient light. This overcomes the shortcomings of traditional visual detection that are easily affected by light, significantly reduces the false alarm rate and manual maintenance costs, and improves the detection accuracy of the system. Attached Figure Description
[0072] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0073] Figure 1 This is a schematic diagram of the injection molding production process using existing technology.
[0074] Figure 2 This is a flowchart illustrating the manual selection modeling process used in existing technologies.
[0075] Figure 3 This is one of the flowcharts for in-mold foreign object detection provided by the present invention.
[0076] Figure 4 This is a schematic diagram of the process for in-mold foreign object detection using existing technology.
[0077] Figure 5 This is the second schematic diagram of the in-mold foreign object detection process provided by the present invention.
[0078] Figure 6 This is a schematic diagram of the process for obtaining image texture feature parameters provided by the present invention.
[0079] Figure 7 This is one of the flowcharts provided by the present invention for determining the cause of the difference in the region.
[0080] Figure 8 This is the second flowchart of the process for determining the cause of the difference in the region provided by the present invention.
[0081] Figure 9 This is a schematic diagram of the process for determining the preset detection area provided by the present invention.
[0082] Figure 10 This is a schematic diagram of the process for determining the contour feature region provided by the present invention.
[0083] Figure 11 This is a schematic diagram of the automatic acquisition process of the image to be detected provided by the present invention.
[0084] Figure 12 This is a schematic diagram of the classification and recognition process for real differences provided by the present invention.
[0085] Figure 13 This is a schematic diagram illustrating the strategies for dealing with different categories of real differences provided by the present invention.
[0086] Figure 14 This is the third schematic diagram of the in-mold foreign object detection process provided by the present invention.
[0087] Figure 15 This is the fourth schematic diagram of the in-mold foreign object detection process provided by the present invention.
[0088] Figure 16 This is a schematic diagram of the in-mold foreign object detection device provided by the present invention.
[0089] Figure 17 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0090] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0091] It should be noted that in the description of this invention, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. The terms "upper," "lower," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0092] The terms "first," "second," etc., used in this invention are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more.
[0093] Figure 1 This is a schematic diagram of the injection molding production process using existing technology. Figure 2 This is a flowchart illustrating the manual selection modeling process used in existing technologies. Currently, for example... Figure 1 As shown, a complete injection molding production cycle includes actions such as mold closing, injection, demolding, and ejection, accompanied by electrical signals such as mold closing signal and mold opening to the bottom signal issued by the injection molding machine control system. Existing vision inspection solutions use these electrical signals as detection trigger signals to guide the camera to take pictures.
[0094] like Figure 2 As shown, when establishing the detection model, the operator needs to manually set a fixed delay after receiving the injection molding machine's mold opening signal. ΔTAfter the delay, the system acquires a detection image. Subsequently, the operator needs to manually select the mold cavity region to be detected on the detection image, i.e., the Region of Interest (ROI). The system crops the image within the ROI and saves it as a standard template image. At the same time, the operator also needs to manually set a series of complex detection parameters such as the area of the connected region and the grayscale difference threshold.
[0095] In the subsequent inspection process, after receiving the mold opening signal each time, the system also acquires real-time images after a fixed delay T2, and extracts the image to be inspected according to the pre-set ROI, then compares it with a fixed standard template image. The shortcomings of this method are obvious: First, the delay T2 is a fixed value, which cannot adapt to the varying speeds of mechanical movements caused by changes in equipment operating conditions (such as fluctuations in oil temperature and air pressure), easily resulting in motion-blurred or inaccurate images, affecting inspection accuracy; second, manually setting the ROI and various parameters is cumbersome and relies on experience, and must be repeated after mold changes; most importantly, its core judgment logic is based on the difference comparison between the real-time image and a fixed template, which cannot cope with the complex and ever-changing ambient lighting in the production site. When the lighting changes, it is very easy to generate large areas of false differences, leading to frequent false alarms from the system and seriously affecting production efficiency.
[0096] To address the aforementioned problems in existing technologies, this invention provides a novel method for detecting foreign objects within a mold. Unlike existing technologies, this invention, after extracting the difference region, does not directly determine whether it is abnormal. Instead, it innovatively adds a feature analysis step: first, it acquires and analyzes the image texture feature parameters of the difference region. Based on these parameters, it further determines whether the difference is a false difference caused by ambient light interference or a genuine difference caused by a physical foreign object. For cases determined to be false differences, the solution provided by this invention does not trigger an alarm or system shutdown. Instead, it intelligently updates the current image to the template image set, making it a new benchmark for subsequent detection, thus achieving adaptability to changes in ambient light. Only when a difference is determined to be genuine does the system output a foreign object detection anomaly signal.
[0097] Unless otherwise specified, the in-mold foreign object detection method provided in this embodiment of the invention can be executed by an in-mold foreign object detection device. This detection device can be a standalone industrial computer or a processing unit integrated into the injection molding machine control system, such as a controller containing hardware such as a processor and memory. In the following embodiments, the processor in the in-mold foreign object detection device will be used as the execution entity for description.
[0098] Figure 3 This is one of the flowcharts for in-mold foreign object detection provided by the present invention, such as... Figure 3As shown, the main steps include, but are not limited to, the following:
[0099] Step 1: In response to the detection trigger signal of the current detection cycle, acquire a real-time image of the mold area as the image to be detected.
[0100] The current inspection cycle refers to the complete process of injection molding production, from the first mold closing, through a series of actions such as injection, holding pressure, cooling, mold opening, and ejection, until the next mold closing begins. The detection trigger signal is a signal used to instruct the processor to perform image acquisition actions, and its source can be diverse. In one embodiment, it can be a level signal directly output from the injection molding machine's Programmable Logic Controller (PLC). For example, when the mold is fully open and stops moving, the PLC outputs a "mold open to the bottom" signal, which the processor can capture as the detection trigger signal. In another embodiment, the detection trigger signal can also be generated by a timer inside the processor, for example, generated after an estimated delay time after receiving the mold opening command. The real-time image of the mold area refers to a digital image reflecting the current physical state inside the mold, captured by an industrial camera mounted above the mold when it receives an acquisition command. This real-time image is defined by the system as the image to be inspected within the current inspection cycle after acquisition.
[0101] Step 2: Determine the region of interest (ROI) image corresponding to the preset detection region in the image to be detected.
[0102] The preset detection area refers to the critical area that needs to be detected for foreign objects, which usually corresponds to the cavity, core, runner, or ejector pin movement area of the mold. The parameters of this preset detection (such as coordinates, dimensions, and shape) can be stored in the system in advance.
[0103] Determining the region of interest (ROI) refers to the process by which the processor spatially locates and crops the image to be detected based on pre-stored preset detection region parameters. A simple way to understand this is that if the preset detection region is defined as a rectangle, the processor will extract a corresponding image sub-block from the image to be detected based on the coordinates of the top-left corner and the dimensions of the rectangle; this sub-block is the ROI.
[0104] Step 3: Compare the region of interest image with the template images in the template image set, and extract the difference region from the region of interest image.
[0105] Unlike existing technologies that use only a single fixed template, the template image set used in this embodiment is a dynamic collection that can store multiple reference template images taken under different, but all confirmed to be in normal conditions (such as clean molds under different lighting conditions). These template images together constitute the reference standard for subsequent comparisons.
[0106] The comparison operation between the region of interest image and template images in the template image set can be one or more image processing operations performed by the processor. For example, the processor can perform pixel-level grayscale subtraction between the region of interest image and one or more template images in the template image set to obtain a difference image.
[0107] Furthermore, in this embodiment, regions in the differential image where the pixel value is not zero or exceeds a specific noise threshold are identified as difference regions. These difference regions physically represent the parts where the current mold state is inconsistent with the template state.
[0108] Step 4: Obtain the image texture feature parameters of the difference region. These image texture feature parameters can be mathematical measures used to quantitatively describe the local patterns and arrangement rules of an image. They do not only include simple geometric features such as the area or perimeter of the difference region, but also deep features reflecting the complexity, roughness, or statistical characteristics of the internal pixel grayscale distribution.
[0109] For example, the texture of an image of a physical object (such as a screw) is usually characterized by clear boundaries and internal structure, and its texture feature parameters show high complexity and locality; while the difference caused by changes in lighting usually shows a large area of gentle gradation, and its texture feature parameters show lower complexity and global consistency.
[0110] In this embodiment, the method for obtaining image texture feature parameters of the difference region is that the processor runs a specific feature extraction algorithm on the extracted pixel data of the difference region to calculate one or a set of values that can characterize its texture characteristics. These values are the image texture feature parameters.
[0111] Step 5: Based on the image texture feature parameters, determine whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object.
[0112] This embodiment performs logical judgments based on the acquired image texture feature parameter values. False differences refer to differences generated during image comparison caused by non-physical factors, such as overall or local changes in ambient lighting. True differences, on the other hand, refer to differences caused by actual physical entities present within the mold (such as product residue, metal debris, oil stains, etc.).
[0113] The principle behind this embodiment for determining the cause of difference regions is that regions with different physical causes exhibit significantly different image texture feature parameters. Optionally, the processor may preset one or more decision thresholds. When the calculated image texture feature parameters fall within a specific numerical range—for example, if the image texture feature parameters indicate that the difference region has low complexity, high spatial continuity, and global distribution—the processor will determine it as a false difference. Conversely, if the image texture feature parameters indicate that the difference region has high complexity, strong edges, and local concentration, it will be determined as a true difference.
[0114] Furthermore, if the difference region is determined to be a false difference caused by ambient light interference, the image of the region of interest is updated to the template image set as a comparison benchmark for subsequent detection.
[0115] Figure 4 This is a schematic diagram of the in-mold foreign object detection process used in existing technologies, such as... Figure 4 As shown, in existing technologies, once the system detects a difference after calling the anomaly detection algorithm, regardless of its cause, it will directly trigger an alarm and pause the model merging process. If the difference is only caused by changes in illumination, the operator must manually re-check to confirm the absence of foreign objects before manually adding the current image to be detected to the standard template image set and adjusting the detection parameters, a process that is extremely cumbersome.
[0116] Figure 5 This is the second schematic diagram of the in-mold foreign object detection process provided by the present invention, as shown below. Figure 5 As shown, in this embodiment of the invention, when the processor determines that the difference region is a false difference caused by changes in ambient light, the system does not trigger an alarm. Instead, it automatically performs an update operation, adding or fusing the image of the region of interest, which is now confirmed to be normal under the new lighting conditions, into the template image set. In this way, in the next detection cycle, the system can use the updated template image set as a benchmark for comparison, thereby achieving adaptation to new lighting environments.
[0117] Conversely, if the discrepancy is determined to be a genuine difference, a foreign object detection anomaly signal will be output. It should be noted that in this embodiment, this step is only executed when the processor confirms that the difference area is caused by a real, existing physical foreign object. This foreign object detection anomaly signal can be a control signal sent by the processor to the injection molding machine's PLC or other external control unit via a communication interface (such as an I / O port), for example, a high-level signal or a specific communication message. The function of this foreign object detection anomaly signal is to trigger a response from the external device; its most typical application is to immediately stop the ongoing mold closing action of the injection molding machine, thereby effectively protecting the mold from damage.
[0118] The foreign object detection method provided by this invention analyzes image texture features to determine the physical properties of differences, effectively distinguishes between light interference and real foreign objects, and realizes adaptive template updating under changes in ambient light. It overcomes the shortcomings of traditional visual detection that are easily affected by light, greatly reduces the false alarm rate and manual maintenance costs, and improves the detection accuracy of the system.
[0119] Figure 6 This is a schematic diagram of the process for obtaining image texture feature parameters provided by the present invention, as shown below. Figure 6 As shown, based on the above embodiments, the embodiments of the present invention further illustrate how to quantitatively characterize the texture evolution characteristics of an image by calculating the specific features of local entropy, thereby realizing the acquisition of the aforementioned image texture feature parameters.
[0120] Specifically, the step of obtaining the image texture feature parameters of the difference region may include, but is not limited to:
[0121] Step 61: Extract the grayscale image of the difference region and its surrounding neighborhood.
[0122] After extracting the difference region, this embodiment expands outward by a preset number of pixels based on the edge of the difference region, thereby including the background information around the difference region and forming a complete analysis area that includes the surrounding neighborhood.
[0123] The purpose of including the surrounding neighborhood in the extracted grayscale image is to preserve sufficient contextual structure information in subsequent feature extraction and prevent feature calculation distortion caused by edge truncation. Subsequently, the image data within the analysis area is uniformly converted into a single-channel grayscale image to eliminate interference from color information, significantly reduce the computational load of subsequent matrix operations, and allow the processor to focus its analysis on the light and dark distribution and texture structure that reflect the physical properties of the object.
[0124] Step 62: Use a sliding window of a preset size to traverse the grayscale image, calculate the local entropy value within each sliding window, and generate the current local entropy map.
[0125] After acquiring the grayscale image, the processor will construct a memory array with a preset size (e.g., N). A sliding window (N pixel matrix) is used. The processor controls this sliding window to traverse the grayscale image region by region according to a preset step size. When the sliding window stops at a certain local area of the grayscale image, the processor extracts the grayscale values of all pixels within the sliding window and calculates the grayscale histogram of that local image.
[0126] Next, the histogram can be normalized, and then the degree of disorder or texture complexity of the pixel distribution within the specific window can be calculated according to the information entropy calculation formula. This value is the local entropy value.
[0127] After the sliding window completes its traversal of the entire grayscale image, all the calculated local entropy values are rearranged and mapped according to their corresponding spatial pixel coordinates, thereby constructing a two-dimensional matrix image that can intuitively reflect the spatial distribution of texture complexity in the region, namely the current local entropy map.
[0128] Step 63: Calculate the rate of change matrix of the current local entropy map relative to the reference local entropy map of the previous detection period, and use it as the image texture feature parameter.
[0129] After generating the current local entropy map, the processor will further call the historical data cached in the system memory, that is, read the reference local entropy map generated in the same spatial location in the previous detection cycle.
[0130] Subsequently, by performing element-wise difference and ratio calculations between the local entropy value of each coordinate point in the current local entropy map and the corresponding local entropy value in the reference local entropy map, the relative rate of change at each spatial location is obtained. These relative rates of change are combined according to the original spatial topology to form a rate of change matrix that fully reflects the dynamic evolution of the texture. Since this rate of change matrix filters out static background texture information and only retains the abrupt change in texture complexity between the current period and historical periods, it can be directly used as the image texture feature parameter for determining the cause of difference in the aforementioned embodiments.
[0131] The intramural foreign object detection method provided in this embodiment introduces a sliding window to calculate the local entropy value and construct a rate of change matrix before and after the detection period. It no longer relies on absolute gray values, which are extremely sensitive to light, for anomaly judgment. Instead, it delves into the essential differences between physical foreign objects and illumination in terms of changes in image texture structure. By using the rate of change matrix as an image texture feature parameter, it retains both spatial features and incorporates temporal evolution features. It can highly sensitively capture texture damage caused by the intrusion of physical foreign objects, providing a reliable data foundation for subsequent accurate elimination of ambient light interference.
[0132] Based on the above embodiments, as an optional embodiment, this invention describes in detail how the processor performs in-depth analysis of the rate of change matrix from three dimensions: space, scale, and time, thereby accurately removing the influence of ambient light fluctuations. Figure 7 This is one of the flowcharts provided by the present invention for determining the cause of the difference in regions, such as... Figure 7As shown, the step of determining whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object, based on the image texture feature parameters, mainly includes:
[0133] Based on the rate of change matrix, the multi-scale consistency characteristics of the difference region are determined, and the multi-scale consistency characteristics can be determined based on the sign of the change direction of the difference region at multiple scales.
[0134] This embodiment performs downsampling operations on the input rate of change matrix at different scales to generate frame change maps before and after each scale. Subsequently, the sign of the local entropy change direction can be calculated at each scale, that is, to determine whether the texture complexity increases (represented by a positive sign) or decreases (represented by a negative sign).
[0135] Thus, multi-scale consistency features are characterized by checking symbolic consistency. Since changes in ambient lighting in the workshop (such as overall darkening or brightening due to direct sunlight) usually cause a global and physically consistent interference to the imaging of the entire mold surface, the direction of texture change at different resolution scales often maintains a high degree of symbolic consistency. Conversely, if it is a solid foreign object such as a broken ejector pin, the abrupt change at its edge will cause chaotic alternating positive and negative symbols at different scales.
[0136] Furthermore, this embodiment extracts the spatial continuity features of the difference regions, which can be determined based on the proportion of connected domain area and the degree of discretization of the difference regions.
[0137] Changes in ambient light, like the spread of light waves, typically manifest as large-area, continuous changes in light and shadow. Therefore, their dominant region accounts for a very high percentage and their discretization is extremely low. In contrast, residual plastic debris and other physical foreign objects are mostly distributed locally and sporadically, resulting in a higher degree of discretization. Therefore, this embodiment, after identifying the changing regions, performs connected region analysis to extract all independent differential patches. Next, it calculates the dominant region percentage of the largest connected region relative to the total area of all changing regions, and simultaneously calculates the degree of discretization of each independent connected region in its spatial distribution.
[0138] Furthermore, this embodiment also extracts the temporal context features of the difference region, which can be determined based on the variance of feature changes of the difference region in multiple consecutive historical detection cycles.
[0139] It should be noted that this embodiment not only focuses on the current detection results but also reads the historical result sequence. The persistence of change is assessed by calculating the variance of the feature values in the current rate of change matrix compared to the feature changes over multiple consecutive production cycles. Changes in ambient light intensity are typically gradual or relatively stable over time, resulting in small variance in feature changes; however, the fall of a foreign object is a sudden event, causing significant variance fluctuations in the texture features of the current cycle compared to historical stable sequences.
[0140] Then, the multi-scale consistency features, spatial continuity features, and temporal context features are weighted and fused to obtain a weighted comprehensive score. The processor internally configures corresponding weight coefficients for each of the three dimensions. The processor obtains the symbol consistency score, dominant region proportion score, region discretization score, and change persistence score, and uses a weighted decision algorithm to linearly or non-linearly superimpose these scores to obtain a weighted comprehensive score that comprehensively reflects the physical attribute tendency of the differing region.
[0141] Finally, if the processor determines that the weighted composite score is greater than or equal to the preset ambient light interference judgment threshold, it determines it as a false difference. When the weighted composite score reaches or exceeds the ambient light interference judgment threshold, it means that the difference region simultaneously meets the three physical conditions of consistent change direction, contiguous spatial distribution, and stable temporal evolution. Based on this, the processor has sufficient logical basis to classify it as light change interference caused by light change, i.e., a false difference. Conversely, if the weighted composite score is lower than the ambient light interference judgment threshold, it indicates that it exhibits characteristics of local destruction, high dispersion, or suddenness. The processor then determines it as local interference, i.e., a real difference caused by physical foreign objects.
[0142] The in-mold foreign object detection method provided in this embodiment abandons the crude logic of relying on a single two-dimensional image grayscale threshold for a one-size-fits-all judgment in traditional visual inspection. It creatively constructs a three-dimensional analysis architecture that integrates "scale-space-time". By cross-validating the physical consistency of the direction of change, spatial clustering, and suddenness on the time axis, it rigorously separates the essential difference between photons (uniform and global fluctuation properties of light) and physical matter (local and sudden structural damage properties) in imaging from a mathematical perspective. This improvement enables the system to not only be completely immune to large-scale false alarms caused by extremely harsh light changes such as switching on and off high-ceiling lights in workshops, day and night alternation, and sunlight movement, but also retain the high sensitivity detection capability for small physical foreign objects without loss. It truly upgrades a fragile system that is easily affected by environmental interference into an industrial-grade adaptive detection system with extremely high environmental robustness.
[0143] Figure 8This is the second flowchart of the process for determining the cause of the difference in regions provided by the present invention, such as... Figure 8 As shown, to more intuitively understand the ambient light change detection algorithm in the diagram, this embodiment uses a specific example of an injection molding workshop in the early morning when sunlight shines directly on the mold surface, causing the entire surface to brighten. The entire algorithm's operation process will be explained in detail below:
[0144] First, image texture feature parameters are extracted to generate a local entropy map. After extracting the difference region, the processor first extracts the grayscale image of that difference region and its surrounding neighborhood. Because sunlight has now entered the workshop, the overall pixel grayscale value of this grayscale image is higher than that of the previous detection cycle.
[0145] The grayscale image is traversed using a sliding window of a preset size. As the window moves, the local entropy value within each window is calculated in real time. Since sunlight typically alters grayscale values uniformly without damaging the original physical texture of the mold surface, such as the brushed metal finish, the local entropy values within each sliding window do not undergo drastic changes. This allows the generation of the current local entropy map based on the local entropy values calculated from all sliding windows.
[0146] Furthermore, the processor reads the reference local entropy map from the previous detection cycle stored in memory—that is, the local entropy map before sunlight entered—and calculates the rate of change matrix of the current local entropy map relative to the reference local entropy map. This rate of change matrix then serves as the image texture feature parameter for subsequent determination.
[0147] To accurately determine whether the rate of change matrix is caused by ambient light or by a large transparent film or other solid foreign object, the processor extracts features from three dimensions based on the rate of change matrix:
[0148] (1) Extracting multi-scale consistency features, including multi-scale downsampling of the rate of change matrix and determining the sign of the change direction of the difference region at multiple scales. Since the overall brightness is caused by sunlight, the trend of its texture complexity change is highly consistent at each resolution scale. Therefore, the processor determines that the difference region has highly consistent multi-scale consistency features.
[0149] (2) Extracting spatial continuity features, including connected component analysis of the differential regions. Since sunlight covers the entire surface of the mold, the processor calculates that the area of the connected components in the differential regions is extremely high and the degree of discretization is extremely low. Based on this, spatial continuity features that conform to a large-area continuous distribution are extracted.
[0150] (3) Extracting temporal context features, including reading records from multiple consecutive historical detection periods. Since the brightening of the morning sunlight is a gradual and continuous process, not a sudden event, it can be calculated that the variance of the feature changes in the difference region in multiple consecutive historical detection periods is extremely small, and thus the temporal context features of stable evolution can be extracted.
[0151] Finally, the extracted multi-scale consistency features, spatial continuity features, and temporal context features are weighted and fused to obtain a weighted comprehensive score. Since the above features perfectly conform to the physical laws of consistent global change signs and extremely high spatial connectivity, the weighted comprehensive score calculated by the processor will inevitably be greater than or equal to the preset ambient light interference judgment threshold.
[0152] Ultimately, based on the comparison results, it can be determined that the discrepancy is a false difference caused by ambient light interference, rather than a real difference caused by a physical foreign object. Subsequently, the image of the region of interest currently illuminated by sunlight will be updated to the template image set to continue safely guiding subsequent production, thereby avoiding false alarms and shutdowns caused by changes in lighting.
[0153] Figure 9 This is a schematic diagram of the process for determining the preset detection area provided by the present invention, as shown below. Figure 9 As shown, before determining the region of interest image corresponding to the preset detection region in the image to be detected, this embodiment further includes:
[0154] Step 91: Obtain a first reference image when the mold is fully open and contains the injection molded product, and a second reference image when the mold is closed and does not contain the injection molded product.
[0155] Step 92: Perform a difference operation on the first reference image and the second reference image to extract the contour feature region;
[0156] Step 93: Set the region within the outer polygon boundary of the contour feature region as the preset detection region.
[0157] To achieve a high degree of automation in the inspection process and reduce manual intervention, this invention also provides a mechanism for automatically establishing inspection areas. In this embodiment, taking the injection molding of plastic machine caps as an example, it will be explained in detail how the key area of the preset inspection area is automatically locked by utilizing the natural physical state differences in the production process.
[0158] In the actual injection molding process of plastic covers, when an injection cycle ends and the mold is fully opened to the set position (i.e., in the fully open state), the newly formed plastic cover is still attached to the mold cavity. Upon receiving the signal from the fully open equipment, the processor immediately controls the camera to capture the current image, thus obtaining a first reference image containing the plastic cover. Subsequently, the ejector mechanism of the injection molding machine ejects the plastic cover, which is then picked up and removed by a robotic arm. Just before the mold is about to close for the next time (i.e., in the pre-close state), the mold cavity is emptied. The processor then controls the camera to capture the current image again, thus obtaining a second reference image completely free of the plastic cover.
[0159] After acquiring the two reference images, pixel-level difference operations are performed on them in memory. Since the camera's physical position remains fixed, the surrounding background structures, such as the mold frame and guide pillars, are completely static and consistent in both the first and second reference images. After the difference operation, the pixel differences in these static backgrounds approach zero. The only element whose physical state changes between the two images is the ejected plastic cover. Therefore, through the difference operation, the processor can perfectly extract the shape of the plastic cover from the complex mold background. The processor identifies these connected pixels with significant pixel differences, and then accurately extracts the contour feature region that perfectly matches the actual projected shape of the plastic cover.
[0160] After extracting the contour feature region, considering the possibility of minute reflective noise or pixel-level shifts caused by mechanical vibration at the edges, the processor does not directly use the irregular contour to ensure the inclusiveness and stability of the subsequent detection area. Instead, it calculates the minimum bounding rectangle or convex hull polygon boundary of the contour feature region using geometric algorithms. The processor then formally sets the entire pixel space inside this bounding polygon boundary, which can completely enclose the contour of the plastic cover plate, as the preset detection area for subsequent foreign object comparison by the system.
[0161] This embodiment cleverly utilizes the two deterministic physical states inherent in the injection molding process—product presence and product disappearance—to achieve automatic learning and calibration of the detection area through a pure vision algorithm. This completely overturns the outdated mode of traditional vision inspection systems that relied on experienced operators manually drawing detection frames on a screen using a mouse. It not only completely eliminates human error and blind spot omissions caused by manual frame drawing but also endows the system with plug-and-play flexible production capabilities. Whether the production line switches from injection molded covers to injection molded parts or changes to molds of different sizes, it can automatically and accurately reconstruct the detection area of the new mold after only one normal mold opening and closing cycle, greatly improving the automated production changeover efficiency and adaptability to the on-site environment of the inspection system.
[0162] Based on the above embodiments, the present invention further provides an automated construction mechanism for a preset detection area. Figure 10 This is a schematic diagram of the process for determining the contour feature region provided by the present invention, as shown below. Figure 10 As shown, the step of performing a difference operation on the first reference image and the second reference image to extract the contour feature region further includes the following steps:
[0163] Step 101: Filter the first reference image (region of interest image) and the second reference image (template image) respectively.
[0164] In the actual shooting environment of an industrial injection molding workshop, camera sensors are inevitably affected by electromagnetic interference, dust reflections, or minor vibrations, introducing high-frequency noise points into the acquired first and second reference images. To prevent this noise from being amplified and mistakenly identified as object contours in subsequent differential calculations, this embodiment performs filtering processing on the acquired first and second reference images respectively.
[0165] First, filtering algorithms (such as Gaussian filtering, median filtering, or mean filtering) can be called to perform spatial domain smoothing on the two reference images respectively. This can effectively preserve macroscopic structural features such as image edges while suppressing and eliminating isolated noise pixels, thus providing a clean image data source for subsequent pixel-level operations.
[0166] Step 102: Perform a difference operation on the filtered first reference image and the second reference image to obtain an initial difference image.
[0167] After filtering and noise reduction, the filtered first reference image (containing the product) and the second reference image (excluding the product) are extracted, and absolute value subtraction is performed on the corresponding spatial coordinate pixels of the two images. Since the background structure of the two images is completely identical, their corresponding pixel differences are close to zero; however, due to the fundamental change in the state of the product area from presence to absence, the corresponding pixel differences will increase significantly. By remapping the difference results of all pixels into a new two-dimensional grayscale matrix, the resulting two-dimensional grayscale matrix is the initial difference image, which intuitively highlights the potential product change areas in the form of high grayscale values.
[0168] Step 103: After binarizing the initial difference image, perform morphological processing and connected component analysis to extract the contour feature region.
[0169] Since the initial difference image is still a grayscale gradient image, the processor first binarizes it by setting an appropriate grayscale threshold, forcibly dividing the pixels into foreground (changing area) and background (unchanging area). Considering that the surface of the injection molded product may have uneven reflection or local areas similar in color to the mold background, resulting in voids or broken edges in the foreground area after binarization, this embodiment performs morphological processing (such as a dilation-erosion closing operation) to fill the voids in the foreground area and smooth its outer boundary. Subsequently, connected component analysis (i.e., blob analysis) is performed on the morphologically repaired image to calculate and filter out one or more independent connected patches with the largest area, filtering out small isolated patches caused by subtle changes in light and shadow. The processor finally extracts the selected connected patches completely as the contour feature region representing the true physical boundary of the product.
[0170] The in-mold foreign object detection method provided in this embodiment addresses the pain points of high noise levels in industrial field images and complex optical properties of product surfaces. It constructs a complete machine vision processing logic that includes pre-filtering noise reduction, differential highlighting, binarization segmentation, morphological repair, and connected component removal. This effectively overcomes the interference of spurious changes caused by product reflection, sensor noise, or weak environmental vibrations, ensuring that the final extracted product contour feature region has extremely high physical fidelity and boundary integrity.
[0171] Based on the above embodiments, in order to solve the technical defects of the prior art that the fixed delay parameter is easily affected by physical factors such as the different speed of the injection molding machine's mechanical movements and signal delay fluctuations, resulting in the capture of motion-blurred images or the loss of the best shooting opportunity, this embodiment has carried out an adaptive optimization design for the acquisition triggering mechanism of the image to be detected.
[0172] Figure 11 This is a schematic diagram of the automatic acquisition process of the image to be detected provided by the present invention, as shown below. Figure 11 As shown, this embodiment provides a scheme for dynamic soft-delay image capture using a moving target detection algorithm. Specifically, the step of acquiring a real-time image of the mold area as the image to be detected in response to the detection trigger signal of the current detection cycle may include, but is not limited to:
[0173] Step 111: Receive the detection trigger signal and start continuous video frame acquisition of the mold area.
[0174] Upon receiving a detection trigger signal from the injection molding machine control system, such as indicating a production process node like mold opening to completion or preparation for mold closing, the processor does not enter a fixed-duration blind waiting state as in existing technologies. Instead, it immediately controls the industrial camera connected to it to start video streaming mode. Through this video streaming mode, the processor begins high-frame-rate continuous video frame acquisition of the mold area, thus transforming the monitoring method for mold status from passive, timed triggering to active, real-time dynamic observation.
[0175] Step 112: Calculate the global pixel difference between adjacent video frames sequentially.
[0176] After acquiring a continuous video stream, a sliding data buffer is allocated in the processor's memory, and adjacent video frames arriving sequentially in chronological order (e.g., the current frame and the previous frame) are extracted one by one. Using a moving target detection algorithm, a global difference assessment is performed on the corresponding pixels of these two frames. By calculating the magnitude of change in the overall grayscale distribution or feature point position between the two, a quantitative index is obtained; this quantitative index is the global pixel difference. This global pixel difference objectively reflects, in a physical sense, whether the internal components of the mold (such as sliders, ejector pins, and robotic arms) are still in a state of mechanical movement or vibration.
[0177] Step 113: The video frame in which the global pixel difference is detected to be below a preset steady-state threshold for N consecutive frames is taken as the image to be detected, where N is a natural number greater than 1.
[0178] In this embodiment, after calculating the global pixel difference, it is compared in real time with a preset steady-state threshold within the system. This steady-state threshold represents the limit of minute environmental oscillations that the system can tolerate without affecting image sharpness.
[0179] To prevent misjudgments caused by brief pauses or instantaneous stops during mechanical movement, this embodiment can also add a time-dimensional fault tolerance check. This requires not only that the global pixel difference in a single calculation be below the steady-state threshold, but also that this low-difference state be maintained continuously for N frames in the time series. When the processor detects that the steady-state condition of N consecutive frames is met, it can logically and absolutely determine that all mechanical movements of the mold have completely stopped, and the mold is in a completely stationary steady state. At this point, the processor immediately extracts the current video frame that meets the condition from the video stream and uses it as the final image to be detected for anomaly comparison.
[0180] This embodiment completely breaks away from the hardware synchronization requirement of traditional machine vision inspection, which relies on fixed manual adjustment of the photo delay time. It introduces a soft delay mechanism based on moving target detection. By continuously calculating the global difference of video frames and combining it with multi-frame steady-state verification, it gives the inspection system a WYSIWYG dynamic perception capability. This enables the inspection system to be perfectly compatible with the signal delay differences of different brands of injection molding machines and to adapt to the fluctuations in action speed caused by hydraulic oil temperature and mechanical aging.
[0181] Based on the above embodiments that the difference area is a real difference, in order to further investigate two-dimensional artifacts caused by oil stains or strong metal reflections on the mold surface and prevent them from being falsely reported as solid foreign objects by the system, this embodiment of the invention introduces a three-dimensional feature verification mechanism based on light and shadow geometric correlation.
[0182] Figure 12 This is a schematic diagram of the classification and recognition process for real differences provided by the present invention, such as... Figure 12 As shown, this embodiment further provides a scheme for in-depth identification of the three-dimensional physical properties of real differences by analyzing the spatial relationship between bright reflections and projected shadows. Specifically, the step of outputting a foreign object detection anomaly signal if the difference is determined to be caused by a physical foreign object includes:
[0183] The difference region is segmented using high and low thresholds to extract bright and dark sub-regions respectively. In industrial visual inspection environments, the light source is usually a fixed, directional light source. Any physical object with physical height (such as a broken metal pin or residual plastic particles) will inevitably produce high-intensity specular or diffuse reflection on its illuminated surface under the illumination of a fixed directional light source, and project obvious shadows on its back surface or adjacent mold surfaces. Based on this physical optical phenomenon, this embodiment does not immediately trigger an alarm after determining that the difference region is a genuine difference. Instead, it performs dual threshold filtering on the grayscale distribution of the difference region. This mainly uses a preset high grayscale threshold to filter out a set of pixels with extremely high brightness as the bright sub-region, representing the illuminated and reflected part of the object; at the same time, it uses a preset low grayscale threshold to filter out a set of pixels with extremely low brightness as the dark sub-region, representing the projected shadow part formed by the object blocking the light.
[0184] Further, the shadow association vector formed between the centroids of the bright and dark sub-regions is calculated. After successfully separating the bright and dark sub-regions, the spatial geometric center coordinates of these two irregular pixel sets are calculated, i.e., the centroids of the bright and dark sub-regions are determined. Subsequently, in the two-dimensional image coordinate system, a spatial vector with a clear direction and length is constructed, starting from the centroid of the bright sub-region and ending at the centroid of the dark sub-region (or vice versa). This vector is the shadow association vector. The shadow association vector mathematically quantifies the relative spatial arrangement relationship between the luminous points and the shadow areas.
[0185] If the angle between the shadow association vector and the preset ambient light source direction vector is within the preset parallel tolerance range, then the output foreign object detection anomaly signal can be determined to include the difference region as a solid foreign object with three-dimensional height.
[0186] The system memory pre-calibrates and stores parameters reflecting the relative geometric relationship between the industrial camera and the fixed light source in the workshop, namely the ambient light direction vector. Since the direction of the shadow cast by a real three-dimensional foreign object must strictly follow the incident direction of the ambient light, the spatial angle between the newly acquired shadow correlation vector and the system-preset ambient light direction vector can be calculated. Considering that the irregularity of the foreign object's shape may cause a slight shift in the centroid position, this embodiment can set an angle range that allows for reasonable deviation as a parallel tolerance range. When the calculated angle falls within this parallel tolerance range, it is physically and logically confirmed that the brightness and darkness distribution is caused by an object of the same height blocking the light source, thus determining that the difference area is a solid foreign object with three-dimensional height, and this judgment result reflecting the three-dimensional physical properties is encapsulated in the final output foreign object detection anomaly signal.
[0187] If the included angle exceeds the parallel tolerance range, the output foreign object detection anomaly signal is determined to include the difference region as two-dimensional interference caused by surface oil or reflection. Conversely, if the mold surface only has planar oil, water stains, or random high-gloss reflections caused by mold surface wear, these two-dimensional plane anomalies, although they will also appear as uneven patches of brightness and darkness in the image, do not have the physical height to block light and form directional shadows. Therefore, the shadow correlation vector formed by the centroids of the bright and dark sub-regions randomly generated by these two-dimensional plane interferences exhibits great randomness in direction. When the processor finds that the included angle deviates significantly from the light source illumination pattern and exceeds the parallel tolerance range, it can disprove the possibility of it being a solid foreign object from a three-dimensional geometric perspective, thereby determining that it is two-dimensional interference caused by surface oil or reflection, and clearly identifying the type of interference in the output foreign object detection anomaly signal so that the system or personnel can selectively ignore or lightly clean it.
[0188] The in-mold foreign object detection method provided in this invention introduces light and shadow geometric logic verification into the two-dimensional machine vision system. Instead of blindly piling up expensive 3D structured light or laser contour sensors, it deeply explores the physical law that solid foreign objects under a fixed light source will inevitably be accompanied by directional shadows. By extracting the bright and dark centroids through high and low threshold segmentation, and calculating the angle between the shadow correlation vector and the ambient light source direction vector, it successfully eliminates two-dimensional visual deception caused by oil stains, water stains or random reflective patches on the mold surface.
[0189] Based on the above embodiments, which determine that the output foreign object detection anomaly signal includes a difference region consisting of a solid foreign object with three-dimensional height, this embodiment of the invention provides a linkage control mechanism based on a fault knowledge base in order to further endow the detection system with the ability to intelligently classify and automatically handle foreign objects.
[0190] Figure 13 This is a schematic diagram illustrating the strategies for addressing different categories of real differences provided by this invention, such as... Figure 13 As shown, after determining that the output foreign object detection anomaly signal includes the difference region as a solid foreign object with three-dimensional height, it also includes:
[0191] Extract the geometric shape features and physical coordinate information of the difference region;
[0192] The geometric features and physical coordinate information are input into a preset fault knowledge base for matching to identify the current type of foreign object;
[0193] If the foreign object is identified as unremoved product residue, a linkage control signal is generated and output to trigger the injection molding machine to perform a secondary ejection action.
[0194] If the foreign object is identified as a damaged metal component of the mold, a shutdown alarm signal is generated and output to force the mold closing action to be locked.
[0195] In this embodiment, after confirming that the difference region belongs to a solid foreign object with three-dimensional height, morphological analysis and spatial positioning of the pixel set of the difference region will be performed.
[0196] Optionally, by calling a contour analysis algorithm to calculate morphological parameters such as the area, perimeter, aspect ratio, and roundness of the difference region, geometric shape features used to characterize the outline of the foreign object are obtained. Simultaneously, the centroid or circumscribed rectangle coordinates of this difference region in the two-dimensional coordinate system of the mold image are calculated, and combined with the camera calibration parameters, they are mapped to absolute position data in the actual physical three-dimensional space of the mold, thereby obtaining physical coordinate information used to characterize the spatial position of the foreign object. The geometric shape features and physical coordinate information together constitute a multi-dimensional data source comprehensively describing the attributes of the physical foreign object.
[0197] A fault knowledge base can be pre-built and maintained in the processor's memory. This knowledge base contains a large amount of historically accumulated typical mold fault sample data and their corresponding feature labels (e.g., ejector pin breakage, product sticking to the mold, slider misalignment, etc.). The processor uses the newly acquired geometric shape features and physical coordinate information as input conditions for retrieval or reasoning, comparing the geometric similarity and spatial distance with the sample feature templates in the fault knowledge base. Through this data matching process, it can intelligently and quickly determine the physical defect category of the current three-dimensional foreign object, thereby accurately identifying the type of foreign object and providing a direct basis for subsequent decision-making.
[0198] After completing the fault knowledge base matching, distinctly different automated response strategies can be triggered based on the specific type of foreign object. If the matching results show that the physical foreign object is located precisely in the cavity or main runner area of the mold, and its geometric features are highly similar to the outer contour of a normal injection-molded product, then the foreign object can be determined to be a plastic part that failed to be successfully demolded.
[0199] At this point, directly triggering a shutdown alarm would severely disrupt the production rhythm. Therefore, when the processor identifies the foreign object as undried product residue, it does not immediately trigger an alarm to force a shutdown. Instead, it sends a specific communication command to the injection molding machine's programmable logic controller (PLC), generating and outputting a linkage control signal that triggers the injection molding machine to perform a second ejection action. This linkage control signal directly instructs the injection molding machine's ejection hydraulic cylinder or automated robotic arm to perform a standard demolding action again, attempting to automatically remove the product residue through automated retry, thereby maximizing production continuity while ensuring mold safety. It should be noted that in this scenario, if the injection molding machine still detects undried product residue after performing a preset number of second ejection actions (generally set to once), a shutdown alarm signal forcibly locking the mold closing action is output, alerting on-site operators to quickly intervene and clean up the residue.
[0200] Conversely, if the results of matching the fault knowledge base show that the physical foreign object appears in critical coordinate areas with frequent mechanical friction, such as pin holes and slider guides, and its geometric characteristics are metal cross-sections, debris, or irregular sharp shapes, then the foreign object can be determined to be an extremely dangerous piece of hardware mechanical damage.
[0201] In this situation, any continued mechanical action to close the mold will result in devastating crushing damage to the precision structures inside the mold. Therefore, when the processor identifies the foreign object as a broken metal component of the mold, it will immediately generate and output a shutdown alarm signal that forcibly locks the mold closing action through the highest priority safety control interface. This shutdown alarm signal not only triggers the audible and visual alarm device to alert on-site operators to quickly intervene in maintenance, but more importantly, it directly cuts off the injection molding machine's mold closing hydraulic actuation circuit or electrical enable terminal, absolutely preventing mold closing from the physical level to avoid irreversible mold crushing accidents.
[0202] This embodiment successfully upgrades the traditional one-size-fits-all passive shutdown alarm protection mechanism into an intelligent hierarchical response and automated handling closed loop with deep cognitive capabilities. By extracting the geometric features and physical coordinate information of the differential areas and deeply integrating them with a fault knowledge base, it achieves accurate qualitative and location analysis of three-dimensional physical foreign objects. For occasional product residues that have not detached, a linkage control signal that triggers the injection molding machine to perform a secondary ejection action is output to achieve self-healing fault handling, significantly reducing unnecessary manual intervention and downtime, and significantly improving the overall efficiency of production equipment. For destructive damage to mold metal components, a shutdown alarm signal that forces the mold closing action is output to ensure the absolute physical safety of high-value molds.
[0203] Based on the above embodiments, as an optional embodiment, for the widespread multi-cavity production scenario in the injection molding industry, i.e., simultaneously molding multiple identical injection molded products within one injection cycle, a depth expansion mechanism based on spatial periodic self-verification is further provided. This mechanism utilizes the natural symmetry of multiple cavities within the same image to be detected to construct an absolute comparison benchmark that does not rely on historical templates. Specifically, when the mold to be detected has multiple repeating cavities, after determining the region of interest image corresponding to the preset detection area in the image to be detected, the main steps include:
[0204] In the region of interest image, periodic sub-regions corresponding to each cavity are divided;
[0205] Calculate the image similarity between each periodic sub-region in the image to be detected;
[0206] Calculate the average image similarity between each periodic sub-region and all other periodic sub-regions;
[0207] If the average similarity of the image in any periodic sub-region is lower than a preset consistency threshold, then it is directly determined that there is a real difference in any periodic sub-region, and the foreign object detection abnormal signal is output.
[0208] If the average similarity of the images is not lower than the consistency threshold, then the step of comparing the region of interest image with the template images in the template image set continues.
[0209] In this embodiment, after acquiring an image of the region of interest (ROI) containing the entire mold cavity layout, the coordinates of the pre-stored mold CAD design drawing or the manually taught physical interval parameters are invoked. Since the arrangement of multiple repeating cavities on the mold exhibits strict geometric symmetry and consistent spacing, virtual dividing lines can be used to precisely mesh and crop the ROI image based on these physical interval parameters. This seamlessly decomposes a complete ROI image into multiple non-overlapping image blocks with identical area and size. These successfully segmented image blocks are the periodic sub-regions corresponding to each cavity.
[0210] After successfully identifying all periodic sub-regions, a pairwise cross-matching matrix is constructed in memory. For example, image matching algorithms (including normalized cross-correlation, structural similarity index determination, or local feature point matching algorithms) are invoked to quantify the similarity between the pixel grayscale distribution and texture topology of each pair of periodic sub-regions in this cross-matching matrix. Through this lateral calculation within the same image frame, the image similarity value between any two periodic sub-regions under the current lighting and physical conditions can be obtained, reflecting the visual similarity between the two physical cavities.
[0211] After obtaining the image similarity scores for all pairwise pairings, each periodic sub-region is sequentially used as the baseline core, i.e., it is set as the target periodic sub-region. Next, the image similarity values corresponding to the specific target periodic sub-region and all other periodic sub-regions are extracted, and these values are calculated by arithmetic mean or weighted average. Finally, a statistical index that can characterize the degree of deviation of the target periodic sub-region from the commonality of the overall cavity group is obtained, namely, the image average similarity.
[0212] After calculating the average image similarity of each target periodic sub-region, it is compared one by one with the system's preset consistency threshold. This consistency threshold represents the maximum allowable visual difference limit between cavities under normal machining tolerances and uneven lighting conditions. Since changes in ambient light in the workshop usually cover the entire mold surface globally at the same physical instant, causing synchronized changes in light and shadow in all periodic sub-regions, the average image similarity between regions will remain high even under pure lighting interference. Conversely, if it is a broken ejector pin or residual plastic debris, it is highly likely to appear in isolation within a specific cavity, causing a severe visual separation between the target periodic sub-region containing the foreign object and other normal cavities. Therefore, once any image average similarity is detected to be lower than the preset consistency threshold, it can be directly determined that there is a real difference caused by physical damage within the target periodic sub-region. At this time, the processor will immediately skip the subsequent cumbersome cross-frame template comparison process and directly output a foreign object detection anomaly signal to the control system to implement shutdown protection.
[0213] If, after verification, the average similarity of the images of all target periodic sub-regions is found to be no less than the consistency threshold, this indicates that all cavities of the current mold maintain a high degree of visual consistency. This consistency may represent that the mold is in a completely clean and normal state, or it may represent that the mold surface is experiencing some kind of global ambient light fluctuation. To prevent all cavities from experiencing the same failure simultaneously in the extremely rare event of failure, the processor will then continue to execute the step of comparing the overall region of interest image with the template images in the historically accumulated template image set, according to the conventional processing pipeline, to ensure the rigor of the detection process and a zero false negative rate.
[0214] The in-mold foreign object detection method provided in this embodiment breaks the traditional technical paradigm of machine vision inspection that relies excessively on the cross-temporal and spatial comparison between the current frame and historical templates. By utilizing the spatial symmetrical arrangement characteristics of multi-cavity molds, and extracting the average similarity of images between different periodic sub-regions at the same physical instant, an absolute consistency evaluation method based on intra-frame spatial mutual verification is cleverly constructed. This intra-frame self-similarity verification mechanism is immune to any form of sudden change in global ambient light in the workshop (such as light flickering or direct sunlight), because changes in global illumination will not destroy the relative similarity relationship between cavities.
[0215] Based on the above embodiments, this embodiment further provides an optional embodiment for accurately separating the difference regions from the original region of interest image and the template image through image preprocessing, difference operation, binarization and post-processing.
[0216] Figure 14 This is the third schematic diagram of the in-mold foreign object detection process provided by the present invention, as shown below. Figure 14 As shown, the step of comparing the region of interest image with template images in the template image set and extracting the difference region from the region of interest image may include, but is not limited to:
[0217] Step 141: Perform filtering processing on the region of interest image and the template image respectively.
[0218] Before performing image comparison, this embodiment preprocesses both the currently acquired region of interest image and the comparison reference template image selected from the template image set. This preprocessing includes, but is not limited to, applying filtering algorithms, such as Gaussian filtering or median filtering, to smooth the spatial domain of both images. The purpose of this is to effectively suppress isolated high-frequency noise points caused by camera sensor thermal noise, electromagnetic interference, or reflections from tiny dust particles on the mold surface. The filtered images retain the true edges and texture structures, while randomly distributed noise is smoothed out, thus providing a cleaner and more stable data foundation for subsequent pixel-level precise difference calculations and preventing noise from being misjudged as minor differences.
[0219] Step 142: Perform a difference operation on the filtered region of interest image and the template image to obtain a comparison difference image.
[0220] After filtering and noise reduction, a difference operation can be performed on the preprocessed region of interest image and the template image. Specifically, the pixel grayscale values of corresponding spatial coordinates in the two images are subtracted point by point, and the absolute value is taken. Since the pixel values of the mold background area remain basically unchanged under normal circumstances, the difference is close to zero; however, in areas with foreign objects or changes in lighting, the pixel values will change significantly, resulting in a larger difference. By recombining the difference results of all pixels into a new grayscale image, a comparison difference image can be obtained, which can intuitively highlight all inconsistencies between the current image and the template image as highlighted areas.
[0221] Step 143: After binarizing the comparison difference image, perform morphological processing and connected component analysis to extract abnormal regions.
[0222] Since the comparison difference image is still a grayscale gradient image, in order to clearly distinguish the meaningful differences from the negligible background fluctuations, this embodiment will first perform binarization processing on it.
[0223] By using a preset grayscale threshold, pixels in the difference image with values greater than the threshold are set to white (foreground), and pixels with values less than the threshold are set to black (background). After binarization, all the differences are clearly identified. Considering that the binarized foreground region may have internal holes or broken edges due to factors such as lighting, shadows, or uneven color on the surface of foreign objects, this embodiment will then perform morphological processing on it, such as a dilation-erosion closing operation, to fill internal holes and connect broken edges, forming one or more complete anomalous regions. Finally, connected component analysis (Blob analysis) can be performed on the morphologically repaired image to calculate the area, perimeter, and other geometric parameters of each independent white patch. Based on a preset lower area threshold, excessively small patches caused by weak electrical noise are filtered out, and the remaining connected patches of a certain size are taken as the finally identified anomalous regions.
[0224] Step 144: Use the polygonal boundary of the abnormal region as the difference region.
[0225] After extracting the abnormal regions, these abnormal regions, which are usually irregular in shape, will be described in a structured way to facilitate subsequent feature calculation and localization.
[0226] Optionally, the processor invokes a contour detection algorithm to track and extract the outer pixel contours of each anomalous region. Subsequently, a polygon approximation algorithm (such as Douglas Peucker) is used to fit these contours, thereby obtaining the coordinates of the circumscribed polygon boundaries that accurately describe the shape and extent of the anomalous region. Finally, these polygon boundaries, or the set of pixels they enclose, can be formally defined as the discrepancy regions to be analyzed in the preceding steps.
[0227] This embodiment constructs a robust and efficient visual processing logic from the original image to the structured difference region. Through a series of interconnected image processing steps, such as filtering and noise reduction, differential highlighting, binary segmentation, morphological restoration, and connected component filtering-contour extraction, it ensures that the finally extracted difference region can not only accurately reflect the real changes in the physical world, but also has a complete shape, clear boundaries, and effectively eliminates the interference of various noise sources.
[0228] Based on the extraction and analysis of the difference regions in the above embodiments, this embodiment further provides a predictive maintenance mechanism for gradual failures of molds, which aims to capture early failure signs that have not yet reached the direct alarm criteria.
[0229] Figure 15 This is the fourth schematic diagram of the in-mold foreign object detection process provided in this embodiment of the invention, as shown below. Figure 15As shown, after comparing the region of interest image with the template images in the template image set, the following steps may also be included:
[0230] Step 151: Extract small difference regions where the pixel difference value is lower than the alarm threshold but higher than the base noise threshold, where the alarm threshold is the pixel difference threshold used to determine the difference region.
[0231] In this embodiment, after binarization processing, in addition to using an alarm threshold to determine significant differences (i.e., difference regions that may trigger alarms), a lower floor noise threshold is introduced. This floor noise threshold is used to define background pixel jitter caused by thermal noise from the camera sensor itself or extremely weak ambient light fluctuations that can be completely ignored. During binarization segmentation, special attention is paid to extracting the set of pixels whose pixel difference values in the compared difference images are between the floor noise threshold and the alarm threshold; these pixel sets are the small difference regions. These small difference regions physically represent early signs of anomalies that, although changes have occurred, have not yet reached the severity required for immediate shutdown, such as initial minor scratches on the mold surface, minor lubricant leakage, or slight growth of plastic burrs.
[0232] Step 152: Record the coordinates of the occurrence of the minute difference region and the frequency of its occurrence in multiple consecutive detection cycles.
[0233] After extracting the areas of slight difference, this embodiment does not process them immediately, but archives them as potential early signs of failure.
[0234] The processor calculates the centroid coordinates of each individual, minute difference region, or the center coordinates of its circumscribed rectangle, as its occurrence coordinates in the mold space. These occurrence coordinates, along with the timestamp of the current inspection cycle, are then stored in a dedicated historical trend database within the system for trend analysis. By repeating this process in each production cycle, the occurrence history and frequency of minute anomalies at specific physical locations on the mold can be continuously tracked and accumulated.
[0235] Step 153: If the frequency of occurrence of the small difference area at the same occurrence coordinate shows an increasing trend, or the area feature of the small difference area at the same occurrence coordinate shows a cumulative expansion trend, then a predictive maintenance warning signal is output indicating that the mold has chronic wear or residue accumulation at the same occurrence coordinate.
[0236] The processor periodically or after each recording performs time series analysis on the data in the historical trend database. By statistically analyzing the data at specific occurrence coordinates, it analyzes whether the frequency of occurrence in the most recent continuous detection period shows a clear linear or exponential increasing trend.
[0237] At the same time, the processor will also accumulate and calculate the area of the small difference region that appears at the same coordinate point, and analyze whether its area characteristics show a continuous cumulative expansion trend.
[0238] When the processor detects any of the aforementioned trends of deterioration—that is, an increase in frequency or an accumulation of area reaching the preset warning model conditions—it can logically determine that a gradual, chronic physical damage or contamination accumulation is occurring at that location. Examples include chronic wear of the mold, sintering carbon buildup on the ejector pins, or the gradual growth of flash on the parting surface. In this case, even if a single detection does not trigger a shutdown alarm, the processor will proactively generate and output a specific type of predictive maintenance warning signal.
[0239] Predictive maintenance warning signals can be displayed by highlighting potential fault areas on the human-machine interface or by sending maintenance work order requests to the upper-level Manufacturing Execution System (MES) via industrial Ethernet. The aim is to remind equipment maintenance personnel to focus on checking and maintaining the specific location during planned downtime, thereby achieving early intervention in mold failures and preventing them from evolving into major failures that lead to production interruptions.
[0240] This embodiment successfully upgrades the traditional binary (normal / abnormal) detection mode based on a single snapshot to a four-dimensional (spatial + temporal) predictive diagnostic paradigm based on time series analysis. By keenly capturing and continuously tracking those subthreshold minute differences that are usually ignored by traditional detection systems, and modeling and analyzing their evolution trend (increasing frequency or area expansion) in the time dimension, it achieves early and accurate warning of gradual failures such as chronic wear of molds and accumulation of residues.
[0241] Figure 16 This is a schematic diagram of the in-mold foreign object detection device provided by the present invention, as shown below. Figure 16 As shown, the present invention also provides an in-mold foreign object detection device, which mainly includes, but is not limited to:
[0242] Image acquisition module 161 is used to acquire real-time images of the mold area as images to be detected in response to the detection trigger signal of the current detection cycle;
[0243] The region determination module 162 is used to determine the region of interest image corresponding to the preset detection region in the image to be detected;
[0244] The difference extraction module 163 is used to compare the region of interest image with the template images in the template image set, and extract the difference region from the region of interest image;
[0245] Feature acquisition module 164 is used to acquire image texture feature parameters of the difference region;
[0246] The anomaly determination module 165 is used to determine, based on the image texture feature parameters, whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object; if it is determined to be a false difference, the region of interest image is updated to the template image set as a comparison benchmark for subsequent detection; if it is determined to be a real difference, a foreign object detection anomaly signal is output.
[0247] It should be noted that the in-mold foreign object detection device provided by the present invention can execute the in-mold foreign object detection method described in any of the above embodiments during specific operation, which will not be elaborated in this embodiment.
[0248] The in-mold foreign object detection device provided by this invention analyzes image texture features to determine the physical properties of differences, effectively distinguishes between light interference and real foreign objects, and realizes adaptive template updates under changes in ambient light. It overcomes the shortcomings of traditional visual detection that are easily affected by light, greatly reduces the false alarm rate and manual maintenance costs, and improves the detection accuracy of the system.
[0249] Figure 17 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 17 As shown, the electronic device may include a processor 1710, a communications interface 1720, a memory 1730, and a communication bus 1740, wherein the processor 1710, the communications interface 1720, and the memory 1730 communicate with each other via the communication bus 1740. The processor 1710 can call logic instructions in the memory 1730 to execute an in-mold foreign object detection method. The method includes: in response to a detection trigger signal of the current detection cycle, acquiring a real-time image of the mold area as the image to be detected; determining a region of interest (ROI) image corresponding to a preset detection area in the image to be detected; comparing the ROI image with template images in a template image set, and extracting the difference region from the ROI image; obtaining image texture feature parameters of the difference region; based on the image texture feature parameters, determining whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object; if determined to be a false difference, updating the ROI image to the template image set as a comparison benchmark for subsequent detection; if determined to be a real difference, outputting a foreign object detection anomaly signal.
[0250] Furthermore, the logical instructions in the aforementioned memory 1730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0251] On the other hand, the present invention also provides a computer program product, the computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, when the program instructions are executed by a computer, the computer is able to execute the in-mold foreign object detection method provided in the above embodiments, the method including: in response to a detection trigger signal of the current detection cycle, acquiring a real-time image of the mold area as an image to be detected; determining a region of interest image corresponding to a preset detection area in the image to be detected; comparing the region of interest image with template images in a template image set, and extracting a difference region from the region of interest image; obtaining image texture feature parameters of the difference region; based on the image texture feature parameters, determining whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object; if determined to be a false difference, updating the region of interest image to the template image set as a comparison benchmark for subsequent detection; if determined to be a real difference, outputting a foreign object detection abnormal signal.
[0252] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the in-mold foreign object detection method provided in the above embodiments. The method includes: in response to a detection trigger signal of the current detection cycle, acquiring a real-time image of the mold area as an image to be detected; determining a region of interest (ROI) image corresponding to a preset detection region in the image to be detected; comparing the ROI image with template images in a template image set, and extracting a difference region from the ROI image; obtaining image texture feature parameters of the difference region; based on the image texture feature parameters, determining whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object; if determined to be a false difference, updating the ROI image to the template image set as a comparison benchmark for subsequent detection; if determined to be a real difference, outputting a foreign object detection abnormality signal.
[0253] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0254] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0255] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting in-mold foreign objects, characterized in that, include: In response to the detection trigger signal of the current detection cycle, a real-time image of the mold area is acquired as the image to be detected; Determine the region of interest (ROI) image corresponding to the preset detection region in the image to be detected; The region of interest image is compared with the template images in the template image set, and the difference region is extracted from the region of interest image; Obtain the image texture feature parameters of the difference region; Based on the image texture feature parameters, it is determined whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object. If the discrepancy is determined to be false, the region of interest image is updated to the template image set and used as a comparison benchmark for subsequent detection. If the difference is determined to be a genuine difference, an abnormal foreign object detection signal is output. The step of obtaining the image texture feature parameters of the difference region includes: Extract the grayscale image of the difference region and its surrounding neighborhood; The grayscale image is traversed using a sliding window of a preset size, and the local entropy value within each sliding window is calculated to generate the current local entropy map; Calculate the rate of change matrix of the current local entropy map relative to the reference local entropy map of the previous detection period, and use it as the image texture feature parameter; The step of determining whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical foreign object based on the image texture feature parameters includes: Based on the rate of change matrix, the multi-scale consistency characteristics of the difference region are determined, wherein the multi-scale consistency characteristics are determined based on the sign of the change direction of the difference region at multiple scales; The spatial continuity features of the differential regions are extracted, and these features are determined based on the proportion of connected domain area and the degree of discretization of the differential regions. Extract the temporal context features of the difference region, which are determined based on the variance of the feature changes of the difference region in multiple consecutive historical detection periods; The multi-scale consistency feature, the spatial continuity feature, and the temporal context feature are weighted and fused to obtain a weighted comprehensive score; If the weighted composite score is greater than the preset ambient light interference judgment threshold, it is determined to be a false difference; Otherwise, it is determined to be a genuine difference.
2. The in-mold foreign object detection method according to claim 1, characterized in that, Before determining the region of interest image corresponding to the preset detection region in the image to be detected, the method further includes: Acquire a first reference image when the mold is fully open and contains the injection molded product, and a second reference image when the mold is closed and does not contain the injection molded product; Perform a difference operation on the first reference image and the second reference image to extract the contour feature region; The region within the outer polygon boundary of the contour feature region is set as the preset detection region.
3. The in-mold foreign object detection method according to claim 2, characterized in that, The step of performing a difference operation on the first reference image and the second reference image to extract the contour feature region includes: The first reference image and the second reference image are filtered respectively; An initial difference image is obtained by performing a difference operation on the filtered first reference image and the second reference image; After binarizing the initial difference image, morphological processing and connected component analysis are performed to extract the contour feature region.
4. The in-mold foreign object detection method according to claim 1, characterized in that, The process of acquiring a real-time image of the mold area as the image to be detected in response to the detection trigger signal of the current detection cycle includes: Upon receiving the detection trigger signal, continuous video frame acquisition of the mold area is initiated; Calculate the global pixel difference between adjacent video frames sequentially; The video frame in which the global pixel difference is detected to be below a preset steady-state threshold for N consecutive frames is taken as the image to be detected, where N is a natural number greater than 1.
5. The in-mold foreign object detection method according to claim 1, characterized in that, If the difference is determined to be real, an abnormal foreign object detection signal is output, including: If the difference is determined to be a real difference, the difference region is segmented by high and low thresholds to extract the bright sub-region and the dark sub-region respectively. Calculate the shadow correlation vector formed between the centroid of the bright sub-region and the centroid of the dark sub-region; If the angle between the shadow association vector and the preset ambient light source direction vector is within the preset parallel tolerance range, the output foreign object detection anomaly signal is determined to include the difference region as a solid foreign object with three-dimensional height; If the included angle exceeds the parallel tolerance range, the output foreign object detection abnormal signal is determined to include the difference area as two-dimensional interference caused by surface oil or reflection.
6. The in-mold foreign object detection method according to claim 5, characterized in that, After determining that the output foreign object detection anomaly signal includes a solid foreign object with three-dimensional height in the difference region, the method further includes: Extract the geometric shape features and physical coordinate information of the difference region; The geometric features and physical coordinate information are input into a preset fault knowledge base for matching to identify the current type of foreign object; If the foreign object is identified as unremoved product residue, a linkage control signal is generated and output to trigger the injection molding machine to perform a secondary ejection action. If the foreign object is identified as a damaged metal component of the mold, a shutdown alarm signal is generated and output to force the mold closing action to be locked.
7. The in-mold foreign object detection method according to claim 1, characterized in that, When the mold to be inspected has multiple repeating cavities, after determining the region of interest image corresponding to the preset detection area in the image to be inspected, the method further includes: In the region of interest image, periodic sub-regions corresponding to each cavity are divided; Calculate the image similarity between each periodic sub-region in the image to be detected; Calculate the average image similarity between each periodic sub-region and all other periodic sub-regions; If the average similarity of the image in any periodic sub-region is lower than a preset consistency threshold, then it is directly determined that there is a real difference in any periodic sub-region, and the foreign object detection abnormal signal is output. If the average similarity of the images is not lower than the consistency threshold, then the step of comparing the region of interest image with the template images in the template image set continues.
8. The in-mold foreign object detection method according to claim 1, characterized in that, The step of comparing the region of interest image with template images in the template image set and extracting the difference region from the region of interest image includes: The region of interest image and the template image are filtered respectively; A difference operation is performed on the filtered region of interest image and the template image to obtain a comparison difference image; After binarizing the comparison difference image, morphological processing and connected component analysis are performed to extract abnormal regions; The polygonal boundary of the abnormal region is taken as the difference region.
9. The in-mold foreign object detection method according to claim 8, characterized in that, After comparing the region of interest image with template images in the template image set, the method further includes: Extract small difference regions where the pixel difference value is lower than the alarm threshold but higher than the floor noise threshold, wherein the alarm threshold is the pixel difference threshold for extracting the abnormal region; Record the coordinates of the occurrence of the minute difference regions and their frequency of occurrence in multiple consecutive detection cycles; If the frequency of occurrence of the small difference area at the same coordinate is increasing, or the area of the small difference area at the same coordinate is expanding cumulatively, a predictive maintenance warning signal is output indicating that the mold has chronic wear or residue accumulation at the same coordinate.
10. An in-mold foreign object detection device, characterized in that, include: The image acquisition module is used to acquire real-time images of the mold area as the images to be detected in response to the detection trigger signal of the current detection cycle; The region determination module is used to determine the region of interest image corresponding to the preset detection region in the image to be detected; The difference extraction module is used to compare the region of interest image with the template images in the template image set, and extract the difference region from the region of interest image; The feature acquisition module is used to acquire image texture feature parameters of the difference region, including: extracting grayscale images of the difference region and its surrounding neighborhood; The grayscale image is traversed using a sliding window of a preset size, and the local entropy value within each sliding window is calculated to generate the current local entropy map; Calculate the rate of change matrix of the current local entropy map relative to the reference local entropy map of the previous detection period, and use it as the image texture feature parameter; An anomaly detection module is used to determine, based on the image texture feature parameters, whether the difference region is a false difference caused by ambient light interference or a real difference caused by a physical object, including: determining the multi-scale consistency feature of the difference region according to the rate of change matrix, wherein the multi-scale consistency feature is determined based on the sign of the change direction of the difference region at multiple scales; The spatial continuity features of the differential regions are extracted, and these features are determined based on the proportion of connected domain area and the degree of discretization of the differential regions. Extract the temporal context features of the difference region, which are determined based on the variance of the feature changes of the difference region in multiple consecutive historical detection periods; The multi-scale consistency feature, the spatial continuity feature, and the temporal context feature are weighted and fused to obtain a weighted comprehensive score; If the weighted composite score is greater than the preset ambient light interference judgment threshold, it is determined to be a false difference; Otherwise, it is determined to be a genuine difference; If the difference is determined to be false, the region of interest image is updated to the template image set as a comparison benchmark for subsequent detection; if the difference is determined to be true, an abnormal foreign object detection signal is output.
11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the intramold foreign object detection method as described in any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the intramold foreign object detection method as described in any one of claims 1 to 9.
13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the intramold foreign object detection method as described in any one of claims 1 to 9.