Workpiece missing detection method based on ai vision
By constructing a historical detection result database and using causal reasoning methods, the AI visual detection parameters are adaptively optimized and cross-face logically correlated, solving the problems of detection parameter deviation and inconsistency in multi-face detection results, thus improving detection accuracy and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGXI LINGYUN AUTOMOBILE IND TECH CO LTD
- Filing Date
- 2026-05-22
- Publication Date
- 2026-06-19
AI Technical Summary
Existing AI visual inspection technologies in industrial applications suffer from problems such as detection parameters deviating from the optimal state, lack of consistency verification of multi-faceted inspection results, and lack of closed-loop linkage between detection parameter adjustment and root cause tracing results, resulting in insufficient detection accuracy and stability.
By constructing a template adaptive optimization mechanism driven by a historical test result database, parameter adjustments are made using qualified and unqualified samples. A dynamic threshold multi-faceted collaborative detection method guided by a benchmark surface is adopted, combined with causal reasoning methods for root cause analysis, to achieve adaptive optimization of detection parameters and cross-faceted logical association.
It improves the adaptability of the detection template, enhances the accuracy of missing part detection for multi-faceted workpieces, reduces false detections and misjudgments, and improves detection efficiency and system stability.
Smart Images

Figure CN122244053A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision, and in particular to a method for detecting missing workpieces based on AI vision. Background Technology
[0002] In the context of intelligent manufacturing in industry, AI visual inspection has become a core technology for product quality control. The rapid development of deep learning and computer vision technologies has driven the widespread application of AI visual inspection systems in tasks such as surface defect identification and assembly integrity inspection of industrial parts. Object detection methods based on convolutional neural networks (CNNs), such as the YOLO series models and their variants, have been extensively applied to tasks such as hole detection, surface scratch identification, and component assembly integrity assessment in industrial products, significantly improving the level of automation and efficiency of inspection. In recent years, transfer learning techniques based on pre-trained models have further enhanced the generalization ability of AI visual inspection models in small-sample scenarios, and intelligent analysis methods based on knowledge graphs and causal reasoning have also begun to be explored in the field of industrial defect tracing.
[0003] However, current AI visual inspection technologies still face the following technical challenges in practical industrial applications, hindering further improvements in inspection accuracy and system stability: Firstly, in existing AI vision inspection systems, the inspection templates (including brightness parameters, inspection strategy parameters, and inspection surface division parameters) for different workpiece models are typically pre-configured by technicians during production deployment and remain unchanged throughout the entire production cycle. Although some research has used pre-trained AI vision models for feature extraction, the acquisition parameters input to the model (such as brightness and exposure time) still rely on static templates. With changes in production batches, fluctuations in lighting conditions, and performance degradation of camera hardware over time, the originally adapted inspection parameters gradually deviate from their optimal state, leading to a decrease in the quality of the input images to the AI vision inspection model and consequently, a degradation in inspection accuracy.
[0004] Secondly, for complex workpieces with multiple inspection surfaces (such as the front, side, and bottom), existing AI vision inspection methods typically perform image acquisition and AI model inference independently for each inspection surface, lacking logical connections and consistency verification mechanisms at the result level between the inspection surfaces. When a false detection occurs on a certain inspection surface due to poor lighting, occlusion, or positional offset, the system cannot determine whether the detection result indicates a defect in the workpiece itself or a misjudgment caused by the input quality of the AI vision inspection model. It is also difficult to perform logical verification between the detection results of different inspection surfaces. Although some research has attempted to use the output confidence level of the AI vision inspection model as a reference indicator of inspection reliability, the confidence level is usually only used for quality judgment of a single inspection and has not been used for cross-surface consistency verification or as an active basis for subsequent decisions. This technical deficiency is particularly prominent in the inspection of long workpieces such as longitudinal beams and irregularly shaped workpieces.
[0005] Third, when the inspection system identifies missing defects in a workpiece or inconsistencies in the inspection results, existing technologies typically handle this by manual re-inspection, full re-inspection, or issuing alarm messages. This makes it difficult to automatically distinguish whether the root cause of the defect is a defect in the workpiece itself or a false detection due to parameter degradation in the inspection system. In recent years, AI visual reasoning models based on knowledge graphs and causal reasoning have begun to be applied in the field of industrial defect tracing, enabling analysis of the process causes of defects. However, these reasoning results are usually output in the form of tracing reports and are not effectively fed back to the parameter adaptive optimization stage of the inspection template. This results in a lack of a closed-loop linkage mechanism between the parameter adjustment of the inspection system and the root cause tracing results. The degradation of inspection parameters cannot be corrected in a timely manner, and the AI visual inspection model continues to operate under suboptimal input conditions, leading to unreliable inspection results. Summary of the Invention
[0006] In view of the above situation, the main objective of this invention is to propose a workpiece missing detection method based on AI vision in order to solve the above-mentioned technical problems.
[0007] This invention proposes a workpiece missing detection method based on AI vision. The method includes the following steps: Step 1: Determine the model of the workpiece to be tested, call the corresponding initial detection template, and read the pre-configured detection strategy parameters and brightness parameters. Based on the historical detection result database, adaptively optimize the initial detection template to generate an optimized detection template, so as to obtain the configured detection environment. Step 2: In the configured detection environment, start the corresponding camera according to the pre-configured detection strategy parameters and brightness parameters, and collect surface images of the detection surface of the workpiece to be tested according to the detection sequence parameters in the pre-configured detection strategy parameters to obtain the image set to be tested; Step 3: Based on the detection surface division parameters in the pre-configured detection strategy parameters, use the pre-trained AI visual detection model to perform workpiece missing detection on each detection surface image in the image set to be detected, so as to obtain the initial missing detection results of each detection surface and the confidence level of each detection surface detection result. Step 4: Use a pre-trained AI visual reasoning model to perform causal reasoning analysis on the initial missing detection results of each detection surface, identify the root causes of the detection contradictions, and obtain the causal reasoning results. Step 5: Execute an adaptive detection strategy based on the confidence of the causal inference results and the detection results of each detection surface. If the causal inference results indicate a false detection, fine-tune the parameters of the target detection surface based on the optimized detection template. After parameter fine-tuning, re-detect using a pre-trained AI visual detection model to obtain the repaired missing detection results, which will be used as the final workpiece missing detection results. If the causal inference results indicate that the workpiece itself has a missing defect, the initial missing detection results will be used as the final workpiece missing detection results. Step 6: Store the detection data generated during this detection process in the historical detection result database for adaptive optimization of the initial detection template in the next detection.
[0008] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention employs a template adaptive optimization mechanism driven by a historical detection result database to process qualified and unqualified samples separately: High-quality samples are selected by weighted fusion of the confidence level and image quality score of qualified samples, and the standard template image is updated through autoencoder feature fusion reconstruction; a baseline defect template image is generated using the defect distribution information of unqualified samples, and the brightness parameters and detection surface division parameters are adaptively adjusted at the parameter level accordingly. This mechanism enables the detection template to continuously self-evolve with the accumulation of historical detection data, reducing the degradation of detection accuracy caused by environmental factors such as changes in illumination and camera attenuation from the source, thus solving the technical problem that static template configuration cannot adapt to dynamic environments.
[0009] 2. This invention proposes a reference-plane-guided dynamic threshold multi-face collaborative detection method. First, missing data is detected on the reference plane image. Then, the judgment thresholds for the remaining detection planes are dynamically adjusted based on the number of missing locations on the reference plane and the detection confidence level (positively correlated with the number of missing reference plane locations and negatively correlated with the reference plane detection confidence level). This mechanism transforms the reference plane detection results into prior information for other detection planes, achieving logical association and collaborative judgment across detection planes. This effectively overcomes the defect of unreliable overall results due to single-face false detection in traditional independent detection methods, significantly improving the accuracy of missing data detection for multi-faceted workpieces.
[0010] 3. This invention employs a causal reasoning method based on confidence level labels and root cause classification rule tables. The confidence level of the detection surface is discretized into high / low confidence level labels. Combined with the weights of the associated edges in pre-stored cross-surface association rules as a joint index, the probability of false detections attributable to each detection surface and the probability of defects attributable to the workpiece itself are directly obtained through table lookup. This eliminates the need to train complex causal graph models or deep neural networks. The reasoning process is fully rule-based and interpretable, with extremely low computational overhead. Simultaneously, it achieves precise quantitative localization of the root causes of detection contradictions, providing a reliable decision-making basis for subsequent adaptive detection strategies.
[0011] 4. This invention directly uses root cause analysis results to guide the adjustment of detection parameters. When causal reasoning determines a false detection, the system can automatically locate the most likely erroneous detection surface and determine the magnitude of parameter adjustment based on the current confidence level of that detection surface; the lower the confidence level, the larger the adjustment magnitude. Then, the specific brightness increment value and detection area offset are obtained by looking up a table. After boundary constraints, the image is re-acquired for detection. The entire system forms an automatic closed loop from detection, analysis to adjustment and re-detection. Compared with the existing technology that requires either full re-detection or manual intervention, this invention reduces unnecessary repeated detections and avoids misjudging system false detections as workpiece defects, significantly improving detection efficiency while ensuring detection quality.
[0012] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by means of embodiments of the invention. Attached Figure Description
[0013] Figure 1 This is a flowchart of the steps of the AI vision-based workpiece missing detection method proposed in this invention.
[0014] Figure 2 This is a general framework diagram of the workpiece missing detection method based on AI vision proposed in this invention.
[0015] Figure 3 This is a schematic diagram of the workpiece to be tested placed on the testing table in Embodiment 1 (small part inspection).
[0016] Figure 4 This is a schematic diagram of the placement position of the workpiece to be tested in Embodiment 2 (Intermediate Part Inspection) of the present invention.
[0017] Figure 5 This is a schematic diagram showing the placement of the workpiece to be tested in Embodiment 3 (longitudinal beam component detection) of the present invention. Detailed Implementation
[0018] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0019] These and other aspects of the embodiments of the present invention will become clear from the following description and accompanying drawings. In these descriptions and drawings, some specific embodiments of the present invention are specifically disclosed to provide some ways of implementing the principles of the embodiments of the present invention; however, it should be understood that the scope of the embodiments of the present invention is not limited thereto.
[0020] Please see Figure 1 This invention proposes a workpiece missing detection method based on AI vision, which includes the following steps: Step 1: Determine the model of the workpiece to be tested, call the corresponding initial detection template, and read the pre-configured detection strategy parameters and brightness parameters. Based on the historical detection result database, adaptively optimize the initial detection template to generate an optimized detection template, so as to obtain the configured detection environment.
[0021] Please see Figure 2 In step 1, the model of the workpiece to be tested is determined, the corresponding initial detection template is called, and the pre-configured detection strategy parameters and brightness parameters are read. Based on the historical detection result database, the initial detection template is adaptively optimized to generate an optimized detection template, thereby obtaining the configured detection environment. Specifically, the steps include the following: The model identifier of the workpiece to be tested is obtained, and an initial detection template matching the model identifier is retrieved from a preset detection template library to obtain the initial detection template corresponding to the workpiece to be tested; wherein, the initial detection template includes the number of cameras, detection surface division parameters, detection sequence parameters, and brightness parameters corresponding to the model identifier of the workpiece to be tested; the brightness parameters include a first brightness mode and a second brightness mode. The pre-configured detection strategy parameters and brightness parameters are parsed and read from the initial detection template to obtain the detection strategy parameters and brightness parameters to be optimized. From the historical inspection results database, read the workpiece missing inspection results and the confidence level of each inspection surface image of the workpiece model to be tested during the most recent inspection process. Then, classify the inspection results that are judged as qualified and the inspection results that are judged as unqualified in the workpiece missing inspection results. At the same time, associate and store the confidence level of each inspection surface inspection result with the inspection results that are judged as qualified in the workpiece missing inspection results to obtain the qualified inspection sample set and the unqualified inspection sample set. Based on the set of qualified and unqualified test samples, the brightness parameters and detection strategy parameters to be optimized are adjusted, and an optimized detection template is generated. The optimized detection template is then deployed to the detection environment to obtain the configured detection environment.
[0022] In a preferred embodiment of the present invention, based on a set of qualified and unqualified test samples, the brightness parameters and detection strategy parameters to be optimized are adjusted, and an optimized detection template is generated. The optimized detection template is then deployed to the detection environment to obtain the configured detection environment. Specifically, the steps include the following: In the set of qualified test samples, the image sharpness score, workpiece placement offset score, and test surface image brightness uniformity score are calculated for each qualified test sample. The image sharpness score, workpiece placement offset score, and test surface image brightness uniformity score are then weighted and fused with the confidence level of the qualified test sample to obtain the comprehensive quality score of each qualified test sample. The weight coefficient corresponding to the confidence level of the qualified test sample is higher than the individual weight coefficients of the image sharpness score, workpiece placement offset score, and test surface image brightness uniformity score. The qualified test samples whose overall quality score is higher than the preset quality threshold are marked as high-quality samples. The missing location information and missing type information of the initial missing test results corresponding to each unqualified test sample are extracted from the set of unqualified test samples to obtain the set of high-quality qualified samples and the distribution information of unqualified defects. From the set of high-quality qualified samples, a first preset number of qualified detection samples are selected as samples to be fused. The detection surface images corresponding to the samples to be fused are sorted in order of image clarity score from high to low. After sorting, a second preset number of detection surface images are selected as fusion candidate images to obtain a sorted fusion candidate image sequence. The sorted fusion candidate image sequence of each detection surface image is input into a pre-trained autoencoder network for feature extraction according to the sorting order. The image feature vectors corresponding to each detection surface image are then weighted and averaged to obtain the fusion feature vector. The weight coefficients of the weighted average calculation are determined by the image sharpness score of each detection surface image and the confidence level of the qualified detection sample corresponding to each detection surface image. The fused feature vector is input into a pre-trained feature decoder network to reconstruct the image, and the reconstructed image is used as the updated standard template image. Based on the missing location and missing type information in the non-conforming defect distribution information, a defect marking area is generated at the corresponding position and type in the updated standard template image, and the updated standard template image with the defect marking area is used as the reference defect template image. The brightness parameter to be optimized is compared pixel by pixel with the pixel brightness distribution in the reference defect template image to calculate the brightness parameter offset, and the brightness parameter to be optimized is adjusted according to the brightness parameter offset to obtain the updated brightness parameter. The detection surface division parameters in the detection strategy parameters to be optimized are matched with the spatial distribution of the defect marking region in the benchmark defect template image to obtain the matching result. The division boundary coordinates of each detection surface in the detection surface division parameters are adjusted according to the matching result to obtain the updated detection surface division parameters. The optimized detection template is composed of the updated standard template image, the reference defect template image, the updated brightness parameters, and the updated detection surface division parameters. The updated brightness parameters and updated detection surface division parameters from the optimized detection template are deployed to the detection environment to obtain the configured detection environment.
[0023] In this embodiment of the invention, an initial detection template matching the model of the workpiece to be tested is retrieved from the detection template library. Detection strategy parameters such as the number of cameras, detection surface division boundaries, and detection order, as well as initial brightness parameters, are parsed from this template. Then, the image missing detection results and confidence levels of each detection surface of the most recent 50 detections of this workpiece model are read from the historical detection result database. Samples with qualified detection results are assigned to the qualified sample set, and those with unqualified results are assigned to the unqualified sample set.
[0024] For qualified samples, calculate the sharpness score (using the Laplacian variance method, with values from 0 to 100), workpiece placement offset score (normalized to 0 to 100 based on the average distance between the workpiece edge and the preset baseline in the image), and brightness uniformity score for each image (calculated by normalizing the inverse standard deviation of the brightness difference between the four corners and the center of the image). Multiply the sharpness score, offset score, and uniformity score by 0.2, 0.2, and 0.2 respectively, then multiply by the confidence level (value from 0 to 1) as an additional weighting factor. Sum of the three products and divide by 0.6 to obtain the comprehensive quality score. Samples with a comprehensive quality score higher than 80 are retained as high-quality qualified samples. The top 20 images are selected from high-quality qualified samples in descending order of sharpness and are sequentially input into a pre-trained convolutional autoencoder. The encoding part of the autoencoder contains 4 convolutional layers with a kernel size of 3x3 and a stride of 2, outputting a 128-dimensional feature vector. The 20 feature vectors are then weighted and averaged according to the weights after normalization by the product of sharpness and confidence, to obtain a fused feature vector. The decoder part contains 4 deconvolutional layers, which reconstruct the fused feature vector into an updated standard template image of 256x256 pixels.
[0025] From the defective samples, the frequency of missing markers at each pixel location is statistically analyzed to generate a defect probability map of the same size as the template image. Locations with a probability value greater than 0.5 are marked as defect areas, resulting in a baseline defect template image. The exposure time (microseconds) and gain (dB) in the initial brightness parameters are compared pixel-by-pixel with the average pixel brightness of the non-defective areas in the baseline defect template image. The exposure time and gain adjustment amount that bring the brightness of the non-defective areas close to 128 are calculated to obtain the updated brightness parameters. The boundary coordinates (in pixels) of each detection surface in the initial detection surface division parameters are matched with the edge of the defect area in the baseline defect template image. The distance from the centroid of the defect area to the boundary of each detection surface is calculated, and the detection surface boundary is adjusted by 10% towards the defect area to obtain the updated detection surface division parameters. Using the updated standard template image as the comparison benchmark and the baseline defect template image as the defect reference, together with the updated brightness parameters and detection surface division parameters, an optimized detection template is constructed. The brightness parameters and detection surface division parameters are then written into the configuration file of the detection system to complete the detection environment configuration.
[0026] It should be noted that the above convolutional autoencoder was pre-trained using publicly available industrial image datasets (such as MVTec AD). The encoder contains four convolutional layers (3×3 kernels, stride 2, and channel numbers of 32, 64, 128, and 256 respectively), with a symmetrical decoder. The loss function is mean squared error, and training continues until the validation set loss is less than 0.01. The brightness parameter offset is calculated using a binary search method: within an exposure time range of 5000 to 20000 microseconds and a gain range of 0 to 12 dB, the exposure time and gain are adjusted to ensure that the absolute difference between the average pixel brightness of the non-defective area in the baseline defect template image and the target brightness of 128 is less than 5. The baseline distance for adjusting the detection surface boundary is the Euclidean distance from the centroid of the defective area to the original detection surface boundary. The adjustment amount is 10% of this distance; if the centroid is inside the boundary, it expands outward, and if it is outside, it shrinks inward.
[0027] Step 2: In the configured detection environment, start the corresponding camera according to the pre-configured detection strategy parameters and brightness parameters, and collect surface images of the detection surface of the workpiece to be tested according to the detection sequence parameters in the pre-configured detection strategy parameters to obtain the image set to be tested.
[0028] In step 2, under the configured detection environment, the corresponding camera is activated according to the pre-configured detection strategy parameters and brightness parameters, and surface images of the workpiece to be tested are acquired according to the detection sequence parameters in the pre-configured detection strategy parameters to obtain the image set to be detected. The specific steps include the following: In the configured detection environment, based on the number of cameras in the optimized detection template, the cameras that need to be activated are determined, and the activation order of each camera is determined according to the detection order parameters to be used in the optimized detection template, so as to obtain the camera activation order queue; wherein, the number of cameras is determined to be 1, 2 or 3 depending on the model of the workpiece to be tested; the detection order parameters are collected in ascending order according to the detection surface number. According to the camera startup order queue, a startup command is sent to each camera. After each camera is started, the exposure time and gain parameters of each camera are configured according to the updated brightness parameters to obtain a camera group with complete parameter configuration. Based on the updated detection surface division parameters, the identification of the detection surface to be collected for each camera is determined, and the camera group with completed parameter configuration is controlled according to the detection order parameters to be used, and the surface images of their respective detection surfaces are collected in sequence to obtain the original detection surface image sequence. The original detection surface image sequence is sorted and indexed according to the order of the detection order parameters and the surface number of the updated detection surface division parameters to form a detection image containing image data and corresponding detection surface identifiers. Based on all the detection images containing image data and corresponding detection surface identifiers, a detection image set is obtained.
[0029] In this embodiment of the invention, the number of cameras is read from the optimized detection template, for example, one camera for small parts, two for medium parts, and three for long longitudinal beam parts. The camera identifiers are arranged according to the detection order parameters (e.g., front, side, and bottom) to obtain the startup order queue. Each camera is started sequentially by sending a software trigger command through the industrial camera SDK. After each camera returns to the ready state, the camera attribute setting interface is called to configure it using the updated brightness parameters, including the exposure time (e.g., 10,000 microseconds) and gain (e.g., 6dB).
[0030] Based on the updated detection surface segmentation parameters, the camera number and acquisition area coordinates corresponding to each detection surface are used to control the corresponding camera to acquire images of the specified area. After each camera acquires one image, it immediately switches to the next camera to avoid interference caused by simultaneous acquisition. After acquisition, the original image sequence is obtained. An index is built according to the detection order parameters and surface number (e.g., 01 represents the front, 02 represents the side) to form a set of images to be detected. The image resolution is 1920x1080 pixels, and the format is 8-bit grayscale.
[0031] Step 3: Based on the detection surface division parameters in the pre-configured detection strategy parameters, use the pre-trained AI visual detection model to perform workpiece missing detection on each detection surface image in the image set to be detected, so as to obtain the initial missing detection results of each detection surface and the confidence level of each detection surface detection result.
[0032] In step 3, based on the detection surface division parameters in the pre-configured detection strategy parameters, the pre-trained AI visual detection model is used to perform workpiece missing detection on each detection surface image in the image set to be detected, so as to obtain the initial missing detection results of each detection surface and the confidence level of each detection surface detection result. Specifically, the steps are as follows: For the images to be detected in the image set, extract each detection surface image in the image to be detected according to the surface number of the updated detection surface division parameter in ascending order, and obtain the extracted detection surface images. Arrange the extracted detection surface images in the order of surface number to obtain the sorted detection surface image sequence. The detection surface image with the smallest surface number is selected from the sorted detection surface image sequence as the reference surface image. The reference surface image is then input into the pre-trained AI vision detection model to perform workpiece missing detection, and the reference surface missing detection result and reference surface detection confidence are obtained. Based on the baseline missing detection results and the baseline detection confidence, a corresponding detection threshold is calculated for each remaining detection surface image in the sorted detection surface image sequence excluding the baseline image, to obtain an adjusted set of detection thresholds; wherein, the detection threshold is positively correlated with the number of missing positions in the baseline missing detection results and negatively correlated with the baseline detection confidence. According to the arrangement order of the remaining detection surface images in the sorted detection surface image sequence, each remaining detection surface image is sequentially input into the pre-trained AI vision detection model to perform workpiece missing detection, obtain detection output, and use the detection threshold corresponding to the current remaining detection surface image in the adjusted detection threshold set to perform binarization judgment on the detection output to obtain the initial missing detection result of each remaining detection surface and the confidence level of each remaining detection surface detection result; The missing detection results of the reference surface, the confidence level of the reference surface, the initial missing detection results of each remaining detection surface, and the confidence level of the detection results of each remaining detection surface are associated and stored with the corresponding detection surface image according to the detection surface number, so as to obtain the initial missing detection results of each detection surface and the confidence level of the detection results of each detection surface.
[0033] In this embodiment of the invention, the images in the image set to be detected are first sorted in ascending order by face number, with the face with the smallest number serving as the reference face. The reference face image is scaled to 224x224 pixels and then input into a pre-trained YOLOv8 object detection model. This model outputs a vector of length 84, where the first 4 bits are the bounding box coordinates, the 5th bit is the confidence score, and the 6th to 84th bits represent the probabilities of various types of missing objects (such as missing holes or missing nuts). The model returns the missing object detection result for the reference face (whether there is a missing object, and the coordinates of the missing object's location) and the reference face detection confidence score (the highest confidence score among all detected bounding boxes).
[0034] For each remaining detection surface, the detection threshold is calculated as: 0.5 + (number of missing locations on the reference surface × 0.05) - (reference surface detection confidence score × 0.3), with the threshold range limited to between 0.3 and 0.8. The remaining detection surface images are sequentially input into the same YOLOv8 model to obtain the detection output vector for each surface. Detection boxes with confidence scores below the calculated threshold are filtered out, and those with scores above the threshold are retained as the initial missing detection results for that surface. The confidence score of each detection box is also recorded. Finally, the results for all detection surfaces are stored by surface number, with each surface stored in a list containing (missing type, bounding box coordinates, confidence score).
[0035] It should be noted that the coefficients 0.5, 0.05, and 0.3 in the above formula for calculating the detection threshold were determined through offline experiments: 100 reference surface images with varying numbers of missing elements and corresponding remaining detection surface images were selected, and the coefficient combinations that maximized the detection accuracy of the remaining detection surfaces were statistically analyzed. In practical applications, operators can also manually fine-tune these coefficients through the human-machine interface to adapt to different lighting conditions.
[0036] Step 4: Use a pre-trained AI visual reasoning model to perform causal reasoning analysis on the initial missing detection results of each detection surface, identify the root causes of the detection contradictions, and obtain the causal reasoning results.
[0037] In step 4, a pre-trained AI visual reasoning model is used to perform causal reasoning analysis on the initial missing detection results of each detection surface to identify the root causes of the detection contradictions and obtain the causal reasoning results. Specifically, this includes the following steps: From the initial missing detection results of each detection surface, extract the missing judgment value corresponding to each detection surface, and combine the missing judgment values of all detection surfaces into a detection result vector according to the detection surface number order; From the confidence scores of the detection results of each detection surface, extract the confidence score value corresponding to each detection surface, and combine the confidence scores of all detection surfaces in the order of detection surface number to form a confidence score vector to obtain the confidence score vector. According to the preset cross-surface association rules, the physical constraint relationship and logical dependency relationship between the detection surfaces corresponding to the model of the workpiece to be tested are extracted, and the physical constraint relationship and logical dependency relationship are transformed into ordered detection surfaces to obtain an ordered detection surface list. The consistency of the detection result vector with each detection surface in the ordered detection surface list is checked separately. All detection surfaces that violate physical constraints or logical dependencies are marked to form a detection surface group. Based on all detection surface groups, a set of contradictory detection surface groups is formed. For each contradiction detection surface group in the contradiction detection surface group set, based on the two confidence values in the confidence vector corresponding to the target contradiction detection surface group and the two association edge weight values in the preset cross-surface association rules corresponding to the target contradiction detection surface group, the corresponding false detection probability allocation scheme is found from the preset root cause classification rule table, and the found false detection probability allocation scheme is used as the root cause probability distribution of the target contradiction detection surface group to obtain the root cause probability distribution of each contradiction detection surface group; The root cause probability distribution of each contradiction detection surface group is weighted and fused according to the confidence value of the detection surface involved in each contradiction detection surface group, and the root cause type with the highest probability after fusion is selected as the causal inference result.
[0038] The specific implementation of transforming physical constraints and logical dependencies into an ordered detection surface group is as follows: For each preset cross-surface association rule, based on the spatial positional relationship or functional dependency relationship between the two detection surfaces defined in the rule, an ordered pair containing two detection surface numbers (first detection surface number, second detection surface number) is generated. This ordered pair is then associated and stored with the association edge weight value in the rule to form an ordered detection surface group. The order of the first and second detection surface numbers in the ordered pair is determined by ascending order of the detection surface numbers, or by the order in which the detection surfaces were collected in the detection order parameter.
[0039] As an example, for the longitudinal beam of Embodiment 3, the preset cross-surface association rules include three rules: Rule 1: Surface 1 and Surface 2 should be qualified or unqualified at the same time, and the weight of the associated edge is 0.8; Rule 2: Surface 1 and Surface 3 should be qualified or unqualified at the same time, and the weight of the associated edge is 0.8; Rule 3: Surface 2 and Surface 3 should be qualified or unqualified at the same time, and the weight of the associated edge is 0.5.
[0040] These rules are transformed into an ordered list of detection face groups, each of which is represented as a triple of (first detection face number, second detection face number, associated edge weight).
[0041] In the subsequent consistency verification step, each ordered detection face group in the list is traversed sequentially. Based on the missing judgment values of the two corresponding detection faces in the detection result vector (0 indicates no missing, 1 indicates missing), it is determined whether the rule is violated. For example, for rule 1, if the missing judgment values of face 1 and face 2 are not equal (one is 0 and the other is 1), it is determined that the ordered detection face group has a contradiction, and it is added to the contradictory detection face group set. The weight value of the associated edge corresponding to the group is recorded.
[0042] Among them, the preset cross-surface association rules include: when the workpiece to be tested is a longitudinal beam with multiple detection surfaces, the missing detection result of the multiple detection surfaces of the longitudinal beam is obtained by judging whether each detection surface is qualified or unqualified at the same time.
[0043] In a preferred embodiment of the present invention, for each contradiction detection surface group in the contradiction detection surface group set, based on the two confidence values in the confidence vector corresponding to the target contradiction detection surface group and the two association edge weight values in the preset cross-surface association rules corresponding to the target contradiction detection surface group, the corresponding false detection probability allocation scheme is found from the preset root cause classification rule table, specifically including the following steps: Obtain the confidence value of the first detection surface and the confidence value of the second detection surface for each detection surface in the contradiction detection surface group set, as well as the weight value of the direct association edge between the first and second detection surfaces in the preset cross-surface association rules; The confidence level of the first detection surface is compared with the pre-stored confidence threshold. If the confidence level of the first detection surface is lower than the confidence threshold, the first detection surface is marked as a low-confidence detection surface; if the confidence level of the first detection surface is not lower than the confidence threshold, the first detection surface is marked as a high-confidence detection surface, so as to obtain the confidence level marking status of the first detection surface. The confidence level of the second detection surface is compared with the pre-stored confidence threshold. If the confidence level of the second detection surface is lower than the confidence threshold, the second detection surface is marked as a low-confidence detection surface; if the confidence level of the second detection surface is not lower than the confidence threshold, the second detection surface is marked as a high-confidence detection surface, so as to obtain the confidence level marking status of the second detection surface. The confidence level of the first detection surface, the confidence level of the second detection surface, and the weight value of the directly associated edge are used as a joint query index and simultaneously input into a preset root cause classification rule table for matching. From the preset root cause classification rule table, the probability values of false detection attributable to the first detection surface and the probability values of false detection attributable to the second detection surface corresponding to the joint query index are read to obtain the first false detection probability value and the second false detection probability value. Read the preset complete probability value from the preset root cause classification rule table, and subtract the sum of the first false detection probability value and the second false detection probability value from the preset complete probability value to obtain the probability value attributable to the missing defect in the workpiece itself. The first false detection probability value is used as the probability of false detection attributable to the first detection surface, the second false detection probability value is used as the probability of false detection attributable to the second detection surface, and the probability value of false detection attributable to the workpiece itself is used as the probability of false detection attributable to the workpiece itself, so as to obtain the root cause probability distribution of the target contradiction detection surface group, and the root cause probability distribution of the target contradiction detection surface group is used as the corresponding false detection probability allocation scheme.
[0044] In this embodiment of the invention, the missing determination results of each inspection surface are converted into an N-dimensional vector, where N is the total number of inspection surfaces, and each dimension takes a value of 0 to indicate no missing surfaces and 1 to indicate missing surfaces. Simultaneously, the highest confidence scores of each inspection surface are combined to form another N-dimensional confidence vector. The association rules for the current model of workpiece are read from a preset cross-surface association rule library. The rule format is (surface A number, face B number, logical relationship, weight), for example (surface A number: 1, face B number: 2, logical relationship: both qualified or both unqualified, weight: 0.8). All rules are converted into an ordered inspection surface list.
[0045] For each detection facet, if the values of two faces in the detection result vector violate the rule (e.g., the rule requires both to be qualified, but one is qualified and the other is unqualified), then the detection facet is marked as a contradictory detection facet group, and the numbers of the two faces and their weights in the association rule are recorded. For each contradictory detection facet group, the confidence scores c1 and c2 of the two faces and the rule weight w are extracted. The preset confidence threshold is 0.6; if c1 < 0.6, it is marked as low confidence, otherwise it is marked as high confidence; c2 is processed in the same way. The pre-stored root cause classification rule table is a three-dimensional table, with the index (face1 label, face2 label, weight level). The weight levels are divided into high (w ≥ 0.7), medium (0.4 ≤ w < 0.7), and low (w < 0.4). The table stores two probability values p1 and p2; for example, the index (low, high, high) corresponds to p1 = 0.7 and p2 = 0.1.
[0046] After obtaining p1 and p2 from the table, p3 = 1 - p1 - p2 is calculated as the probability attributed to the workpiece defect. (p1, p2, p3) is taken as the root cause probability distribution for this contradictory detection surface group. For all contradictory detection surface groups, the root cause probability distribution is weighted and averaged according to the average confidence level of the two detection surfaces in each surface, resulting in a fused root cause probability distribution. The root cause type with the highest probability is taken as the final causal inference result.
[0047] It should be noted that, as an example, part of the root cause classification rule table is as follows: when (face 1 label = low, face 2 label = high, weight level = high), p1 = 0.7, p2 = 0.1; when (face 1 label = low, face 2 label = low, weight level = high), p1 = 0.4, p2 = 0.4; when (face 1 label = high, face 2 label = high, weight level = low), p1 = 0.15, p2 = 0.15; when (face 1 label = high, face 2 label = high, weight level = high), p1 = 0.2, p2 = 0.2. This fusion method ensures that the conflict detection face group with higher confidence contributes more to the final decision.
[0048] Step 5: Execute an adaptive detection strategy based on the confidence of the causal inference results and the detection results of each detection surface. If the causal inference results indicate a false detection, fine-tune the parameters of the target detection surface based on the optimized detection template. After parameter fine-tuning, re-detect using a pre-trained AI visual detection model to obtain the repaired missing detection results, which will be used as the final workpiece missing detection results. If the causal inference results indicate that the workpiece itself has a missing defect, the initial missing detection results will be used as the final workpiece missing detection results.
[0049] In step 5, an adaptive detection strategy is executed based on the causal inference results and the confidence levels of the detection results for each detection surface. If the causal inference results indicate a false detection, the parameters of the target detection surface are fine-tuned based on the optimized detection template. After parameter fine-tuning, the pre-trained AI visual detection model is used for re-detection to obtain the repaired missing detection results, which are then used as the final workpiece missing detection results. If the causal inference results indicate that the workpiece itself has a missing defect, the initial missing detection results are used as the final workpiece missing detection results. Specifically, this includes the following steps: Extract the final root cause type from the causal reasoning results to obtain the root cause type identifier; The root cause type identifier is compared with the preset root cause type set to obtain the first comparison result; If the root cause type identifier in the first comparison result belongs to the false detection type set, the number of the false detection surface with the highest probability is extracted from the root cause probability distribution of each contradiction detection surface group according to the false detection type in the false detection type set, so as to determine the target detection surface; Read the confidence value corresponding to the target detection surface from the confidence of the detection results of each detection surface, and read the brightness parameter and detection surface division parameter corresponding to the target detection surface from the optimized detection template to obtain the current confidence, current brightness parameter and current detection surface division parameter of the target detection surface; Based on the current confidence level, current brightness parameter, and current detection surface division parameter of the target detection surface, a parameter fine-tuning strategy is performed on the target detection surface to obtain the fine-tuned brightness parameter and the fine-tuned detection surface division parameter. The fine-tuned brightness parameters and fine-tuned detection surface segmentation parameters are applied to the target detection surface, and the pre-trained AI vision detection model is used to re-detect the workpiece missing from the target detection surface to obtain the repaired missing detection result, which is then used as the final workpiece missing detection result. If the root cause type identifier in the first comparison result belongs to the workpiece defect type set, the initial missing detection result corresponding to the target detection surface in the initial missing detection results of each detection surface will be taken as the final workpiece missing detection result.
[0050] In a preferred embodiment of the present invention, a parameter fine-tuning strategy is performed on the target detection surface based on the current confidence level, current brightness parameter, and current detection surface division parameter to obtain the fine-tuned brightness parameter and the fine-tuned detection surface division parameter. Specifically, this includes the following steps: The current confidence level of the target detection surface is compared with the preset confidence threshold to obtain a second comparison result. The adjustment range is determined based on the difference range between the current confidence level of the target detection surface and the preset confidence threshold in the second comparison result to obtain the adjustment range mark. According to the adjustment range mark, the brightness increment value corresponding to the current brightness parameter is queried from the preset parameter adjustment rule table, and then the division boundary offset corresponding to the current detection surface division parameter is queried to obtain the brightness increment value and the division boundary offset; wherein, the division boundary offset can also be determined according to the statistical value of the workpiece placement position offset in the historical detection results; The current brightness parameter is added to the brightness increment value to obtain the temporary brightness parameter. The temporary brightness parameter is then clipped to the pre-stored upper and lower limits of the brightness parameter. If the temporary brightness parameter exceeds the upper limit, the upper limit is used; if it is below the lower limit, the lower limit is used to obtain the updated brightness parameter. Add the boundary coordinates of each detection surface in the current detection surface division parameters to the boundary offset of each detection surface to obtain the temporary boundary coordinates. Then, calculate the intersection of the temporary boundary coordinates and the pre-stored detection area boundary range. If the temporary boundary coordinates exceed the pre-stored detection area boundary range, take the boundary range value to obtain the updated detection surface division parameters. The exposure time and gain parameters of the camera corresponding to the target detection surface are reconfigured using the updated brightness parameters to obtain the reconfigured camera parameters. The updated detection surface division parameters are used to redetermine the detection area coordinates of the target detection surface in the image to be detected, so as to obtain the repositioned detection area coordinates. The reconfigured camera parameters and the repositioned detection area coordinates are combined to form a fine-tuned detection configuration, resulting in fine-tuned brightness parameters and fine-tuned detection surface division parameters.
[0051] In this embodiment of the invention, the root cause type identifier is extracted from the causal reasoning result. The preset root cause type set includes single-sided false detection and double-sided false detection, and the workpiece defect type is the workpiece itself being missing. If it is determined to be a false detection, the detection surface with the highest false detection probability is found from the root cause probability distribution of each contradictory detection surface group, and its number is used as the target detection surface. The confidence value of the target detection surface (denoted as c_target) is extracted from the confidence values of each detection surface stored in step 3. The exposure time (denoted as E0, in microseconds) and gain (denoted as G0, in decibels) corresponding to the surface and the boundary coordinates of the detection surface (denoted as x_min, y_min, x_max, y_max, in pixels) are read from the optimized detection template. Parameter fine-tuning is performed on the target detection surface: the preset low confidence threshold is 0.5. If the confidence value c_target is lower than 0.5, it is marked as a large adjustment; otherwise, it is a small adjustment.
[0052] The pre-stored parameter adjustment rule table is divided into two tables: a large-amplitude table and a small-amplitude table. In the large-amplitude table, the exposure time increment is 500 microseconds, the gain increment is 1 dB, and the boundary offset is 10 pixels; in the small-amplitude table, the exposure time increment is 100 microseconds, the gain increment is 0.2 dB, and the boundary offset is 2 pixels. The temporary exposure time is obtained by adding the corresponding increment to the exposure time E0. If the temporary exposure time exceeds the maximum exposure time of 20000 microseconds, it is set to 20000; if it is lower than the minimum exposure time of 5000 microseconds, it is set to 5000. The cropped value is used as the updated exposure time (denoted as E_new).
[0053] Similarly, the gain is processed as follows: The gain G0 is added to the corresponding increment to obtain a temporary gain. If the temporary gain exceeds the maximum gain of 12 dB, it is set to 12; if it is lower than the minimum gain of 0 dB, it is set to 0. The cropped value is used as the updated gain (denoted as G_new). For the detection surface boundary coordinates, the offset is subtracted from the left boundary x_min, the offset is added to the right boundary x_max, the offset is subtracted from the upper boundary y_min, and the offset is added to the lower boundary y_max to obtain temporary boundary coordinates. Then, the intersection operation is performed between the temporary boundary coordinates and the preset global detection region boundary (image edge indented inward by 20 pixels). That is, the excess part is cropped to the boundary value to obtain the updated boundary coordinates (denoted as x_min_new, y_min_new, x_max_new, y_max_new).
[0054] The camera corresponding to the target detection surface is reconfigured using the updated exposure time E_new and the updated gain G_new. The image region of the detection surface is re-extracted using the updated boundary coordinates and then input into the pre-trained AI vision detection model (e.g., YOLOv8) for detection to obtain the repaired missing detection result. If it is determined to be a workpiece defect, the initial missing detection result of the detection surface in step 3 is directly output.
[0055] It should be noted that the confidence threshold of 0.5, exposure time increments of 500 microseconds (large increment) and 100 microseconds (small increment), gain increments of 1 dB and 0.2 dB, and boundary offsets of 10 pixels and 2 pixels in the fine-tuning parameters are all determined based on historical statistical data for this type of workpiece: the confidence distribution of the target detection surface in all false detection cases is statistically analyzed, and the median confidence level is used as the dividing point. The increment value is the smallest step size that makes the false detection repair success rate exceed 90%. The 20-pixel indentation during boundary clipping is to avoid the detection area exceeding the effective range of the image. This value can be adjusted within the range of 10 to 30 pixels depending on the camera installation accuracy and lens distortion.
[0056] Step 6: Store the detection data generated during this detection process in the historical detection result database for adaptive optimization of the initial detection template in the next detection.
[0057] In this embodiment of the invention, all data generated during the current inspection is organized into a single record, including: workpiece model, inspection timestamp, initial missing detection results for each inspection surface (a list of missing location coordinates and confidence levels for each surface), final missing detection results for each inspection surface, causal inference results (root cause type and probability values), and brightness parameters and inspection surface division parameters generated during parameter fine-tuning before and after the update. This data is appended to a historical inspection result database file in JSON format. The database uses a lightweight SQLite database, and the table structure includes fields for model, timestamp, and inspection result. Each write operation automatically triggers an index update in the database, enabling rapid retrieval when reading the most recent 50 records in subsequent step 1.
[0058] The technical solution of the present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0059] Example 1: Please see Figure 3 In this embodiment 1, we take a small single-camera workpiece (such as model CX756.5.0-01, CX756.6.0-01, etc.) in the automotive manufacturing field as an example. During inspection, the workpiece is placed stably on the second line in the middle of the inspection table and aligned with the fixing plate.
[0060] Step 1: The operator inputs the model identifier and calls the corresponding initial detection template. This template includes one camera, detection surface division parameters (coordinates of the initial detection area of surface 1), detection order parameters (single order), and brightness parameters (including normal mode and brightening mode). The qualified and unqualified samples from the most recent N tests of this model are read from the historical detection result database, and an optimized detection template is generated according to the aforementioned method of this invention (see Step 1, which describes reconstructing the standard template based on autoencoder feature fusion, adjusting the brightness parameters and detection surface division parameters according to the defect distribution).
[0061] Step 2: Activate the unique camera, configure the exposure time and gain according to the optimized brightness parameters, and acquire the surface image of surface 1 to obtain the image set to be detected.
[0062] Step 3: Since there is only one detection surface, this surface is directly used as the reference surface. Input the image of surface 1 into the pre-trained AI visual detection model to obtain the initial missing detection results and confidence scores. No dynamic threshold adjustment is required.
[0063] Step 4: Perform causal inference using a pre-trained AI visual reasoning model. Since it is only one-sided, the cross-sided association rule is simplified to a one-sided self-consistency check (e.g., the degree of matching between the detection result and the historical statistical pattern), and the causal inference result is output.
[0064] Step 5: If the inference result is a false detection, then fine-tune the parameters of face 1 based on the optimized detection template (such as switching the brightness mode or adjusting the exposure time, gain and detection boundary), and output the repaired result after re-detection; if it is a workpiece defect, directly output the initial result.
[0065] Step 6: Store the detected data in the historical database.
[0066] Example 2: Please see Figure 4 In this embodiment 2, we take a mid-sized (dual-camera) workpiece (such as model CX756.4.0-01, EKS.2.0-01, etc.) in the automotive manufacturing field as an example. During inspection, the workpiece must be placed close to the leftmost and topmost edges of the inspection locator, and irregularly shaped parts must be aligned with the middle fixing plates on the leftmost and rightmost sides.
[0067] Step 1: Call the corresponding initial detection template, which includes two cameras, with the detection surface divided into surface 1 and surface 2, and the detection order being surface 1-surface 2. An optimized detection template is generated by classifying historical data, reconstructing the standard template through autoencoder feature fusion, adjusting brightness parameters guided by defect distribution, and adjusting the detection surface boundaries.
[0068] Step 2: Start the two cameras in sequence, and according to the optimized brightness parameters, acquire surface images of surface 1 and surface 2 to form the image set to be detected.
[0069] Step 3: Use surface 1 as the reference surface for detection to obtain the missing results and confidence level of the reference surface. Dynamically adjust the judgment threshold of surface 2 based on the number of missing surfaces and the confidence level (the threshold is positively correlated with the number of missing surfaces and negatively correlated with the confidence level of the reference surface). Perform binarization judgment on the detection results of surface 2 to obtain the initial missing detection results and confidence level of each surface.
[0070] Step 4: Using a pre-trained AI visual reasoning model, consistency verification is performed based on preset cross-face association rules (e.g., face 1 and face 2 should be simultaneously qualified or simultaneously unqualified, with a weight of 0.9) to identify conflicting face groups. By discretizing the confidence level and looking up the root cause classification rule table, the probability distribution of each conflicting face is obtained, and the causal reasoning result is output after fusion.
[0071] Step 5: If the target is a false positive, locate the target detection surface, determine the parameter fine-tuning range (brightness increment and boundary offset) based on its current confidence level, update the brightness parameters and detection surface division parameters, and then re-detect; if the target is a workpiece defect, directly output the initial result.
[0072] Step 6: Store the data from this test in the historical database.
[0073] Example 3: Please see Figure 5This embodiment 3 uses a long longitudinal beam component (e.g., model V363.1.0-01, V363.2.0-02, etc.) as an example, which is a large workpiece in the automotive manufacturing field. This workpiece has three detection surfaces: surface 1 (front), surface 2 (side near the display screen), and surface 3 (side near where a person stands). During detection, it needs to be placed close to the leftmost and topmost edges of the locator, with the right side aligned with the fixing plate.
[0074] Step 1: Activate the initial detection template, which includes three cameras, detection surface division parameters (initial coordinates of surfaces 1, 2, and 3), detection order (surface 1-surface 2-surface 3), and brightness parameters (normal / brightening mode). Based on the historical detection result database, qualified samples are selected as high-quality samples through a weighted fusion of image clarity, offset, brightness uniformity scores, and confidence levels. The updated standard template image is then reconstructed using a weighted average of autoencoder features. Defect distribution is extracted from unqualified samples to generate a baseline defect template image. Based on this, the brightness parameters (to make the average brightness of non-defective areas approach the target value) and detection surface division parameters (to adjust the boundaries towards the defective areas) are adjusted to obtain the optimized detection template.
[0075] Step 2: Start the three cameras in sequence, and according to the optimized brightness parameters, acquire surface images of surface 1, surface 2 and surface 3 in order to form the image set to be detected.
[0076] Step 3: Use surface 1 as the baseline surface for detection to obtain the baseline surface missing results and confidence level. Dynamically calculate the judgment thresholds for surfaces 2 and 3 based on the number of missing surfaces and the confidence level (formula example: 0.5 + number of missing surfaces × 0.05 - baseline surface confidence level × 0.3, limited to 0.3~0.8). Filter the AI model outputs for surfaces 2 and 3 to obtain the initial missing detection results and confidence levels for each surface.
[0077] Step 4: Using a pre-trained AI visual reasoning model, consistency verification is performed based on cross-face association rules (faces 1 and 2, 1 and 3, and 2 and 3 should be simultaneously qualified / unqualified, assigned weights of 0.8, 0.8, and 0.5 respectively). For each group of conflicting detected faces, the confidence level is compared with the threshold (0.6) to obtain high / low markings. Combined with the weight level, the root cause classification rule table is consulted to obtain the probability of false detection attribution to each face and the probability of workpiece defects. After weighted fusion, the causal reasoning result is output.
[0078] Step 5: If the inference points to a false detection, locate the target detection surface (e.g., the surface with the lowest confidence and the most contradictions). Determine the adjustment range (large or small) based on the difference between its current confidence and the threshold. Look up the brightness increment (exposure time, gain) and boundary offset from the table, update the brightness parameters and detection surface division parameters, and re-detect. If the confidence recovers and the logic is consistent after re-detection, output the corrected missing detection result. If it points to a workpiece defect, directly output the initial result. It can also automatically switch between normal / brightness enhancement modes to further optimize detection conditions.
[0079] Step 6: Store the test data (model, timestamp, initial and final results for each facet, inference probability, parameter adjustment records) in the historical database for subsequent template optimization.
[0080] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0081] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0082] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
Claims
1. A workpiece missing detection method based on AI vision, characterized in that, The method includes the following steps: Step 1: Determine the model of the workpiece to be tested, call the corresponding initial detection template, and read the pre-configured detection strategy parameters and brightness parameters. Based on the historical detection result database, adaptively optimize the initial detection template to generate an optimized detection template, so as to obtain the configured detection environment. Step 2: In the configured detection environment, start the corresponding camera according to the pre-configured detection strategy parameters and brightness parameters, and collect surface images of the detection surface of the workpiece to be tested according to the detection sequence parameters in the pre-configured detection strategy parameters to obtain the image set to be tested; Step 3: Based on the detection surface division parameters in the pre-configured detection strategy parameters, use the pre-trained AI visual detection model to perform workpiece missing detection on each detection surface image in the image set to be detected, so as to obtain the initial missing detection results of each detection surface and the confidence level of each detection surface detection result. Step 4: Use a pre-trained AI visual reasoning model to perform causal reasoning analysis on the initial missing detection results of each detection surface, identify the root causes of the detection contradictions, and obtain the causal reasoning results. Step 5: Execute an adaptive detection strategy based on the confidence of the causal inference results and the detection results of each detection surface. If the causal inference results indicate a false detection, fine-tune the parameters of the target detection surface based on the optimized detection template. After parameter fine-tuning, re-detect using a pre-trained AI visual detection model to obtain the repaired missing detection results and use them as the final workpiece missing detection results. If the causal reasoning result points to the presence of a missing defect in the workpiece itself, then the initial missing defect detection result will be taken as the final missing defect detection result. Step 6: Store the detection data generated during this detection process in the historical detection result database for adaptive optimization of the initial detection template in the next detection.
2. The workpiece missing detection method based on AI vision according to claim 1, characterized in that, In step 1, the model of the workpiece to be tested is determined, the corresponding initial detection template is called, and the pre-configured detection strategy parameters and brightness parameters are read. Based on the historical detection result database, the initial detection template is adaptively optimized to generate an optimized detection template, thereby obtaining the configured detection environment. Specifically, the steps include the following: The model identifier of the workpiece to be tested is obtained, and an initial detection template matching the model identifier is retrieved from a preset detection template library to obtain the initial detection template corresponding to the workpiece to be tested; wherein, the initial detection template includes the number of cameras, detection surface division parameters, detection sequence parameters, and brightness parameters corresponding to the model identifier of the workpiece to be tested; the brightness parameters include a first brightness mode and a second brightness mode. The pre-configured detection strategy parameters and brightness parameters are parsed and read from the initial detection template to obtain the detection strategy parameters and brightness parameters to be optimized. From the historical inspection results database, read the workpiece missing inspection results and the confidence level of each inspection surface image of the workpiece model to be tested during the most recent inspection process. Then, classify the inspection results that are judged as qualified and the inspection results that are judged as unqualified in the workpiece missing inspection results. At the same time, associate and store the confidence level of each inspection surface inspection result with the inspection results that are judged as qualified in the workpiece missing inspection results to obtain the qualified inspection sample set and the unqualified inspection sample set. Based on the set of qualified and unqualified test samples, the brightness parameters and detection strategy parameters to be optimized are adjusted, and an optimized detection template is generated. The optimized detection template is then deployed to the detection environment to obtain the configured detection environment.
3. The workpiece missing detection method based on AI vision according to claim 2, characterized in that, Based on the sets of qualified and unqualified test samples, the brightness parameters and detection strategy parameters to be optimized are adjusted, and an optimized detection template is generated. The optimized detection template is then deployed to the detection environment to obtain the configured detection environment. The specific steps include the following: Calculate the image clarity score, workpiece placement offset score, and inspection surface image brightness uniformity score for each qualified inspection sample in the qualified inspection sample set. Then, weight and fuse the image clarity score, workpiece placement offset score, and inspection surface image brightness uniformity score with the confidence score of the qualified inspection sample to obtain the comprehensive quality score of each qualified inspection sample. The qualified test samples whose overall quality score is higher than the preset quality threshold are marked as high-quality samples. The missing location information and missing type information of the initial missing test results corresponding to each unqualified test sample are extracted from the set of unqualified test samples to obtain the set of high-quality qualified samples and the distribution information of unqualified defects. From the set of high-quality qualified samples, a first preset number of qualified detection samples are selected as samples to be fused. The detection surface images corresponding to the samples to be fused are sorted in order of image clarity score from high to low. After sorting, a second preset number of detection surface images are selected as fusion candidate images to obtain a sorted fusion candidate image sequence. The images of each detection surface in the sorted fusion candidate image sequence are input into the pre-trained autoencoder network for feature extraction according to the sorting order. The image feature vectors corresponding to each detection surface image are then weighted and averaged to obtain the fusion feature vector. The fused feature vector is input into a pre-trained feature decoder network to reconstruct the image, and the reconstructed image is used as the updated standard template image. Based on the missing location and missing type information in the non-conforming defect distribution information, a defect marking area is generated at the corresponding position and type in the updated standard template image, and the updated standard template image with the defect marking area is used as the reference defect template image. The brightness parameter to be optimized is compared pixel by pixel with the pixel brightness distribution in the reference defect template image to calculate the brightness parameter offset, and the brightness parameter to be optimized is adjusted according to the brightness parameter offset to obtain the updated brightness parameter. The detection surface division parameters in the detection strategy parameters to be optimized are matched with the spatial distribution of the defect marking region in the benchmark defect template image to obtain the matching result. The division boundary coordinates of each detection surface in the detection surface division parameters are adjusted according to the matching result to obtain the updated detection surface division parameters. The optimized detection template is composed of the updated standard template image, the reference defect template image, the updated brightness parameters, and the updated detection surface division parameters. The updated brightness parameters and updated detection surface division parameters from the optimized detection template are deployed to the detection environment to obtain the configured detection environment.
4. The workpiece missing detection method based on AI vision according to claim 3, characterized in that, In step 2, under the configured detection environment, the corresponding camera is activated according to the pre-configured detection strategy parameters and brightness parameters, and surface images of the workpiece to be tested are acquired according to the detection sequence parameters in the pre-configured detection strategy parameters to obtain the image set to be detected. The specific steps include the following: In the configured detection environment, based on the number of cameras in the optimized detection template, the cameras that need to be activated are determined, and the activation order of each camera is determined according to the detection order parameters to be used in the optimized detection template, so as to obtain the camera activation order queue; wherein, the number of cameras is determined to be 1, 2 or 3 depending on the model of the workpiece to be tested; the detection order parameters are collected in ascending order according to the detection surface number. According to the camera startup order queue, a startup command is sent to each camera. After each camera is started, the exposure time and gain parameters of each camera are configured according to the updated brightness parameters to obtain a camera group with complete parameter configuration. Based on the updated detection surface division parameters, the identification of the detection surface to be collected for each camera is determined, and the camera group with completed parameter configuration is controlled according to the detection order parameters to be used, and the surface images of their respective detection surfaces are collected in sequence to obtain the original detection surface image sequence. The original detection surface image sequence is sorted and indexed according to the order of the detection order parameters and the surface number of the updated detection surface division parameters to form a detection image containing image data and corresponding detection surface identifiers. Based on all the detection images containing image data and corresponding detection surface identifiers, a detection image set is obtained.
5. The workpiece missing detection method based on AI vision according to claim 4, characterized in that, In step 3, based on the detection surface division parameters in the pre-configured detection strategy parameters, the pre-trained AI visual detection model is used to perform workpiece missing detection on each detection surface image in the image set to be detected, so as to obtain the initial missing detection results of each detection surface and the confidence level of each detection surface detection result. Specifically, the steps are as follows: For the images to be detected in the image set, extract each detection surface image in the image to be detected according to the surface number of the updated detection surface division parameter in ascending order, and obtain the extracted detection surface images. Arrange the extracted detection surface images in the order of surface number to obtain the sorted detection surface image sequence. The detection surface image with the smallest surface number is selected from the sorted detection surface image sequence as the reference surface image. The reference surface image is then input into the pre-trained AI vision detection model to perform workpiece missing detection, and the reference surface missing detection result and reference surface detection confidence are obtained. Based on the baseline missing detection results and the baseline detection confidence, for each remaining detection surface image in the sorted detection surface image sequence other than the baseline image, the corresponding detection threshold is calculated to obtain the adjusted detection threshold set. According to the arrangement order of the remaining detection surface images in the sorted detection surface image sequence, each remaining detection surface image is sequentially input into the pre-trained AI vision detection model to perform workpiece missing detection, obtain detection output, and use the detection threshold corresponding to the current remaining detection surface image in the adjusted detection threshold set to perform binarization judgment on the detection output to obtain the initial missing detection result of each remaining detection surface and the confidence level of each remaining detection surface detection result; The missing detection results of the reference surface, the confidence level of the reference surface, the initial missing detection results of each remaining detection surface, and the confidence level of the detection results of each remaining detection surface are associated and stored with the corresponding detection surface image according to the detection surface number, so as to obtain the initial missing detection results of each detection surface and the confidence level of the detection results of each detection surface.
6. The workpiece missing detection method based on AI vision according to claim 5, characterized in that, In step 4, a pre-trained AI visual reasoning model is used to perform causal reasoning analysis on the initial missing detection results of each detection surface to identify the root causes of the detection contradictions and obtain the causal reasoning results. Specifically, this includes the following steps: From the initial missing detection results of each detection surface, extract the missing judgment value corresponding to each detection surface, and combine the missing judgment values of all detection surfaces into a detection result vector according to the detection surface number order; From the confidence scores of the detection results of each detection surface, extract the confidence score value corresponding to each detection surface, and combine the confidence scores of all detection surfaces into a confidence score vector according to the detection surface number order; According to the preset cross-surface association rules, the physical constraint relationship and logical dependency relationship between the detection surfaces corresponding to the model of the workpiece to be tested are extracted, and the physical constraint relationship and logical dependency relationship are transformed into ordered detection surfaces to obtain an ordered detection surface list. The consistency of the detection result vector with each detection surface in the ordered detection surface list is checked separately. All detection surfaces that violate physical constraints or logical dependencies are marked to form a detection surface group. Based on all detection surface groups, a set of contradictory detection surface groups is formed. For each contradiction detection surface group in the contradiction detection surface group set, based on the two confidence values in the confidence vector corresponding to the target contradiction detection surface group and the two association edge weight values in the preset cross-surface association rules corresponding to the target contradiction detection surface group, the corresponding false detection probability allocation scheme is found from the preset root cause classification rule table, and the found false detection probability allocation scheme is used as the root cause probability distribution of the target contradiction detection surface group to obtain the root cause probability distribution of each contradiction detection surface group; The root cause probability distribution of each contradiction detection surface group is weighted and fused according to the confidence value of the detection surface involved in each contradiction detection surface group, and the root cause type with the highest probability after fusion is selected as the causal inference result.
7. The workpiece missing detection method based on AI vision according to claim 6, characterized in that, The preset cross-surface association rules include: when the workpiece to be tested is a longitudinal beam with multiple detection surfaces, the missing detection results of the multiple detection surfaces of the longitudinal beam are obtained by judging whether each detection surface is qualified or unqualified at the same time.
8. The workpiece missing detection method based on AI vision according to claim 7, characterized in that, In step 5, an adaptive detection strategy is executed based on the causal inference results and the confidence levels of the detection results for each detection surface. If the causal inference results indicate a false detection, the parameters of the target detection surface are fine-tuned based on the optimized detection template. After parameter fine-tuning, the pre-trained AI visual detection model is used for re-detection to obtain the repaired missing detection results, which are then used as the final workpiece missing detection results. If the causal inference results indicate that the workpiece itself has a missing defect, the initial missing detection results are used as the final workpiece missing detection results. Specifically, this includes the following steps: Extract the final root cause type from the causal reasoning results to obtain the root cause type identifier; The root cause type identifier is compared with the preset root cause type to obtain the first comparison result; If the root cause type identifier in the first comparison result belongs to the false detection type, according to the false detection type, the number of the false detection surface with the highest probability is extracted from the root cause probability distribution of each contradiction detection surface group to confirm the target detection surface. Read the confidence value corresponding to the target detection surface from the confidence of the detection results of each detection surface, and read the brightness parameter and detection surface division parameter corresponding to the target detection surface from the optimized detection template to obtain the current confidence, current brightness parameter and current detection surface division parameter of the target detection surface; Based on the current confidence level, current brightness parameter, and current detection surface division parameter of the target detection surface, a parameter fine-tuning strategy is performed on the target detection surface to obtain the fine-tuned brightness parameter and the fine-tuned detection surface division parameter. The fine-tuned brightness parameters and fine-tuned detection surface segmentation parameters are applied to the target detection surface, and the pre-trained AI vision detection model is used to re-detect the workpiece missing from the target detection surface to obtain the repaired missing detection result, which is then used as the final workpiece missing detection result. If the root cause type identifier in the first comparison result belongs to the workpiece defect type set, the initial missing detection result corresponding to the target detection surface in the initial missing detection results of each detection surface will be taken as the final workpiece missing detection result.
9. The workpiece missing detection method based on AI vision according to claim 8, characterized in that, Based on the current confidence level, current brightness parameter, and current detection surface segmentation parameter of the target detection surface, a parameter fine-tuning strategy is performed on the target detection surface to obtain the fine-tuned brightness parameter and the fine-tuned detection surface segmentation parameter. The specific steps include the following: The current confidence level of the target detection surface is compared with the preset confidence threshold to obtain a second comparison result. The adjustment range is determined based on the difference range between the current confidence level of the target detection surface and the preset confidence threshold in the second comparison result to obtain the adjustment range mark. Based on the adjustment range mark, the brightness increment value corresponding to the current brightness parameter is queried from the preset parameter adjustment rule table, and then the division boundary offset corresponding to the current detection surface division parameter is queried to obtain the brightness increment value and the division boundary offset. The current brightness parameter is added to the brightness increment value to obtain the temporary brightness parameter. The temporary brightness parameter is then clipped to the pre-stored upper and lower limits of the brightness parameter. If the temporary brightness parameter exceeds the upper limit, the upper limit is used; if it is below the lower limit, the lower limit is used to obtain the updated brightness parameter. Add the boundary coordinates of each detection surface in the current detection surface division parameters to the boundary offset of each detection surface to obtain the temporary boundary coordinates. Then, calculate the intersection of the temporary boundary coordinates and the pre-stored detection area boundary range. If the temporary boundary coordinates exceed the pre-stored detection area boundary range, take the boundary range value to obtain the updated detection surface division parameters. The exposure time and gain parameters of the camera corresponding to the target detection surface are reconfigured using the updated brightness parameters to obtain the reconfigured camera parameters. The updated detection surface division parameters are used to redetermine the detection area coordinates of the target detection surface in the image to be detected, so as to obtain the repositioned detection area coordinates. The reconfigured camera parameters and the repositioned detection area coordinates are combined to form a fine-tuned detection configuration, resulting in fine-tuned brightness parameters and fine-tuned detection surface division parameters.