A surface defect detection method and device based on machine vision

By analyzing image quality parameters, optimizing images in casting defect detection, and dividing the casting surface area and extracting feature, the problem of difficult to guarantee image clarity and accuracy of casting surfaces in the prior art is solved, and the accuracy and reliability of detection are improved.

CN119600026BActive Publication Date: 2025-06-24GUANGDONG QIXIN MOLD CO LTD

Patent Information

Application Number
CN202510143213.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-10
Publication Date
2025-06-24
Estimated Expiration
2045-02-10

AI Technical Summary

Technical Problem

The existing casting defect detection methods are difficult to guarantee the clarity and accuracy of the casting surface image due to errors during scanning, which affects the reliability of the detection.

Method used

The image of the casting surface is obtained by the image acquisition device, and the image quality parameters are analyzed to determine the image accuracy index. If the standards are not met, image optimization will be performed. The image is divided into multiple areas, the area feature parameters are extracted and compared with preset thresholds, and defect detection and early warning are performed.

Benefits of technology

The accuracy and reliability of surface defect detection of castings are improved. Through careful area division and feature extraction, areas with possible defects are initially screened out, which improves detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119600026B_ABST
    Figure CN119600026B_ABST
Patent Text Reader

Abstract

Embodiments of the present invention relate to the field of vision detection technology, and disclose a surface defect detection method based on machine vision, including: performing parameter analysis on the image quality parameters corresponding to the surface image of the casting to determine the image precision index of the surface image of the casting; if the image precision index of the surface image of the casting is not less than the precision index threshold; if the regional feature parameter is less than the preset regional standard feature threshold, defect detection is performed on the corresponding casting area image, and if the regional feature parameter is not less than the preset regional standard feature threshold, the corresponding casting area image is marked as a defect image to be detected; comparing the regional defect parameter with the preset surface defect standard index in the casting detection library. In the surface defect detection method based on machine vision in the embodiments of the present invention, the surface image of the casting is divided into multiple regions, and feature extraction is performed on each region, which can analyze the surface condition of the casting more carefully and improve the detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of visual detection, and particularly relates to a surface defect detection method and device based on machine vision. Background Art

[0002] At present, during the manufacturing process of castings, due to process and material reasons, defects such as cracks and pores are likely to occur. These defects directly affect the mechanical properties and service life of castings. Therefore, it is particularly important to detect defects on the surface of castings. AI vision uses digital image processing technology and computer vision technology to simulate human vision and can achieve rapid and accurate detection of surface defects on castings.

[0003] For example, the invention patent with the publication number CN115184368B discloses a casting defect detection control system. The system includes: a casting feature acquisition module for acquiring model information of a standard casting; a detection strategy generation module for generating a detection strategy according to the model information. The steps for generating the detection strategy are: S1, obtaining all detection planes of the casting according to the model information; S2, obtaining the fill light intensity and focal length information corresponding to each detection plane according to all detection planes of the casting; S3, using the corresponding fill light intensity and focal length information to detect each detection plane and generate a detection strategy; a detection module for obtaining image information of each detection plane of the casting according to the detection strategy; and an analysis module for comparing the image information of each detection plane of the casting with the standard image information to analyze whether the casting is faulty and the type of fault.

[0004] For example, the invention patent with the publication number CN118408951B discloses an aluminum die-casting defect detection system. It includes a device body, which is composed of a base, a frame body, a display, and an optical scanner. The bottom of the inner cavity of the frame body is fixedly connected with a workbench. One end of the workbench away from the groove is fixedly connected with a vertical frame. An adjustment component is installed inside the vertical frame. A clamping component is sleeved outside the object stage. When the optical scanner slides on the surface of the clamping component driven by the adjustment component, it can drive the cover kit in the clamping component to slide at the same time. At this time, the scanning surface of the optical scanner is aligned with the display frame plate, and the area outside the display frame plate can be covered to concentrate resources for high-precision scanning and analysis inside the display frame plate.

[0005] However, in the process of implementing the technical solutions of the present invention in the embodiments of the present application, it is found that the above technologies have at least the following technical problems: In the existing casting defect detection methods, mainly the surface of the casting is directly scanned for images and the casting defects are detected through the scanned images of the casting surface. However, for the scanned images of the casting surface based on this defect detection, due to errors in the scanning process, it is difficult to ensure the clarity and accuracy of the scanned casting surface images, which directly affects the reliability of the casting surface defect detection. Summary of the Invention

[0006] In view of the above defects, embodiments of the present invention disclose a surface defect detection method based on machine vision, which can achieve accurate detection of surface defects of castings.

[0007] A first aspect of the embodiments of the present invention discloses a surface defect detection method based on machine vision, including:

[0008] Collecting an image of the casting by an image acquisition device to obtain a surface image of the casting, analyzing the surface image of the casting to determine an image quality parameter corresponding to the surface image of the casting, and performing parameter analysis on the image quality parameter corresponding to the surface image of the casting to determine an image accuracy index of the surface image of the casting;

[0009] Comparing the image accuracy index of the surface image of the casting with a corresponding accuracy index threshold stored in a casting detection library. If the image accuracy index of the surface image of the casting is less than the accuracy index threshold, optimizing the surface image of the casting until the set requirements are met. If the image accuracy index of the surface image of the casting is not less than the accuracy index threshold, proceed to the next step;

[0010] Dividing the obtained surface image of the casting into multiple casting region images, extracting features of each casting region image through an image feature extraction module to obtain corresponding region feature parameters; and comparing the region feature parameters with a preset region standard feature threshold. If the region feature parameters are less than the preset region standard feature threshold, proceed to the next step to detect defects in the corresponding casting region image. If the region feature parameters are not less than the preset region standard feature threshold, mark the corresponding casting region image as a defect image to be detected;

[0011] Extracting defect features of each defect image to be detected through an image feature extraction module to obtain defect features of each defect image to be detected, and performing parameter analysis on the defect features to obtain corresponding region defect parameters. Comparing the region defect parameters with a preset surface defect standard index in a casting detection library. If the matching is unqualified, a defect warning prompt is given.

[0012] As an optional implementation manner, in the first aspect of the embodiments of the present invention, the image quality parameters include image resolution, maximum brightness, minimum brightness, number of noise points, and number of colors;

[0013] The performing parameter analysis on the image quality parameter corresponding to the surface image of the casting to determine the image accuracy index of the surface image of the casting includes:

[0014] Determine the brightness contrast corresponding to the surface image of the casting according to the highest brightness and the lowest brightness of the surface image of the casting;

[0015] Calculate the image precision index of the surface image of the casting according to the image precision calculation formula, the brightness contrast of the surface image of the casting, the number of noise points in the image resolution, and the number of colors. The image precision calculation formula is:

[0016] ;

[0017] In the formula, is the image precision index of the surface image of the casting, e is the natural constant, is the image resolution of the surface image of the casting, is the resolution definition value preset in the casting detection library, is the brightness contrast of the surface image of the casting, is the brightness contrast threshold preset in the casting detection library, is the number of colors of the surface image of the casting, is the number of colors of the reference image preset in the casting detection library, is the number of noise points in the surface image of the casting, is the reference number of noise points preset in the casting detection library.

[0018] As an optional implementation manner, in the first aspect of the embodiments of the present invention, if the image precision index of the surface image of the casting is less than the precision index threshold, image optimization is performed on the surface image of the casting until the set requirements are met, including:

[0019] If the image precision index of the surface image of the casting is less than the precision index threshold, perform image parameter statistics on the surface image of the casting to obtain the corresponding gray-scale statistical result. The gray-scale statistical result includes the number of pixels at each gray level in the surface image of the casting;

[0020] Calculate the corresponding cumulative distribution function according to the gray-scale statistical result. The cumulative distribution function is used to represent the proportion of the number of pixels less than or equal to a certain gray level in the total number of pixels;

