Surface defect detection method and device based on machine vision

By analyzing and optimizing the image quality parameters of the casting surface image, calculating the image accuracy index, and performing image optimization, the problem of difficult to ensure the sharpness and accuracy of the casting surface scanning image is solved, and the accuracy and reliability of casting defect detection are improved.

CN119600026AActive Publication Date: 2025-03-11GUANGDONG QIXIN MOLD CO LTD

Patent Information

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

AI Technical Summary

Technical Problem

In the existing casting defect detection methods, the clarity and accuracy of the scanning image on the surface of the casting are difficult to guarantee, which affects the reliability of the detection.

Method used

The image of the casting surface is obtained through the image acquisition device, the image quality parameters are analyzed, the image accuracy index is calculated, and the image optimization is performed based on the accuracy index. If the image accuracy index does not meet the standard, the image will be optimized until the setting requirements are met.

Benefits of technology

The accuracy and reliability of the detection of surface defects of castings are improved. Through careful area division and feature extraction, the conditions of the casting surface can be more accurately analyzed, and areas with possible defects can be initially screened out, thereby improving detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119600026A_ABST
    Figure CN119600026A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of visual inspection, and discloses a surface defect detection method based on machine vision, which comprises the following steps: performing parameter analysis on an image quality parameter corresponding to a casting surface image to determine an image accuracy index of the casting surface image; if the image precision index of the casting surface image is not less than a precision index threshold; if the area characteristic parameters are smaller than a preset area standard characteristic threshold value, defect detection is conducted on the corresponding casting area image, and if the area characteristic parameters are not smaller than the preset area standard characteristic threshold value, the corresponding casting area image is marked as a to-be-detected defect image; and comparing the regional defect parameter with a surface defect standard index preset in a casting detection library. According to the surface defect detection method based on machine vision in the embodiment of the invention, the casting surface image is divided into a plurality of areas, and feature extraction is performed on each area, so that the surface condition of the casting can be analyzed more meticulously, and the detection accuracy is improved.
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 inspection, and in particular to a surface defect inspection 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 prone 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, which can realize fast and accurate detection of surface defects of castings.

[0003] For example, the invention patent with announcement number CN115184368B announces a casting defect detection control system, which includes: a casting feature acquisition module, used to acquire model information of standard castings; a detection strategy generation module, used to generate a detection strategy based on the model information; the steps of 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 the 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, used to obtain image information of each detection plane of the casting according to the detection strategy; an analysis module, used to compare the image information of each detection plane of the casting with the standard image information, and analyze whether the casting is faulty and the type of fault.

[0004] For example, the invention patent with the announcement number CN118408951B announces a defect detection system for aluminum die castings. 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 to a workbench, and the end of the workbench away from the groove is fixedly connected to a stand. The inside of the stand is installed with an adjustment component, and the outer cover of the storage table is connected to a clamping component. 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 board, and the area outside the display frame board can be covered, and resources are concentrated to perform high-precision scanning and analysis inside the display frame board.

[0005] However, in the process of implementing the technical solution of the invention in the embodiments of the present application, the present application discovered that the above-mentioned technology has at least the following technical problems: in the existing casting defect detection method, the casting surface is mainly directly image-scanned and casting defect detection is performed through the scanned image of the casting surface. However, the scanned image of the casting surface based on this defect detection will have errors in the scanning process, resulting in the difficulty in ensuring the clarity and accuracy of the scanned casting surface image, which directly affects the reliability of casting surface defect detection. Summary of the invention

[0006] In response to the above defects, an embodiment of the present invention discloses a surface defect detection method based on machine vision, which can realize accurate detection of casting surface defects.

[0007] The first aspect of the embodiment of the present invention discloses a surface defect detection method based on machine vision, comprising: Capturing an image of the casting by an image acquisition device to obtain a casting surface image, analyzing the casting surface image to determine an image quality parameter corresponding to the casting surface image, and performing parameter analysis on the image quality parameter corresponding to the casting surface image to determine an image accuracy index of the casting surface image; 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.

[0008] As an optional implementation manner, in the first aspect of the embodiment of the present invention, 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.

[0009] As an optional implementation, in the first aspect of the embodiment of the present invention, 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, 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.

[0010] As an optional implementation, in the first aspect of the embodiments of the present invention, the regional characteristic parameters include the maximum brightness, minimum brightness, shape contour length and shape contour width of the casting surface image in each region; the defect characteristics of each defect image to be detected include the edge width, average grayscale value, texture region shape area and texture number of each suspected defect area image on the casting surface.

