A Method and System for Hole Detection in Aluminum Alloy Die Castings Based on Industrial Vision

By using industrial vision technology, combined with region segmentation, grayscale gradient analysis, and hole coefficient screening, the problem of misjudgment in hole detection of aluminum alloy die castings has been solved, achieving efficient and accurate hole detection, and improving detection efficiency and product quality.

CN121437469BActive Publication Date: 2026-06-30DONG GUAN ALUMINIUM MASTER DIE-CASTING IND CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DONG GUAN ALUMINIUM MASTER DIE-CASTING IND CO LTD
Filing Date
2025-11-06
Publication Date
2026-06-30

Smart Images

  • Figure CN121437469B_ABST
    Figure CN121437469B_ABST
Patent Text Reader

Abstract

This invention relates to the field of industrial vision inspection technology, specifically to a method and system for detecting holes in aluminum alloy die castings based on industrial vision. The method includes: acquiring and preprocessing an image of the aluminum alloy die casting; segmenting the image into regions, and based on the distribution characteristics of grayscale and gradient in the region segmentation results, identifying suspected hole regions in the image; using the contour and texture features of the suspected hole regions, filtering them to obtain hole regions and regions to be determined; calculating the hole coefficient of the region to be determined based on the grayscale value distribution level of pixels in the region to be determined, and using the hole coefficient to filter out the hole regions in the region to be determined; and using the scale of the hole regions contained on the surface of the aluminum alloy die casting to assess the quality of the aluminum alloy die casting. This invention improves the accuracy of detecting hole defects in aluminum alloy die castings.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial vision inspection technology, specifically to a method and system for detecting holes in aluminum alloy die-cast parts based on industrial vision. Background Technology

[0002] As a key component in modern manufacturing, aluminum alloy die casting involves injecting molten aluminum alloy at high speed and under high pressure into a precision mold and then rapidly cooling it to form the final product. However, this process is prone to generating defects such as pores, which severely affect the surface integrity and density of the casting. Therefore, efficient and accurate detection of pores on the surface of die castings is crucial to ensure that the finished product meets quality standards.

[0003] Pore ​​defects on the surface of aluminum alloy die castings are mainly divided into two categories: shrinkage cavities and air pores, which typically appear as regular or irregular shapes in images. In actual inspection, minor and inconspicuous pore defects on the casting surface can easily be visually confused with dirt (such as dust, oil residue, and slight oxidation spots) on the die casting surface. Both appear as dark spots in images, leading to an increased misjudgment rate with traditional inspection methods. Therefore, image inspection technology is used to analyze the pore characteristics on the surface of aluminum alloy die castings. Summary of the Invention

[0004] This invention provides a method and system for detecting holes in aluminum alloy die-cast parts based on industrial vision, in order to solve existing problems.

[0005] The present invention provides a method and system for detecting holes in aluminum alloy die-castings based on industrial vision, which adopts the following technical solution:

[0006] One embodiment of the present invention provides a method for detecting holes in aluminum alloy die castings based on industrial vision, the method comprising the following steps:

[0007] Acquire images of aluminum alloy die-cast parts and perform preprocessing;

[0008] Region segmentation is performed on the image of aluminum alloy die casting. Based on the distribution information of grayscale and gradient of the region segmentation results, suspected hole regions in the image of aluminum alloy die casting are obtained. The contour and texture features of the suspected hole regions are used to screen the suspected hole regions to obtain the hole regions and the regions to be determined.

[0009] Based on the grayscale value distribution level of the pixels in the region to be determined, the hole coefficient of the region to be determined is calculated, and the hole region in the region to be determined is screened out using the hole coefficient;

[0010] The quality of aluminum alloy die castings is assessed by utilizing the size of the porous area on the surface of the die casting.

[0011] Optionally, the method for performing region segmentation on the aluminum alloy die-casting image and obtaining suspected hole regions in the image based on the distribution information features of the region segmentation results in grayscale and gradient includes:

[0012] The image of the aluminum alloy die casting was processed by a superpixel segmentation algorithm to obtain several superpixel regions;

[0013] Any superpixel region is taken as the target superpixel region. The gradient values ​​of all pixels in the target superpixel region are obtained using the Sobel operator. Based on the distribution of grayscale values ​​and gradient values ​​of all pixels in the target superpixel region, the grayscale-gradient information entropy of the target superpixel region is calculated. The average value of the grayscale-gradient information entropy of all superpixel regions is obtained. The superpixel regions in the aluminum alloy die casting image whose grayscale-gradient information entropy is greater than or equal to the average value are taken as suspected hole regions.

[0014] Optionally, the process of processing the image of the aluminum alloy die-casting part using a superpixel segmentation algorithm to obtain several superpixel regions includes the following specific methods:

