A machine vision-based anesthetic mask injection flash detection method
Patent Information
- Application Number
- CN202610826676.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-09
- Publication Date
- 2026-09-01
AI Technical Summary
[0007]为了解决现有技术中人工目视检测一致性差效率低、单视角二维图像对透明半透明注塑件飞边区分不可靠且无法完整评价三维边缘飞边分布的技术问题,本发明提供了一种基于机器视觉的麻醉面罩注塑飞边检测方法
(1)在本发明中,通过多角度同步采集并结合标准三维几何模型在各视角图像中划定带状检测区域,使飞边分析始终以理想边缘位置为参考基准,不受面罩主体透明特性造成的透射干扰和背景纹理影响,从源头上提高了边缘特征提取的准确性与稳定性;同时,以标准三维几何模型引导的检测方式无需依赖实物标准样件进行图像配准,显著降低了检测系统对工装定位精度的依赖和环境适应性要求。
Smart Images

Figure CN122675784A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision inspection technology, and in particular to a machine vision-based method for detecting flash edges in injection molding of anesthesia masks. Background Technology
[0002] Anesthesia masks are widely used disposable or reusable medical consumables, typically molded from polymers such as polyvinyl chloride, silicone, or thermoplastic elastomers using injection molding. During injection molding, molten material overflows at the mold parting line, forming thin, excess sheet-like structures upon cooling—the flash. The presence of flash not only affects the seal between the anesthesia mask and the patient's face, reducing clinical comfort and treatment effectiveness, but also poses a risk of breakage due to stress concentration during use, potentially releasing debris into the patient's airway. Therefore, reliable flash defect detection before the anesthesia mask leaves the factory is crucial for ensuring product quality and clinical safety.
[0003] Currently, the inspection of flash on anesthesia masks still mainly relies on manual visual inspection. Operators flip the injection-molded parts under specific lighting conditions and judge the presence and severity of flash based on experience. This method has significant shortcomings: the inspection results are affected by the degree of operator fatigue, visual condition, and differences in subjective judgment standards, making it difficult to guarantee consistency and repeatability; under continuous high-intensity operation, even tiny flashes are easily missed; and the speed of manual inspection is limited, making it difficult to fully match the pace of high-speed injection molding production, thus creating a bottleneck in production capacity.
[0004] To overcome the drawbacks of manual inspection, some companies have attempted to introduce automated inspection methods based on machine vision. The conventional approach involves using industrial cameras to acquire images of injection-molded parts from specific angles, extracting edge features through image processing algorithms, and comparing them with standard templates. However, this approach encounters several difficulties when dealing with a specific object like anesthesia masks. First, the main body of anesthesia masks is often made of transparent or semi-transparent materials, resulting in low edge contrast during imaging and susceptibility to interference from transmitted images from objects behind and stray light from the environment, leading to unstable edge positioning. Second, both flash and normal edges appear as grayscale transition areas, making reliable differentiation difficult based solely on conventional edge strength or width information, easily leading to numerous false alarms or missed detections of genuine flash. Furthermore, injection-molded parts often have draft angles, parting line marks, and surface textures. These background structures are easily confused with flash in a single-frame image, making rule-based judgment methods significantly less adaptable to actual production lines.
[0005] Furthermore, since flash typically only occurs in localized sections of the three-dimensional edge, images acquired from a single viewpoint cannot fully represent the entire mold line edge surrounding the mask. When the flash extends perpendicular to the shooting viewpoint or is at a grazing angle to the camera's line of sight, its imaging is extremely weak, easily leading to missed detections in space. How to effectively integrate information from multiple viewpoints and uniformly determine the distribution and extent of flash in three-dimensional space, rather than simply making independent two-dimensional judgments on images from each viewpoint, is also a problem that current detection solutions generally have not yet solved.
[0006] In summary, existing technologies for detecting flash in injection molding of anesthesia masks have significant shortcomings in three key areas: imaging reliability, flash feature differentiation capability, and multi-view information fusion. These limitations make it difficult to meet the comprehensive requirements of production lines for detection accuracy, speed, and adaptability. The industry urgently needs a detection method that can automatically adapt to the optical properties of the material, stably capture the faint visual features of flash, and make an overall judgment by integrating information from various perspectives under three-dimensional geometric constraints. Summary of the Invention
[0007] To address the technical problems of poor consistency and low efficiency in existing technologies, such as the unreliability of single-view two-dimensional images in distinguishing flash edges of transparent and semi-transparent injection molded parts, and the inability to fully evaluate the distribution of three-dimensional edge flash edges, this invention provides a machine vision-based method for detecting flash edges in injection molded anesthesia masks.
[0008] The technical solution provided by this invention is as follows: This invention provides a machine vision-based method for detecting flash during injection molding of anesthesia masks, comprising: S1: Acquire multi-angle images of the injection-molded anesthesia mask to be tested, and preprocess the acquired multi-angle images; S2: Perform edge extraction on the preprocessed multi-angle images to obtain the edge images corresponding to each angle; S3: Obtain the standard three-dimensional geometric model of the injection molded anesthesia mask to be tested, determine the theoretical edge contour line according to the standard three-dimensional geometric model, and delineate the detection area in the edge image corresponding to each angle according to the theoretical edge contour line; S4: Within the detection area corresponding to each angle, calculate the edge sharpness parameter and gradient direction coherence coefficient of each edge pixel. The edge sharpness parameter is used to characterize the severity of grayscale changes at the edge, and the gradient direction coherence coefficient is used to characterize the consistency of the gradient direction of each pixel in the local area. S5: Identify flash defect pixels in the detection area corresponding to each angle based on the edge sharpness parameter and the gradient direction coherence coefficient; S6: Map the flash defect pixels identified from each angle to a unified reference coordinate system, fuse them to obtain a flash defect distribution map, and determine whether the injection molded anesthesia mask to be tested has flash defects based on the flash defect distribution map, and output the detection result.
[0009] Further, in S1, multi-angle images of the injection-molded anesthesia mask to be tested are acquired, and the acquired multi-angle images are preprocessed, including the following steps: S101: Simultaneously trigger at least two image acquisition devices to synchronously acquire images of the injection-molded anesthesia mask to be tested from at least two different preset angles to obtain multi-angle original images; S102: Denoise the original image from multiple angles; S103: Perform contrast enhancement processing on the denoised image to obtain a multi-angle preprocessed image.
[0010] By sequentially performing denoising and contrast enhancement processing on the original images from multiple angles, the gray-scale dynamic range of the edge region is stretched while suppressing random noise. This enables the subsequent edge extraction process to obtain clearer and more continuous edge responses, reducing the risk of missed edge detection due to poor image quality.
[0011] Further, in S3, a standard three-dimensional geometric model of the injection-molded anesthesia mask to be tested is obtained, and the theoretical edge contour line is determined based on the standard three-dimensional geometric model, including the following steps: S301: Obtain the standard three-dimensional geometric model corresponding to the model number of the injection molded anesthesia mask to be tested; S302: Based on the intrinsic and extrinsic parameter matrices of each image acquisition device, the standard three-dimensional geometric model is projected onto the image plane of each image acquisition device to obtain the theoretical edge projection lines corresponding to each angle. S303: The theoretical edge projection line is used as the theoretical edge contour line in the corresponding angle image.
[0012] By projecting a standard 3D geometric model onto the image plane based on the intrinsic and extrinsic parameters of each camera, the theoretical edge contour is obtained. This ensures that the theoretical edge position accurately corresponds to the actual imaging geometry under the current viewpoint, avoiding theoretical edge positioning errors caused by perspective distortion and camera pose deviation. This provides a reliable reference benchmark for the delineation of the detection area and subsequent flash edge analysis.
[0013] Furthermore, S4 calculates the edge sharpness parameter for each edge pixel, including the following steps: S401: For any edge pixel in the detection area, extract a pixel grayscale profile line passing through the edge pixel in the detection area along the normal direction of the theoretical edge contour line at the edge pixel. S402: On the pixel grayscale profile line, with the edge pixel as the center, calculate the distribution curve of the grayscale gradient magnitude along the normal direction; S403: Determine the edge sharpness parameter of the edge pixel based on the sharpness of the peak of the distribution curve, wherein the sharper the peak of the distribution curve, the larger the value of the edge sharpness parameter.
[0014] By extracting grayscale profile lines along the normal direction and quantifying edge sharpness using the peak sharpness of the gradient amplitude distribution curve, the smooth transition caused by flare edges is effectively distinguished numerically from the sharp transition of normal edges, providing a relatively stable identification feature for flare edge pixel determination in response to illumination changes.
[0015] Further, in S4, the gradient direction coherence coefficient of each edge pixel is calculated, including the following steps: S411: Within the detection area, for any edge pixel, determine a local neighborhood window centered on that edge pixel; S412: Calculate the gradient direction angle values of all pixels within the local neighborhood window; S413: Weight the gradient direction angle values of each pixel based on the gradient magnitude of each pixel, and calculate the weighted gradient direction covariance matrix. S414: Perform eigenvalue decomposition on the gradient direction covariance matrix to obtain the largest and second largest eigenvalues; S415: Determine the gradient direction coherence coefficient of the edge pixel based on the ratio of the largest eigenvalue to the second largest eigenvalue.
[0016] By constructing an amplitude-weighted covariance matrix of gradient directions within a local neighborhood window and using the eigenvalue ratio as the gradient direction coherence coefficient, the consistency of gradient directions within the neighborhood of edge pixels can be robustly measured, effectively distinguishing between continuous contours with consistent directions and jagged edge fragments, thus compensating for the misjudgment defect of single edge intensity features in textured regions.
[0017] Furthermore, in S411, a local neighborhood window centered on the edge pixel is determined, specifically: a local neighborhood window of size (2k+1)×(2k+1) pixels is determined centered on the edge pixel, where the value of k is related to the radius of curvature of the theoretical edge contour at the edge pixel. The smaller the radius of curvature, the smaller the value of k.
[0018] By adaptively associating the size of the local neighborhood window with the radius of curvature of the theoretical edge contour, the window is reduced at curved edges to avoid directional dispersion interference, and the window is increased at straight edges to obtain more robust directional statistics. This achieves a balance in the ability to detect burrs at edges with different curvatures, and significantly improves the detection effect of tiny burrs at the corners of the mask.
[0019] Further, in S5, based on the edge sharpness parameter and the gradient direction coherence coefficient, the flash defect pixels are identified within the detection area corresponding to each angle, including the following steps: S501: Compare the edge sharpness parameter of each edge pixel with a preset first threshold, and compare the gradient direction coherence coefficient of each edge pixel with a preset second threshold. S502: Edge pixels with edge sharpness parameters less than the first threshold and gradient direction coherence coefficient less than the second threshold are identified as fringe defect pixels.
[0020] By using the edge sharpness parameter being greater than the first threshold and the gradient direction coherence coefficient being less than the second threshold as joint judgment conditions, the two complementary features of grayscale transition shape and local direction consistency are integrated for decision-making. This avoids the problem of being easily affected by material texture or lighting fluctuations when relying on a single feature, and effectively suppresses false alarms while maintaining a high level of flash recall.
[0021] Furthermore, the first threshold and the second threshold are determined as follows: a test sample of anesthesia mask injection molded part with known true distribution of flash defects is obtained, and the first threshold and the second threshold are adaptively determined by maximizing the recognition accuracy of flash defect pixels based on the numerical distribution of edge sharpness parameters and gradient direction coherence coefficients of each edge pixel of the test sample.
[0022] By adaptively determining the first and second thresholds using test samples with known true distribution of flash edges, the judgment thresholds are automatically matched with the current material type, light source conditions, and imaging system characteristics. This avoids the shortcomings of manually setting fixed thresholds that are not adaptable to different working conditions. When changing product models or adjusting production line configurations, there is no need to readjust parameters, thus improving the working condition migration capability of the detection method.
[0023] Furthermore, in S6, the burr defect pixels identified from each angle are mapped to a unified reference coordinate system and fused to obtain a burr defect distribution map, including the following steps: S601: Based on the intrinsic and extrinsic parameter matrices of each image acquisition device, the flash defect pixels identified from each angle are back-projected into three-dimensional space to obtain the flash defect spatial point cloud. S602: Register the positions of each point in the spatial point cloud of the flash defect with the standard three-dimensional geometric model; S603: Perform clustering and connected component analysis on the registered point cloud of flash defects, and determine the point cloud clusters that are interconnected and whose distance to the edge of the standard three-dimensional geometric model is less than a preset distance threshold as valid flash defect regions. S604: Back-project the effective flash defect area onto the surface of the standard three-dimensional geometric model to generate the flash defect distribution map.
[0024] By back-projecting the flash edge pixels from each viewpoint into a spatial point cloud and registering, clustering, and filtering with standard 3D geometric models and distance constraints, multi-view information is uniformly integrated at the 3D spatial level. This not only filters out false defects caused by image noise and outliers, but also stitches together the flash edge fragments of intermittent imaging from each viewpoint into a complete flash edge region, overcoming the missed detection of flash edges caused by occlusion or grazing angles from a single viewpoint.
[0025] Furthermore, the acquisition of multi-angle images described in S101 also includes: S1011: Obtain the material type of the injection molded anesthesia mask to be tested, wherein the material type includes at least transparent material and semi-transparent material; S1012: Determine the corresponding light source parameters according to the material type; S1013: Based on the light source parameters, while triggering the image acquisition device, control the light source to illuminate according to the light source parameters.
[0026] By adaptively matching and controlling the light source parameters according to the material type, the edges of transparent materials can obtain a high-contrast backlighting effect, effectively suppressing the interference of embossed textures on the surface of semi-transparent materials. This improves the distinguishability of the burr edges from the background from the imaging source, providing higher quality input images for subsequent feature extraction and defect determination.
[0027] The beneficial effects of the technical solution provided by this invention include at least the following: (1) In this invention, by simultaneously acquiring data from multiple angles and combining it with a standard three-dimensional geometric model, a strip detection area is delineated in the images from each viewpoint. This ensures that the edge analysis always takes the ideal edge position as the reference benchmark, and is not affected by the transmission interference caused by the transparency of the mask body or the background texture. This improves the accuracy and stability of edge feature extraction from the source. At the same time, the detection method guided by the standard three-dimensional geometric model does not require image registration with physical standard samples, which significantly reduces the dependence of the detection system on the tooling positioning accuracy and the environmental adaptability requirements.
[0028] (2) In this invention, two complementary features, edge sharpness parameter and gradient direction coherence coefficient, are used to jointly determine the pixel point of the flash defect. The edge sharpness parameter distinguishes between sharp edges and smooth transitions from the gray-scale profile distribution pattern, while the gradient direction coherence coefficient distinguishes between continuous contours and messy flash fragments from the local directional consistency. The combination of the two effectively solves the problem that it is difficult to reliably distinguish between normal edges and flash by relying on a single feature, so that the detection can significantly suppress false alarms while maintaining a high flash recall level.
[0029] (3) In this invention, the flash pixels identified independently from each viewpoint are restored into a flash defect spatial point cloud through back projection and three-dimensional registration. The effective flash defect area is obtained by clustering and model edge distance constraint screening, and finally a flash defect distribution map is generated on the surface of the standard three-dimensional geometric model. This multi-view fusion strategy makes full use of the consistency constraint of three-dimensional geometric information on spatial relationships, overcomes the missed detection caused by the discontinuity of flash imaging due to viewpoint occlusion and grazing angle in single viewpoint, and realizes the overall and reliable evaluation of the flash distribution around the entire mask mold line edge. Attached Figure Description
[0030] Figure 1 A flowchart illustrating a machine vision-based method for detecting flash during injection molding of anesthesia masks, as provided in an embodiment of the present invention. Figure 2 This is a flowchart illustrating a machine vision-based method for detecting flash edges in injection molding of anesthesia masks, as provided in an embodiment of the present invention. Detailed Implementation
[0031] This invention provides a machine vision-based method for detecting flash defects in injection-molded anesthesia masks. This method can be fully applied to the injection molding production line of anesthesia masks, achieving automatic, rapid, and non-contact detection of flash defects. The method is described in detail below with reference to several optional implementation methods.
[0032] Before starting the inspection, the following steps can be performed to achieve material-adaptive light source configuration: S1011: Obtain the material type of the injection-molded anesthesia mask to be tested, wherein the material type includes at least transparent and translucent materials. As an example, injection-molded anesthesia mask parts are typically made of transparent or translucent polymer materials, such as polyvinyl chloride, silicone, or thermoplastic elastomers. The material type can be obtained by reading production batch information or by using a photoelectric sensor to determine the material's light transmission characteristics.
[0033] S1012: Determine the corresponding light source parameters based on the material type. For transparent materials, since the abrupt change in thickness at the flash will cause refraction and scattering, a parallel backlight is recommended for illumination to give the flash edges a high-contrast dark or bright field characteristic. For translucent materials, a low-angle ring light source or a diffuse dome light source can be used to highlight the surface undulations and shadows caused by the flash. The light source parameters include light source brightness, light source angle, light source wavelength, and illumination mode.
[0034] S1013: Based on the light source parameters, while triggering the image acquisition device, control the light source to illuminate according to the light source parameters. Using a parallel backlight for transparent materials effectively enhances the imaging contrast of the burr edge; using a ring-shaped diffused light source for semi-transparent materials effectively suppresses interference from surface embossing textures, thereby improving the stability of subsequent feature parameters.
[0035] Then, we proceed to the main detection process of this method.
[0036] S1: Acquire multi-angle images of the injection-molded anesthesia mask to be inspected, and preprocess the acquired multi-angle images. This step specifically includes: S101: Simultaneously trigger at least two image acquisition devices to synchronously acquire images of the injection-molded anesthesia mask under inspection from at least two different preset angles, obtaining multi-angle raw images. In one embodiment, two industrial cameras with fixed-focus lenses are arranged on the front and side of the anesthesia mask, respectively, at an angle of approximately 90 degrees, for synchronous acquisition. In another embodiment, four cameras are evenly arranged around the part under inspection, with an angle of approximately 90 degrees between adjacent cameras to cover a more comprehensive edge area. Each camera has completed intrinsic and extrinsic parameter calibration in advance. The intrinsic parameter matrix includes focal length and principal point coordinates, and the extrinsic parameter matrix includes rotation and translation parameters of the camera coordinate system relative to a unified reference coordinate system. During synchronous triggering, the controller sends a single trigger signal, and all cameras expose at the same time to obtain multi-angle raw images. Since the anesthesia mask may have a certain degree of transparency, the image of adjacent background objects may enter the camera through the mask. Therefore, interference can be eliminated in conjunction with the aforementioned light source settings.
[0037] S102: Denoise the original image from multiple angles. Optionally, Gaussian filtering or bilateral filtering can be used. Gaussian filtering can quickly suppress random noise, while bilateral filtering can smooth noise while preserving edge details, making it more suitable for subsequent edge sharpness analysis.
[0038] S103: Perform contrast enhancement processing on the denoised image to obtain a multi-angle preprocessed image. In one embodiment, histogram equalization is used to stretch the gray-level dynamic range; in another embodiment, adaptive histogram equalization is used to limit the contrast amplification factor in order to enhance the gray-level difference in local edge areas while avoiding excessive amplification of noise.
[0039] The above preprocessing effectively suppressed noise interference in the original image and enhanced the grayscale contrast of the edge region, providing a higher quality input image for subsequent edge extraction.
[0040] S2: Perform edge extraction on the preprocessed multi-angle images to obtain edge images corresponding to each angle. Edge extraction can use the Canny operator, Sobel operator, or a deep learning-based edge detection network, with the Canny operator being preferred due to its ability to balance detection accuracy and continuity. The resulting edge images contain both true mask edges and potentially false edges caused by burrs and interference edges caused by textures.
[0041] S3: Obtain a standard three-dimensional geometric model of the injection-molded anesthesia mask to be inspected, determine the theoretical edge contour line based on the standard three-dimensional geometric model, and delineate the detection area in the edge image corresponding to each angle based on the theoretical edge contour line. This step specifically includes: S301: Obtain a standard three-dimensional geometric model corresponding to the model number of the injection-molded anesthesia mask to be tested. In one embodiment, the CAD model of the same model mask is directly retrieved from the product design database; in another embodiment, a known defect-free standard sample is scanned with three-dimensional structured light to reconstruct a high-precision point cloud and convert it into a three-dimensional model in STL or STEP format. This standard three-dimensional geometric model defines the theoretical geometric position of the edge of the anesthesia mask under normal conditions.
[0042] S302: Based on the intrinsic and extrinsic parameter matrices of each image acquisition device, the standard three-dimensional geometric model is projected onto the image plane of each image acquisition device to obtain the theoretical edge projection lines corresponding to each angle. This projection process is equivalent to simulating the edge position that an ideal fringe-free mask should present in the camera.
[0043] S303: The theoretical edge projection line is used as the theoretical edge contour line in the corresponding angle image.
[0044] Then, detection regions are defined in the edge images corresponding to each angle based on the theoretical edge contour line. In one embodiment, the detection region is a strip-shaped area centered on the theoretical edge contour line and extending to both sides by a certain number of pixels, for example, extending by 15 pixels. This area is defined as the location where fringe may occur. The bandwidth can also be dynamically adjusted according to the specific location of the anesthesia mask edge, for example, appropriately narrowing it in areas with greater curvature and appropriately widening it in straight sections.
[0045] By defining the detection area guided by a standard 3D geometric model, subsequent edge analysis is performed only within the target area, effectively reducing interference from the background and texture and improving detection efficiency.
[0046] S4: Within the detection area corresponding to each angle, calculate the edge sharpness parameter and gradient direction coherence coefficient for each edge pixel. The edge sharpness parameter characterizes the drastic change in grayscale at the edge, and the gradient direction coherence coefficient characterizes the consistency of the gradient direction among pixels within the local area. The specific steps for calculating the edge sharpness parameter include: S401: For any edge pixel in the detection area, extract a pixel grayscale profile line passing through the edge pixel in the detection area along the normal direction of the theoretical edge contour line at the edge pixel.
[0047] S402: On the pixel grayscale profile line, with the edge pixel as the center, calculate the distribution curve of the grayscale gradient magnitude along the normal direction. The gradient magnitude can be calculated using the central difference or Sobel operator. The distribution curve reflects the shape of the edge transition. Normal injection molded edges have a crisp edge transition due to the precision of the mold, and the gradient magnitude distribution is concentrated with sharp peaks; while flash edges usually have excess thin layer overflow, the edge transition becomes gentle, and the gradient magnitude distribution is dispersed.
[0048] S403: Determine the edge sharpness parameter of the edge pixel based on the sharpness of the peak of the distribution curve, wherein the sharper the peak of the distribution curve, the larger the value of the edge sharpness parameter. To quantify this sharpness, the kurtosis of the distribution curve can be used as the edge sharpness parameter. Assuming there are N pixels on the profile line, and the gradient magnitude of the i-th pixel is G_i, then the kurtosis of the distribution curve... The calculation formula is: ; in, This represents the average of the N gradient magnitudes along the profile line. This represents the standard deviation of the N gradient magnitudes along this profile. Kurtosis. A larger kurtosis value indicates a sharper peak in the distribution curve and a closer proximity to the ideal sharpness of the edges; conversely, a smaller kurtosis value indicates a more blurred edge and a greater likelihood of sharp edges. In practical applications, other metrics such as the reciprocal of the peak half-width can also be used as edge sharpness parameters, as long as they can characterize the sharpness of the peak. Kurtosis, as an edge sharpness parameter, exhibits relative stability in response to changes in illumination.
[0049] The specific steps for calculating the gradient direction coherence coefficient include: S411: Within the detection area, for any edge pixel, determine a local neighborhood window centered on that edge pixel. In one embodiment, a local neighborhood window of size (2k+1) × (2k+1) pixels is determined centered on the edge pixel, where the value of k is related to the radius of curvature of the theoretical edge contour at the edge pixel; the smaller the radius of curvature, the smaller the value of k. For example, it can be set as follows: ; Where R is the radius of curvature at that point on the theoretical edge contour line, in pixels. For example, a preset scaling factor, When R is large, k increases; when R is small, k is limited to its minimum value. By adaptively adjusting the window size, the detection capability at the bends of the mask (such as the edge of a bent pipe interface) is kept consistent with that of the straight section, avoiding the directional dispersion interference caused by a fixed large window at the corner, and effectively improving the detection capability of small burrs at the corner.
[0050] S412: Calculate the gradient direction angle values of all pixels within the local neighborhood window. Let the horizontal gradient at pixel (i,j) be... The vertical gradient is Then the gradient magnitude Gradient direction angle S413: Weight the gradient direction angle values of each pixel based on the gradient magnitude of each pixel, and calculate the weighted gradient direction covariance matrix. The specific construction method involves treating the gradient direction of each pixel as a unit vector. With gradient magnitude Assuming weights, a weighted tensor is constructed: ; in It represents the set of all pixels within a local neighborhood window centered on the edge pixel.
[0051] S414: Perform eigenvalue decomposition on the gradient direction covariance matrix to obtain the largest eigenvalue. and the second largest eigenvalue ,and These two eigenvalues reflect the dispersion of gradient direction distribution within the window: if all gradient directions are highly consistent, then the energy is concentrated in the direction of the first eigenvector. Larger and Approaching 0; if the directions are disordered, then and Quite close.
[0052] S415: Determine the gradient direction coherence coefficient C of the edge pixel based on the ratio of the largest eigenvalue to the second largest eigenvalue, i.e.: ; The larger the ratio, the more consistent the gradient directions within the window, and the more likely the edge pixels belong to the normal contour. The smaller the ratio, the worse the consistency of the directions, indicating that the gradient directions in this area are scattered, which is likely a false edge caused by flash, noise, or texture. When there are no flashes, normal edges usually have a high gradient direction coherence coefficient.
[0053] S5: Based on the edge sharpness parameter and the gradient direction coherence coefficient, identify flash defect pixels within the detection area corresponding to each angle. Specifically, this includes: S501: Compare the edge sharpness parameter of each edge pixel with a preset first threshold, and compare the gradient direction coherence coefficient of each edge pixel with a preset second threshold.
[0054] S502: Edge pixels with an edge sharpness parameter less than the first threshold and a gradient direction coherence coefficient less than the second threshold are identified as flash defect pixels. Normal edges have sharp gradient amplitude distributions and relatively high edge sharpness parameter values; while flash edges, due to overflow causing a smooth grayscale transition, typically have lower edge sharpness parameters. Simultaneously, the gradient directions within the neighborhood of normal edge points are highly consistent, resulting in a larger gradient direction coherence coefficient; flash regions, due to the presence of irregularly oriented edge fragments, often have a smaller coherence coefficient. Using both parameters in combination for judgment improves the reliability of flash detection and effectively controls false detections.
[0055] The first and second thresholds can be determined adaptively. Specifically, test samples of injection-molded anesthesia mask parts with known true distributions of flash defects are obtained. These true distributions can be obtained through manual marking under a microscope or high-precision scanning. Based on the numerical distribution of edge sharpness parameters and gradient direction coherence coefficients of each edge pixel in the test samples, the first and second thresholds are adaptively determined by maximizing the accuracy of flash defect pixel recognition. For example, using the F1 score as the optimization objective, a grid search or iterative optimization method is used for automatic optimization. In this way, the thresholds can be automatically adjusted for detection tasks under different materials and light source conditions, eliminating the need for manual parameter adjustment when changing anesthesia mask models and significantly reducing changeover time.
[0056] S6: Map the identified flash defect pixels from each angle to a unified reference coordinate system, fuse them to obtain a flash defect distribution map, and determine whether the injection-molded anesthesia mask to be inspected has flash defects based on the flash defect distribution map, and output the inspection result. Specifically, this includes: S601: Based on the intrinsic and extrinsic parameter matrices of each image acquisition device, the flash defect pixels identified from each angle are back-projected into three-dimensional space to obtain the flash defect spatial point cloud. For pixel coordinates (u,v) in a certain camera image, the spatial ray corresponding to the pixel can be determined using the camera imaging model and known camera parameters. Since flash pixels are often located near the mask edge, the intersection point of the ray and the model surface can be obtained by combining the surface constraints of the standard three-dimensional geometric model, thus obtaining the flash defect spatial point cloud.
[0057] S602: Register the positions of each point in the spatial point cloud of the flash defect with the standard three-dimensional geometric model to eliminate accumulated system errors. Registration can be performed using an iterative nearest-point algorithm or a registration method based on model feature points.
[0058] S603: Perform clustering and connectivity analysis on the registered point cloud of flash defects. Point cloud clusters that are interconnected and whose distance to the edge of the standard 3D geometric model is less than a preset distance threshold are identified as valid flash defect regions. Specifically, a density clustering algorithm based on Euclidean distance is used to group points that are close together into the same cluster. Then, the shortest distance from each point cloud cluster to the edge of the standard 3D geometric model is calculated, and clusters that satisfy connectivity and whose distance is less than the threshold are retained. Here, the preset distance threshold can be set according to the mask size tolerance and imaging accuracy, for example, 1.5 mm. This step can effectively filter out false defects caused by image noise or outliers in the point cloud.
[0059] S604: The effective flash defect area is back-projected onto the surface of the standard three-dimensional geometric model to generate the flash defect distribution map. This distribution map can visually show the position, shape, and size of the flash on the mask's three-dimensional model. Based on this distribution map, it is possible to further determine whether the injection-molded anesthesia mask to be inspected has flash defects, as well as the severity and location information of the defects, and output the inspection results. For example, if there is a flash area with a connected area exceeding a preset area threshold, the part is determined to be a defective product.
[0060] The multi-angle fusion strategy makes full use of three-dimensional geometric information to spatially aggregate the discontinuous flash edges found from various perspectives, which can be pieced together to form a complete flash edge shape, overcoming the problem of missed detection caused by the discontinuity of flash edges from a single perspective.
[0061] It is understood that in the above embodiments, the number and angle of the image acquisition devices are not limited to the examples listed. The denoising and enhancement algorithms in the preprocessing can be substituted for each other or used in combination. Edge extraction can use any operator that can obtain a reliable edge response. The acquisition of the standard three-dimensional geometric model can also be achieved by combining CAD import and scanning reconstruction methods. Any simple modifications, equivalent substitutions, and reasonable adjustments to the order of method steps made by those skilled in the art without departing from the technical concept of this invention are within the protection scope of this invention.
[0062] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: (1) In this invention, by simultaneously acquiring data from multiple angles and combining it with a standard three-dimensional geometric model, a strip detection area is delineated in the images from each viewpoint. This ensures that the edge analysis always takes the ideal edge position as the reference benchmark, and is not affected by the transmission interference caused by the transparency of the mask body or the background texture. This improves the accuracy and stability of edge feature extraction from the source. At the same time, the detection method guided by the standard three-dimensional geometric model does not require image registration with physical standard samples, which significantly reduces the dependence of the detection system on the tooling positioning accuracy and the environmental adaptability requirements.
[0063] (2) In this invention, two complementary features, edge sharpness parameter and gradient direction coherence coefficient, are used to jointly determine the pixel point of the flash defect. The edge sharpness parameter distinguishes between sharp edges and smooth transitions from the gray-scale profile distribution pattern, while the gradient direction coherence coefficient distinguishes between continuous contours and messy flash fragments from the local directional consistency. The combination of the two effectively solves the problem that it is difficult to reliably distinguish between normal edges and flash by relying on a single feature, so that the detection can significantly suppress false alarms while maintaining a high flash recall level.
[0064] (3) In this invention, the flash pixels identified independently from each viewpoint are restored into a flash defect spatial point cloud through back projection and three-dimensional registration. The effective flash defect area is obtained by clustering and model edge distance constraint screening, and finally a flash defect distribution map is generated on the surface of the standard three-dimensional geometric model. This multi-view fusion strategy makes full use of the consistency constraint of three-dimensional geometric information on spatial relationships, overcomes the missed detection caused by the discontinuity of flash imaging due to viewpoint occlusion and grazing angle in single viewpoint, and realizes the overall and reliable evaluation of the flash distribution around the entire mask mold line edge.
[0065] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. The scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A machine vision-based method for detecting flash during injection molding of anesthesia masks, characterized in that, include: S1: Acquire multi-angle images of the injection-molded anesthesia mask to be tested, and preprocess the acquired multi-angle images; S2: Perform edge extraction on the preprocessed multi-angle images to obtain the edge images corresponding to each angle; S3: Obtain the standard three-dimensional geometric model of the injection molded anesthesia mask to be tested, determine the theoretical edge contour line according to the standard three-dimensional geometric model, and delineate the detection area in the edge image corresponding to each angle according to the theoretical edge contour line; S4: Within the detection area corresponding to each angle, calculate the edge sharpness parameter and gradient direction coherence coefficient of each edge pixel. The edge sharpness parameter is used to characterize the degree of grayscale change at the edge, and the gradient direction coherence coefficient is used to characterize the consistency of the gradient direction of each pixel in the local area. S5: Identify burr defect pixels in the detection area corresponding to each angle based on the edge sharpness parameter and the gradient direction coherence coefficient; S6: Map the flash defect pixels identified from each angle to a unified reference coordinate system, fuse them to obtain a flash defect distribution map, and determine whether the injection molded anesthesia mask to be tested has flash defects based on the flash defect distribution map, and output the detection result.
2. The method for detecting flash in injection molding of anesthesia masks based on machine vision according to claim 1, characterized in that, In S1, multi-angle images of the injection-molded anesthesia mask to be tested are acquired, and the acquired multi-angle images are preprocessed, including the following steps: S101: Simultaneously trigger at least two image acquisition devices to synchronously acquire images of the injection-molded anesthesia mask to be tested from at least two different preset angles to obtain multi-angle original images; S102: Denoise the original image from multiple angles; S103: Perform contrast enhancement processing on the denoised image to obtain a multi-angle preprocessed image.
3. The method for detecting flash in injection molding of anesthesia masks based on machine vision according to claim 1, characterized in that, In S3, a standard three-dimensional geometric model of the injection-molded anesthesia mask to be tested is obtained. The theoretical edge contour line is determined based on the standard three-dimensional geometric model, including the following steps: S301: Obtain the standard three-dimensional geometric model corresponding to the model number of the injection molded anesthesia mask to be tested; S302: Based on the intrinsic and extrinsic parameter matrices of each image acquisition device, the standard three-dimensional geometric model is projected onto the image plane of each image acquisition device to obtain the theoretical edge projection lines corresponding to each angle. S303: The theoretical edge projection line is used as the theoretical edge contour line in the corresponding angle image.
4. The method for detecting flash in injection molding of anesthesia masks based on machine vision according to claim 1, characterized in that, S4 calculates the edge sharpness parameter for each edge pixel, including the following steps: S401: For any edge pixel in the detection area, extract a pixel grayscale profile line passing through the edge pixel in the detection area along the normal direction of the theoretical edge contour line at the edge pixel. S402: On the pixel grayscale profile line, with the edge pixel as the center, calculate the distribution curve of the grayscale gradient magnitude along the normal direction; S403: Determine the edge sharpness parameter of the edge pixel based on the sharpness of the peak of the distribution curve, wherein the sharper the peak of the distribution curve, the larger the value of the edge sharpness parameter.
5. The method for detecting flash in injection molding of anesthesia masks based on machine vision according to claim 1, characterized in that, The gradient direction coherence coefficient of each edge pixel in S4 is calculated, including the following steps: S411: Within the detection area, for any edge pixel, determine a local neighborhood window centered on that edge pixel; S412: Calculate the gradient direction angle values of all pixels within the local neighborhood window; S413: Weight the gradient direction angle values of each pixel based on the gradient magnitude of each pixel, and calculate the weighted gradient direction covariance matrix. S414: Perform eigenvalue decomposition on the gradient direction covariance matrix to obtain the largest and second largest eigenvalues; S415: Determine the gradient direction coherence coefficient of the edge pixel based on the ratio of the largest eigenvalue to the second largest eigenvalue.
6. The method for detecting flash in injection molding of anesthesia masks based on machine vision according to claim 5, characterized in that, In S411, a local neighborhood window centered on the edge pixel is determined. Specifically, a local neighborhood window of size (2k+1)×(2k+1) pixels is determined centered on the edge pixel. The value of k is related to the radius of curvature of the theoretical edge contour at the edge pixel. The smaller the radius of curvature, the smaller the value of k.
7. The method for detecting flash in injection molding of anesthesia masks based on machine vision according to claim 1, characterized in that, S5 identifies flash defect pixels within the detection area corresponding to each angle based on the edge sharpness parameter and the gradient direction coherence coefficient, including the following steps: S501: Compare the edge sharpness parameter of each edge pixel with a preset first threshold, and compare the gradient direction coherence coefficient of each edge pixel with a preset second threshold. S502: Edge pixels with edge sharpness parameters less than the first threshold and gradient direction coherence coefficient less than the second threshold are identified as fringe defect pixels.
8. The method for detecting flash in injection molding of anesthesia masks based on machine vision according to claim 7, characterized in that, The first threshold and the second threshold are determined as follows: a test sample of anesthesia mask injection molded part with known true distribution of flash defects is obtained, and the first threshold and the second threshold are adaptively determined by maximizing the recognition accuracy of flash defect pixels based on the numerical distribution of edge sharpness parameters and gradient direction coherence coefficients of each edge pixel of the test sample.
9. The method for detecting flash in injection molding of anesthesia masks based on machine vision according to claim 1, characterized in that, In S6, the burr defect pixels identified from various angles are mapped to a unified reference coordinate system and fused to obtain a burr defect distribution map, including the following steps: S601: Based on the intrinsic and extrinsic parameter matrices of each image acquisition device, the flash defect pixels identified from each angle are back-projected into three-dimensional space to obtain the flash defect spatial point cloud. S602: Register the positions of each point in the spatial point cloud of the flash defect with the standard three-dimensional geometric model; S603: Perform clustering and connected component analysis on the registered point cloud of flash defects, and determine the point cloud clusters that are interconnected and whose distance to the edge of the standard three-dimensional geometric model is less than a preset distance threshold as valid flash defect regions. S604: Back-project the effective flash defect area onto the surface of the standard three-dimensional geometric model to generate the flash defect distribution map.
10. A method for detecting flash in injection molding of anesthesia masks based on machine vision according to claim 2, characterized in that, The acquisition of multi-angle images described in S101 also includes: S1011: Obtain the material type of the injection molded anesthesia mask to be tested, wherein the material type includes at least transparent material and semi-transparent material; S1012: Determine the corresponding light source parameters according to the material type; S1013: Based on the light source parameters, while triggering the image acquisition device, control the light source to illuminate according to the light source parameters.