[0011] As an optional implementation manner, in the first aspect of the embodiment of the present invention, 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.

[0012] As an optional implementation, in the first aspect of the embodiment of the present invention, the characteristic index of the image of the suspected defect area on the surface of each casting includes: 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.

[0013] As an optional implementation, in the first aspect of the embodiment of the present invention, comparing the regional defect parameter with a surface defect standard index preset in a casting inspection library includes: 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.

[0014] A second aspect of an embodiment of the present invention discloses a surface defect detection device based on machine vision, comprising: A first acquisition module: used for acquiring an image of a casting through an image acquisition device to obtain an image of a casting surface, analyzing the casting surface image to determine an image quality parameter corresponding to the casting surface image, and performing 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 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.

[0015] The third aspect of an embodiment of the present invention discloses an electronic device, comprising: 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.

[0016] A fourth aspect of an embodiment of the present invention discloses a computer-readable storage medium storing 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 an embodiment of the present invention.

[0017] Compared with the prior art, the embodiments of the present invention have the following beneficial effects: The surface defect detection method based on machine vision in the embodiment of the present invention divides the casting surface image into multiple regions and extracts features from each region, which can analyze the surface condition of the casting more carefully and improve the accuracy of detection. By comparing the regional feature parameters with the preset standard feature threshold, the regions where defects may exist can be preliminarily screened out, so that subsequent detection can be carried out in a targeted manner, thereby improving the detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0019] Figure 1 It is a flow chart of a surface defect detection method based on machine vision disclosed in an embodiment of the present invention; Figure 2 It is a schematic diagram of a process for obtaining an image precision index disclosed in an embodiment of the present invention; Figure 3 is a schematic diagram of a process for image optimization disclosed in an embodiment of the present invention; Figure 4 is a schematic structural diagram of a surface defect detection device based on machine vision provided by an embodiment of the present invention; Figure 5 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0021] It should be noted that the terms "first", "second", "third", "fourth", etc. in the specification 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. For example, a process, method, system, product or device including a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0022] In the existing casting defect detection method, the casting surface is mainly scanned directly and the casting defect detection is performed through the scanned image of the casting surface. However, the scanning image of the casting surface based on this defect detection will cause the clarity and accuracy of the scanned casting surface image to be difficult to guarantee due to errors in the scanning process, which directly affects the reliability of casting surface defect detection. Based on this, the embodiment of the present invention discloses a surface defect detection method, system, electronic device and storage medium based on machine vision, which divides the casting surface image into multiple areas and extracts features from each area, so as to analyze the surface condition of the casting in more detail and improve the accuracy of detection. By comparing the regional feature parameters with the preset standard feature threshold, the area where defects may exist can be preliminarily screened out, so that subsequent detection can be carried out in a targeted manner, thereby improving the detection efficiency.

[0023] Embodiment 1 See also Figure 1 , Figure 1 It is a flow chart of the surface defect detection method based on machine vision disclosed in the 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 and / or hardware, and the execution subject can receive relevant information by wired or / and wireless means, and can send certain instructions. Of course, it can also have certain processing functions and storage functions. The execution subject can control multiple devices, such as a remote physical server or cloud server and related software, or it can be a local host or server and related software that performs related operations on a device placed somewhere. In some scenarios, multiple storage devices can also be controlled, and the storage devices can be placed in the same place or different places as the devices. For example Figure 1 As shown, the surface defect detection method based on machine vision includes the following steps: S101: acquiring an image of a casting by an image acquisition device to obtain a casting surface image, analyzing the casting surface image to determine an image quality parameter corresponding to the casting surface image, and performing parameter analysis on the image quality parameter corresponding to the casting surface image to determine an image accuracy index of the casting surface image; S102: comparing the image precision index of the casting surface image with the corresponding precision index threshold stored in the casting inspection library; if the image precision index of the casting surface image is less than the precision index threshold, optimizing the casting surface image until the set requirement is met; if the image precision index of the casting surface image is not less than the precision index threshold, executing the next step; The embodiment of the present invention divides the casting surface image into regions through an image processing device to obtain casting surface images in each region. The specific region division is as follows: division based on edge detection of the casting surface image. The edge is the place where the grayscale, color, texture and other features in the image change significantly. Edge detection can be used to detect the edges of defects such as cracks and scratches on the casting surface. Through edge detection, these defective regions can be separated from the background to facilitate further analysis and processing, thereby completing the regional division of the casting surface image to obtain casting surface images in each region; feature extraction is performed on the casting surface image in each region through an image feature extraction device. This is performed through an edge detection algorithm in the image feature extraction device. A method (such as Canny edge detector) is used to extract the edge contour of the casting surface, and a texture analysis algorithm (such as grayscale co-occurrence matrix, Fourier transform, etc.) is used to extract the texture features of the casting surface. The extracted features can be matched with reference features in the casting inspection library to evaluate the quality of the casting surface or detect potential defects. The above-mentioned visual analysis device is used to analyze and obtain the surface image feature indicators of each area of ​​the casting, and the key features in the surface image of each area of ​​the casting, such as shape, texture, etc., are extracted, and these features are compared with the preset standard or reference image. Through comparison and analysis, the visual analysis device can evaluate the quality of the casting surface and give the corresponding surface image feature indicators of each area of ​​the casting.