[0015] Several seed points are uniformly selected in the image of the aluminum alloy die casting. A search is performed in the eight-neighbor area of ​​each seed point. The vector formed by the gray value and coordinate position of the pixel is used as the basic vector of the corresponding pixel. The cosine similarity of the basic vectors between adjacent pixels is used as the distance metric. The pixels in the image of the aluminum alloy die casting are clustered through an iterative K-means clustering process to form several regions as superpixel regions.

[0016] Optionally, the specific method for calculating the gray-level gradient information entropy of the target superpixel region is as follows:

[0017] Obtain the information entropy of the grayscale values ​​and the information entropy of the gradient values ​​of all pixels in the target superpixel region, denoted as grayscale entropy and gradient entropy respectively. Use the average value of grayscale entropy and gradient entropy as the grayscale-gradient information entropy of the target superpixel region.

[0018] Optionally, the method of using the contour and texture features of the suspected hole region to screen the suspected hole region and obtain the hole region and the region to be determined includes the following specific methods:

[0019] The regularity of the suspected hole area is calculated based on the edge variation of any suspected hole area in the image of the aluminum alloy die casting.

[0020] The grayscale value difference between different pixels in the suspected hole area is obtained, and the texture coefficient of the suspected hole area is obtained by combining the regularity of the suspected hole area.

[0021] By utilizing the distribution of texture coefficients in all suspected hole regions, the suspected hole regions are screened to obtain hole regions and regions to be determined.

[0022] Optionally, the method for calculating the regularity of the suspected hole region based on the edge variation of any suspected hole region in the image of the aluminum alloy die casting includes:

[0023] The Canny algorithm is used to perform edge detection on all suspected hole regions to obtain the edge line of each suspected hole region. A two-dimensional rectangular coordinate system is established, and the lower left corner of the aluminum alloy die casting image is used as the origin of the two-dimensional rectangular coordinate system. The coordinates of all edge pixels of the edge line in any suspected hole region are obtained in the two-dimensional rectangular coordinate system. The slope of the edge pixel on its respective edge line is obtained using the coordinates of the edge pixels. Based on the slope changes of all edge pixels on the edge line in the suspected hole region, the regularity of the suspected hole region is calculated.

[0024] Optionally, the specific method for obtaining the grayscale value difference between different pixels in the suspected hole region and combining it with the regularity of the suspected hole region to obtain the texture coefficient of the suspected hole region includes:

[0025] Obtain any combination of two pixels in the suspected hole region, denoted as a pixel combination. Obtain the gray value difference between the pixels contained in the pixel combination. Based on the gray value difference corresponding to all pixel combinations in the suspected hole region and the regularity of the suspected hole region, obtain the texture coefficient of the suspected hole region.

[0026] Optionally, the method for screening suspected hole regions by utilizing the distribution of texture coefficients across all suspected hole regions to obtain hole regions and regions to be determined includes:

[0027] Arrange the texture coefficients of all suspected hole regions in ascending order to obtain a texture coefficient sequence. Obtain the forward difference sequence of the texture coefficient sequence, which contains several difference values. Take the element in the texture coefficient sequence corresponding to the largest difference value as the split point. Use the split point to sieve the elements in the texture coefficient sequence to obtain the first element and the second element. Take the suspected hole region corresponding to the first element as the hole region and the suspected hole region corresponding to the second element as the region to be determined.

[0028] Optionally, the specific method for calculating the hole coefficient of the region to be determined based on the grayscale value distribution level of pixels in the region to be determined, and using the hole coefficient to filter out the hole regions in the region to be determined, includes:

[0029] In the image of the aluminum alloy die-casting part, superpixel regions whose gray-level gradient entropy is less than the average gray-level gradient entropy of all superpixel regions are designated as normal regions. The average gray value of all pixels within these normal regions is recorded as the baseline gray value. Pixels continuously adjacent to any pixel on the edge of the region to be determined are then identified. A narrow band region formed by a number of pixels is denoted as the outer perimeter of the region to be determined. The average gray value of all pixels contained in the outer perimeter is denoted as the outer perimeter gray value of the region to be determined. The average gray value of all pixels in the region to be determined is denoted as the overall gray value of the region to be determined. Based on the difference between the gray values ​​of pixels in the region to be determined that have a gray value greater than the overall gray value and the reference gray value, and the ratio between the corresponding outer perimeter gray value and the reference gray value in the outer perimeter of the region to be determined, the hole coefficient of the region to be determined is obtained. This is the preset first parameter;

[0030] The region to be determined where the hole coefficient is greater than or equal to the preset hole threshold is designated as the hole region.

[0031] The industrial vision-based aluminum alloy die-casting hole detection system includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of any one of the industrial vision-based aluminum alloy die-casting hole detection methods.