[0021] Perform data mapping on each pixel value in the surface image of the casting according to the cumulative distribution function to replace the corresponding pixel point with the corresponding equalized pixel value, and obtain the image after equalization processing until the set requirements are met;

[0022] Or, if the image precision index of the surface image of the casting is less than the precision index threshold, calculate each pixel point in the surface image of the casting through the image adjustment formula to obtain the adjusted pixel parameters. The image adjustment formula is: , where y is the adjusted pixel parameter, x is the input pixel parameter, k is a constant, r is the adjustment parameter value, and the adjustment parameter value is used to adjust the brightness of each pixel. If r is greater than 1, it is used to reduce the image brightness; if r is less than or equal to 1, it is used to increase the image brightness;

[0023] Remap the adjusted pixel parameters to the range of 0 - 255, map the minimum pixel value and the maximum pixel value to 0 and 255 respectively, and perform linear interpolation on other pixel values;

[0024] Obtain the optimized image according to the adjusted pixel values above.

[0025] As an optional implementation manner, in the first aspect of the embodiments of the present invention, the region feature parameters include the highest brightness, the lowest brightness, the shape contour length, and the shape contour width of the surface image of each region casting; the defect features of each to-be-detected defect image include the edge width, the average gray value, the shape area of the texture region, and the texture quantity of the surface image of each suspected defect region of the casting.

[0026] As an optional implementation manner, in the first aspect of the embodiments of the present invention, the region feature parameters are obtained through the following steps:

[0027] Perform a ratio process on the highest brightness and the lowest brightness of the surface image of each region casting to obtain the brightness contrast of the surface image of each region casting;

[0028] Perform a difference process on the brightness contrast of the surface image of each region casting and the brightness contrast of the surface image of the casting, and perform an absolute value process to obtain the brightness contrast deviation value of the surface image of each region casting;

[0029] Perform a difference process on the shape contour length and the shape contour width of the surface image of each region casting and the shape contour length and the shape contour width of the preset reference image of the surface of each region casting in the casting detection library, and perform an absolute value process to respectively obtain the shape contour length deviation value and the shape contour width deviation value of the surface image of each region casting;

[0030] Perform a comprehensive analysis on the brightness contrast deviation value, the shape contour length deviation value, and the shape contour width deviation value of the surface image of each region casting to obtain the feature index of the surface image of each region casting.

[0031] As an optional implementation manner, in the first aspect of the embodiments of the present invention, the feature index of the surface image of each suspected defect region of the casting includes:

[0032] Obtain the feature index of the surface image of each suspected defect region of the casting;

[0033] Comprehensively analyze the characteristic indexes of the images of the suspected defect areas on the surfaces of the castings, including the edge width, average gray value, texture shape area, and texture quantity of the images of the suspected defect areas on the surfaces of the castings, to obtain the characteristic indexes of the images of the suspected defect areas on the surfaces of the castings.

[0034] As an optional implementation manner, in the first aspect of the embodiments of the present invention, the comparison of the regional defect parameters with the preset surface defect standard indexes in the casting detection library includes:

[0035] If the characteristic index of the image of the suspected defect area on the surface of a certain casting is greater than or equal to the preset surface defect index of the casting, a defect warning prompt is given to the surface area of the casting corresponding to the image of the suspected defect area on the surface of the casting through the defect warning device;

[0036] If the characteristic index of the image of the suspected defect area on the surface of a certain casting is less than the preset surface defect index of the casting, there is no need to give a defect warning prompt to the surface area of the casting corresponding to the image of the suspected defect area on the surface of the casting.

[0037] The second aspect of the embodiments of the present invention discloses a surface defect detection device based on machine vision, including:

[0038] The first acquisition module: used to acquire an image of the casting through an image acquisition device to obtain an image of the surface of the casting, analyze the image of the surface of the casting to determine the image quality parameters corresponding to the image of the surface of the casting, and perform parameter analysis on the image quality parameters corresponding to the image of the surface of the casting to determine the image accuracy index of the image of the surface of the casting;

[0039] The first judgment module: used to compare the image accuracy index of the image of the surface of the casting with the corresponding accuracy index threshold stored in the casting detection library. If the image accuracy index of the image of the surface of the casting is less than the accuracy index threshold, the image of the surface of the casting is optimized until the set requirements are met. If the image accuracy index of the image of the surface of the casting is not less than the accuracy index threshold, the next step is executed;

[0040] The area division module: used to divide the acquired image of the surface of the casting into multiple casting area images, extract features from each of the casting area images through the image feature extraction module to obtain corresponding area feature parameters; and compare the area feature parameters with the preset area standard feature threshold. If the area feature parameters are less than the preset area standard feature threshold, the next step is executed to perform defect detection on the corresponding casting area image. If the area feature parameters are not less than the preset area standard feature threshold, the corresponding casting area image is marked as a to-be-detected defect image;

[0041] Defect comparison module: It is used to extract defect features of the to-be-detected defect images through the image feature extraction module to obtain the defect features of each to-be-detected defect image, analyze the parameters of the defect features to obtain corresponding regional defect parameters, compare the regional defect parameters with the preset surface defect standard index in the casting detection library, and if the matching is unqualified, defect warning prompts will be given.

[0042] A third aspect of an embodiment of the present invention discloses an electronic device, including: a memory storing executable program code; a processor coupled to the memory; the processor calls the executable program code stored in the memory to execute the surface defect detection method based on machine vision disclosed in the first aspect of the embodiment of the present invention.

[0043] A fourth aspect of an embodiment of the present invention discloses a computer-readable storage medium, which stores a computer program, wherein the computer program enables a computer to execute the surface defect detection method based on machine vision disclosed in the first aspect of the embodiment of the present invention.

[0044] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0045] In the surface defect detection method based on machine vision in the embodiments of the present invention, the surface image of the casting is divided into multiple regions, and feature extraction is performed on each region, which can analyze the surface condition of the casting more carefully and improve the detection accuracy. By comparing the regional feature parameters with the preset standard feature threshold, the regions that may have defects can be initially screened out, so as to perform subsequent detections targeted, improving the detection efficiency. Description of the Drawings

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the following described drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0047] Figure 1 It is a flowchart of the surface defect detection method based on machine vision disclosed in the embodiment of the present invention;

[0048] Figure 2 It is a flowchart of obtaining the image precision index disclosed in the embodiment of the present invention;

[0049] Figure 3 It is a flowchart of image optimization disclosed in the embodiment of the present invention;

[0050] Figure 4It is a schematic structural diagram of a surface defect detection device based on machine vision provided by an embodiment of the present invention;

[0051] Figure 5 It is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. Detailed implementation manners

[0052] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0053] It should be noted that the terms "first", "second", "third", "fourth", etc. in the description and claims of the present invention are used to distinguish different objects, rather than to describe a specific order. The terms "including" and "having" in the embodiments of the present invention and any variations thereof are intended to cover non-exclusive inclusions. Exemplarily, a process, method, system, product, or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0054] In the existing casting defect detection methods, mainly the surface of the casting is directly scanned for images and the casting defects are detected through the scanned images of the casting surface. However, for the scanned images of the casting surface based on this defect detection, due to errors in the scanning process, it is difficult to ensure the clarity and accuracy of the scanned casting surface images, directly affecting the reliability of the casting surface defect detection. Based on this, the embodiments of the present invention disclose a surface defect detection method, system, electronic device, and storage medium based on machine vision, which divide the casting surface image into multiple regions and extract features for each region, so as to analyze the surface condition of the casting more carefully and improve the detection accuracy. By comparing the regional feature parameters with the preset standard feature thresholds, the regions that may have defects can be initially screened out, so as to conduct subsequent detections targeted, improving the detection efficiency.