[0024] S103: Divide the acquired casting surface image into regions to obtain a plurality of casting region images, extract features of each casting region image through an 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, execute the next step 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, mark the corresponding casting region image as a defect image to be detected; S104: extracting defect features from the defect images to be detected by an image feature extraction module to obtain defect features of each defect image to be detected, performing parameter analysis on the defect features to obtain corresponding regional defect parameters, and comparing the regional defect parameters with the surface defect standard index preset in the casting inspection library. If the match is unsatisfactory, a defect warning prompt is issued.

[0025] The embodiment of the present invention acquires an image of the casting surface through an image acquisition device, and performs parameter analysis on the image quality to determine the image accuracy index. This step ensures the basic quality of the image for subsequent analysis and avoids false detection or missed detection due to problems such as image blur and insufficient light. When the image accuracy index does not meet the preset threshold, image optimization processing will be performed until the image quality meets the requirements. This can significantly improve the accuracy and reliability of detection.

[0026] The embodiment of the present invention divides the casting surface image into multiple regions and extracts features from each region, which can analyze the surface condition of the casting more carefully and improve the accuracy of detection. The feature extraction module can quickly and accurately identify the key feature parameters of each region, providing strong data support for subsequent defect detection.

[0027] The embodiment of the present invention can preliminarily screen out areas where defects may exist by comparing regional feature parameters with preset standard feature thresholds, so as to carry out subsequent detection in a targeted manner and improve detection efficiency. For the defect image to be detected, the 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 issued. This step realizes the intelligent identification and warning of casting surface defects, which helps to timely discover and deal with potential quality problems.

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

[0029] In actual industrial inspection scenarios, resources (such as time, computing power, and manpower) are limited. Therefore, inspection strategies often need to balance inspection accuracy and inspection efficiency. By setting thresholds for characteristic indicators, the risks of various areas on the casting surface can be evaluated. If the characteristic indicators of an area indicate that its surface condition is consistent with the normal or acceptable range (that is, greater than or equal to the threshold), then the risk of finding serious defects in this area is relatively low, so detailed defect detection in this area can be skipped to save resources. The characteristic indicator threshold can also be used to determine which areas require more detailed inspection. When resources are limited, areas with characteristic indicators below the threshold (that is, areas that are more likely to contain defects) can be inspected first to ensure that these areas receive adequate attention and treatment.

[0030] If the characteristic index of a certain area is very high, indicating that its surface condition is very close to or completely meets the standard, then detailed defect inspection in this area may result in a high false alarm rate (i.e., incorrectly identifying defects that do not exist). By skipping detailed inspection of these areas, the overall false alarm rate can be reduced, and the accuracy and efficiency of inspection can be improved.

[0031] 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 casting surface image can be determined by checking the technical specifications of the resolution of the scanning device when the scanning device scans the casting surface; the maximum brightness and the minimum brightness are obtained by measuring the brightness value of the brightest area and the brightness value of 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, which determines the number of colors that can be represented by each pixel in the image; for example, each pixel of an image with an 8-bit depth can represent 256 different colors ( ), in image processing software, you can view the bit depth information of the image to find out the number of colors it has.

[0032] In this example, the brightness contrast, resolution, number of noise points and number of colors of the casting surface image interact with each other and jointly determine the accuracy index of the casting surface image. Higher brightness contrast helps to highlight different areas in the image, making the details of the high-resolution image more obvious. If the brightness contrast is too low, even if the resolution is very high, the details may not be easily recognized due to the lack of sufficient light and dark differences. Conversely, high resolution can provide more pixels to capture brightness changes, thereby enhancing the contrast performance. The improvement of 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 junction of light and dark. In the casting surface image, changes in brightness contrast will cause changes in color saturation and brightness. For example, increasing brightness may make colors look brighter, while reducing brightness may make colors appear darker. When the resolution is increased, it means that more pixels are used to represent the image, which reduces the number of noise points to a certain extent. The presence of noise points will interfere with the color accuracy of the image. Too much noise points may cause color distortion or blurring, affecting the overall color performance of the image.

