A Vision-Based Method and System for Defect Detection in Automotive Engine Blocks
By introducing a post-processing filtering mechanism with spatial region constraints and forward and reverse detection strategies, the problems of high false detection rate and difficulty in identifying rare defects in engine block inspection are solved, achieving efficient and accurate defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-14
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies cannot effectively distinguish between critical and non-critical areas in the defect detection of automotive engine blocks, resulting in a high false detection rate and difficulty in identifying rare defects, thus failing to meet the requirements for high-quality detection.
A post-processing filtering mechanism based on spatial region constraints is adopted, which combines forward and reverse detection strategies. The initial detection results are filtered through predefined spatial region constraint rules to process forward and reverse detection defects respectively, thereby achieving accurate detection of key regions and identification of rare defects.
It reduced the false detection rate, improved the reliability and practicality of the test results, and achieved comprehensive and effective automated quality inspection of engine blocks.
Smart Images

Figure CN121121325B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of defect detection technology, and in particular to a method and system for detecting defects in automobile engine cylinder blocks based on visual inspection. Background Technology
[0002] In automotive cylinder block manufacturing, AI-powered intelligent vision inspection technology uses cameras to capture images and then identifies defects through target detection. First, collecting a sufficiently diverse and representative dataset of anomalies is particularly difficult for complex components like cylinder blocks. The cylinder block's complex structure and the variety of possible anomaly forms make comprehensive coverage challenging, limiting the generalization ability of the trained model. Second, different regions of the cylinder block have varying sensitivities and acceptable standards for defects. For example, the cylinder bore region has extremely high requirements for dimensional accuracy and surface finish, while some non-load-bearing areas are relatively less demanding. This makes it difficult to use a single model or standard to detect all types of defects in all regions, requiring customized detection strategies or models for different regions, increasing system complexity and implementation difficulty. Existing target detection models have significant limitations when dealing with complex components such as engine cylinder blocks. First, they cannot distinguish between critical and non-critical areas, leading to false positives for areas that do not require detection, thus increasing the false detection rate. Second, they are prone to misclassifying normal local design features as defects. Third, for rare defects, negative samples are extremely difficult to collect, and traditional methods cannot be effectively trained and identified through defect marking, resulting in a high risk of missed detection in actual production and making it difficult to meet the requirements of high-quality testing. Therefore, how to achieve accurate detection of engine block defects and reduce the frequency of false detections and false alarms is an urgent problem to be solved in this field. Summary of the Invention
[0003] Therefore, the purpose of this invention is to provide a visual inspection-based method and system for detecting defects in automotive engine cylinder blocks. This system organically combines a post-processing filtering mechanism based on spatial area constraints with reverse detection techniques within a unified framework. This allows for flexible responses to complex inspection needs of different areas and types on the engine cylinder block, enabling more comprehensive and efficient automated quality inspection and reducing false detections and false alarms.
[0004] To achieve the above objectives, the present invention provides a vision-based method for detecting defects in automotive engine cylinder blocks, comprising the following steps:
[0005] Acquire an image of the engine block to be inspected;
[0006] The engine block image is input into the target detection model to obtain an initial detection result set containing at least one detection box. Each detection box in the initial detection result set contains position coordinates and defect category information. The defect category information is divided into forward detection defects and reverse detection defects.
[0007] Based on predefined spatial region constraint rules, the initial detection result set is post-processed and filtered to generate accurate detection results;
[0008] The post-processing filtering includes at least one of the following processing modes:
[0009] First processing mode: For positive detection type defects, the initial detection result is matched with at least one predefined first type ground truth box, and the initial detection result is either retained or filtered according to the matching result and the associated filtering rules.
[0010] The second processing mode: For reverse detection type defects, the detection boxes representing normal features in the initial detection results are matched with at least one predefined second type of real boxes. If the matching fails, it is determined that the second type of real box has a defect of missing normal features.
[0011] More preferably, the first processing mode includes:
[0012] The first type of real bounding box is predefined and associated with filtering rules, which are used to specify the defect categories that need to be retained or masked in this area;
[0013] Calculate the coordinates of the center point of the detection box corresponding to each initial detection result;
[0014] Determine whether the coordinates of the center point fall within the first type of real bounding box;
[0015] If and only if the center point coordinates fall within the first type of true bounding box, then a decision is made on whether to retain the detection result based on the filtering rules and the defect category information of the detection box.
[0016] More preferably, the coordinates of the center point of the detection frame are calculated according to the following formula.
[0017] / 2
[0018] / 2
[0019] Among them, (x center, y center () represents the coordinates of the center point; (x min , y min ) This represents the bottom left corner of the detection frame. (x max , y max ) This represents the top right corner of the detection frame;
[0020] More preferably, the first type of true bounding box is a rectangular region; the distance between the center point of the detection box and the rectangular region is calculated according to the following formula, and it is determined whether the center point of the detection box falls within the rectangular region:
[0021] The rectangular region is represented as:
[0022] detect_area=( detect_x min ,detect_y min ,detect_x max ,detect_y max )
[0023] Determine if it satisfies detect_x min <x center <detect_x max and detect_y min <y center <detect_ y max If the condition is met, the center point of the detection box falls within the rectangular area; otherwise, the center point of the detection box is outside the rectangular area.
[0024] More preferably, the first type of true bounding box is a circular region. The distance between the center point of the detection box and the circular region is calculated according to the following formula to determine whether the center point of the detection box is within the circular region:
[0025]
[0026] If the distance is less than or equal to the detection box radius r, the center of the detection box is determined to be within the circular area; otherwise, it is determined to be outside the circular area. The x-coordinate of the center point of the circular region; The vertical coordinate represents the center point of the circular region.
[0027] More preferably, the filtering rules include at least one of the following:
[0028] Area whitelist rule: The detection result is retained only when the center point of the detection box falls into a detection area and its defect category belongs to the preset allowed category set of that area;
[0029] Area blacklist rule: If the center point of the detection box falls into a detection area and its defect category belongs to the preset masking category set of that area, then the detection result is filtered.
[0030] More preferably, the second processing mode includes:
[0031] All real standard regions that require reverse defect identification are statistically analyzed and used as the second type of real bounding boxes;
[0032] The detection boxes in the initial detection result set are matched with each of the second type of real boxes;
[0033] When all detection boxes fail to match any of the second type of ground truth boxes, it is determined that the region has a feature missing defect.
[0034] More preferably, when matching the detection box with the second type of real bounding box, the following steps are included:
[0035] Calculate the similarity scores between the detection box and the second type of ground truth boxes in multiple dimensions; perform a weighted summation of the similarity scores in the multiple dimensions to obtain the overall quality score (QS);
[0036] ;
[0037] Where w1 is the positional overlap weight, w2 is the shape similarity weight, and w3 is the orientation alignment weight; and w 1+ w2+w3=1; S_DIoU represents positional overlap, S_Shape represents shape similarity, and S_Angle represents orientational alignment.
[0038] The overall quality score QS is compared with a preset threshold. If the overall quality score QS ≤ the preset threshold, it is determined that the match has failed.
[0039] Furthermore, the positional overlap S_DIoU = IoU - (d 2 / c 2 );
[0040] Shape similarity S_Shape= ;
[0041] Orientation alignment S_Angle = 1 - (|θ_pred - θ_gt| / 90°);
[0042] Where d is the Euclidean distance between the center points of the detection box and the second type of ground truth boxes; c is the diagonal length of the minimum bounding rectangle of the detection box and the second type of ground truth boxes; and IoU is the intersection-union ratio of the detection box and the second type of ground truth boxes. Indicates the width of the detection box; Indicates the width of the actual bounding box; Indicates the height of the detection frame; θ_pred represents the height of the ground truth bounding box; θ_gt represents the angle of the detection bounding box; θ_gt represents the angle of the ground truth bounding box.
[0043] This application also provides a vision-based automotive engine cylinder block defect detection system, comprising the steps of implementing the aforementioned vision-based automotive engine cylinder block defect detection method, including:
[0044] The image acquisition module is used to acquire images of the engine block to be detected.
[0045] The model inference module is used to input the image into the target detection model to obtain an initial set of detection results;
[0046] The region post-processing module is configured to perform post-processing filtering on the initial detection result set based on predefined spatial region constraint rules to generate accurate detection results;
[0047] The region post-processing module includes:
[0048] The first processing unit is used to execute the first processing mode described above for defects detected in the positive direction.
[0049] The second processing unit is used to execute the second processing mode described above for reverse detection type defects.
[0050] This application discloses a vision-based method and system for detecting defects in automotive engine cylinder blocks. By introducing a post-processing filtering mechanism based on spatial region constraints, it allows users to precisely define the detection area and associate filtering rules (such as whitelists and blacklists), effectively filtering false alarms caused by normal structures and improving the reliability and practicality of the detection results. Through spatial region restrictions, only detection results located in "critical areas" are retained, while those located in "non-critical areas" or "low-confidence areas" are filtered out, achieving a significant reduction in the false detection rate. This application innovatively proposes a "reverse detection" strategy. This strategy only requires training with readily available positive sample (normal product) data, and indirectly infers whether a normal feature is "missing" by judging whether it "exists" at a predetermined location, thus overcoming the application bottleneck of traditional target detection models in data-imbalanced scenarios. Attached Figure Description
[0051] Figure 1 This is a schematic diagram of the structure of the vision-based inspection method for detecting defects in automobile engine cylinder blocks proposed in this invention.
[0052] Figure 2 This is a schematic diagram of the structure of the first processing mode proposed in this invention;
[0053] Figure 3 This is a schematic diagram of the second processing mode proposed in this invention. Detailed Implementation
[0054] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0055] Most existing target detection models can only guarantee accuracy for single-item defect detection of a single model. When it comes to defect detection of complex components like engine blocks, they cannot simultaneously output multi-faceted inspection results for the engine block under inspection. For example, not all surfaces of the block need to be inspected for defects; certain non-working surfaces, chamfered areas, or specific marked areas may be excluded from the detection range. If these areas are not explicitly excluded, any features detected by the model in these areas that it considers "defects" will be reported, increasing the number of false positives. Cylinder blocks typically have bolt holes, locating pin holes, bosses, or grooves for mounting other components. These are normal design features. The edges, hole walls, or surface textures of these features may be similar to certain defects (such as scratches or dents). Without limiting the detection area, the model might misreport the edges or surface textures of these installation features as defects, such as identifying minor undulations at the edge of a bolt hole as a "pit." On the other hand, when inspecting cylinder blocks, there are often requirements to detect thread and chamfer defects in a specific area. However, in reality, thread and chamfer defects are very rare and cannot be identified by marking existing thread and chamfer defects. Furthermore, real-world thread and chamfer defects are diverse, and conventional detection methods are insufficient for scenarios where negative samples, such as missing threads or chamfers, are extremely difficult to collect. Therefore, this application proposes two processing modes, which can be chosen independently or in parallel depending on the detection needs. Figure 1 As shown in the figure, one embodiment of the present invention provides a vision-based method for detecting defects in an automotive engine cylinder block, comprising the following steps:
[0056] Acquire an image of the engine block to be inspected;
[0057] The engine block image is input into the target detection model to obtain an initial detection result set containing at least one detection box. Each detection box in the initial detection result set contains position coordinates and defect category information. The defect category information includes forward detection defects and reverse detection defects.
[0058] Based on predefined spatial region constraint rules, the initial detection result set is post-processed and filtered to generate accurate detection results. It should be noted that the predefined spatial region constraint rules (i.e., the forward detection and reverse detection of defects in the subsequent two modes) are based on prior spatial location judgment rules. That is, when a defect occurs, it is only necessary to determine whether the defect is the one to be displayed according to the set defect detection area. This application uses a first type of true bounding box to represent the true detection area of forward detection defects and a second type of true bounding box to represent the true detection area of reverse detection defects.
[0059] Forward detection defects are those that can be directly identified as defects themselves. For example, when detecting scratches or dents, only the detection area of this type of defect (i.e., the first type of true bounding box) and a whitelist or blacklist of the area are required for forward detection. For example, in the "cylinder bore inner surface" area, the whitelist only detects scratches. If a "dent" is detected in this area, it will be filtered out.
[0060] Reverse detection of defects involves indirectly inferring feature-deficient defects by identifying normal features. This method is suitable for defects with missing features (such as missing threads or chamfers). When the overall quality score (QS) between the detection box (representing a normal feature) and a predefined second ground truth box in multiple dimensions (position, shape, orientation, etc.) exceeds a threshold, the region is considered normal. Matching failure rule: If a second ground truth box fails to achieve sufficient matching with any detection box, then the feature at that location is considered missing, i.e., a defect exists.
[0061] The post-processing filtering includes at least one of the following processing modes:
[0062] First processing mode: For positive detection type defects, the initial detection result is matched with at least one predefined first type real bounding box, and the initial detection result is retained or filtered according to the matching result and the associated filtering rules; to solve the problem that false alarms often occur in specific location areas, such as certain non-working surfaces, chamfer areas and other areas that do not need to be detected, and reduce the occurrence of false alarms.
[0063] More preferably, the first processing mode includes:
[0064] S101. Predefine the first type of real bounding box and associate it with filtering rules, wherein the filtering rules are used to specify the defect categories that need to be retained or masked in this area;
[0065] S102. Calculate the coordinates of the center point of the detection box corresponding to each initial detection result;
[0066] The coordinates of the center point of the detection frame are calculated according to the following formula.
[0067] / 2
[0068] / 2
[0069] Among them, (x center, y center () represents the coordinates of the center point; (x min , y min ) This represents the bottom left corner of the detection frame. (x max , y max ) This represents the upper right corner of the detection frame.
[0070] S103. Determine whether the coordinates of the center point fall within the first type of real bounding box;
[0071] S104. If the result falls within the range, then based on the filtering rules and the defect category information of the detection box, decide whether to retain the detection result.
[0072] It should be noted that, in determining whether the center point of the detection box is within the specified area, the first type of real bounding box can be either a circle or a rectangle, and the determination is made in conjunction with the label ID.
[0073] If only scratches are detected within the specified detection area, first determine if the detected defect ID is a scratch ID, then determine if the center point of the detection box is within the area of the first type of true bounding box. If both conditions are met, save the result; otherwise, filter it out. If only scratch defects are masked, first determine if the detected result ID is a scratch, then determine if the center point is within the area. If it is within the area, filter it out; save all other results.
[0074] If it is a rectangular frame, the center point (x) of the detection frame can be determined directly. _center ,y _center Whether the position is within the detection range of the given rectangular bounding box. The rectangular region is represented as:
[0075] detect_area=( detect_x min ,detect_y min ,detect_x max ,detect_y max )
[0076] Determine if it satisfies detect_x min <x center <detect_x max and detect_ymin <y center <detect_ y max If the condition is met, the center point of the detection box falls within the detection area; otherwise, the center point of the detection box is outside the detection area. Combining this with the tag ID allows for the filtering of false detections.
[0077] Therefore, further, the first type of true bounding box is a rectangular region; the distance between the center point of the detection box and the rectangular region is calculated according to the following formula, and it is determined whether the center point of the detection box falls within the rectangular region:
[0078] The rectangular region is represented as detect_area=( detect_x min ,detect_y min ,detect_x max ,detect_ y max )
[0079] Determine if it satisfies detect_x min <x center <detect_x max and detect_y min <y center <detect_ y max If the condition is met, the center point of the detection box falls within the rectangular area; otherwise, the center point of the detection box is outside the rectangular area.
[0080] After specifying the detection area, you can also skip calculating the center point of the detection box and directly use the coordinates of the detection box. x min , y min , xmax ,y max A similar effect can be achieved by comparing the data with the first type of real bounding box in the specified detection area.
[0081] Detection box coordinates:
[0082] ( x min ,y min , xmax ,ymax ) ,
[0083] First type of ground truth bounding box coordinates:
[0084] ( detect_x min ,detect_y min ,detect_x max ,detect_y max )
[0085] judge:
[0086] detect_x min < x min < detect_x max
[0087] detect_y min < y min < detect_y max
[0088] detect_x min < x max < detect_x max
[0089] detect_y min < y max < detect_y max
[0090] If all four conditions are met, the area is considered to be within the detection range; otherwise, it is not.
[0091] More preferably, the first type of true bounding box is a circular region. The distance between the center point of the detection box and the circular region is calculated according to the following formula to determine whether the center point of the detection box is within the circular region:
[0092]
[0093] When distance distance Less than or equal to the detection frame radius r If the center of the detection box is within the circular area, it is determined that the center of the detection box is within the circular area; otherwise, it is determined that the center is outside the circular area. The x-coordinate of the center point of the circular region; The vertical coordinate represents the center point of the circular region.
[0094] More preferably, the filtering rules include at least one of the following:
[0095] Area whitelist rule: The detection result is retained only when the center point of the detection box falls into a detection area and its defect category belongs to the preset allowed category set of that area;
[0096] Area blacklist rule: If the center point of the detection box falls into a detection area and its defect category belongs to the preset masking category set of that area, then the detection result is filtered.
[0097] Another embodiment of this application provides a second processing mode: for reverse detection type defects, the detection box representing normal features in the initial detection result is matched with at least one predefined second-type real box. If the match fails, it is determined that the second-type real box has a feature missing defect. The second processing mode is used for rare defects such as missing threads and chamfers. Because negative samples are extremely difficult to collect, traditional methods cannot be effectively trained and identified through defect marking, resulting in a high risk of missed detection in actual production. Reverse detection is used to address this issue. If the detected detection box represents normal features and matches successfully with the second-type real box, it indicates that the thread exists. If the match fails, it indicates that the thread is missing at that location.
[0098] This processing mode is suitable for actual inspections of parts that are not prone to defects or have no inspection requirements but are prone to missing parts, such as thread inspection. Since it is rare for cylinder block production to be without threads, but there is a need to detect the presence or absence of threads, this algorithm can be used to first collect thread images, label them, and then train a visual inspection model. At this time, the model can recognize threads normally, but it cannot tell when threads are missing.
[0099] It should be noted that the detection box is the recognition result of the target location output by the target recognition algorithm. The position of the detection box in the recognition result may not be accurate. Therefore, it is necessary to manually mark the true box of the target's actual location to determine which detection boxes need to be kept and which need to be removed.
[0100] Furthermore, the second processing mode includes:
[0101] S201. Collect all real standard regions that require reverse defect identification as the second type of real bounding boxes;
[0102] S202, Match the detection boxes in the initial detection result set with each of the second type of real boxes;
[0103] S203. When all detection boxes fail to match any of the second type of real boxes, it is determined that the region has a normal feature missing defect.
[0104] This involves acquiring the region for each thread and marking the detection frame for each thread. The system determines whether a detection result is found for the corresponding thread based on the region. If a result is found, the thread is considered OK; otherwise, the result for the given region is saved, and the thread is considered NG.
[0105] When matching the detection box with the second type of real bounding box, the following steps are included:
[0106] Calculate the similarity scores between the detection box and the second type of ground truth boxes in multiple dimensions; perform a weighted summation of the similarity scores in the multiple dimensions to obtain the overall quality score (QS);
[0107] ;
[0108] Where w1 is the positional overlap weight, w2 is the shape similarity weight, and w3 is the orientation alignment weight; and w 1+ w2+w3=1; S_DIoU represents positional overlap, S_Shape represents shape similarity, and S_Angle represents orientational alignment.
[0109] The overall quality score QS is compared with a preset threshold. If the overall quality score QS ≤ the preset threshold, it is determined that the match has failed.
[0110] Furthermore, the positional overlap S_DIoU = IoU - (d 2 / c 2 );
[0111] Shape similarity S_Shape= ;
[0112] Orientation alignment S_Angle = 1 - (|θ_pred - θ_gt| / 90°);
[0113] Where d is the Euclidean distance between the center points of the detection box and the second type of ground truth boxes; c is the diagonal length of the minimum bounding rectangle of the detection box and the second type of ground truth boxes; and IoU is the intersection-union ratio of the detection box and the second type of ground truth boxes. Indicates the width of the detection box; Indicates the width of the actual bounding box; Indicates the height of the detection frame; θ_pred represents the height of the ground truth bounding box; θ_gt represents the angle of the detection bounding box; θ_gt represents the angle of the ground truth bounding box.
[0114] When calculating positional overlap, IoU represents the ratio of the intersection area to the union area of the ground truth bounding box and the detection bounding box of type II.
[0115] When calculating IoU, the coordinates of the detection box at this moment are recorded as ( x A1,y A1, x A2, y A2 The coordinates of the second type of ground truth bounding box are ( x B1, y B1, x B2, y B2 )
[0116] Therefore, the coordinates of the intersection region are calculated as ( x left, y top, x right, y bottom ):
[0117] x left =max(x A1 ,x B1 ),y top =max(y A1 ,y B1 )
[0118] x right =min(x A2 ,x B2 ),y bottom =min(y A2, y B2 )
[0119] Then determine if... x left <x right and y top <y bottom ,
[0120] The area of the intersection region is:
[0121] Area_Intersection=(x right- x left )×(ybottom- y top )
[0122] Otherwise, it is considered that there is no intersection, and the value is 0, indicating that the two boxes do not overlap.
[0123] For example: the coordinates of the detection bounding box are [x1, y1, x2, y2] = [30, 30, 90, 90]; the coordinates of the second type of ground truth bounding box are [50, 50, 110, 110]; then the coordinates of the intersection region are:
[0124] x left= max(30, 50)=50
[0125] y top= max(30, 50)=50;
[0126] x right= min(90, 110)=90
[0127] y bottom= min(90, 110) = 90;
[0128] The area of the intersection region is (90 - 50) * (90 - 50) = 40 * 40 = 1600.
[0129] Then calculate the area of the union region:
[0130] Area_Union=Area_A + Area_B -Area_Intersection
[0131] in: Area_A=(x A2- x A1 )×(y A2- y A1 ),Area_B=(x B2- x B1 )×(y B2- y B1 )
[0132] Finally, calculate IoU:
[0133]
[0134] The value will be between 0 and 1, representing the area of overlap between the two boxes. Then, the threshold is set according to the actual situation to filter and retain.
[0135] Therefore, it can be seen that the positional overlap ratio (DIoU) not only considers area but also retains the scale invariance of IoU, directly penalizing cases where the center point is off-center. Moreover, even if two boxes have the same IoU, the box with the closer center point is clearly of higher quality and will have a higher DIoU value.
[0136] DIoU = IoU - (d 2 / c 2 )
[0137] Where d is the Euclidean distance between the center points of the detection box and the ground truth box, and c is the diagonal length of the minimum bounding rectangle between the detection box and the ground truth box. The value range of DIoU is also between [0, 1], and it has the same semantics as IoU (the larger the value, the better).
[0138] Furthermore, when calculating shape similarity:
[0139] S_Shape= ,
[0140] Where d is the Euclidean distance between the center points of the detection box and the second type of ground truth boxes; c is the diagonal length of the minimum bounding rectangle of the detection box and the second type of ground truth boxes; and IoU is the intersection-union ratio of the detection box and the second type of ground truth boxes. Indicates the width of the detection box; Indicates the width of the actual bounding box; Indicates the height of the detection frame; θ_pred represents the height of the ground truth bounding box; θ_gt represents the angle of the detection bounding box; θ_gt represents the angle of the ground truth bounding box.
[0141] The shape similarity S_Shape value ranges more towards [0,1]. The closer this value is to 1, the more similar the aspect ratios are. Therefore, shape similarity can assess whether the aspect ratios of the detected bounding box and the ground truth bounding box match.
[0142] Furthermore, this application also sets an orientation alignment dimension for thread-like objects, that is, if it is a rotating frame, it evaluates whether their angles are aligned.
[0143] When the detection box has an angle θ, then: S_Angle=1 - (|θ_pred - θ_gt| / 90°)
[0144] Angle similarity = |θ_pred-θ_gt| minus the minimum value (considering 180-degree symmetry).
[0145] The closer this value is to 1, the more consistent the directions are.
[0146] In summary, after standardizing the above dimensions into a comprehensive quality score (QS), ensure that all indicators are in the range of [0,1], with larger values being better.
[0147] S_DIoU = DIoU (DIoU itself is approximately [0,1])
[0148] S_Shape It is already in the interval [0,1].
[0149] S_Angle It is already in the interval [0,1].
[0150] The comprehensive quality score calculation formula requires a weighted sum of the above multiple parameters, with weights allocated according to business needs. For example... w 1 = 0.6( Location is the most important factor. w 2 = 0.3 (Shape is of secondary importance) w 3 = 0.1 (The angle is used for fine-tuning) Therefore, the overall quality score (QS) is expressed by the following formula:
[0151] ;
[0152] If and only if QS > T_final ( T_final This is a newly set comprehensive threshold, for example, 0.5), which is considered OK when a match is successful. QS <= T_final If the match fails, output NG.
[0153] This application also provides a vision-based automotive engine cylinder block defect detection system, comprising the steps of implementing the aforementioned vision-based automotive engine cylinder block defect detection method, including:
[0154] The image acquisition module is used to acquire images of the engine block to be detected.
[0155] The model inference module is used to input the image into the target detection model to obtain an initial set of detection results;
[0156] The region post-processing module is configured to perform post-processing filtering on the initial detection result set based on predefined spatial region constraint rules to generate accurate detection results;
[0157] The region post-processing module includes:
[0158] The first processing unit is used to execute the first processing mode for defects detected in the positive direction.
[0159] The second processing unit is used to execute the second processing mode for reverse detection type defects.
[0160] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. A method for detecting defects in a cylinder block of an automobile engine based on visual inspection, characterized by, The method comprises the following steps: obtaining an engine cylinder image to be detected; inputting the engine cylinder image into a target detection model to obtain an initial detection result set containing at least one detection box, wherein each detection box in the initial detection result set contains position coordinates and defect category information; dividing the defect category information into positive detection category defects and reverse detection category defects; the positive detection category defects are defects that can be directly identified; the reverse detection category defects are feature missing type defects that are indirectly inferred by identifying normal features; performing post-processing filtering on the initial detection result set based on a predefined spatial region constraint rule to generate accurate detection results; wherein the post-processing filtering based on the predefined spatial region constraint rule comprises at least one of the following processing modes: a first processing mode: for the positive detection category defects, matching the initial detection result with at least one first type of real box, and performing a reservation or filtering operation on the initial detection result according to the matching result and the associated filtering rule; a second processing mode: for the reverse detection category defects, matching the detection box representing the normal feature in the initial detection result with at least one second type of real box, and if the matching fails, it is determined that the second type of real box has a normal feature missing defect; the first type of real box represents the real detection area of the positive detection category defect, and the second type of real box represents the real detection area of the reverse detection category defect.
2. The method for detecting defects in a cylinder block of an automobile engine based on visual inspection according to claim 1, characterized in that, The first processing mode comprises: predefining the first type of real box and associating a filtering rule, which is used to indicate the defect categories that need to be reserved or shielded in the area; calculating the center point coordinates of each initial detection result corresponding detection box; determining whether the center point coordinates fall within the first type of real box; only when the center point coordinates fall within the first type of real box, it is determined whether to reserve the detection result according to the filtering rule and the defect category information of the detection box.
3. The method for detecting defects in a cylinder block of an automobile engine based on visual inspection according to claim 2, characterized in that, The coordinates of the center point of the detection box are calculated according to the following formula: / 2 / 2 wherein, x center ,y center is the center point coordinate; x min ,y min represents the left lower corner point of the detection frame, x max ,y max represents the right upper corner point of the detection frame; The first type of real box is a rectangular area; the distance between the center point of the detection box and the rectangular area is calculated according to the following formula to determine whether the center point of the detection box falls within the rectangular area: The rectangular area is expressed as detect_area = (x, y, w, h) detect_x min ,detect_y min ,detect_x max ,detect_y max ) determining whether or not the condition is satisfied detect_x min <x center <detect_x max and detect_y min <y center <detect_y max If the condition is satisfied, the center point of the detection frame falls within the rectangular region, and if the condition is not satisfied, the center point of the detection frame is outside the rectangular region.
4. The method for detecting defects in a cylinder block of an automobile engine based on visual inspection according to claim 2, characterized in that, The first type of real box is a circular area; the distance between the center point of the detection box and the circular area is calculated according to the following formula to determine whether the center point of the detection box falls within the circular area: When the distance distance is less than or equal to the detection frame radius r , it is determined that the center of the detection frame is within the circular region, otherwise it is determined to be outside the circular region, x represents the horizontal coordinate of the center point of the circular region; y represents the vertical coordinate of the center point of the circular region.
5. The method for detecting defects in a cylinder block of an automobile engine based on visual inspection according to claim 1, characterized in that, The filtering rule comprises at least one of the following: region white list rule: only when the center point of the detection box falls within a detection area and its defect category belongs to the preset allowed category set of the area, the detection result is reserved; region black list rule: if the center point of the detection box falls within a detection area and its defect category belongs to the preset shielding category set of the area, the detection result is filtered.
6. The method for detecting defects in a cylinder block of an automobile engine based on visual inspection according to claim 1, characterized in that, The second processing mode comprises: counting all real standard regions that need reverse identification of defects as the second type of real box; Matching the detection frame in the initial detection result set with the second type of real frame is judged; When all detection frames fail to match any of the second type of real frame, it is determined that the region has a feature missing defect.
7. The method for detecting defects in a cylinder block of an automobile engine based on visual inspection according to claim 6, characterized in that, When the detection frame is matched with the second type of real frame, the following steps are included: Calculate the similarity score of the detection frame and the second type of real frame in multiple dimensions; Weighted sum of the similarity scores of the multiple dimensions to obtain the comprehensive quality score QS; QS= w 1 * S_DIoU + w 2 * S_Shape + w 3 * S_Angle ; wherein, w 1 is a position coincidence weight, w 2 is a shape similarity weight ,w 3 is a direction alignment weight; and w 1+ w 2 +w 3 =1 ; S_DIoU represents a position coincidence, S_Shape represents a shape similarity; S_Angle represents a direction alignment; The comprehensive quality score QS Compared with a preset threshold, when the overall quality score QS If the value is less than or equal to the preset threshold, the match is considered to have failed.
8. The method for detecting defects in a cylinder block of an automobile engine based on visual inspection according to claim 7, characterized in that, the position coincidence degree S_DIoU=IoU - (d² / c²) ; Shape similarity ; Direction alignment S_Angle=1 - (|θ_pred - θ_gt| / 90°); wherein d: is the Euclidean distance between the detection box and the center point of the second type of real box; c: is the diagonal line length of the minimum circumscribed rectangle of the detection box and the second type of real box; and IoU is the intersection over union of the detection box and the second type of real box. represents the width of the detection box; represents the width of the real box; represents the height of the detection box; represents the height of the real box; θ_pred represents the angle of the detection box; and θ_gt represents the angle of the real box.
9. A visual inspection based system for detecting defects in a cylinder block of an automobile engine, characterized in that, The steps for implementing the visual detection-based automobile engine cylinder defect detection method of any one of claims 1-8 include: An image acquisition module for acquiring an engine cylinder image to be detected; A model inference module for inputting the image to a target detection model to obtain an initial detection result set; A region post-processing module configured to post-process and filter the initial detection result set based on predefined spatial region constraint rules to generate accurate detection results; The region post-processing module includes: A first processing unit for performing the first processing mode as claimed in any one of claims 2 to 5 for forward detection class defects; A second processing unit for performing the second processing mode as claimed in any one of claims 6 to 8 for reverse detection class defects.
Citation Information
Patent Citations
Appearance detection and defect judgment system and method for automobile engine cylinder cover based on machine vision, storage medium and computer program product
CN120009281A
Power transmission line high-altitude anomaly detection method combining positive and negative sample algorithms
CN120298779A