[0055] Embodiment 1

[0056] Please refer to Figure 1 , Figure 1It is a schematic flowchart of a surface defect detection method based on machine vision disclosed in an embodiment of the present invention. Among them, the execution subject of the method described in the embodiment of the present invention is an execution subject composed of software or / and hardware. This execution subject can receive relevant information through wired or / and wireless means and can send certain instructions. Of course, it can also have certain processing functions and storage functions. This execution subject can control multiple devices, such as remote physical servers or cloud servers and related software, or it can be a local host or server and related software that performs relevant operations on devices placed somewhere. In some scenarios, it can also control multiple storage devices, and the storage devices can be placed in the same place or different places as the devices. As Figure 1 shown, the surface defect detection method based on machine vision includes the following steps:

[0057] S101: Use an image acquisition device to acquire an image of the casting to obtain a surface image of the casting, analyze the surface image of the casting to determine the image quality parameters corresponding to the surface image of the casting, and perform parameter analysis on the image quality parameters corresponding to the surface image of the casting to determine the image precision index of the surface image of the casting;

[0058] S102: Compare the image precision index of the surface image of the casting with the corresponding precision index threshold stored in the casting detection library. If the image precision index of the surface image of the casting is less than the precision index threshold, optimize the surface image of the casting until the set requirements are met. If the image precision index of the surface image of the casting is not less than the precision index threshold, proceed to the next step;

[0059] In the embodiments of the present invention, the image processing device divides the surface image of the casting into regions to obtain the surface images of the casting in each region. The specific region division is as follows: it is divided based on the edge detection of the surface image of the casting. The edge is the place where features such as gray scale, color, and texture in the image change significantly. Edge detection can be used to detect the edges of defects such as cracks and scratches on the surface of the casting. Through edge detection, these defect regions can be separated from the background, facilitating further analysis and processing. Thus, the region division of the surface image of the casting is completed, and the surface images of the casting in each region are obtained; the image feature extraction device extracts features from the surface images of the casting in each region. The edge detection algorithm (such as the Canny edge detector) in the image feature extraction device is used to extract the edge contour of the surface of the casting, and texture analysis algorithms (such as gray level co-occurrence matrix, Fourier transform, etc.) are used to extract the texture features of the surface of the casting. The extracted features can be matched with the reference features in the casting detection library to evaluate the quality of the surface of the casting or detect potential defects. The above-mentioned visual analysis device analyzes to obtain the characteristic indexes of the surface images of the casting in each region, extracts the key features in the surface images of the casting in each region, such as shape, texture, etc., and compares these features with the preset standards or reference images. Through comparison and analysis, the visual analysis device can evaluate the quality of the surface of the casting and give the corresponding characteristic indexes of the surface images of the casting in each region.

[0060] S103: Perform region division on the obtained surface image of the casting to obtain multiple casting region images, extract features from each of the casting region images through the image feature extraction module to obtain corresponding region feature parameters; and compare the region feature parameters with the pre-set region standard feature threshold. If the region feature parameter is less than the pre-set region standard feature threshold, then perform the next step to perform defect detection on the corresponding casting region image. If the region feature parameter is not less than the pre-set region standard feature threshold, then mark the corresponding casting region image as a to-be-detected defect image;

[0061] S104: Extract defect features from the to-be-detected defect image through the image feature extraction module to obtain the defect features of each to-be-detected defect image, perform parameter analysis on the defect features to obtain corresponding region defect parameters, compare the region defect parameters with the preset surface defect standard index in the casting detection library. If the matching is unqualified, then give a defect warning prompt.

[0062] In the embodiments of the present invention, an image acquisition device is used to obtain an image of the surface of a casting, and parameter analysis is performed on the image quality to determine the accuracy index of the image. This step ensures the basic quality of the image for subsequent analysis and avoids false detection or missed detection caused by problems such as blurred images and insufficient light. When the image accuracy index does not meet the preset threshold, image optimization processing is carried out until the image quality meets the requirements. This can significantly improve the accuracy and reliability of detection.

[0063] In the embodiments of the present invention, the surface image of the casting is divided into multiple regions, and feature extraction is performed on each region, which can analyze the surface condition of the casting more carefully and improve the detection accuracy. The feature extraction module can quickly and accurately identify the key feature parameters of each region, providing strong data support for subsequent defect detection.

[0064] In the embodiments of the present invention, by comparing the regional feature parameters with the preset standard feature thresholds, regions that may have defects can be initially screened out, so as to conduct subsequent detection targeted, improving the detection efficiency. For the defect images to be detected, defect features are further extracted and analyzed to obtain regional defect parameters. These parameters are compared with the preset surface defect standard index. If they do not match, a defect warning prompt is given. This step realizes the intelligent identification and warning of the surface defects of the casting, helping to timely discover and handle potential quality problems.

[0065] The entire detection process is highly automated and intelligent, reducing the influence of manual intervention and subjective judgment, and improving the objectivity and consistency of detection. By establishing a casting detection library to store key parameters such as the accuracy index threshold, regional standard feature threshold, and surface defect standard index, the detection process becomes more standardized and normalized.

[0066] In actual industrial detection scenarios, resources (such as time, computing power, and manpower) are limited. Therefore, detection strategies often need to balance detection accuracy and detection efficiency. By setting the threshold of the feature index, the risks of each region on the surface of the casting can be evaluated. If the feature index of a certain region indicates that its surface state conforms to the normal or acceptable range (i.e., greater than or equal to the threshold), then the risk of finding serious defects in this region is relatively low. Therefore, the detailed defect detection of this region can be skipped preferentially to save resources. The feature index threshold can also be used to determine which regions need more detailed detection. When resources are limited, regions with feature indices lower than the threshold (i.e., regions more likely to contain defects) can be detected first to ensure that these regions receive sufficient attention and processing.

[0067] If the characteristic index of a certain area is very high, indicating that its surface state is very close to or fully meets the standard, then performing detailed defect detection in this area may lead to a high false alarm rate (i.e., falsely identifying non-existent defects). By skipping the detailed detection of these areas, the overall false alarm rate can be reduced, and the accuracy and efficiency of detection can be improved.

[0068] More preferably, the image quality parameters include image resolution, maximum brightness, minimum brightness, number of noise points, and number of colors; the resolution of the surface image of the casting can be determined by checking the technical specifications of the resolution of the scanning device when the scanning device scans the surface of the casting. The maximum brightness and minimum brightness are obtained by measuring the brightness values of the brightest area and the darkest area in the image using a brightness measurement tool in the image processing software. The number of noise points can be measured by a noise detection tool in the image processing software. The number of colors is usually related to the bit depth of the image. The bit depth determines the number of colors that each pixel in the image can represent. For example, an 8-bit depth image can represent 256 different colors for each pixel ( ), in the image processing software, the bit depth information of the image can be viewed to know its number of colors.

[0069] In this example, the brightness contrast, resolution, number of noise points, and number of colors of the surface image of the casting affect each other and jointly determine the accuracy index of the surface image of the casting. A higher brightness contrast helps to highlight different areas in the image, making the details of a high-resolution image more obvious. If the brightness contrast is too low, even with a high resolution, the details may not be easily recognized due to the lack of sufficient light and dark differences. On the contrary, a high resolution can provide more pixels to capture the brightness changes, thus enhancing the performance of the contrast. The increase in brightness contrast will make the noise more obvious, especially in low light conditions or when the sensor performance is poor. High-contrast images will amplify the impact of noise because they are more prominent at the light and dark boundaries. In the surface image of the casting, changes in brightness contrast will cause changes in the saturation and lightness of colors. For example, increasing the brightness may make the colors look more vivid, while decreasing the brightness may make the colors appear darker. When the resolution is increased, it means that more pixels are used to represent the image, which to a certain extent reduces the number of noise points. The presence of noise will interfere with the color accuracy of the image. Excessive noise may cause color distortion or blurring, affecting the overall color performance of the image.