[0033] like Figure 2 As shown, the performing of 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: S1011: determining a brightness contrast of a corresponding casting surface image according to a maximum brightness and a minimum brightness of the casting surface image; S1012: Calculate the image accuracy index of the casting surface image according to the image accuracy calculation formula and the brightness contrast, image resolution noise number and color number of the casting surface image. The image accuracy 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.

[0034] The image quality parameters of the embodiment of the present invention include image resolution, maximum brightness, minimum brightness, number of noise points and number of colors, which together constitute a comprehensive evaluation system for image quality. This comprehensive evaluation method helps to more accurately reflect the actual quality status of the casting surface image. By introducing an image precision calculation formula, combined with multiple factors such as brightness contrast, image resolution, number of noise points and number of colors, the image precision index of the casting surface image can be scientifically calculated. This calculation method takes into account both the clarity of the image (resolution, brightness contrast), as well as the purity (number of noise points) and richness (number of colors) of the image, so as to more comprehensively reflect the quality level of the image. As the basis for subsequent detection, the accuracy and reliability of the image precision index directly affect the effect of the entire detection process. Through scientific calculation and comprehensive evaluation, it can be ensured that the image precision index can truly reflect the quality status of the casting surface image, thereby improving the accuracy and reliability of subsequent defect detection.

[0035] In the detection process, the image can be optimized or directly enter the next step of detection based on the comparison result of the image precision index and the preset threshold. This intelligent processing process based on image quality helps to reduce unnecessary detection steps and improve detection efficiency. By presetting parameters such as resolution limit 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.

[0036] In this example, if the resolution of the casting surface image is low, or even lower than the preset resolution limit, the details in the image cannot be clearly displayed, making it difficult to identify and analyze tiny defects or features. In casting surface inspection, this means that surface defects such as cracks and pores cannot be found, thereby affecting the evaluation and subsequent processing of casting surface defects; if the brightness contrast of the casting surface image is low, or even lower than the preset brightness contrast threshold, it will make it difficult to distinguish between light and dark areas in the image, resulting in loss and blurring of details. In casting surface inspection, this may make important features such as texture and defects on the casting surface unclear or even completely covered up, thereby seriously affecting the accuracy of casting surface defect detection results; if When the number of colors in the casting surface image is low, or even lower than the number of colors in the preset reference image, the color characteristics of the casting surface will not be able to accurately reflect the actual situation, and will also lead to the inability to accurately identify and extract the characteristics of the target area, reducing the reliability of the casting surface defect detection results; if the number of noise points in the casting surface image is large, or even more than the preset reference number of noise points, too many noise points will interfere with the real information of the casting surface image, making the defects and features of the casting surface image difficult to identify, which will lead to an increase in the error of subsequent casting surface defect detection results. Therefore, through a detailed analysis of each parameter in the casting surface image precision index, image quality problems can be discovered and solved, thereby improving the accuracy and reliability of casting surface detection.

[0037] In this example, the obtained casting surface image accuracy index is compared with the casting surface image accuracy index threshold preset in the casting inspection library. If the casting surface image accuracy index is less than the preset casting surface image accuracy index threshold, it means that the clarity or accuracy of the current casting surface image is insufficient. In this case, directly using the current casting surface image for feature extraction will lead to inaccurate or misleading results. Therefore, it is necessary to optimize the casting surface image through an image processing device. If the casting surface image accuracy index is greater than or equal to the preset casting surface image accuracy index threshold, 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.

[0038] More preferably, Figure 3 As shown, 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: S1021: If the image accuracy index of the casting surface image is less than the accuracy index threshold, image parameter statistics are performed on the casting surface image to obtain corresponding grayscale statistical results, wherein the grayscale statistical results include the number of pixels at each grayscale level in the casting surface image; S1022: Calculate a corresponding cumulative distribution function according to the grayscale statistical result, where 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; S1023: 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; The embodiment of the present invention can redistribute the gray levels in the image through grayscale equalization processing, so that the grayscale values ​​are more evenly distributed in the image. This helps to improve the contrast of the image, making the details of the casting surface clearer, which is convenient for subsequent detection and analysis. Grayscale equalization enhances the detail information in the image by stretching the grayscale range of the image. This is particularly important for the detection of surface defects of castings, because defects often appear as grayscale differences from surrounding areas. The method performs automatic processing based on grayscale statistical results and cumulative distribution functions, without manual intervention, and improves processing efficiency and consistency.