[0032] The beneficial effects of the technical solution of this invention are as follows: By employing region segmentation technology and combining grayscale and gradient distribution features, suspected hole areas are initially located, enhancing the accuracy of target area extraction. Based on this, contour morphology and texture characteristics are further utilized to finely screen suspected areas, effectively distinguishing between real defects and background interference, significantly reducing the false judgment rate. For areas that are difficult to determine directly, the concept of a hole coefficient is introduced. By analyzing the differences in pixel grayscale distribution levels within the area, a quantitative assessment of potential defects is achieved, thus completing the final judgment. The entire detection process fully integrates multi-dimensional image features, taking into account both macroscopic shape and microscopic details, improving the detection capability of small-sized or low-contrast holes under complex working conditions. Furthermore, by scientifically assessing the overall quality level of die-cast parts, it meets the needs of industrial automated quality inspection. This effectively improves detection efficiency and accuracy, thereby further contributing to increasing product qualification rates and reducing manufacturing costs. Attached Figure Description

[0033] To more clearly illustrate the technical solutions in the embodiments of the present 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 only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0034] Figure 1 This is a flowchart of the steps of the method for detecting holes in aluminum alloy die castings based on industrial vision according to the present invention;

[0035] Figure 2 An example image of the surface of an aluminum alloy die-casting part provided in one embodiment of the present invention;

[0036] Figure 3 This is a structural block diagram of the hole detection system for aluminum alloy die castings based on industrial vision according to the present invention. Detailed Implementation

[0037] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of the industrial vision-based hole detection method and system for aluminum alloy die castings proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0038] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0039] The following description, in conjunction with the accompanying drawings, details the specific scheme of the hole detection method and system for aluminum alloy die castings based on industrial vision provided by this invention.

[0040] Please see Figure 1 The diagram illustrates a flowchart of a method for detecting holes in aluminum alloy die-castings based on industrial vision, according to an embodiment of the present invention. The method includes the following steps:

[0041] Step S001: Obtain the image of the aluminum alloy die casting and perform preprocessing.

[0042] It should be noted that surface defects such as pores in aluminum alloy die castings are easily confused with dirt in industrial visual inspection, making them difficult to distinguish. This poses a challenge to the quality inspection of die castings. Figure 2The image shown is an example of a surface image of an aluminum alloy die-casting part. Real-time defect detection is performed after die-casting, identifying die-casting parts with defects such as pores on the production line. Automatic calibration and positioning are achieved using CAD images of the aluminum alloy die-casting part to ensure consistent workpiece posture and distance from the camera during each inspection (avoiding misjudgments of defect coordinates due to workpiece misalignment). The die-casting part is photographed from the front using a resolution of ≥5 megapixels in a uniformly lit, dust-free environment.

[0043] Specifically, in order to implement the industrial vision-based hole detection method for aluminum alloy die castings proposed in this embodiment, it is first necessary to acquire images of the aluminum alloy die castings. The specific process is as follows:

[0044] First, the industrial camera is controlled to trigger shooting under standard lighting conditions to obtain the original image of the aluminum alloy die casting in the front view direction; at the same time, based on the pre-stored CAD model image, the original image is calibrated by affine transformation through feature matching algorithm to eliminate workpiece posture deviation.

[0045] Then, the image of the aluminum alloy die casting is preprocessed.

[0046] As an optional embodiment, the specific method for preprocessing the aluminum alloy die casting image is as follows: Gaussian filtering and histogram equalization are performed on the aluminum alloy die casting image to obtain a noise-reduced and augmented aluminum alloy die casting image.

[0047] Thus, the image of the aluminum alloy die-casting part is obtained through the above method.

[0048] Step S002: Perform region segmentation on the image of the aluminum alloy die casting. Based on the distribution information features of the region segmentation results in grayscale and gradient, obtain the suspected hole regions in the image of the aluminum alloy die casting. Use the contour and texture features of the suspected hole regions to screen the suspected hole regions and obtain the hole regions and the regions to be determined.

[0049] It should be noted that the aluminum alloy die-casting part in the image is first located, and then the image of the aluminum alloy die-casting part is segmented and clustered through superpixel segmentation to divide it into multiple regions. Based on the gradient features of the regions, suspected hole areas can be located. The complexity of the region shape and internal pixel information can identify areas with large hole information; for areas where hole information and dirt information are not obvious and are easily confused, the possibility of the area to be detected being a hole can be analyzed by analyzing the difference in brightness between the bright pixels inside and the normal aluminum alloy surface, as well as the characteristic that the brightness of the downward concave edge of the hole is higher than that of the normal aluminum alloy surface due to the influence of light.

[0050] Specifically, in step S201, the image of the aluminum alloy die casting is segmented into regions, and the suspected hole regions in the image of the aluminum alloy die casting are obtained based on the distribution information features of the region segmentation results in grayscale and gradient.

[0051] It should be noted that the holes and dirt on the surface of aluminum alloy die castings differ from the pixel grayscale values ​​of the aluminum alloy die castings themselves. Therefore, the suspected hole areas can be identified based on the grayscale values ​​of the pixels in the image.