[0070] As Figure 2 shown, the parameter analysis of the image quality parameters corresponding to the surface image of the casting to determine the image accuracy index of the surface image of the casting includes:

[0071] S1011: Determine the brightness contrast corresponding to the surface image of the casting according to the highest brightness and the lowest brightness of the surface image of the casting;

[0072] S1012: Calculate the image precision index of the surface image of the casting according to the image precision calculation formula, the brightness contrast of the surface image of the casting, the number of noise points of the image resolution, and the number of colors. The image precision calculation formula is:

[0073] ;

[0074] In the formula, is the image precision index of the surface image of the casting, e is the natural constant, is the image resolution of the surface image of the casting, is the resolution definition value preset in the casting detection library, is the brightness contrast of the surface image of the casting, is the brightness contrast threshold preset in the casting detection library, is the number of colors of the surface image of the casting, is the number of colors of the reference image preset in the casting detection library, is the number of noise points of the surface image of the casting, is the reference number of noise points preset in the casting detection library.

[0075] The image quality parameters in the embodiments of the present invention include image resolution, highest brightness, lowest brightness, number of noise points, and number of colors. These parameters together constitute a comprehensive evaluation system for image quality. This comprehensive evaluation method helps to more accurately reflect the actual quality status of the surface image of the casting. By introducing the image precision calculation formula and combining multiple factors such as brightness contrast, image resolution, number of noise points, and number of colors, the image precision index of the surface image of the casting can be scientifically calculated. This calculation method takes into account both the clarity (resolution, brightness contrast) of the image and the purity (number of noise points) and richness (number of colors) of the image, so as to be able to more comprehensively reflect the quality level of the image. The image precision index, as the basis for subsequent detection, directly affects the effect of the entire detection process in terms of its accuracy and reliability. Through scientific calculation and comprehensive evaluation, it can be ensured that the image precision index can truly reflect the quality status of the surface image of the casting, thereby improving the accuracy and reliability of subsequent defect detection.

[0076] In the detection process, based on the comparison result between the image accuracy index and the preset threshold, the image can be optimized or directly proceed to the next detection step. This intelligent processing flow based on image quality helps reduce unnecessary detection steps and improve detection efficiency. By presetting parameters such as the resolution definition value, brightness contrast threshold, number of colors in the reference image, and number of noise references, the detection system can be adjusted and optimized according to different casting types and detection requirements. This flexibility enables the detection system to better adapt to different application scenarios and detection requirements.

[0077] In this example, if the resolution of the casting surface image is low, even lower than the preset resolution definition value, it will cause the details in the image to not be clearly shown, making it difficult to identify and analyze small defects or features. In the detection of the casting surface, it means that defects such as cracks and pores on the casting surface cannot be detected, thus affecting the evaluation and subsequent processing of casting surface defects; if the brightness contrast of the casting surface image is low, even lower than the preset brightness contrast threshold, it will make it difficult to distinguish the bright and dark areas in the image, resulting in the loss and blurring of details. In the detection of the casting surface, this may make important features such as the texture and defects on the casting surface become unclear or even completely masked, thus seriously affecting the accuracy of the casting surface defect detection result; if the number of colors in the casting surface image is low, even lower than the preset number of colors in the reference image, it will cause the color characteristics of the casting surface to not accurately reflect the actual situation, and at the same time, it will lead to the inability to accurately identify and extract the features of the target area, reducing the reliability of the casting surface defect detection result; if the number of noise points in the casting surface image is large, even more than the preset number of noise references, excessive noise will interfere with the real information of the casting surface image, making it difficult to identify defects and features on the casting surface image, and will increase the error of the subsequent casting surface defect detection result. Therefore, through the detailed analysis of each parameter in the image accuracy index of the casting surface image, image quality problems can be discovered and solved, thereby improving the accuracy and reliability of casting surface detection.

[0078] In this example, the precise index of the casting surface image is compared with the threshold value of the precise index of the casting surface image preset in the casting detection library. If the precise index of the casting surface image is less than the preset threshold value of the precise index of the casting surface image, it means that the clarity or accuracy of the current casting surface image is insufficient. In this case, if the current casting surface image is directly used for feature extraction, it will lead to inaccurate or misleading results. Therefore, it is necessary to optimize the casting surface image through an image processing device. If the precise index of the casting surface image is greater than or equal to the preset threshold value of the precise index of the casting surface image, it means that the clarity and accuracy of the casting surface image are high enough and can be directly used for feature extraction. In this case, there is no need to perform additional optimization processing on the image, but the features of the casting surface can be directly extracted through the casting surface image.

[0079] More preferably, as Figure 3 shown, if the precise index of the casting surface image is less than the precise index threshold value, then the casting surface image is optimized until the set requirements are met, including:

[0080] S1021: If the precise index of the casting surface image is less than the precise index threshold value, then the image parameters of the casting surface image are statistically analyzed to obtain the corresponding gray-scale statistical result, and the gray-scale statistical result includes the number of pixels of each gray level in the casting surface image;

[0081] S1022: Calculate the corresponding cumulative distribution function according to the gray-scale statistical result, and the cumulative distribution function is used to represent the proportion of the number of pixels less than or equal to a certain gray level in the total number of pixels;

[0082] S1023: Perform data mapping on each pixel value in the casting surface image according to the cumulative distribution function to replace the corresponding pixel point with the corresponding equalized pixel value, and obtain the image after equalization processing until the set requirements are met;

[0083] In the embodiment of the present invention, through gray-scale equalization processing, the gray levels in the image can be redistributed, so that the gray values are more evenly distributed in the image. This helps to improve the contrast of the image, making the details on the casting surface clearer and facilitating subsequent detection and analysis. Gray-scale equalization enhances the detail information in the image by stretching the gray range of the image. This is particularly important for the detection of casting surface defects, because defects often show gray differences from the surrounding areas. This method is automatically processed based on the gray-scale statistical result and the cumulative distribution function, without manual intervention, improving the processing efficiency and consistency.

[0084] Alternatively, if the image precision index of the casting surface image is less than the precision index threshold, calculate each pixel point in the casting surface image through an image adjustment formula to obtain an adjusted pixel parameter; the image adjustment formula is: , where y is the adjusted pixel parameter, x is the input pixel parameter, k is a constant, r is an adjustment parameter value, and the adjustment parameter value is used to adjust the brightness of each pixel point. If r is greater than 1, it is used to reduce the image brightness. If r is less than or equal to 1, it is used to increase the image brightness;

[0085] Remap the adjusted pixel parameters to the range of 0 - 255, map the minimum pixel value and the maximum pixel value to 0 and 255 respectively, and perform linear interpolation on other pixel values;

[0086] Obtain an optimized image based on the adjusted pixel values above.

[0087] In the embodiment of the present invention, by adjusting the constant k and the adjustment parameter r in the formula, the brightness of the image can be flexibly adjusted. This is particularly effective for image brightness problems caused by poor lighting conditions or reflection on the casting surface.

[0088] While adjusting the brightness, the relative relationship of other pixel values is maintained through linear interpolation, thereby maintaining the detail information of the image. This method can optimize the image quality by adjusting the parameters k and r according to different casting types and detection requirements, and has strong adaptability. Through the above two image optimization methods, the clarity and contrast of the casting surface image can be significantly improved, thereby improving the accuracy of defect detection. Image optimization processing can be used as part of the detection process to automatically adjust the image quality, reduce manual intervention, and improve the detection efficiency.

[0089] Facing the changes in different lighting conditions and casting surface characteristics, the system can maintain stable detection performance through image optimization processing, enhancing the robustness of the system.