[0039] 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.

[0040] The embodiment of the present invention can flexibly adjust the brightness of the image by adjusting the constant k in the formula and the adjustment parameter r. This is particularly effective for image brightness problems caused by poor lighting conditions or reflections on the casting surface.

[0041] While adjusting the brightness, the relative relationship of other pixel values ​​is maintained through linear interpolation, thereby maintaining the detailed 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 detection efficiency.

[0042] Faced with different lighting conditions and changes in casting surface properties, the system can maintain stable detection performance through image optimization processing, enhancing the robustness of the system.

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

[0044] More preferably, the regional characteristic parameters include the maximum brightness, minimum brightness, shape contour length and shape contour width of the casting surface image in each region; the defect characteristics of each defect image to be detected include the edge width, average grayscale value, texture area shape area and texture number of each suspected defect area image on the casting surface.

[0045] The regional characteristic parameters in the embodiment of the present invention include the highest brightness, the lowest brightness, the shape contour length and the shape contour width, which can fully reflect the brightness distribution and shape characteristics of each area on the casting surface. By analyzing these regional characteristic parameters, it is easier to find potential defect areas that are significantly different from the surrounding areas, thereby improving the sensitivity of defect detection. The measurement of shape contour length and width helps to accurately judge the defects such as deformation and cracks on the casting surface and enhance the reliability of the detection results.

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

[0047] It should be explained that the highest brightness and the lowest brightness of the surface image of the casting in the above-mentioned areas are obtained by measuring the brightness value of the brightest area and the brightness value of the darkest area in the image using a brightness measurement tool in the image processing software. The shape contour length and the shape contour width can be obtained through image segmentation and feature extraction. The edges in the image are identified using edge detection methods (such as the Canny operator), and then the size of the shape is determined by calculating the distance between the edges.

[0048] In this example, there are complex interrelationships between the characteristic parameters of the above casting surface images, which 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 images with high contrast, details are clearer, which helps to more accurately identify the features and defects of the casting surface. The length and width of the shape contour jointly determine the area of ​​the shape. 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 defect. Different aspect ratios may correspond to different types of defects, such as cracks, holes or protrusions. The highest brightness is usually related to the edge in the image, and edge detection is a key step in determining the length of the shape contour. In the high brightness area, the edge is more easily detected, thereby improving the accuracy of the shape contour length measurement. The lowest brightness area may be caused by shadows or occlusions, which may affect the detection of the shape contour width. The details in the shadow area may not be easily captured, resulting in inaccurate width measurement.

[0049] More preferably, 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.

[0050] The embodiment of the present invention calculates the ratio of the highest brightness to the lowest brightness of the casting surface image in each region to obtain the brightness contrast, and further performs difference processing with the brightness contrast of the overall casting surface image, so as to quantify the difference in brightness contrast between each region and the overall. This helps to identify areas with abnormal brightness, which may be defects. The shape contour length and shape contour width of the casting surface image in each region are subjected to difference processing with a preset reference image, and the absolute value is taken, so that the deviation of the shape contour of each region can be accurately evaluated. This helps to find defects such as shape deformation and incomplete contour. The brightness contrast deviation value, shape contour length deviation value and shape contour width deviation value are comprehensively analyzed to obtain characteristic indicators of the casting surface image in each region. This comprehensive indicator can more comprehensively reflect the characteristics of each region and improve the accuracy of defect detection.

[0051] Through quantitative processing and comprehensive analysis, the system can more accurately identify and process the characteristics of each area on the casting surface, enhance its adaptability to different casting types and surface characteristics, and improve the robustness of the system.

[0052] In this example, both the casting surface image accuracy index and the casting surface image characteristic index of each region use the ratio 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 casting surface image accuracy index is mainly used to evaluate the overall quality of the entire casting surface image, including image clarity and contrast. The ratio of the highest brightness to the lowest brightness is an important link, which is used to reflect the brightness distribution of the image. In the casting surface image characteristic index of each region, more emphasis is placed on evaluating the characteristic differences of different regions on the casting surface. By comparing the brightness contrast deviation values ​​of each region with the preset reference image, the abnormal region can be identified, and then it can be determined whether there are defects. Although the two are different in the calculation process and application scenarios, they are both important parameters in the surface defect detection method based on machine vision. Together, they provide a strong basis for evaluating the quality of casting surface images and identifying potential defects.

