Automobile pipe defect detection method and system
By adjusting the viewing angle, blocking and sparse value adjustment of the car pipe fitting images, the impact of reflective interference on detection is solved, and the accuracy and reliability of the appearance quality detection of the car pipe fittings is achieved.
Patent Information
- Application Number
- CN202510289244.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-12
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-03-12
AI Technical Summary
In the appearance quality inspection of automobile pipe fittings, reflective interference is difficult to eliminate, resulting in the inability to accurately distinguish reflection from defects, affecting the accuracy of detection.
By collecting images of automobile pipe fittings from different perspectives, adjusting the same view angle and image blocking, using the K-SVD algorithm to decompose sparse vectors, analyzing the degree of light abnormality and image splitting, adjusting the sparse value to eliminate reflective interference, and achieving accurate appearance quality detection.
Effectively eliminate reflective interference, improve the accuracy of the appearance quality inspection of automobile pipe fittings, and ensure the reliability and safety of inspection results.
Smart Images

Figure CN119810098B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a method and system for detecting defects in automobile pipes. Background Art
[0002] In the automobile manufacturing industry, pipe fittings are key components used in fuel systems, brake systems, cooling systems, exhaust systems, etc. The quality of these pipe fittings is directly related to the safety, reliability and performance of the car. However, due to the complexity of the manufacturing process and the diversity of material properties, pipe fittings are prone to various defects during the production process, such as scratches, burrs, cracks, etc. These defects not only affect the mechanical properties of the pipe fittings, but may also cause system failure and even cause serious safety accidents.
[0003] Since some automobile pipes are often made of smooth metal, they are easily disturbed by reflections when performing appearance quality inspection on automobile pipes. Defects such as scratches and burrs on automobile pipes will show grayscale changes, and reflections will also show grayscale changes, so it is impossible to distinguish reflections from defects through grayscale change characteristics. At the same time, since the morphology of the reflective area is not fixed, for example, the reflective area sometimes shows linear features and sometimes shows regional features, it is impossible to distinguish the reflective area from the defective area using morphological features. Therefore, how to eliminate reflection interference and achieve accurate appearance inspection of automobile pipes has become the research focus of the present invention.
[0004] The patent application document published as CN118485648A discloses a method for detecting surface defects of pipe fittings based on improved YOLO-v8. The patent application document mainly uses the YOLO-v8 network to realize the detection of surface defects of pipe fittings. The method in the patent application document does not involve the content of eliminating the interference of reflective light. Therefore, the method in the patent application document cannot solve the problem in this solution. Summary of the invention
[0005] In order to solve the problem of how to eliminate reflection interference and achieve accurate appearance inspection of automobile pipes, the present invention provides an automobile pipe defect inspection method and system.
[0006] In a first aspect, the present invention provides a method for detecting defects in automobile pipes, which adopts the following technical solution:
[0007] A method for detecting defects in automobile pipe parts comprises the following steps:
[0008] Collecting automobile pipe images at different viewing angles, adjusting the automobile pipe images to the same viewing angle, and then performing image block processing;
[0009] All image blocks of a block position are obtained and recorded as image blocks of the same part; the sparse vectors corresponding to the image blocks of the same part are decomposed by using the K-SVD algorithm; according to the variance of the sparse values of an element position in all sparse vectors, all element positions are clustered into two categories; the element position in the category with a large mean value of the variance of the sparse values is recorded as a light-related position; the sparse values of other element positions in the sparse vector except the light-related position are set to zero, and the light image block is reconstructed by using the sparse vector after being set to zero; the degree of light anomaly is calculated; the light image blocks are divided into two categories according to the degree of light anomaly, and the value range of the sparse values of each light-related position of the sparse vector corresponding to the light image block in the category with a small mean value of the light anomaly is obtained as a feasible value range; the sparse value of each element position in the sparse vector is taken as one of the values within the feasible value range, and the light adjustment image block is reconstructed by using the re-valued sparse vector, the degree of image fragmentation is calculated, and the sparse value of each element position is continuously adjusted until the degree of image fragmentation is minimized; the image is spliced using the light adjustment image block with the minimum value of the image fragmentation degree to achieve defect detection.
[0010] The present invention adjusts the light in the automobile pipe image to eliminate the interference of reflection on the appearance quality detection, thereby realizing accurate appearance quality detection; further, considering that the reflection degree of each area of the automobile pipe image is different, the automobile pipe image is divided into blocks to adjust the light of each image block respectively, thereby improving the accuracy of the light adjustment; further, in the process of adjusting the light of each image block, the sparse value of the feature specifically associated with the light is accurately extracted by analyzing the difference of the sparse values of the same element position in the sparse vector of the image block at the same position under different viewing angles, thereby providing a basis for only adjusting the light information in the subsequent process without damaging the useful image information; further, in the process of adjusting the light of each image block, the value range of the sparse value corresponding to the light feature under good light is accurately obtained by analyzing the degree of light abnormality, thereby providing a direction for the subsequent accurate light adjustment; further, considering that the light adjustment will cause the light splitting phenomenon between adjacent image blocks, the light adjustment is supervised by using the image splitting degree in the process of adjusting the light of the image block, thereby making the adjusted automobile pipe image not only have good light information, but also have no image splitting phenomenon.
[0011] Preferably, the calculating of the degree of light abnormality includes:
[0012] The mean grayscale value of all pixels in the light image block is recorded as the comprehensive grayscale value of the light image block; the mean comprehensive grayscale value of all light image blocks except the light image block is recorded as the reference grayscale value; the absolute value of the difference between the comprehensive grayscale value of the light image block and the reference grayscale value is taken as the degree of light abnormality of the light image block.
[0013] The present invention takes into account that the light conditions in the automobile pipe inspection environment are good, but there is strong reflective interference in a small area. Therefore, the overall light information of the automobile pipe image is used as a comparison to analyze the light anomalies of each light image block. This analysis method is relatively simple and has high accuracy.
[0014] Preferably, the calculating the degree of image segmentation includes:
[0015] Acquire a light-adjusted image block adjacent to the light-adjusted image block;
[0016] The outermost circle of pixels in the light adjustment image block is recorded as boundary pixels, the adjacent pixels of the boundary pixels are obtained in the adjacent light adjustment image block, the absolute value of the difference between the grayscale value of the boundary pixel and the grayscale value of the adjacent pixel is used as the splitting degree of the boundary pixel, the average of the splitting degrees of all boundary pixels in the light adjustment image block is used as the splitting degree of the light adjustment image block, and the average of the splitting degrees of all light adjustment image blocks is used as the image splitting degree.
[0017] The present invention reflects the degree of light splitting between image blocks through the grayscale difference of adjacent pixels of adjacent image blocks. The analysis method is relatively simple to implement and has higher implementation efficiency.
[0018] Preferably, reconstructing the light image block by using the sparse vector after being set to zero includes:
[0019] The vector obtained by splicing the rows of the image blocks at the same position is recorded as the same position vector;
[0020] Using K-SVD algorithm to process all the same-position vectors, a dictionary matrix and a sparse vector corresponding to the same-position vector of each same-position image block are obtained;
[0021] The vector obtained by multiplying the dictionary matrix with the zeroed sparse vector is restored to an image block, which is recorded as a light image block.
[0022] Preferably, the method for obtaining the feasible value range includes:
[0023] According to the degree of light abnormality, all light image blocks are clustered into two categories, and the category with a small average value of light abnormality is recorded as a normal category; all light image blocks at a block position are obtained in the normal category and recorded as normal light image blocks at the block position; the value range of all sparse values at a light-related position is obtained in the sparse vector corresponding to the normal light image block at the block position as the feasible value range of the sparse value at the light-related position in the sparse vector;
[0024] The feasible value range of the sparse values of the element positions other than the light-related positions in the sparse vector is replaced by the original sparse values.
[0025] The present invention accurately reflects the sparse value value under better light conditions through the value range of the sparse value of the sparse vector of the light image block with a smaller light anomaly, and provides an adjustment direction for subsequent light adjustment.
[0026] Preferably, the step of taking a sparse value of each element position in the sparse vector as one of the values within a feasible value range and reconstructing the light adjustment image block using the revalued sparse vector includes:
[0027] The sparse value of each element position in the sparse vector of each block position is taken as any value within the corresponding feasible value range, and the image block obtained by multiplying the re-valued sparse vector by the dictionary matrix is restored as the light adjustment image block of each block position.
[0028] Preferably, the step of continuously adjusting the sparse value of each element position until the image fragmentation degree is minimized includes:
[0029] The degree of image segmentation is taken as the objective function, and the feasible value range of all element positions in the sparse vector of each block position constitutes the solution space of the sparse vector of each block position. The genetic algorithm is used to solve the solution when the objective function takes the minimum value, which is used as the adjusted sparse vector of each block position. The image block obtained by multiplying the adjusted sparse vector by the dictionary matrix is restored as the light adjusted image block of each block position.
[0030] The present invention ensures the light quality of the automobile pipe image by taking the sparse values under better light for each sparse value in the sparse vector; further, the sparse value adjustment of the image splitting degree is used for supervision, so as to ensure that after the sparse value adjustment, the light splitting between the image blocks is small, thereby ensuring the light quality of the automobile pipe image.
[0031] Preferably, the step of using light rays with a minimum image fragmentation degree to adjust the image blocks and stitching out an image to achieve defect detection includes:
[0032] The image spliced by using the light-adjusted image blocks at all block positions is used as the automobile pipe image after light adjustment.
[0033] A design image of an automobile pipe is obtained, and edge detection processing is performed on the light-adjusted automobile pipe image to obtain an edge image. The design image is matched with the edge image, and edge lines in the edge image that do not match edge lines in the design image are obtained as defective edge lines.
[0034] Preferably, the image segmentation process is performed after the same viewing angle adjustment is performed on the image of the automobile pipe, including:
[0035] One of the viewing angles is used as a reference viewing angle, the automobile tube images at other viewing angles are adjusted to the reference viewing angle, and the automobile tube images at each viewing angle after the viewing angle adjustment are evenly divided into a number of image blocks.
[0036] In a second aspect, the present invention provides an automobile pipe defect detection system, which adopts the following technical solution:
[0037] A system for detecting defects in automobile pipe parts comprises: a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned method for detecting defects in automobile pipe parts is implemented.
[0038] By adopting the above technical solution, the above-mentioned automobile pipe defect detection method is generated into a computer program and stored in a memory so as to be loaded and executed by a processor, thereby making a terminal device based on the memory and the processor for easy use.
[0039] The present invention has the following technical effects:
[0040] The present invention adjusts the light in the automobile pipe image to eliminate the interference of reflection on the appearance quality detection, thereby achieving accurate appearance quality detection;
[0041] Furthermore, considering that the different areas of the automobile pipe image are affected by different degrees of reflection interference, the automobile pipe image is divided into blocks to adjust the light of each image block, thereby improving the accuracy of the light adjustment;
[0042] Furthermore, in the process of adjusting the light of each image block, the sparse values of the features specifically associated with the light are accurately extracted by analyzing the differences in the sparse values of the same element position in the sparse vector of the image block at the same position under different viewing angles, which provides a basis for adjusting only the light information in the subsequent step without damaging the useful image information.
[0043] Furthermore, in the process of adjusting the light of each image block, the range of sparse values corresponding to the light characteristics under good light is accurately obtained by analyzing the degree of light anomaly, thereby providing a direction for subsequent accurate light adjustment;
[0044] Furthermore, considering that light adjustment may cause light splitting between adjacent image blocks, the light adjustment is supervised by using the image splitting degree during the light adjustment of the image blocks, so that the adjusted automobile pipe image not only has better light information, but also does not have image splitting. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-restrictive manner, and the same or corresponding reference numerals represent the same or corresponding parts.
[0046] Figure 1 It is a flow chart of a method in a method for detecting defects in automobile pipes according to an embodiment of the present invention;
[0047] Figure 2 A schematic diagram of image acquisition provided by the present invention;
[0048] Figure 3 A schematic diagram of the dictionary matrix-sparse vector relationship provided by the present invention. DETAILED DESCRIPTION
[0049] 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 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0050] It should be understood that when the terms "first", "second", etc. are used in the claims, descriptions, and drawings of the present invention, they are only used to distinguish different objects, rather than to describe a specific order. The terms "include" and "comprise" used in the description and claims of the present invention indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their collections.
[0051] The embodiment of the present invention discloses a method for detecting defects in automobile pipes, referring to Figure 1 , comprising steps S1 to S4:
[0052] S1: collecting automobile pipe images at different viewing angles, adjusting the automobile pipe images to the same viewing angle, and then performing image block processing.
[0053] S10: Collect images of automobile pipes from different perspectives.
[0054] Specifically, Figure 2As shown in the image acquisition schematic diagram, the camera is placed on a circle with a vertical distance H from the desktop where the automobile pipe is located and a horizontal distance R from the geometric center of the automobile pipe. The camera is moved on the circle for one circle. During the movement, an image of the automobile pipe is collected every n seconds, and images of the automobile pipe under several viewing angles are collected. H, R and n represent the preset vertical distance, the preset horizontal distance and the preset time interval respectively. This embodiment is described by taking H as 10, R as 5 and n as 2 as an example. Other embodiments may take other values, and this embodiment does not make specific restrictions.
[0055] S11: performing image block processing after adjusting the automobile pipe image to the same viewing angle.
[0056] Specifically, the world coordinates of the camera when capturing images at various viewing angles are obtained, and any viewing angle is used as a reference viewing angle. The relative position relationship between the other viewing angles and the reference viewing angle in the world coordinate system is obtained according to the world coordinates of the camera at the reference viewing angle and the world coordinates of the cameras at other viewing angles; based on the relative position relationship between the other viewing angles and the reference viewing angle in the world coordinate system, the automobile pipe fittings images at other viewing angles are transformed into the reference viewing angle using a viewing angle transformation method to obtain automobile pipe fittings images at each viewing angle after the viewing angle transformation.
[0057] It should be added that the use of a perspective transformation method to transform automobile pipe images at other perspectives to a reference perspective is an existing technology and will not be described in detail here.
[0058] It should be noted that, since each area of the automobile pipe fittings image at each viewing angle is subject to different degrees of light interference, for example, some areas are strong light areas (reflective areas), some areas are normal light areas, and some areas are dim light areas. Therefore, the light adjustment conditions of each area are different, so it is necessary to divide the automobile pipe fittings image at each viewing angle into blocks and analyze each block separately.
[0059] Specifically, the automobile pipe images at each viewing angle after the viewing angle transformation are evenly divided into a number of image blocks.
[0060] S2: Obtain all image blocks of a block position and record them as image blocks of the same part; use the K-SVD algorithm to decompose the sparse vector corresponding to the image block of the same part; according to the variance of the sparse value of an element position in all sparse vectors, cluster all element positions in the sparse vector into two categories; record the element position in the category with a large mean of the variance of the sparse value as the light-associated position.
[0061] It should be noted that, because the relative position relationship between the camera and the light source changes at different viewing angles, the light reflected from the automobile pipe in the camera is different. After the viewing angle is adjusted, there will be no viewing angle difference in the images of automobile pipes at different viewing angles. At the same time, because the automobile pipes are photographed at each viewing angle, the structures of the automobile pipes in the images of automobile pipes at different viewing angles are the same. Based on this, it can be seen that the only difference in the images of automobile pipes at different viewing angles is the light difference.
[0062] S20: Obtain all image blocks at a block position and record them as image blocks at the same position.
[0063] Preferably, as an example, all image blocks at a block position are obtained and recorded as image blocks at the same position, including:
[0064] Any block position is recorded as a target block position, and image blocks at the target block position are respectively obtained from the automobile pipe images at each viewing angle after the viewing angle adjustment and recorded as image blocks at the same position of the target block position.
[0065] It should be noted that the image blocks of the same part at different viewing angles at the same block position describe the same automobile pipe component information, and therefore the difference between the image blocks of the same part at different viewing angles at the same block position is only the light difference.
[0066] S21: Decompose the sparse vector corresponding to the image block in the same part by using the K-SVD algorithm.
[0067] Preferably, as an example, using the K-SVD algorithm to decompose the sparse vector corresponding to the image block in the same part includes:
[0068] The vector obtained by splicing the rows of the image blocks at the same position is recorded as the same position vector;
[0069] The K-SVD algorithm is used to process all the same-position vectors to obtain the dictionary matrix and the sparse vectors corresponding to the same-position vectors of each same-position image block.
[0070] S22: according to the variance of the sparse value of an element position in all sparse vectors, all element positions in the sparse vectors are clustered into two categories; the element position in the category with a larger mean of the variance of the sparse value is recorded as the light-related position.
[0071] Preferably, as an example, according to the variance of the sparse value of an element position in all sparse vectors, all element positions in the sparse vectors are clustered into two categories; the element position in the category with a large mean of the variance of the sparse value is recorded as the ray-related position, including:
[0072] Any element position in the sparse vector is recorded as the target element position, and all sparse values of the target element position are obtained in all sparse vectors, and all sparse values of each element position are also obtained; according to the variance of all sparse values of each element position obtained, all element positions in the sparse vector are clustered into two categories using the K-means clustering algorithm; the mean of the variance of the sparse values of all element positions in each category is calculated, and the category with the larger mean of the variance of the sparse values of all element positions in the two categories is taken as the light-associated category; and the element position in the light-associated category is recorded as the light-associated position.
[0073] It is understandable that if Figure 3 As shown in the diagram of the dictionary matrix-sparse vector relationship, the first column in the dictionary matrix corresponds to the sparse value of the first element position of the sparse vector, the second column in the dictionary matrix corresponds to the sparse value of the second element position of the sparse vector, ..., the last column in the dictionary matrix corresponds to the sparse value of the last element position of the sparse vector; each column of data in the dictionary matrix describes a feature, and each sparse value in the sparse vector describes the content of the corresponding feature in the image block. Since the image blocks in the same part under different viewing angles only have light differences, only the feature content associated with the light is different. By analyzing the variance of the sparse values of an element position under different viewing angles, the features associated with the light can be extracted. In this embodiment, the feature corresponding to the sparse value at the light-related position is the light-related feature.
[0074] S3: setting the sparse values of the element positions other than the light-related positions in the sparse vector to zero, and reconstructing the light image block using the sparse vector after setting to zero; calculating the degree of light anomaly, wherein the degree of light anomaly represents the difference in grayscale values of the light image block; dividing the light image blocks into two categories according to the degree of light anomaly, and obtaining the value range of the sparse values of each element position of the sparse vector corresponding to the light image block in the category with a small mean value of the light anomaly as a feasible value range.
[0075] It should be noted that the light-related features in the dictionary matrix can describe the light conditions in the image blocks at the same location, and thus the light information in the image blocks at the same location can be adjusted by adjusting the sparse values corresponding to the light-related features.
[0076] It should be further explained that in order to better adjust the light information in the image blocks in the same part, it is necessary to obtain the sparse value under better light conditions. This embodiment reflects the sparse value under better light conditions through a feasible value range.
[0077] S30: setting the sparse values of the element positions other than the light-related position in the sparse vector to zero, and reconstructing the light image block using the sparse vector after setting to zero.
[0078] Preferably, setting the sparse values of the element positions other than the light-related position in the sparse vector to zero, and reconstructing the light image block using the sparse vector after setting to zero, includes:
[0079] The sparse values of the element positions other than the light-related position in the sparse vector are set to zero, and the vector obtained by multiplying the sparse vector after being set to zero by the dictionary matrix is restored to an image block, which is recorded as a light image block.
[0080] It should be noted that by setting the sparse values of other element positions to zero, the light information in the image block at the same position can be extracted, thereby eliminating the interference of other factors and providing a basis for subsequent accurate analysis of the light situation.
[0081] S31: Calculate the degree of light abnormality.
[0082] It should be noted that in order to collect better automobile pipe images, the light environment when collecting images is relatively good, but there are a few areas with abnormal light, such as reflection in a small area, so the overall light situation in the automobile pipe image is relatively good. Based on this, the abnormal light situation in each light image block can be analyzed by comparing the gray value in each light image block with the overall gray value of all light image blocks.
[0083] Preferably, as an example, calculating the degree of light abnormality includes:
[0084] The mean grayscale value of all pixels in the light image block is recorded as the comprehensive grayscale value of the light image block; the mean comprehensive grayscale value of all light image blocks except the light image block is recorded as the reference grayscale value; the absolute value of the difference between the comprehensive grayscale value of the light image block and the reference grayscale value is taken as the degree of light abnormality of the light image block.
[0085] It can be understood that the comprehensive grayscale value reflects the overall light condition in the automobile pipe image. Since the overall light condition is good, the difference between the grayscale value in each light image block and the comprehensive grayscale value can accurately reflect the light abnormality in each light image block.
[0086] S32: Divide the light image blocks into two categories according to the light anomaly degree, and obtain the value range of the sparse value of each element position of the sparse vector corresponding to the light image block in the category with a small light anomaly degree mean as the feasible value range.
[0087] Preferably, as an example, the light image blocks are divided into two categories according to the light anomaly degree, and the value range of the sparse value of each element position of the sparse vector corresponding to the light image block in the category with a small light anomaly mean is obtained as the feasible value range, including:
[0088] The degree of light anomaly is used as a classification index, and the K-means clustering algorithm is used to divide the light image blocks of image blocks at all block positions into two categories. The mean of the light anomaly degree of all light image blocks in each category is calculated, and the category with a small mean value of the light anomaly degree is taken as the normal category. All light image blocks at a block position in the normal category are obtained and recorded as normal light image blocks at the block position; the value range of all sparse values at a light-associated position is obtained in the sparse vector corresponding to the normal light image block at the block position as the feasible value range of the sparse value of the light-associated position in the sparse vector of the block position.
[0089] The feasible value range of the sparse values of the element positions other than the light-related position in the sparse vector of the block position is taken as the original sparse value.
[0090] It can be understood that the lighting conditions of the light image blocks in the category with a small mean light anomaly degree are better, and thus the sparse values corresponding to the light image blocks in the category with a small mean light anomaly degree can reflect the better lighting condition information. Therefore, the sparse values in the sparse vectors corresponding to the light image blocks in the category with a small mean light anomaly degree can be used to guide the sparse value adjustment, thereby achieving light adjustment.
[0091] S4: The sparse value of each element position in the sparse vector is taken as one of the values within the feasible value range, and the light adjustment image block is reconstructed using the revalued sparse vector, the image segmentation degree is calculated, and the sparse value of each element position is continuously adjusted until the image segmentation degree is minimized; the image is spliced using the light adjustment image block with the minimum image segmentation degree to achieve defect detection.
[0092] S40: taking a sparse value of each element position in the sparse vector as one of the values within a feasible value range, and reconstructing a light adjustment image block using the revalued sparse vector.
[0093] Preferably, as an example, taking a sparse value of each element position in the sparse vector as one of the values within a feasible value range, and reconstructing the light adjustment image block using the revalued sparse vector, including:
[0094] The sparse value of each element position in the sparse vector of each block position is taken as any value within the corresponding feasible value range, and the image block obtained by multiplying the re-valued sparse vector by the dictionary matrix is restored as the light adjustment image block of each block position.
[0095] S41: Calculate the degree of image segmentation.
[0096] It should be noted that since the light adjustment is performed on each image block separately, the light of the image blocks at different positions will be different after the adjustment, resulting in obvious light splitting between adjacent image blocks. Therefore, when adjusting the light, it is necessary to evaluate the light splitting between adjacent image blocks so that the adjusted light information is more natural.
[0097] Preferably, as an example, calculating the image segmentation degree includes:
[0098] Acquire a light-adjusted image block adjacent to the light-adjusted image block;
[0099] The outermost circle of pixels in the light adjustment image block is recorded as boundary pixels, the adjacent pixels of the boundary pixels are obtained in the adjacent light adjustment image block, the absolute value of the difference between the grayscale value of the boundary pixel and the grayscale value of the adjacent pixel is used as the splitting degree of the boundary pixel, the average of the splitting degrees of all boundary pixels in the light adjustment image block is used as the splitting degree of the light adjustment image block, and the average of the splitting degrees of all light adjustment image blocks is used as the image splitting degree.
[0100] It is understandable that in order to prevent obvious light splitting between adjacent image blocks, it is necessary to prevent obvious light jumps between adjacent image blocks; light splitting between adjacent image blocks can be prevented by ensuring that the grayscale difference between adjacent image blocks is small.
[0101] S42: Continuously adjust the sparse value of each element position until the image segmentation degree is minimized.
[0102] Preferably, as an example, the sparse value of each element position is continuously adjusted until the image segmentation degree is minimized, including:
[0103] The degree of image segmentation is taken as the objective function, and the feasible value range of all element positions in the sparse vector of each block position constitutes the solution space of the sparse vector of each block position. The genetic algorithm is used to solve the solution when the objective function takes the minimum value, which is used as the adjusted sparse vector of each block position. The image block obtained by multiplying the adjusted sparse vector by the dictionary matrix is restored as the light adjusted image block of each block position.
[0104] It is understandable that by constraining the sparse value adjustment through the image splitting degree, the light can be adjusted well while preventing the light splitting phenomenon from occurring.
[0105] It should be noted that, based on the solution space and the objective function, using a genetic algorithm to solve the objective function to obtain a minimum solution is a prior art and will not be described in detail here.
[0106] S43: Using the light with the minimum image segmentation degree to adjust the image blocks and stitch them together to obtain an image, so as to achieve defect detection.
[0107] Preferably, as an example, the image blocks are spliced using light with a minimum image splitting degree to achieve defect detection, including:
[0108] The image spliced by using the light-adjusted image blocks at all block positions is used as the automobile pipe image after light adjustment.
[0109] A design image of an automobile pipe is obtained, and edge detection processing is performed on the light-adjusted automobile pipe image to obtain an edge image. The design image is matched with the edge image, and edge lines in the edge image that do not match edge lines in the design image are obtained as defective edge lines.
[0110] It should be noted that by adjusting the light and eliminating the interference of reflection, the edge lines formed by reflection in the automobile tube image are effectively removed, so that only the structural edge lines and defect edge lines exist in the automobile tube image after the light adjustment. The edge lines in the design image reflect the structural edge lines, and the structural edge lines are excluded by the edge lines in the design image, thereby accurately extracting the defect edge lines.
[0111] An embodiment of the present invention further discloses an automobile pipe defect detection system, comprising a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, an automobile pipe defect detection method according to the present invention is implemented.
[0112] The above system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface, and their configuration and functions are known in the art, so they will not be described in detail here.
[0113] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium may be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory, a dynamic random access memory, a static random access memory, an enhanced dynamic random access memory, a high bandwidth memory, a hybrid storage cube, etc., or any other medium that can be used to store the required information and can be accessed by an application, a module, or both. Any such computer storage medium may be part of the device or accessible or connectable to the device.
[0114] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
[0115] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting defects in automobile pipe fittings, characterized in that: Includes steps: Collecting automobile pipe images at different viewing angles, adjusting the automobile pipe images to the same viewing angle, and then performing image block processing; All image blocks of a block position are obtained and recorded as image blocks of the same part; the sparse vector corresponding to the image blocks of the same part is decomposed by using the K-SVD algorithm; all element positions are clustered into two categories according to the variance of the sparse value of an element position in all sparse vectors; the element position in the category with a large mean of the variance of the sparse value is recorded as a light-related position; the sparse values of other element positions in the sparse vector except the light-related position are set to zero, and the light image block is reconstructed by using the sparse vector after being set to zero; Calculate the degree of light anomaly; The light image blocks are divided into two categories according to the degree of light anomaly, and the value range of the sparse value of each light-related position of the sparse vector corresponding to the light image block in the category with the smallest mean value of light anomaly is obtained as the feasible value range; the sparse value of each element position in the sparse vector is taken as one of the values in the feasible value range, and the light adjustment image block is reconstructed using the revalued sparse vector; Calculating the image splitting degree includes: obtaining the adjacent light-adjusted image blocks of the light-adjusted image block; The outermost circle of pixels in the light adjustment image block is recorded as boundary pixels, adjacent pixels of the boundary pixels are obtained in the adjacent light adjustment image block, the absolute value of the difference between the grayscale value of the boundary pixel and the grayscale value of the adjacent pixel is used as the splitting degree of the boundary pixel, the average of the splitting degrees of all boundary pixels in the light adjustment image block is used as the splitting degree of the light adjustment image block, and the average of the splitting degrees of all light adjustment image blocks is used as the image splitting degree; The sparse values of each element position are continuously adjusted until the image segmentation degree is minimized; the image blocks are spliced out using the light with the minimum image segmentation degree to achieve defect detection.
2. The method for detecting defects in automobile pipes according to claim 1, characterized in that: The calculating of the light abnormality degree comprises: The mean grayscale value of all pixels in the light image block is recorded as the comprehensive grayscale value of the light image block; the mean comprehensive grayscale value of all light image blocks except the light image block is recorded as the reference grayscale value; the absolute value of the difference between the comprehensive grayscale value of the light image block and the reference grayscale value is taken as the degree of light abnormality of the light image block.
3. The method for detecting defects in automobile pipes according to claim 1, characterized in that: The step of reconstructing the light image block by using the sparse vector after being set to zero includes: The vector obtained by splicing the rows of the image blocks at the same position is recorded as the same position vector; Using K-SVD algorithm to process all the same-position vectors, a dictionary matrix and a sparse vector corresponding to the same-position vector of each same-position image block are obtained; The vector obtained by multiplying the dictionary matrix with the zeroed sparse vector is restored to an image block, which is recorded as a light image block.
4. The method for detecting defects in automobile pipes according to claim 1, characterized in that: The method for obtaining the feasible value range includes: According to the degree of light abnormality, all light image blocks are clustered into two categories, and the category with a small average value of light abnormality is recorded as a normal category; all light image blocks at a block position are obtained in the normal category and recorded as normal light image blocks at the block position; the value range of all sparse values at a light-related position is obtained in the sparse vector corresponding to the normal light image block at the block position as the feasible value range of the sparse value at the light-related position in the sparse vector; The feasible value range of the sparse values of the element positions other than the light-related positions in the sparse vector is replaced by the original sparse values.
5. The method for detecting defects in automobile pipes according to claim 3, characterized in that: The step of taking a sparse value of each element position in the sparse vector as one of the values within a feasible value range, and reconstructing the light adjustment image block using the revalued sparse vector includes: The sparse value of each element position in the sparse vector of each block position is taken as any value within the corresponding feasible value range, and the image block obtained by multiplying the re-valued sparse vector by the dictionary matrix is restored as the light adjustment image block of each block position.
6. The automobile pipe defect detection method according to claim 1, characterized in that: The step of continuously adjusting the sparse value of each element position until the image fragmentation degree is minimized includes: The degree of image segmentation is taken as the objective function, and the feasible value range of all element positions in the sparse vector of each block position constitutes the solution space of the sparse vector of each block position. The genetic algorithm is used to solve the solution when the objective function takes the minimum value, which is used as the adjusted sparse vector of each block position. The image block obtained by multiplying the adjusted sparse vector by the dictionary matrix is restored as the light adjusted image block of each block position.
7. The automobile pipe defect detection method according to claim 1, characterized in that: The method of using light rays with the minimum image splitting degree to adjust the image blocks and stitching out an image to achieve defect detection includes: An image obtained by splicing the light-adjusted image blocks at all the divided positions is used as an image of the automobile pipe after light adjustment; A design image of an automobile pipe is obtained, and edge detection processing is performed on the light-adjusted automobile pipe image to obtain an edge image. The design image is matched with the edge image, and edge lines in the edge image that do not match edge lines in the design image are obtained as defective edge lines.
8. The automobile pipe defect detection method according to claim 1, characterized in that: The step of adjusting the automobile pipe image to the same viewing angle and then performing image block processing comprises: One of the viewing angles is used as a reference viewing angle, the automobile tube images at other viewing angles are adjusted to the reference viewing angle, and the automobile tube images at each viewing angle after the viewing angle adjustment are evenly divided into a number of image blocks.
9. An automobile pipe defect detection system, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, an automobile pipe defect detection method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Improved YOLO-v8-based pipe surface defect detection method
CN118485648A
Shaft sleeve part surface defect on-line detection method based on compressed sensing
CN104063873A
Small-diameter pipe inside weld surface defect identification device
CN105938620A