[0090] In this example, to improve the resolution of the casting surface image, the super-resolution reconstruction technology in the image processing device can be used to interpolate a low-resolution image into a high-resolution image. Improving the resolution can significantly increase the detail information in the image, making small defects and features more clearly visible, thereby improving the accuracy and reliability of casting surface detection; to reduce the noise in the casting surface image, the median filter image processing technology in the image processing device can effectively remove the noise in the image by replacing the value of each pixel point with the median value in its neighborhood, while retaining the edge details of the image. Reducing the noise can improve the quality of the image, making the casting surface image clearer and more accurate, thereby reducing the possibility of false detection and missed detection of casting surface defects.

[0091] More preferably, the regional feature parameters include the maximum brightness, minimum brightness, shape contour length, and shape contour width of the surface images of the castings in each region; the defect features of each defect image to be detected include the edge width, average gray value, texture region shape area, and texture quantity of the suspected defect region images on the surface of each casting.

[0092] The regional feature parameters in the embodiments of the present invention include the maximum brightness, minimum brightness, shape contour length, and shape contour width. These parameters can comprehensively reflect the brightness distribution and shape characteristics of each region on the surface of the casting. By analyzing these regional feature parameters, it is easier to discover potential defect regions that are significantly different from the surrounding regions, thereby improving the sensitivity of defect detection. The measurement of the shape contour length and width helps to accurately judge defects such as deformation and cracks on the surface of the casting, enhancing the reliability of the detection results.

[0093] The defect features in the embodiments of the present invention include the edge width, average gray value, texture region shape area, and texture quantity. These features can accurately describe the morphology and texture characteristics of the suspected defect regions on the surface of the casting. By analyzing these defect features, different types of defects such as pores, inclusions, and cracks can be more accurately identified, thereby improving the accuracy of defect identification. These defect features can also be used to classify and grade the defects, providing an important basis for subsequent repair and treatment.

[0094] It should be explained that the maximum brightness and minimum brightness of the surface images of the castings in each region above are obtained by measuring the brightness values of the brightest region and the darkest region in the image using a brightness measurement tool in the image processing software. The shape contour length and shape contour width can be obtained through image segmentation and feature extraction. The edge detection method (such as the Canny operator) is used to identify the edges in the image, and then the distance between the edges is calculated to determine the size of the shape.

[0095] In this example, there are complex interrelationships among the characteristic parameters of the above-mentioned casting surface images. These relationships are of great significance for the detection of casting surface defects. The difference between the highest brightness and the lowest brightness determines the contrast of the image. In an image with high contrast, details are clearer, which helps to more accurately identify the characteristics and defects on the casting surface. The length and width of the shape contour jointly determine the area of the shape, and the size of the area can reflect the degree of shape defects, which is very important for the detection of casting surface defects. The length and width of the shape contour reflect the shape characteristics of the defects, and different aspect ratios may correspond to different types of defects, such as cracks, holes or protrusions, etc. The highest brightness is usually related to the edges in the image, and edge detection is a key step in determining the length of the shape contour. In the high-brightness region, edges are more easily detected, thus improving the accuracy of measuring the length of the shape contour. The lowest brightness region may be caused by shadows or occlusions, which may affect the detection of the width of the shape contour. The details in the shadow region may not be easily captured, resulting in inaccurate width measurement.

[0096] More preferably, the regional characteristic parameters are obtained through the following steps:

[0097] Perform a ratio process on the highest brightness and the lowest brightness of the casting surface images in each region to obtain the brightness contrast of the casting surface images in each region;

[0098] Perform a difference process on the brightness contrast of the casting surface images in each region and the brightness contrast of the casting surface image, and perform an absolute value process to obtain the brightness contrast deviation value of the casting surface images in each region;

[0099] Perform a difference process on the shape contour length and the shape contour width of the casting surface images in each region and the shape contour length and the shape contour width of the reference casting surface images preset in the casting detection library for each region, and perform an absolute value process to respectively obtain the shape contour length deviation value and the shape contour width deviation value of the casting surface images in each region;

[0100] Perform a comprehensive analysis on the brightness contrast deviation value, the shape contour length deviation value and the shape contour width deviation value of the casting surface images in each region to obtain the characteristic index of the casting surface images in each region.

[0101] In the embodiments of the present invention, by calculating the ratio of the highest brightness to the lowest brightness of the surface images of the castings in each region, the brightness contrast is obtained, and further, a difference processing is performed with the brightness contrast of the overall surface image of the casting, so as to quantify the difference in brightness contrast between each region and the whole. This helps to identify the regions with abnormal brightness, which may be where the defects are located. By performing a difference processing on the shape contour length and shape contour width of the surface images of the castings in each region with a preset reference image and taking the absolute value, the deviation of the shape contour of each region can be accurately evaluated. This helps to detect defects such as shape deformation and incomplete contour. By comprehensively analyzing the brightness contrast deviation value, the shape contour length deviation value, and the shape contour width deviation value, the characteristic indexes of the surface images of the castings in each region are obtained. This comprehensive index can more comprehensively reflect the characteristics of each region and improve the accuracy of defect detection.

[0102] Through quantization processing and comprehensive analysis, the system can more accurately identify and process the characteristics of each region on the surface of the casting, enhancing the adaptability to different casting types and surface characteristics and improving the robustness of the system.

[0103] In this example, both the precision index of the surface image of the casting and the characteristic indexes of the surface images of the castings in each region use the ratio processing of the highest brightness to the lowest brightness to reflect the brightness characteristics of the image. This is because brightness is an important aspect of image quality and is of great significance for defect detection. The precision index of the surface image of the casting is mainly used to evaluate the overall quality of the entire surface image of the casting, including image clarity, contrast, etc. The ratio processing of the highest brightness to the lowest brightness is an important link among them, used to reflect the brightness distribution of the image. While in the characteristic indexes of the surface images of the castings in each region, it focuses more on evaluating the characteristic differences of different regions on the surface of the casting. By comparing the brightness contrast deviation values between each region and the preset reference image, abnormal regions can be identified, and then it can be judged whether there are defects. Although they are different in the calculation process and application scenarios, they are both important parameters in the surface defect detection method based on machine vision. They jointly provide a strong basis for evaluating the quality of the surface image of the casting and identifying potential defects.

[0104] By performing a difference processing on the brightness contrast of the surface images of the castings in each region with the brightness contrast of the surface image of the casting and taking the absolute value, the brightness contrast deviation value of the surface images of the castings in each region is obtained. By performing a difference processing on the shape contour length and shape contour width of the surface images of the castings in each region respectively with the shape contour length and shape contour width of the preset reference images of the surface of the castings in each region in the casting detection library and taking the absolute value, the shape contour length deviation value and the shape contour width deviation value of the surface images of the castings in each region are obtained respectively.

[0105] It should be noted that the reference images of the casting surfaces in the above regions refer to the standard images preset in the casting detection library.

[0106] Comprehensively analyze the brightness contrast deviation value, shape contour length deviation value, and shape contour width deviation value of the casting surface images in each region to obtain the characteristic indicators of the casting surface images in each region. The specific analysis formula is as follows:

[0107] ;

[0108] In the formula, is the characteristic indicator of the casting surface image in the i-th region. i is the number of the casting surface images in each region, i = 1, 2, 3... p, where p is the total number of the casting surface images in the regions, and e is the natural constant. is the brightness contrast deviation value of the casting surface image in the i-th region, which refers to the ratio of the brightness contrast of the casting surface image in the i-th region to the brightness contrast of the reference image. is the reference deviation value of the brightness contrast of the reference image preset in the casting detection library, which refers to the allowable brightness contrast deviation value of the reference image of the casting surface in the region preset in the casting detection library. is the shape contour length deviation value of the casting surface image in the i-th region, which refers to the difference between the actual length of the shape contour in the casting surface image in the i-th region and the length of the shape contour in the reference image. is the reference deviation value of the shape contour length of the reference image preset in the casting detection library, which refers to an allowable shape contour length deviation value preset in the casting detection library. is the shape contour width deviation value of the casting surface image in the i-th region, which refers to the difference between the actual width of the shape contour in the casting surface image in the i-th region and the width of the shape contour in the reference image. is the reference deviation value of the shape contour width of the reference image preset in the casting detection library, which refers to an allowable shape contour width deviation value preset in the casting detection library.