[0053] The brightness contrast of the casting surface image in each region is processed by difference with the brightness contrast of the casting surface image, and then absolute value processing is performed 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 processed by difference 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 absolute value processing is performed to obtain the shape contour length deviation value and shape contour width deviation value of the casting surface image in each region.

[0054] It should be explained that the above-mentioned reference images of the casting surface in each region refer to standard images pre-set in the casting inspection library.

[0055] 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. The specific analysis formula is: ; In the formula, is the characteristic index of the casting surface image in the i-th region, i is the number of the casting surface image in each region, i=1, 2, 3...p, p is the total number of regional casting surface images, and e is a natural constant. is the brightness contrast deviation value of the casting surface image in the ith region, which refers to the ratio of the brightness contrast of the casting surface image in the ith region to the brightness contrast of the reference image. The reference image brightness contrast reference deviation value preset for the casting inspection library refers to the allowable brightness contrast deviation value of the regional casting surface reference image preset in the casting inspection library. is the shape contour length deviation value of the casting surface image in the ith region, which refers to the difference between the actual length of the shape contour in the casting surface image in the ith region and the shape contour length in the reference image. The reference image shape contour length reference deviation value preset for the casting inspection library refers to an allowable shape contour length deviation value preset in the casting inspection library. is the shape contour width deviation value of the casting surface image in the ith region, which refers to the difference between the actual width of the shape contour in the casting surface image in the ith region and the shape contour width in the reference image. The reference image shape contour width reference deviation value preset for the casting inspection library refers to an allowable shape contour width deviation value preset in the casting inspection library.

[0056] In this example, when the brightness contrast deviation value of the regional casting surface image deviates greatly from the preset reference image brightness contrast reference deviation value, it will cause the loss of details in the regional casting surface image, especially in the high-brightness or low-brightness area, which will affect the ability to recognize tiny defects. At the same time, insufficient brightness contrast will make the edge of the image blurred, making it difficult to accurately detect the shape contour, thereby affecting the subsequent shape analysis; when the shape contour length deviation value is greater than the preset reference image shape contour length reference deviation value, it indicates that there is a large difference between the actual shape length and the expected shape standard length, causing shape disproportion and affecting the structural integrity of the casting; when the shape contour width deviation value is greater than the reference image shape contour width reference deviation value, it indicates that there is a large difference between the actual shape width and the expected shape standard width, which directly leads to a decrease in the regional casting surface image feature index; therefore, through a detailed analysis of each parameter in the regional casting surface image feature index, potential problems in various areas of the casting surface can be discovered, and areas with problems on the casting surface can be accurately located.

[0057] More preferably, the characteristic indexes of the images of the suspected defective regions 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.

[0058] The embodiment of the present invention can comprehensively reflect the morphology, grayscale distribution and texture characteristics of defects by obtaining characteristic indicators such as edge width, average grayscale value, texture shape area and texture quantity of the suspected defect area image of each casting surface. A more accurate characteristic index can be obtained by comprehensively analyzing these characteristic indicators and combining them with the specific characteristics of the suspected defect area image of each casting surface. This index helps to distinguish different types of defects and improve the accuracy of defect recognition.

[0059] More preferably, 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.

[0060] By comparing the characteristic index of the suspected defect area image with the preset casting surface defect index, the embodiment of the present invention can accurately identify the area where the defect actually exists and trigger the early warning prompt in time. This helps to timely discover and deal with the quality problems of the casting surface and prevent defective products from flowing into the subsequent process.

[0061] The preset casting surface defect index is set based on a large amount of actual inspection data and experience, and has high accuracy and reliability. Therefore, comparing the characteristic index with the standard index can reduce false positives and false negatives and improve the accuracy and efficiency of inspection.

[0062] In this example, the surface images of the castings in each area corresponding to the casting surface characteristic index being less than the preset casting surface characteristic index threshold are marked as images of suspected defect areas on the casting surfaces. Therefore, the surface images of the castings in each area include images of suspected defect areas on the casting surfaces. Therefore, the surface characteristic indexes of the castings corresponding to the casting surface characteristic indexes being less than the preset casting surface characteristic index threshold are the characteristic indexes of the images of suspected defect areas on the casting surfaces. In this example, the characteristic indexes of the images of suspected defect areas on the casting surfaces are important bases for evaluating casting surface defects and identifying potential defects. The characteristic indexes of the images of suspected defect areas on the casting surfaces indicate the complex characteristics of the images of suspected defect areas on the casting surfaces.