[0052] The preprocessed image is located based on the CAD model of the aluminum alloy die casting to select the area where the aluminum alloy die casting is located.

[0053] First, the image of the aluminum alloy die casting is processed using a superpixel segmentation algorithm to obtain several superpixel regions.

[0054] As an optional embodiment, the method for obtaining the superpixel region is as follows: several seed points are uniformly selected in the image of the aluminum alloy die casting, and a search is performed in the eight-neighbor area of ​​each seed point. The vector formed by the gray value and coordinate position of the pixel is used as the basic vector of the corresponding pixel. The cosine similarity of the basic vectors between adjacent pixels is used as the distance metric. The pixels in the image of the aluminum alloy die casting are clustered through an iterative K-means clustering process to form several regions, which are used as superpixel regions.

[0055] It should be noted that the Simple Linear Iterative Clustering (SLIC) algorithm is an existing image segmentation algorithm. In this embodiment of the invention, by clustering and segmenting the coordinates and gray values ​​of pixels, the image of aluminum alloy die casting can be segmented into several superpixels containing semantic information, which facilitates the subsequent semantic analysis of hole-related areas in the superpixel areas, thereby quickly and accurately identifying hole areas.

[0056] Then, taking any superpixel region as the target superpixel region, the Sobel operator is used to obtain the gradient values ​​of all pixels in the target superpixel region. Based on the distribution of grayscale values ​​and gradient values ​​of all pixels in the target superpixel region, the grayscale-gradient information entropy of the target superpixel region is calculated. The average value of the grayscale-gradient information entropy of all superpixel regions is obtained. The superpixel regions in the aluminum alloy die casting image whose grayscale-gradient information entropy is greater than or equal to the average value are taken as suspected hole regions.

[0057] As an optional embodiment, the specific calculation method of the gray-gradient information entropy of the target superpixel region is as follows: obtain the information entropy of the gray value and the information entropy of the gradient value of all pixels in the target superpixel region, and denot them as gray-level entropy and gradient entropy respectively, and take the average value of gray-level entropy and gradient entropy as the gray-gradient information entropy of the target superpixel region.

[0058] It should be noted that in aluminum alloy die-casting images, normal areas without any defects typically have smooth surfaces and are brighter due to reflections compared to defective areas, resulting in higher grayscale levels and the absence of complex grayscale distribution features. In other words, the lower the overall grayscale and gradient entropy level of the superpixel region, the more likely it is to be a normal region without any defects. Therefore, in this embodiment of the invention, the grayscale and gradient information distribution features of the superpixel region are used to screen and locate suspected hole areas from aluminum alloy die-casting images.

[0059] Step S202: Using the contour and texture features of the suspected hole area, the suspected hole area is screened to obtain the hole area and the area to be determined.

[0060] It should be noted that, through superpixel segmentation, all suspected hole regions in the image of the aluminum alloy die casting were obtained. Some of these regions have obvious hole features, and the shapes of the holes are extremely irregular (such as shrinkage cavities), appearing as dendritic, mesh-like, band-like, or serrated. In addition, since the holes are concave and the inner walls of the holes are rough with dendritic protrusions, the pixel information of the regions corresponding to the holes in the image is actually complex. Therefore, the regions that simultaneously satisfy the conditions of irregular shape and complex pixel information are the regions corresponding to the holes. Furthermore, there are also some hole regions that are not obvious in terms of shape and pixel information, which are easily confused with dirt. Therefore, in the subsequent steps of this embodiment, it is also necessary to screen out the regions with insignificant hole features to distinguish between holes and dirt.

[0061] First, the regularity of the suspected hole area is calculated based on the edge variation of any suspected hole area in the image of the aluminum alloy die casting.

[0062] As a preferred embodiment, the specific method for obtaining the regularity of the suspected hole region is as follows: Edge detection is performed on all suspected hole regions using the Canny algorithm to obtain the edge line of each suspected hole region; a two-dimensional rectangular coordinate system is established, with the lower left corner of the aluminum alloy die-casting image as the origin of the two-dimensional rectangular coordinate system; the coordinates of all edge pixels of the edge line in any suspected hole region are obtained in the two-dimensional rectangular coordinate system; the slope of the edge pixel on its respective edge line is obtained using the coordinates of the edge pixels; and the regularity of the suspected hole region is calculated based on the slope changes of all edge pixels on the edge line in the suspected hole region.

[0063] As an optional embodiment, the specific method for calculating the regularity is as follows:

[0064]

[0065] in, Indicates the first The regularity of the area suspected of having holes; Indicates the first On the edge of the suspected hole area, the first The slope of each edge pixel; Indicates the first On the edge of the suspected hole area, the first The slope of each edge pixel; Indicates the first The number of edge pixels on the edge line of the suspected hole area; Represents the absolute value function; This represents an exponential function with the natural constant as its base.