[0109] In this example, when the deviation value of the brightness contrast of the regional casting surface image deviates greatly from the preset reference deviation value of the brightness contrast of the reference image, it will cause the loss of details in the regional casting surface image, especially in the high-brightness or low-brightness areas. This will affect the ability to identify minute defects. At the same time, insufficient brightness contrast will make the edges of the image blurred, making it difficult to accurately detect the shape contour, thus affecting subsequent shape analysis. When the deviation value of the shape contour length is greater than the preset reference deviation value of the shape contour length of the reference image, it indicates that there is a large difference between the actual length of the shape and the expected standard length of the shape, causing a disproportion in the shape ratio and affecting the structural integrity of the casting. When the deviation value of the shape contour width is greater than the reference deviation value of the shape contour width of the reference image, it indicates that there is a large difference between the actual width of the shape and the expected standard width of the shape, directly leading to a decline in the characteristic indicators of the regional casting surface image. Therefore, through a detailed analysis of each parameter in the characteristic indicators of the regional casting surface image, potential problems in each area of the casting surface can be discovered, and the areas with problems on the casting surface can be accurately located.

[0110] More preferably, the characteristic index of the image of the suspected defect area on each casting surface includes:

[0111] Obtain the characteristic indicators of the images of the suspected defect areas on each casting surface;

[0112] Comprehensively analyze the characteristic indicators of the images of the suspected defect areas on each casting surface, the edge width, average gray value, texture shape area, and texture quantity of the images of the suspected defect areas on each casting surface to obtain the characteristic index of the image of the suspected defect area on each casting surface.

[0113] In the embodiment of the present invention, by obtaining characteristic indicators such as the edge width, average gray value, texture shape area, and texture quantity of the images of the suspected defect areas on each casting surface, the morphology, gray distribution, and texture characteristics of the defects can be comprehensively reflected. By comprehensively analyzing these characteristic indicators and combining the specific characteristics of the images of the suspected defect areas on each casting surface, a more accurate characteristic index can be obtained. This index helps to distinguish different types of defects and improve the accuracy of defect identification.

[0114] More preferably, the comparison of the regional defect parameters with the preset surface defect standard index in the casting detection library includes:

[0115] If the characteristic index of the image of the suspected defect area on a certain casting surface is greater than or equal to the preset casting surface defect index, a defect warning prompt is given to the casting surface area corresponding to the image of the suspected defect area on the casting surface through the defect warning device;

[0116] If the characteristic index of the image of the suspected defect area on the surface of a casting is less than the preset casting surface defect index, there is no need to give a defect warning prompt for the casting surface area corresponding to the image of the suspected defect area on the surface of the casting.

[0117] In the embodiment of the present invention, by comparing the characteristic index of the image of the suspected defect area with the preset casting surface defect index, it is possible to accurately identify the areas where defects actually exist and trigger a warning prompt in a timely manner. This helps to detect and handle the quality problems on the surface of the casting in a timely manner and prevent defective products from flowing into the subsequent processes.

[0118] The preset casting surface defect index is set based on a large amount of actual detection data and experience, and has high accuracy and reliability. Therefore, comparing the characteristic index with this standard index can reduce false alarms and missed detections, and improve the accuracy and efficiency of detection.

[0119] In this example, the images of the casting surface of each area where the casting surface characteristic index is less than the preset casting surface characteristic index threshold are marked as the images of the suspected defect areas on the surface of each casting. Therefore, the images of the casting surface of each area include the images of the suspected defect areas on the surface of each casting. So, the casting surface characteristic indexes corresponding to less than the preset casting surface characteristic index threshold are the characteristic indexes of the images of the suspected defect areas on the surface of each casting. In this example, the characteristic indexes of the images of the suspected defect areas on the surface of each casting are important bases for evaluating the surface defects of the casting and identifying potential defects. The characteristic index of the image of the suspected defect area on the surface of each casting indicates the complex characteristics of the image of the suspected defect area on the surface of the casting.

[0120] By comprehensively analyzing the characteristic indexes, the edge width, average gray value, texture shape area, and texture quantity of the images of the suspected defect areas on the surface of each casting, the characteristic index of the image of the suspected defect area on the surface of each casting is obtained. The specific analysis formula is:

[0121] ;

[0122] In the formula, is the characteristic index of the j-th image of the suspected defect area on the surface of the casting, j is the number of the images of the suspected defect areas on the surface of each casting, j = 1, 2, 3... k, and k is the total number of the images of the suspected defect areas on the surface of the casting. is the characteristic index of the j-th image of the suspected defect area on the surface of the casting. The weight factor corresponding to the characteristic index of the image of the suspected defect area on the surface of the casting preset in the casting detection library. The weight factor corresponding to the characteristic index of the image of the suspected defect area on the surface of the casting can be directly obtained from the casting detection library, and its corresponding relationship can be a pre-set mapping relationship. For example, a mapping set is formed based on the characteristic index of the historical image of the suspected defect area on the surface of the casting and the weight factor corresponding to the characteristic index of the image of the suspected defect area on the surface of the casting, and the characteristic index of the real-time image of the suspected defect area on the surface of the casting is input into the mapping set to obtain the weight factor corresponding to the characteristic index of the image of the suspected defect area on the surface of the casting. The mapping relationship therein can be a one-to-one or many-to-one relationship. At the same time, in this example, its value range is [0, 1]. $w_{j}$ is the edge width of the image of the suspected defect area on the surface of the $j$-th casting, which refers to the edge width of the detected defect on the casting. The influence factor corresponding to the unit value of the edge width preset in the casting detection library. The influence factor corresponding to the unit value of the edge width can be directly obtained from the casting detection library, and its corresponding relationship can be a pre-set mapping relationship. For example, a mapping set is formed based on the historical edge width and the influence factor corresponding to the unit value of the edge width, and the real-time edge width is input into the mapping set to obtain the influence factor corresponding to the unit value of the edge width. The mapping relationship therein can be a one-to-one or many-to-one relationship. At the same time, in this example, its value range is [0, 1]. $\overline{G}_{j}$ is the average gray value of the image of the suspected defect area on the surface of the $j$-th casting, which refers to the average value of the gray values of multiple pixel points in the image of the suspected defect area on the surface of the $j$-th casting. $G_{ref}$ is the gray reference value preset in the casting detection library, which refers to a pre-set gray value used to compare with the gray value in the casting image to be detected. $S_{j}$ is the texture shape area of the image of the suspected defect area on the surface of the $j$-th casting, which refers to the area occupied by the defect texture. $S_{ref}$ is the defined value of the texture shape area of the reference image preset in the casting detection library, which refers to a pre-set defect texture shape area value. $N_{j}$ is the texture number of the image of the suspected defect area on the surface of the $j$-th casting, which refers to the total number of defect textures. The influence factor corresponding to the unit value of the texture number preset in the casting detection library. The influence factor corresponding to the unit value of the texture number can be directly obtained from the texture number, and its corresponding relationship can be a pre-set mapping relationship. For example, a mapping set is formed based on the historical texture number and the influence factor corresponding to the unit value of the texture number, and the real-time texture number is input into the mapping set to obtain the influence factor corresponding to the unit value of the texture number. The mapping relationship therein can be a one-to-one or many-to-one relationship. At the same time, in this example, its value range is [0, 1].