[0063] 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 quantity 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. The specific analysis formula is: ; In the formula, is the characteristic index of the jth suspected defect area image on the casting surface, j is the number of each suspected defect area image on the casting surface, j=1, 2, 3...k, k is the total number of suspected defect area images on the casting surface, is the characteristic index of the image of the suspected defect area on the jth casting surface. The weight factors corresponding to the characteristic indicators of the images of suspected defect areas on the casting surface preset in the casting inspection library can be directly obtained from the casting inspection library. The corresponding relationship can be a preset mapping relationship. For example, a mapping set is formed according to the characteristic indicators of historical images of suspected defect areas on the casting surface and the weight factors corresponding to the characteristic indicators of the images of suspected defect areas on the casting surface, and the characteristic indicators of the real-time images of suspected defect areas on the casting surface are input into the mapping set to obtain the weight factors corresponding to the characteristic indicators of the images of suspected defect areas on the casting surface. The mapping relationship can be one-to-one or many-to-one. At the same time, in this example, its value range is [0, 1]. is the edge width of the image of the suspected defect area on the jth casting surface, which refers to the edge width of the detected defective casting. The influencing factors corresponding to the edge width unit values ​​preset in the casting inspection library can be directly obtained from the casting inspection library. The corresponding relationship can be a preset mapping relationship. For example, a mapping set is formed according to the influencing factors corresponding to the historical edge widths and the edge width unit values, and the real-time edge width is input into the mapping set to obtain the influencing factors corresponding to the edge width unit values. The mapping relationship can be one-to-one or many-to-one. At the same time, in this example, its value range is [0, 1]. is the average grayscale value of the image of the suspected defect area on the j-th casting surface, which refers to the average grayscale values ​​of multiple pixel points in the image of the suspected defect area on the j-th casting surface. The grayscale reference value preset for the casting inspection library refers to a pre-set grayscale value for comparison with the grayscale value in the casting image to be inspected. is the texture shape area of ​​the image of the suspected defect area on the jth casting surface, which refers to the area occupied by the defective texture. The reference image texture shape area boundary value preset for the casting inspection library refers to a preset defect texture shape area value. is the texture number of the image of the suspected defect area on the jth casting surface, which refers to the total number of defect textures. The influence factor corresponding to the unit value of the texture quantity preset in the casting inspection library can be directly obtained from the texture quantity. The corresponding relationship can be a preset mapping relationship. For example, a mapping set is formed according to the influence factors corresponding to the historical texture quantity and the unit value of the texture quantity, and the real-time texture quantity is input into the mapping set to obtain the influence factor corresponding to the unit value of the texture quantity. The mapping relationship can be one-to-one or many-to-one. At the same time, in this example, its value range is [0, 1].

[0064] The present invention obtains the casting surface image precision index by analyzing image quality parameters such as resolution, brightness contrast, etc., and can optimize the image processing process, provide a basis for the subsequent identification of minor defects on the casting surface, and compare it with the casting surface image precision index threshold preset in the casting inspection library, and optimize the casting surface image that is less than the preset casting surface image precision index threshold to improve the image clarity and make the details in the image more obvious, which is particularly important for detecting minor surface defects. A clear image helps to more accurately evaluate casting surface defects.

[0065] The present invention can more accurately locate and identify defects on the casting surface by dividing the casting surface image into regions. This localized processing method helps to capture tiny defects, thereby improving the overall defect detection accuracy of the casting surface. Feature extraction and analysis are performed on the casting surface image of each region to obtain feature parameters of the casting surface image of each region, and the feature parameters are compared with the casting surface feature index threshold value preset in the casting inspection library. Detailed casting surface defect detection is performed on the region below the preset casting surface feature index threshold value, which can reduce unnecessary casting surface defect detection work and improve the overall casting surface defect detection process and efficiency.

[0066] The present invention obtains the characteristic index of the image of the suspected defect area on the casting surface by quickly analyzing the extracted defect features, and compares it with the preset casting surface defect index, so as to quickly judge whether there are defects on the casting surface, reduce the false alarm rate and missed alarm rate of casting surface defects, and improve the accuracy of casting surface defect detection.

[0067] The surface defect detection method based on machine vision in the embodiment of the present invention divides the casting surface image into multiple regions and extracts features from each region, which can analyze the surface condition of the casting more carefully and improve the accuracy of detection. By comparing the regional feature parameters with the preset standard feature threshold, the regions where defects may exist can be preliminarily screened out, so that subsequent detection can be carried out in a targeted manner, thereby improving the detection efficiency.