[0066] It should be noted that regularity is used to describe the degree of regularity of the outline of the suspected hole area. Since the edge outline of the hole in the aluminum alloy die casting is usually affected by dendrites, the edge changes in the image are complex and the outline is not regular enough. Therefore, the smaller the slope difference between adjacent edge pixels on the edge line of the suspected hole area, the simpler the edge change, thus reflecting the greater the degree of regularity of the outline of the suspected hole area.

[0067] Then, the grayscale value difference between different pixels in the suspected hole area is obtained, and the texture coefficient of the suspected hole area is obtained by combining the regularity of the suspected hole area.

[0068] It should be noted that the hole is a downward-recessed hole with a rough inner wall and dendritic protrusions. The brightness of the inner wall varies depending on the light, so the gradient information of the hole area is relatively complex. Therefore, this embodiment of the invention selects to analyze the pixel information of all suspected hole areas separately. The greater the gray level difference between pixels in a suspected hole area, the more complex the pixel information in that area. In this case, if the shape of the area is more irregular, the area is more likely to be a hole area.

[0069] As a preferred embodiment, the specific method for obtaining the texture coefficient is as follows: obtain a combination formed by any two pixels in the suspected hole region, denoted as a pixel combination; obtain the gray value difference between the pixels contained in the pixel combination; and obtain the texture coefficient of the suspected hole region based on the gray value difference corresponding to all pixel combinations in the suspected hole region and the regularity of the suspected hole region.

[0070] As an optional embodiment, the specific calculation method for the texture coefficient is as follows:

[0071]

[0072] in, Indicates the first Texture coefficients for suspected hole areas; Indicates the first The first suspected hole area The grayscale value of the first pixel in a combination of pixels; Indicates the first The first suspected hole area The grayscale value of the second pixel in the pixel combination; m represents the grayscale value of the second pixel. The number of pixel combinations in a suspected hole area; Indicates the first The regularity of the area suspected of having holes; This represents the absolute value function.

[0073] It should be noted that the texture coefficient is used to describe the degree to which the texture features of the suspected hole region match those of a hole. The larger the texture coefficient value, the greater the probability that the corresponding suspected hole region is a hole region. That is, by combining the regularity of the suspected hole region and the gray value difference of the pixels in the region, it is determined that when the edge contour of the suspected hole region is more irregular and the information of all pixels in the region is more complex, the degree to which the suspected hole region is a hole region is determined.

[0074] Finally, by using the distribution of texture coefficients in all suspected hole regions, the suspected hole regions are screened to obtain hole regions and regions to be determined.

[0075] As an optional embodiment, the specific method for obtaining the hole region and the region to be determined is as follows: Arrange the texture coefficients of all suspected hole regions in ascending order to obtain a texture coefficient sequence; obtain the forward difference sequence of the texture coefficient sequence, which contains several difference values; take the element in the texture coefficient sequence corresponding to the largest difference value as the segmentation point; use the segmentation point to sieve the elements in the texture coefficient sequence to obtain the first element and the second element; take the suspected hole region corresponding to the first element as the hole region, and take the suspected hole region corresponding to the second element as the region to be determined.

[0076] As an optional embodiment, the method of using the segmentation point to sieve the elements in the texture coefficient sequence to obtain the first element and the second element includes: taking the elements in the texture coefficient sequence whose texture coefficient is greater than or equal to the texture coefficient corresponding to the segmentation point as the first element; and taking the elements in the texture coefficient sequence whose texture coefficient is less than the texture coefficient corresponding to the segmentation point as the second element.

[0077] It should be noted that the change between two adjacent P values ​​is calculated, and all changes are iterated to locate the position with the largest change. At this position, the entire data sequence is divided into two parts. The right data (with a large P value) has significant hole features and is considered to be holes. The left data has a smaller P value, meaning that the hole and dirt information in these areas is not obvious and is easily confused. Therefore, the area corresponding to the left data is marked as the area to be detected for subsequent analysis.

[0078] Thus, several hole regions and regions to be determined have been obtained through the above methods.

[0079] Step S003: Based on the grayscale value distribution level of the pixels in the region to be determined, calculate the hole coefficient of the region to be determined, and use the hole coefficient to filter out the hole areas in the region to be determined.

[0080] It should be noted that while the area to be determined may not show obvious holes or dirt information in the image, the holes on the aluminum alloy surface have a downward-concave structure with a slope of a certain thickness at the concave edge. Under the influence of light, the grayscale value of pixels at the slope will be higher than that of the smooth aluminum alloy surface. Therefore, this embodiment of the invention selects to analyze the difference in overall grayscale level between the pixels in the highlighted area and the pixels in the normal area to further determine the possibility that the area to be determined is a hole. Some hole areas may exhibit a highlighted state due to incomplete defects, resulting in two gradient edges at the edge of the hole area. Typically, a highlighted area exists inside the area to be determined. If its pixel grayscale value is similar to or even the same as that of the normal area, the area is more likely to be dirt. Conversely, the inner wall of a hole is rough, often accompanied by dendrite protrusions, and the internal structure is complex and chaotic. If the pixel grayscale difference between the highlighted area and the normal area is significant, and the grayscale value of the outer edge is higher than that of the normal aluminum alloy surface area, the area to be determined is more likely to be a hole.