[0123] The present invention analyzes image quality parameters, such as resolution, brightness contrast, etc., to obtain an accurate index of the casting surface image, which can optimize the image processing process, provide a basis for identifying minute defects on the casting surface subsequently, and compare with the preset threshold of the accurate index of the casting surface image in the casting detection library. Image optimization is performed on the casting surface image with an accurate index of the casting surface image less than the preset threshold to improve the clarity of the image and make the details in the image more obvious. This is particularly important for detecting minute surface defects. A clear image helps to more accurately evaluate the surface defects of the casting.

[0124] The present invention divides the casting surface image into regions, which can more precisely locate and identify the defects on the casting surface. This localized processing method helps to capture minute defects, thereby improving the overall defect detection accuracy of the casting surface. Feature extraction and analysis are performed on the casting surface images of each region to obtain the characteristic parameters of the casting surface images of each region, and compare with the preset threshold of the casting surface characteristic index in the casting detection library. Detailed casting surface defect detection is carried out on the regions with a casting surface characteristic index lower than the preset threshold, which can reduce unnecessary casting surface defect detection work and improve the overall process and efficiency of casting surface defect detection.

[0125] The present invention quickly analyzes the extracted defect features to obtain the characteristic index of the suspected defect region image on the casting surface, and compares with the preset casting surface defect index, thereby quickly determining whether there are defects on the casting surface, reducing the false alarm rate and missed alarm rate of casting surface defects, and improving the accuracy of casting surface defect detection.

[0126] In the embodiment of the present invention, the surface defect detection method based on machine vision divides the casting surface image into multiple regions and performs feature extraction on each region, which can more meticulously analyze the surface condition of the casting and improve the detection accuracy. By comparing the region characteristic parameters with the preset standard characteristic threshold, regions that may have defects can be preliminarily screened out, so as to perform subsequent detection targeted, improving the detection efficiency.

[0127] Embodiment 2

[0128] Please refer to Figure 4 , Figure 4 which is a schematic structural diagram of the surface defect detection device based on machine vision disclosed in the embodiment of the present invention. As Figure 4 shown, the surface defect detection device based on machine vision may include:

[0129] The first acquisition module 21: It is used to acquire the image of the casting through an image acquisition device to obtain the surface image of the casting, analyze the surface image of the casting to determine the image quality parameters corresponding to the surface image of the casting, and perform parameter analysis on the image quality parameters corresponding to the surface image of the casting to determine the image accuracy index of the surface image of the casting;

[0130] The first judgment module 22: It is used to compare the image accuracy index of the surface image of the casting with the corresponding accuracy index threshold stored in the casting detection library. If the image accuracy index of the surface image of the casting is less than the accuracy index threshold, the surface image of the casting is optimized until the set requirements are met. If the image accuracy index of the surface image of the casting is not less than the accuracy index threshold, the next step is executed;

[0131] The area division module 23: It is used to divide the acquired surface image of the casting into multiple casting area images, extract features from each of the casting area images through an image feature extraction module to obtain corresponding area feature parameters; and compare the area feature parameters with the preset area standard feature threshold. If the area feature parameters are less than the preset area standard feature threshold, the next step is executed to detect defects in the corresponding casting area image. If the area feature parameters are not less than the preset area standard feature threshold, the corresponding casting area image is marked as a defect image to be detected;

[0132] The defect comparison module 24: It is used to extract defect features from the defect images to be detected through an image feature extraction module to obtain the defect features of each defect image to be detected, perform parameter analysis on the defect features to obtain corresponding area defect parameters, and compare the area defect parameters with the preset surface defect standard index in the casting detection library. If the matching is unqualified, a defect warning prompt is given.

[0133] In the embodiment of the present invention, the surface defect detection method based on machine vision divides the surface image of the casting into multiple areas and extracts features from each area, which can analyze the surface condition of the casting more carefully and improve the detection accuracy. By comparing the area feature parameters with the preset standard feature threshold, the areas that may have defects can be preliminarily screened out, so as to perform subsequent detection targeted, improving the detection efficiency.

[0134] Embodiment III

[0135] Please refer to Figure 5 , Figure 5It is a schematic structural diagram of an electronic device disclosed in an embodiment of the present invention. The electronic device can be a computer, a server, etc. Of course, in certain cases, it can also be intelligent devices such as mobile phones, tablet computers, and monitoring terminals, as well as an image acquisition device with processing functions. As Figure 5 shown, the electronic device may include:

[0136] A memory 510 storing executable program code;

[0137] A processor 520 coupled to the memory 510;

[0138] Wherein, the processor 520 calls the executable program code stored in the memory 510 and executes some or all of the steps in the surface defect detection method based on machine vision in the first embodiment.

[0139] An embodiment of the present invention discloses a computer-readable storage medium that stores a computer program, wherein the computer program causes a computer to execute some or all of the steps in the surface defect detection method based on machine vision in the first embodiment.

[0140] An embodiment of the present invention also discloses a computer program product, wherein when the computer program product runs on a computer, it causes the computer to execute some or all of the steps in the surface defect detection method based on machine vision in the first embodiment.

[0141] An embodiment of the present invention also discloses an application publishing platform, wherein the application publishing platform is used to publish a computer program product, and when the computer program product runs on a computer, it causes the computer to execute some or all of the steps in the surface defect detection method based on machine vision in the first embodiment.

[0142] In various embodiments of the present invention, it should be understood that the magnitudes of the sequence numbers of the various processes do not necessarily mean the order of execution. The order of execution of the various processes should be determined according to their functions and internal logics, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

[0143] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0144] In addition, in each embodiment of the present invention, the various functional units may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0145] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several requests for causing a computer device (which may be a personal computer, a server, or a network device, etc., specifically, the processor in the computer device) to execute some or all of the steps of the methods described in the various embodiments of the present invention.

[0146] In the embodiments provided by the present invention, it should be understood that "B corresponding to A" means that B is associated with A, and B can be determined according to A. However, it should also be understood that determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information.

[0147] Those of ordinary skill in the art can understand that some or all of the steps in the various methods of the embodiments can be completed by instructing relevant hardware through a program. This program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electrically-erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM), or other optical disc memories, magnetic disk memories, tape memories, or any other computer-readable medium that can be used to carry or store data.

[0148] The above has introduced in detail the method, system, electronic device and storage medium for surface defect detection based on machine vision disclosed in the embodiments of the present invention. Specific examples are used in this article to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.

Claims

1. A surface defect detection method based on machine vision, characterized in that: include: Capturing the casting image by an image acquisition device to obtain a casting surface image, analyzing the casting surface image to determine image quality parameters corresponding to the casting surface image, and performing parameter analysis on the image quality parameters corresponding to the casting surface image to determine an image accuracy index of the casting surface image; the image quality parameters include image resolution, maximum brightness, minimum brightness, number of noise points, and number of colors; The performing parameter analysis on the image quality parameters corresponding to the casting surface image to determine the image accuracy index of the casting surface image includes: Determine the brightness contrast of the corresponding casting surface image according to the maximum brightness and the minimum brightness of the casting surface image; The image precision index of the casting surface image is calculated according to the image precision calculation formula and the brightness contrast, image resolution noise number and color number of the casting surface image. The image precision calculation formula is: ; In the formula, is the image precision index of the casting surface image, e is a natural constant, is the image resolution of the casting surface image, The preset resolution limit value for the casting inspection library, is the brightness contrast of the casting surface image, Preset brightness contrast thresholds for the casting inspection library, is the number of colors of the casting surface image, The number of colors of the reference images preset for the casting inspection library, is the number of noise points in the casting surface image, The number of noise references preset for the casting inspection library; Compare the image precision index of the casting surface image with the corresponding precision index threshold stored in the casting detection library; if the image precision index of the casting surface image is less than the precision index threshold, optimize the casting surface image until the set requirements are met; if the image precision index of the casting surface image is not less than the precision index threshold, execute the next step; The acquired casting surface image is divided into regions to obtain a plurality of casting region images, and the image feature extraction module is used to extract features of each casting region image to obtain corresponding region feature parameters; and the region feature parameters are compared with a preset region standard feature threshold, and if the region feature parameter is less than the preset region standard feature threshold, the next step is executed to perform defect detection on the corresponding casting region image, and if the region feature parameter is not less than the preset region standard feature threshold, the corresponding casting region image is marked as a defect image to be detected; The defect features of the defect images to be detected are extracted by the image feature extraction module to obtain the defect features of each defect image to be detected, and the defect features are subjected to parameter analysis to obtain corresponding regional defect parameters, and the regional defect parameters are compared with the surface defect standard index preset in the casting inspection library. If the match is unqualified, a defect warning prompt is issued.