[0068] Embodiment 2 See also Figure 4 , Figure 4FIG. 1 is a schematic diagram of the structure of a surface defect detection device based on machine vision disclosed in an embodiment of the present invention. Figure 4 As shown, the surface defect detection device based on machine vision may include: The first acquisition module 21 is used to acquire an image of the casting by an image acquisition device to obtain a surface image of the casting, analyze the surface image of the casting to determine an image quality parameter corresponding to the surface image of the casting, and perform 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; The first judgment module 22 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. The region division module 23 is used to divide the acquired casting surface image into regions to obtain a plurality of casting region images, and 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 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 24: 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 unsatisfactory, a defect warning prompt is issued.

[0069] The surface defect detection method based on machine vision in the embodiment of the present invention divides the casting surface image into multiple regions and extracts features from each region, which can analyze the surface condition of the casting more carefully and improve the accuracy of detection. By comparing the regional feature parameters with the preset standard feature threshold, the regions where defects may exist can be preliminarily screened out, so that subsequent detection can be carried out in a targeted manner, thereby improving the detection efficiency.

[0070] Embodiment 3 See also Figure 5 , Figure 5Schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. The electronic device may be a computer, a server, etc. Of course, in certain circumstances, it may also be a smart device such as a mobile phone, a tablet computer, a monitoring terminal, and an image acquisition device with processing functions. Figure 5 As shown, the electronic device may include: A memory 510 storing executable program codes; a processor 520 coupled to the memory 510; The processor 520 calls the executable program code stored in the memory 510 to execute part or all of the steps in the surface defect detection method based on machine vision in the first embodiment.

[0071] An embodiment of the present invention discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute part or all of the steps in the surface defect detection method based on machine vision in the first embodiment.

[0072] The embodiment of the present invention further discloses a computer program product, wherein when the computer program product is run on a computer, the computer is enabled to execute part or all of the steps in the surface defect detection method based on machine vision in the first embodiment.

[0073] An embodiment of the present invention further discloses an application publishing platform, wherein the application publishing platform is used to publish a computer program product, wherein when the computer program product runs on a computer, the computer executes part or all of the steps in the machine vision-based surface defect detection method in embodiment one.

[0074] In various embodiments of the present invention, it should be understood that the size of the serial numbers of the processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0075] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place or distributed over multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

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

[0077] If 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 the technical solution, can be embodied in the form of a software product. The computer software product is stored in a memory and includes several requests to enable a computer device (which can be a personal computer, server or network device, etc., specifically a processor in a computer device) to perform some or all steps of the method described in each embodiment of the present invention.

[0078] 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.

[0079] A person of ordinary skill in the art may understand that part or all of the steps in the various methods of the embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, the storage medium including 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 electronically-erasable programmable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0080] The above is a detailed introduction to the machine vision-based surface defect detection method, system, electronic device and storage medium disclosed in the embodiments of the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A surface defect detection method based on machine vision, characterized in that: include: Capturing an image of the casting by an image acquisition device to obtain a casting surface image, analyzing the casting surface image to determine an image quality parameter corresponding to the casting surface image, and performing parameter analysis on the image quality parameter corresponding to the casting surface image to determine an image accuracy index of the casting surface image; 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: 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.

3. 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.

4. 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.

5. The surface defect detection method based on machine vision according to claim 4, 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.

6. The surface defect detection method based on machine vision according to claim 4, 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.

7. 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.

8. A surface defect detection device based on machine vision, characterized in that: include: A first acquisition module: used for acquiring an image of a casting through an image acquisition device to obtain an image of a casting surface, analyzing the casting surface image to determine an image quality parameter corresponding to the casting surface image, and performing 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 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.

9. 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 7.

10. 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 7.

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

  • Scratch defect detection method, system, equipment and medium thereof

    CN116934746A

  • Laser welding quality detection system based on machine vision

    CN117593298A

Cited By

  • Motorcycle shell high-pressure casting mold defect detection system and method

    CN119985172A

  • A motorcycle shell high-pressure casting mold defect detection system and method

    CN119985172B

  • Plastic film surface defect detection method based on machine vision

    CN120976210A

  • A Machine Vision-Based Method for Detecting Surface Defects in Plastic Films

    CN120976210B

  • Aluminum alloy casting defect identification method and system based on image analysis

    CN121033043A