[0081] Specifically, firstly, superpixel regions in the aluminum alloy die-casting image whose gray-level gradient entropy is less than the average gray-level gradient entropy of all superpixel regions are designated as normal regions. The average gray value of all pixels within these normal regions is recorded as the baseline gray value. Then, the values ​​of pixels continuously adjacent to any pixel on the edge of the region to be determined are obtained. A narrow band region formed by a number of pixels is denoted as the outer perimeter of the region to be determined. The average gray value of all pixels contained in the outer perimeter is denoted as the outer perimeter gray value of the region to be determined. The average gray value of all pixels in the region to be determined is denoted as the overall gray value of the region to be determined. Based on the difference between the gray values ​​of pixels in the region to be determined that have a gray value greater than the overall gray value and the reference gray value, and the ratio between the corresponding outer perimeter gray value and the reference gray value in the outer perimeter of the region to be determined, the hole coefficient of the region to be determined is obtained. This is the preset first parameter.

[0082] It should be noted that, due to the slope of a certain thickness at the recessed edge of the hole, the grayscale value of the pixels at the slope will be higher than that of the smooth aluminum alloy surface under the influence of light. Therefore, in order to obtain a case where the grayscale value of the recessed edge of the hole is relatively high, this embodiment of the invention selects an area formed within a preset width range, that is, an area continuously adjacent to any pixel on the edge of the area to be determined. A narrow band region formed by individual pixels; furthermore, in embodiments of the present invention, a preset based on experience is provided. The value is 2, which can be adjusted according to the actual situation. This embodiment of the invention does not impose specific limitations.

[0083] As an optional embodiment, the specific calculation method for the porosity coefficient is as follows:

[0084]

[0085] in, Indicates the first The porosity of the region to be determined; Indicates the first The outer perimeter of the region to be determined corresponds to the outer perimeter gray value; Indicates the baseline grayscale value; Indicates the first The first region to be determined The gray value corresponding to a pixel that is higher than the overall gray value of the region to be determined; Indicates the first The first region to be determined The number of pixels whose grayscale value is higher than the overall grayscale value of the region to be determined; Represents the absolute value function; This represents the linear normalization function.

[0086] It should be noted that, This represents the difference between the grayscale value of a pixel in the region to be determined that has a higher grayscale value than the overall grayscale value of the region to be determined, and the reference grayscale value; while Indicates the first The ratio of the gray value of the outer perimeter of the region to be determined to the reference gray value; The larger the value, the more significant the effect. The high grayscale pixels within the region to be determined also deviate significantly from the baseline grayscale value; and simultaneously satisfy the following conditions: The larger the value, the more... The larger the porosity of the region to be determined, the better. The higher the probability that an undetermined area is a hole area.

[0087] It should also be noted that the linear normalization function in the formula for calculating the porosity coefficient is used to map the porosity coefficient to... The interval facilitates subsequent threshold determination. In this embodiment of the invention, the linear normalization function adopts the minimum-maximum normalization method to ensure the comparability of detection results of different batches of images.

[0088] Then, the regions to be determined where the hole coefficient is greater than or equal to the preset hole threshold are designated as hole regions.

[0089] It should be noted that, in the embodiments of the present invention, the hole threshold is preset to 0.7 based on experience, and can be adjusted according to the actual situation. The embodiments of the present invention do not impose specific limitations.

[0090] Thus, by using the above method to filter the area to be determined, the hole area within the area to be determined is obtained.

[0091] Step S004: Evaluate the quality of the aluminum alloy die casting by utilizing the size of the pore area contained on the surface of the aluminum alloy die casting.

[0092] It should be noted that this step makes the final judgment based on the spatial distribution characteristics and geometric parameters of the holes, avoiding false rejections caused by single-pixel-level analysis; by combining prior knowledge of high-incidence areas of the process with quantitative thresholds, the accurate classification and grading of hole defects can be achieved, improving the practicality and reliability of the detection system.

[0093] In a specific embodiment of the present invention, the method for evaluating the quality of an aluminum alloy die casting by utilizing the size of the porous area on its surface includes the following:

[0094] First, the industrial vision inspection system imports the CAD model of the casting in advance, marking the coordinate range of high-risk areas such as thick-wall junctions and cooling ends in the model (e.g., setting the coordinate range of high-risk areas with the casting's reference hole as the origin). The industrial vision system locates areas with a high probability of holes, extracts the actual coordinates of these areas, and compares them with the preset high-risk area coordinate range to determine if there is overlap. If the overlapping area is greater than or equal to a preset second parameter, the system determines that the area is in a high-risk zone, marks the aluminum alloy die casting, triggers a red alarm, and controls the robotic arm to remove the workpiece to the defective area.

[0095] It should be noted that the second parameter is preset to 50% based on experience, and can be adjusted according to the actual situation. This embodiment of the invention does not impose specific limitations.

[0096] Then, for aluminum alloy die castings that are not located in areas prone to process defects, the area and number of hole regions are obtained through industrial vision, and the quality of the aluminum alloy die castings is assessed based on the area and number of hole regions.

[0097] In an optional embodiment, the method for assessing the quality of aluminum alloy die castings based on the area and number of holes includes the following steps: First, setting quality assessment conditions, including: the area of ​​a single largest hole is less than or equal to 0.6 mm²; the proportion of the total hole area is less than or equal to 0.5%; the hole density is less than or equal to 2 holes / cm²; then, when all quality assessment conditions are met, it is calibrated as Level 1; when at most 2 quality assessment conditions are met, it is calibrated as Level 2; when at most 1 quality assessment condition is met, it is calibrated as Level 3; when none of the quality assessment conditions are met, it is calibrated as Level 4.

[0098] It should be noted that in the quality assessment results, the higher the corresponding grade number, the worse the quality of the aluminum alloy die casting, and vice versa.

[0099] Finally, the system automatically records the inspection results (defect type, handling method, parameter data) of each workpiece, stores them in the database, and generates defect distribution reports periodically to provide data support for die casting process optimization.

[0100] The above steps complete the monitoring of pores in aluminum alloy die castings.

[0101] Please see Figure 3 The present invention illustrates an industrial vision-based hole detection system for aluminum alloy die castings, comprising a memory 302, a processor 301, and a computer program 3021 stored in the memory 302 and executable on the processor. When the processor 301 executes the computer program 3021, it implements steps S001 to S004 of the industrial vision-based hole detection method for aluminum alloy die castings.

[0102] The memory can be volatile or non-volatile, or may include both. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which serves as an external cache. Many forms of RAM are available by way of example, but not limitation. Examples include Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Sync Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM).

[0103] The aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting Advanced Reduced Instruction Set Machines (ARM) architecture.

[0104] It should be noted that the embodiments used in this example The model is only used to represent negative correlations and the results of the constraint model output are in Within this range, in specific implementations, other models with the same purpose can be substituted; this embodiment is merely an example. The description will be based on a model, without making specific limitations on it. This refers to the input of the model.

[0105] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for detecting holes in aluminum alloy die-castings based on industrial vision, characterized in that, The method includes the following steps: Acquire images of aluminum alloy die-cast parts and perform preprocessing; Region segmentation is performed on the image of aluminum alloy die casting. Based on the distribution information of grayscale and gradient of the region segmentation results, suspected hole regions in the image of aluminum alloy die casting are obtained. The contour and texture features of the suspected hole regions are used to screen the suspected hole regions to obtain the hole regions and the regions to be determined. Based on the grayscale value distribution level of the pixels in the region to be determined, the hole coefficient of the region to be determined is calculated, and the hole region in the region to be determined is screened out using the hole coefficient; The quality of aluminum alloy die castings is assessed by utilizing the size of the pore area contained on the surface of the die casting. The method for obtaining the porosity coefficient is as follows: Superpixel regions in the aluminum alloy die-casting image whose gray-level gradient entropy is less than the average gray-level gradient entropy of all superpixel regions are designated as normal regions; the average gray-level value of all pixels within these normal regions is recorded as the baseline gray-level value; and any pixel continuously adjacent to the edge of the region to be determined is obtained. A narrow band region formed by a number of pixels is denoted as the outer perimeter of the region to be determined. The average gray value of all pixels contained in the outer perimeter is denoted as the outer perimeter gray value of the region to be determined. The average gray value of all pixels in the region to be determined is denoted as the overall gray value of the region to be determined. Based on the difference between the gray values ​​of pixels in the region to be determined that have a gray value greater than the overall gray value and the reference gray value, and the ratio between the corresponding outer perimeter gray value and the reference gray value in the outer perimeter of the region to be determined, the hole coefficient of the region to be determined is obtained. This is the preset first parameter.

2. The method for detecting holes in aluminum alloy die-castings based on industrial vision according to claim 1, characterized in that, The method for performing region segmentation on the image of the aluminum alloy die casting, and obtaining suspected hole regions in the image of the aluminum alloy die casting based on the distribution information features of the region segmentation results in grayscale and gradient, includes the following specific methods: The image of the aluminum alloy die casting was processed by a superpixel segmentation algorithm to obtain several superpixel regions; Any superpixel region is taken as the target superpixel region. The gradient values ​​of all pixels in the target superpixel region are obtained using the Sobel operator. Based on the distribution of grayscale values ​​and gradient values ​​of all pixels in the target superpixel region, the grayscale-gradient information entropy of the target superpixel region is calculated. The average value of the grayscale-gradient information entropy of all superpixel regions is obtained. The superpixel regions in the aluminum alloy die casting image whose grayscale-gradient information entropy is greater than or equal to the average value are taken as suspected hole regions.