2. The surface defect detection method based on machine vision according to claim 1, characterized in that: If the image precision index of the casting surface image is less than the precision index threshold, the casting surface image is optimized until the set requirements are met, including: If the image precision index of the casting surface image is less than the precision index threshold, performing image parameter statistics on the casting surface image to obtain a corresponding grayscale statistical result, wherein the grayscale statistical result includes the number of pixels at each grayscale level in the casting surface image; Calculating a corresponding cumulative distribution function according to the grayscale statistical result, wherein the cumulative distribution function is used to represent the ratio of the number of pixels less than or equal to a certain grayscale level to the total number of pixels; Performing data mapping on each pixel value in the casting surface image according to the cumulative distribution function to replace the corresponding pixel point with the corresponding equalized pixel value, and obtaining an image after equalization processing until the set requirements are met; Or, if the image precision index of the casting surface image is less than the precision index threshold, each pixel point in the casting surface image is calculated by an image adjustment formula to obtain an adjusted pixel parameter; the image adjustment formula is: , where y is the adjusted pixel parameter, x is the input pixel parameter, k is a constant, and r is the adjustment parameter value. The adjustment parameter value is used to adjust the brightness of each pixel. If r is greater than 1, it is used to reduce the image brightness. If r is less than or equal to 1, it is used to increase the image brightness. Remap the adjusted pixel parameters to the range of 0-255, map the minimum pixel value and the maximum pixel value to 0 and 255 respectively, and perform linear interpolation on other pixel values; An optimized image is obtained according to the above adjusted pixel values.

3. The surface defect detection method based on machine vision according to claim 1, characterized in that: The regional characteristic parameters include the maximum brightness, minimum brightness, shape contour length and shape contour width of the casting surface image in each area; the defect characteristics of each defect image to be detected include the edge width, average grayscale value, texture area shape area and texture quantity of each suspected defect area image on the casting surface.

4. The surface defect detection method based on machine vision according to claim 3, characterized in that: The regional characteristic parameters are obtained by the following steps: The highest brightness and the lowest brightness of the surface image of the casting in each area are processed by ratio, so as to obtain the brightness contrast of the surface image of the casting in each area; Performing difference processing on the brightness contrast of the casting surface image in each region and the brightness contrast of the casting surface image, and performing absolute value processing, to obtain the brightness contrast deviation value of the casting surface image in each region; The shape contour length and shape contour width of the casting surface image in each region are respectively subjected to difference processing with the shape contour length and shape contour width of the casting surface reference image in each region preset in the casting inspection library, and then subjected to absolute value processing to obtain the shape contour length deviation value and shape contour width deviation value of the casting surface image in each region; The brightness contrast deviation value, shape contour length deviation value and shape contour width deviation value of the casting surface image in each area are comprehensively analyzed to obtain the characteristic index of the casting surface image in each area.

5. The surface defect detection method based on machine vision according to claim 3, characterized in that: The characteristic indexes of the images of suspected defect areas on the surfaces of the castings include: Obtain characteristic indicators of images of suspected defect areas on the surface of each casting; The characteristic index of the suspected defect area image on the surface of each casting, the edge width, average gray value, texture shape area and texture number of the suspected defect area image on the surface of each casting are comprehensively analyzed to obtain the characteristic index of the suspected defect area image on the surface of each casting.

6. The surface defect detection method based on machine vision according to claim 1, characterized in that: The comparing the regional defect parameter with the surface defect standard index preset in the casting inspection library comprises: If the characteristic index of the image of the suspected defect area on the surface of a casting is greater than or equal to the preset casting surface defect index, a defect warning prompt is given to the casting surface area corresponding to the image of the suspected defect area on the surface of the casting by the defect warning device; If the characteristic index of an image of a suspected defective area on the surface of a casting is less than a preset casting surface defect index, there is no need to provide a defect warning prompt for the casting surface area corresponding to the image of the suspected defective area on the surface of the casting.

7. A surface defect detection device based on machine vision, characterized in that: include: The first acquisition module is used to acquire an image of the casting through an image acquisition device to obtain a casting surface image, analyze the casting surface image to determine an image quality parameter corresponding to the casting surface image, and perform parameter analysis on the image quality parameter corresponding to the casting surface image to determine an image accuracy index of the casting surface image; the image quality parameter includes image resolution, maximum brightness, minimum brightness, number of noise points, and number of colors; The performing parameter analysis on the image quality parameters corresponding to the casting surface image to determine the image accuracy index of the casting surface image includes: Determine the brightness contrast of the corresponding casting surface image according to the maximum brightness and the minimum brightness of the casting surface image; The image precision index of the casting surface image is calculated according to the image precision calculation formula and the brightness contrast, image resolution noise number and color number of the casting surface image. The image precision calculation formula is: ; In the formula, is the image precision index of the casting surface image, e is a natural constant, is the image resolution of the casting surface image, The preset resolution limit value for the casting inspection library, is the brightness contrast of the casting surface image, Preset brightness contrast thresholds for the casting inspection library, is the number of colors of the casting surface image, The number of colors of the reference images preset for the casting inspection library, is the number of noise points in the casting surface image, The number of noise references preset for the casting inspection library; The first judgment module is used to compare the image accuracy index of the casting surface image with the corresponding accuracy index threshold stored in the casting detection library. If the image accuracy index of the casting surface image is less than the accuracy index threshold, the casting surface image is optimized until the set requirements are met. If the image accuracy index of the casting surface image is not less than the accuracy index threshold, the next step is executed. Region division module: used to divide the acquired casting surface image into regions to obtain multiple casting region images, and extract features from each casting region image through the image feature extraction module to obtain corresponding region feature parameters; and compare the region feature parameters with a preset region standard feature threshold. If the region feature parameter is less than the preset region standard feature threshold, the next step is executed to perform defect detection on the corresponding casting region image. If the region feature parameter is not less than the preset region standard feature threshold, the corresponding casting region image is marked as a defect image to be detected; Defect comparison module: used to extract defect features of the defect images to be detected through the image feature extraction module to obtain the defect features of each defect image to be detected, and perform parameter analysis on the defect features to obtain corresponding regional defect parameters, and compare the regional defect parameters with the surface defect standard index preset in the casting inspection library. If the match is unqualified, a defect warning prompt will be issued.

8. An electronic device, characterized in that: include: A memory storing executable program code; a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the surface defect detection method based on machine vision according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program enables a computer to execute the surface defect detection method based on machine vision according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • A casting defect detection and control system

    CN115184368B

  • A defect detection system for aluminum die castings

    CN118408951B

  • Edge defect detection method and device, electronic equipment and storage medium

    CN116188379A

  • Casting product appearance defect detection method and system based on machine vision

    CN119223984A

Cited By

  • Printer injection mold surface defect detection method based on visual inspection

    CN122434890A