3. The method for detecting holes in aluminum alloy die-castings based on industrial vision according to claim 2, characterized in that, The process of processing the image of the aluminum alloy die casting using a superpixel segmentation algorithm to obtain several superpixel regions includes the following specific methods: Several seed points are uniformly selected in the image of the aluminum alloy die casting. A search is performed in the eight-neighbor area of ​​each seed point. The vector formed by the gray value and coordinate position of the pixel is used as the basic vector of the corresponding pixel. The cosine similarity of the basic vectors between adjacent pixels is used as the distance metric. The pixels in the image of the aluminum alloy die casting are clustered through an iterative K-means clustering process to form several regions as superpixel regions.

4. The method for detecting holes in aluminum alloy die-castings based on industrial vision according to claim 2, characterized in that, The specific method for calculating the gray-level gradient information entropy of the target superpixel region is as follows: Obtain the information entropy of the grayscale values ​​and the information entropy of the gradient values ​​of all pixels in the target superpixel region, denoted as grayscale entropy and gradient entropy respectively. Use the average value of grayscale entropy and gradient entropy as the grayscale-gradient information entropy of the target superpixel region.

5. The method for detecting holes in aluminum alloy die-castings based on industrial vision according to claim 1, characterized in that, The method for screening suspected hole regions using their contour and texture features to obtain hole regions and regions to be determined includes the following specific steps: The regularity of the suspected hole area is calculated based on the edge variation of any suspected hole area in the image of the aluminum alloy die casting. The grayscale value difference between different pixels in the suspected hole area is obtained, and the texture coefficient of the suspected hole area is obtained by combining the regularity of the suspected hole area. By utilizing the distribution of texture coefficients in all suspected hole regions, the suspected hole regions are screened to obtain hole regions and regions to be determined.

6. The method for detecting holes in aluminum alloy die-castings based on industrial vision according to claim 5, characterized in that, The method for calculating the regularity of a suspected hole region based on the edge variation of any suspected hole region in an image of an aluminum alloy die-casting part includes: The Canny algorithm is used to perform edge detection on all suspected hole regions to obtain the edge line of each suspected hole region. A two-dimensional rectangular coordinate system is established, and the lower left corner of the aluminum alloy die casting image is used as the origin of the two-dimensional rectangular coordinate system. The coordinates of all edge pixels of the edge line in any suspected hole region are obtained in the two-dimensional rectangular coordinate system. The slope of the edge pixel on its respective edge line is obtained using the coordinates of the edge pixel. The regularity of the suspected hole region is calculated based on the slope changes of all edge pixels on the edge line in the suspected hole region.

7. The method for detecting holes in aluminum alloy die-castings based on industrial vision according to claim 5, characterized in that, The specific method for obtaining the grayscale value difference between different pixels in the suspected hole region and combining it with the regularity of the suspected hole region to obtain the texture coefficient of the suspected hole region includes: Obtain any combination of two pixels in the suspected hole region, denoted as a pixel combination. Obtain the gray value difference between the pixels contained in the pixel combination. Based on the gray value difference corresponding to all pixel combinations in the suspected hole region and the regularity of the suspected hole region, obtain the texture coefficient of the suspected hole region.

8. The method for detecting holes in aluminum alloy die-castings based on industrial vision according to claim 5, characterized in that, The method for screening suspected hole regions by utilizing the distribution of texture coefficients across all suspected hole regions to obtain hole regions and regions to be determined includes the following specific steps: Arrange the texture coefficients of all suspected hole regions in ascending order to obtain a texture coefficient sequence. Obtain the forward difference sequence of the texture coefficient sequence. The forward difference sequence contains several difference values. Take the element in the texture coefficient sequence corresponding to the largest difference value as the dividing point. The elements in the texture coefficient sequence are sieved using the segmentation points to obtain the first element and the second element. The suspected hole region corresponding to the first element is taken as the hole region, and the suspected hole region corresponding to the second element is taken as the region to be determined.

9. The method for detecting holes in aluminum alloy die-castings based on industrial vision according to claim 4, characterized in that, The specific method for filtering out the porous regions in the region to be determined using the porosity coefficient is as follows: The region to be determined where the hole coefficient is greater than or equal to the preset hole threshold is designated as the hole region.

10. A hole detection system for aluminum alloy die-casting parts based on industrial vision, 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 steps of the method for detecting holes in aluminum alloy die-castings based on industrial vision as described in any one of claims 1-9.