Automatic assembly anomaly detection method and system based on machine vision
Through machine vision technology, DINO models and SAM large models are used for automated detection of bolt safety ropes, which solves detection problems in complex industrial environments, achieves efficient and accurate assembly anomaly detection, adapts to diverse detection requirements, and enhances industrial equipment security.
Patent Information
- Application Number
- CN202410975749.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-19
AI Technical Summary
It is difficult for the existing technology to automatically detect the installation errors and status of bolt safety ropes in complex industrial environments, especially in high vibration and high impact environments. Moreover, traditional methods require a large number of labeled samples and high memory usage, making it difficult to adapt to diverse detection requirements. .
Adopt an automated assembly anomaly detection method based on machine vision, use the DINO model for image feature extraction, combine self-supervised learning and knowledge distillation, use the greedy selection algorithm and Kmeans algorithm for screening and clustering, use the SAM large model for image segmentation, and determine screws The positional relationship with the safety rope enables unsupervised learning to detect assembly anomalies.
It improves detection accuracy and efficiency, reduces false alarms, can accurately identify installation errors in complex industrial environments, enhances the safety and reliability of industrial equipment, and adapts to different standards and requirements.
Smart Images

Figure CN118823477A_ABST
Abstract
Description
Background Art
[0002] Bolt safety ropes are essential in industry. They are devices used to prevent bolts from loosening and falling off. Bolt safety ropes are usually made of high-strength metal wire or synthetic materials. One end is fixed to the bolt and the other end is fixed to another bolt, ensuring that the bolt remains in place even under vibration or load changes. It is very important to install bolt safety ropes correctly to ensure that they can play their maximum effectiveness and prevent mechanical failures and safety accidents caused by loose bolts, especially in high-vibration and high-shock environments such as aviation, aerospace, railways and heavy machinery. By using bolt safety ropes, the reliability and service life of equipment can be greatly improved, ensuring production safety and efficiency.
[0003] The automated detection of screw safety ropes faces many challenges in industrial applications, which mainly stem from the complexity of their use environment and objects. First, the background in the industrial environment is usually complex and changeable, including the intersection of various mechanical equipment and parts, which makes it particularly difficult to accurately segment the screw safety rope from the background. In addition, due to the involvement of manual operations during the installation process, there may be large inconsistencies in the appearance of the screw safety rope, such as different tightness and installation angles, which increases the design complexity of the detection system. At the same time, the diversity of standards for normal and abnormal states of screw safety ropes is also a problem. For example, some screw safety ropes may become loose or damaged due to improper installation or long-term use. The definition of these states is not fixed and needs to be adjusted according to specific application scenarios and safety requirements. In addition, the location distribution of screw safety ropes on the equipment may be very complex, including different types of connection points and path configurations, which requires the detection system to have a high degree of flexibility and adaptability. In addition, in some large industrial enterprises or projects, there may be the participation of multiple insurance institutions, which have strict audits and requirements for the safety of equipment. Effective screw safety rope detection must not only meet the manufacturer's internal standards, but also comply with the safety regulations of all relevant insurance agencies, which requires the detection system to be able to recognize and adapt to different standards and requirements. Figure 1 As shown in the figure, the left side shows the correct way to install the bolt safety rope. If a bolt becomes loose due to external force, the tension inside the safety rope will limit the movement of the bolt and give it a tightening force to prevent the bolt from completely loosening or falling off. Fig. 9 As shown in (a), the safety rope will give a clockwise tightening force to the bolts on both sides to prevent the bolts from loosening. Fig. 9The safety rope in (b) exerts opposite tightening forces on the bolts on both sides, which cannot achieve the purpose of tightening the bolts on both sides. This is the wrong way to install the bolt safety rope. Using machine vision technology to automatically detect screw safety ropes can not only greatly improve the accuracy and efficiency of detection and reduce human errors, but also overcome the complexity of the environment and the diversity of operations through advanced algorithms and learning models, and achieve accurate evaluation and management of the status of screw safety ropes, thereby providing a more solid guarantee for industrial safety.
[0004] The commonly used machine vision inspection method in industry is supervised learning, which requires manual analysis and annotation of images and requires a large number of positive and negative samples. However, the bolt safety rope industrial assembly line targeted by the present invention usually has enough normal samples and a small number of defective samples. In addition, there are certain requirements for inspection efficiency and inspection equipment on the assembly line, requiring low memory usage and as high efficiency as possible.
[0005] Unsupervised learning in deep learning can meet the requirements of assembly line inspection while achieving high detection accuracy. Unsupervised learning only needs to train the model based on normal samples on the production line, and has a low demand for real defect samples. It also has strong environmental adaptability and effectively solves problems such as false alarms in actual inspections. However, existing unsupervised detection algorithms are mainly used to detect low-level structural anomalies, such as pits and scratches, but face certain challenges in logical problems such as wrong screw installation direction. In addition, in actual production lines, the main problem with screw safety ropes is installation errors, and surface defects such as pits and scratches are not key inspection requirements. In order to effectively detect the spatial information between the screws and the safety ropes, we need to use a new unsupervised learning algorithm. Summary of the invention
[0006] Traditional methods require a large number of positive and negative samples and manual labeling is cumbersome, while the installation inconsistency and complex background of bolt safety ropes increase the difficulty of detection; the technical problem to be solved by the present invention is to provide an automated assembly anomaly detection method and system based on machine vision in response to the above-mentioned deficiencies in the prior art, and to adopt an unsupervised learning method in deep learning. By training the model using only normal samples, the detection accuracy and efficiency are improved, and the system can adapt to complex industrial environments, effectively identify logical problems such as installation errors, reduce false alarms, and achieve accurate assessment of the status of screw safety ropes, thereby ensuring the safety and reliability of industrial equipment, and solving the technical problem of automated detection of bolt safety ropes in industrial environments.
[0007] The present invention adopts the following technical solutions:
[0008] An automatic assembly anomaly detection method based on machine vision comprises the following steps:
[0009] S1. Use the network structure pre-trained by the DINO model to extract features from the collected screw safety rope images, extract image features through self-supervised learning and knowledge distillation, and generate a core set;
[0010] S2, using a greedy selection algorithm to sample the core set, filter and cluster the core set to complete the extraction of the safety rope image;
[0011] S3, clustering the feature set filtered in step S2 by using the Kmeans algorithm, and then using the fully connected Gaussian conditional random field, threshold segmentation and area screening algorithm to complete the extraction of the safety rope image;
[0012] S4, using the SAM large model and the safety rope image obtained in step S3, inputting the priori prompt box to complete the extraction of the screw image;
[0013] S5. According to the safety rope image and the screw image extracted in step S3 and step S4, the installation of the screw safety rope is judged by using the position judgment knowledge to realize assembly abnormality detection.
[0014] Preferably, step S1 specifically includes:
[0015] Collect a set of normal screw safety rope images χ; follow the strategy of the DINO network structure model and use the pre-trained DINOVisualTransformer-S / 8 model to calculate each image x i The original feature map f i , the original feature map f i The eigenvector v i Stored in memory bank M i middle.
[0016] Preferably, in step S2, the core set is sampled using a greedy selection algorithm as follows:
[0017]
[0018] M C ←M C ∪{m i}
[0019] Among them, M is the total set of image features before core set sampling, M C is the core set after sampling, n is M C A sample in , m is MM C A sample in m i It is the new core set sample found after each algorithm iteration.
[0020] Preferably, step S3 is specifically:
[0021] The obtained core sets are concatenated to construct a memory bank M, and Kmeans is executed to cluster the feature vectors in the memory bank M to obtain K clusters and their central features f Kmeans ;
[0022] Calculate the central feature f Kmeans With the original feature map f i The cosine similarity between them is then interpolated to the original image size to obtain a preliminary segmentation map;
[0023] The fully connected Gaussian conditional random field is used for post-processing, and the safety rope segmentation map S is obtained by image threshold binarization and area threshold screening.
[0024] Preferably, DenseCRF is used for multiple iterations to implement CRF, and the specific implemented pairwise potential function is as follows:
[0025]
[0026] Among them, f i and f j is a pixel node, p i and p j are their corresponding positions, I i and I j are their corresponding colors, w (1) , w (2) ,θ α ,θ β ,θ γ is a hyperparameter.
[0027] Preferably, in step S4, the SAM large model comprises:
[0028] The image encoder, which is made by using the visual transformer pre-trained with MAE and minimizing it, consists of multiple convolutional and pooling layers to extract image features;
[0029] Hint encoder, by inputting the coordinates of the prior box as hint input;
[0030] The lightweight mask decoder predicts the segmentation mask by integrating the information provided by the image encoder and the hint encoder, restores the feature map to the original image size, and generates the segmentation result.
[0031] Preferably, in step S5, if the centers of the two screws are located on both sides of the minimum circumscribed rectangle of the safety rope, the configuration is considered to be correct; if this condition is not met, it is determined to be wrong.
[0032] Preferably, the screw image extraction process is as follows:
[0033] According to the image segmentation and feature extraction results, obtain the specific segmentation map of the screw and the safety rope;
[0034] Perform image preprocessing on the specific segmentation map of the screw and the safety rope, identify the outline of the screw and the fuse, and calculate the geometric center (x c ,y c );
[0035] Compare the positional relationship between the geometric centers of the two screws and the geometric center of the safety rope; if the product of x and y is a positive number, the installation method of the safety rope is correctly configured; if the product of x and y is a negative number, the installation method of the safety rope is incorrectly configured; if one of the values of x or y is 0, it is a normal configuration;
[0036] The workpiece is marked correct based on the judgment result. If it is judged to be an incorrect configuration, the assembly is marked and an abnormal report is generated to prompt the operator to make adjustments.
[0037] Preferably, in step S3 and step S4, an abnormality judgment mechanism is introduced in the feature extraction and analysis process, and an alarm is triggered when data deviation or feature set abnormality is found. The abnormality judgment conditions are specifically:
[0038] Significant deviations in feature clustering results, indicating assembly errors;
[0039] The core feature set fails to pass the greedy algorithm screening, indicating potential image corruption or occlusion;
[0040] Position relationship analysis shows that the relative position of the screw and the safety rope does not meet the design specifications.
[0041] In a second aspect, an embodiment of the present invention provides an automated assembly anomaly detection system based on machine vision, comprising:
[0042] The acquisition module uses the network structure pre-trained by the DINO model to extract features from the collected screw safety rope images, extracts image features through self-supervised learning and knowledge distillation, and generates a core set;
[0043] The screening module uses a greedy selection algorithm to sample and screen the core set;
[0044] The first extraction module clusters the filtered feature set through the Kmeans algorithm, and then uses the fully connected Gaussian conditional random field, threshold segmentation and area screening algorithm to complete the extraction of the safety rope image;
[0045] The second extraction module uses the SAM large model and the obtained safety rope image to input the priori prompt box and complete the extraction of the screw image;
[0046] The detection module uses the safety rope image and the screw image and position judgment knowledge to determine the installation of the screw safety rope and realize assembly anomaly detection
[0047] In a third aspect, a computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned method for automated assembly anomaly detection based on machine vision when executing the computer program.
[0048] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned automatic assembly anomaly detection method based on machine vision.
[0049] Compared with the prior art, the present invention has at least the following beneficial effects:
[0050] A method for automatic assembly anomaly detection based on machine vision, according to the content of claim 1, the purpose of the entire detection method step is to realize automatic assembly anomaly detection based on machine vision. The advantage of this method is that through the network structure pre-trained by the DINO model, combined with self-supervised learning and knowledge distillation, image features can be extracted and core sets can be generated, thereby realizing accurate extraction and analysis of screw safety rope images; such a design can effectively realize the detection and judgment of assembly anomalies, and improve assembly accuracy and efficiency.
[0051] Furthermore, the setting of step S1 is intended to extract features from the collected screw safety rope images using the network structure pre-trained by the DINO model. The purpose of this step is to extract image features and generate a core set through self-supervised learning and knowledge distillation. Through such a feature extraction process, the key features in the screw safety rope image can be effectively identified and extracted, providing a reliable basis for the subsequent extraction and analysis of the safety rope image. This method can improve the accuracy and efficiency of image processing, thereby achieving the purpose of automated assembly anomaly detection.
[0052] Furthermore, the setting of step S2 is intended to use a greedy selection algorithm to sample the core set, screen and aggregate the core set to complete the extraction of the safety rope image. The purpose of this step is to effectively sample the core set through the greedy selection algorithm to screen and aggregate the core set, thereby achieving accurate extraction of the safety rope image. The greedy selection algorithm can select the current best option at each step according to specific criteria and gradually build the optimal solution. In this way, the efficiency of screening and aggregating the core set can be effectively improved, thereby improving the accuracy and efficiency of extracting the safety rope image.
[0053] Furthermore, the setting of step S3 is intended to cluster the feature set after the screening of step S2 by the Kmeans algorithm, and then use the fully connected Gaussian conditional random field, threshold segmentation and area screening algorithm to complete the extraction of the safety rope image. The purpose of this step is to cluster the feature set using the Kmeans algorithm to achieve effective classification and grouping of features, so as to better extract the safety rope image. The application of the fully connected Gaussian conditional random field, threshold segmentation and area screening algorithm can further optimize and improve the image segmentation process and improve the accuracy and stability of the extraction results. Through the comprehensive application of these algorithms, the accurate extraction of the safety rope image can be effectively achieved, providing a reliable foundation for subsequent assembly anomaly detection.
[0054] Furthermore, the setting of step S4 is intended to utilize the SAM large model, including an image encoder, a prompt encoder, and a lightweight mask decoder, to achieve image feature extraction and segmentation result prediction. The purpose of this step is to achieve efficient feature extraction and accurate segmentation of the image through the collaborative work of various components in the SAM large model, thereby achieving the accuracy and stability of assembly anomaly detection. The image encoder extracts image features through convolutional layers and pooling layers, the prompt encoder provides prompt information through prior frame coordinates, and the lightweight mask decoder predicts the segmentation result based on this information. Through the comprehensive application of the SAM large model, the segmentation and anomaly detection of assembly images can be effectively achieved, and the detection accuracy and efficiency of the system can be improved.
[0055] Furthermore, step S5 aims to determine whether the assembly is correct by judging the relationship between the screw position and the minimum circumscribed rectangle of the safety rope. The purpose of this step is to detect the correctness of the assembly by judging the position relationship and ensure that the screw position meets the requirements of the safety rope. If the screw position meets the conditions, it is determined to be a correct configuration; otherwise, it is determined to be an error. The principle of this step is to achieve rapid detection and judgment of the assembly process through simple position relationship judgment, thereby improving assembly accuracy and efficiency.
[0056] Furthermore, the purpose of introducing an abnormal judgment mechanism in the feature extraction and analysis process is to trigger an alarm in time when data deviation or feature set abnormality is found, so as to prompt the operator to make adjustments. The benefit of this mechanism is to improve the efficiency of the system's automated monitoring and ensure assembly quality. The principle analysis is to determine whether there is an assembly error by monitoring abnormal situations such as feature clustering results, core feature set screening, and position relationship analysis. When an abnormal situation is found, the system can issue an alarm in time, so that the operator can take timely measures to ensure the accuracy and stability of the assembly process.
[0057] It can be understood that the beneficial effects of the second to third aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.
[0058] To sum up, the present invention introduces an abnormality judgment mechanism in the feature extraction and analysis process, thereby realizing timely monitoring and alarm of data deviations or feature set abnormalities, thereby improving assembly quality and automated monitoring efficiency; in addition, the system can also accurately segment and identify the image of the screw safety rope, thereby improving the efficiency and reliability of automated detection, and can effectively improve the accuracy and stability of the assembly process.
[0059] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 It is a flow chart of the present invention;
[0061] Figure 2 This is the structure diagram of the DINO network model;
[0062] Figure 3 Comparison of the safety rope segmentation images with and without DenseCRF processing, where (a) is the safety rope segmentation image without DenseCRF processing, and (b) is the safety rope segmentation image with DenseCRF processing;
[0063] Figure 4 It is the safety rope extraction image, where (a) is the original image of the screw safety rope, and (b) is the feature extraction image of the screw safety rope;
[0064] Figure 5 It is the SAM model structure;
[0065] Figure 6 The following are the results of screw segmentation, where (a) is the left screw segmentation image and (b) is the right screw segmentation image.
[0066] Figure 7 It is a flowchart for determining assembly abnormality;
[0067] Figure 8 The diagrams are for judging whether the center coordinates of the safety rope are correctly installed, wherein (a) is a diagram for judging whether the center coordinates of the safety rope are correctly installed, and (b) is a diagram for judging whether the center coordinates of the safety rope are incorrectly installed;
[0068] Fig. 9 Schematic diagrams of correct and incorrect installation of screw safety ropes, wherein (a) is a schematic diagram of correct installation of screw safety ropes, and (b) is a schematic diagram of incorrect installation of screw safety ropes;
[0069] Fig.10 A schematic diagram of a computer device provided by an embodiment of the present invention;
[0070] Fig.11 The present invention is a block diagram of an electronic device provided according to an embodiment. DETAILED DESCRIPTION
[0071] The present invention provides an automated assembly anomaly detection method based on machine vision, which uses a network structure pre-trained by a DINO model to extract features from the collected screw safety rope image, including scaling the image and inputting it into the DINO model, extracting image features through self-supervised learning and knowledge distillation, and generating a core set; then the core set is screened and clustered to complete the extraction of the safety rope image; the core set is sampled using a greedy selection algorithm to reduce data inference time and storage space, and improve algorithm efficiency and performance; then the filtered feature set is clustered using a Kmeans algorithm, and the safety rope image is extracted using a fully connected Gaussian conditional random field, threshold segmentation, and area screening algorithm; then, the SAM large model technology and the extracted safety rope image are used to input a priori prompt box to complete the extraction of the screw image, and finally, according to the extracted partial images, the correct installation of the screw safety rope is judged using position judgment knowledge. Specifically, the geometric center of the minimum circumscribed rectangle of each screw image is calculated, and these center points are compared with the minimum circumscribed rectangle of the safety rope image. This study sets a standard: if the centers of the two screws are located on both sides of the minimum circumscribed rectangle of the safety rope, the configuration is considered correct; if this condition is not met, it is considered wrong. This scheme ensures the accurate segmentation and identification of the screw safety rope image, and improves the efficiency and reliability of automated detection.
[0072] The present invention adopts an unsupervised segmentation model, through which an image is segmented into multiple components, and screened and extracted according to established rules. Unsupervised learning models often generate large feature sets during feature extraction, because such models lack clear label guidance during the training phase, and thus tend to capture as much information as possible from the data to avoid missing any potentially important details. Although this method can reveal the underlying structure of the data to a certain extent, it may also lead to a significant increase in feature dimensions, thereby increasing computational load and storage requirements. In this context, large model algorithms that combine deep learning with feature selection techniques are particularly critical. These algorithms not only maintain or improve performance by designing more efficient network architectures and using advanced data representation methods, but also effectively reduce the number of feature sets. For example, some algorithms use the hierarchical structure of deep learning to automatically screen and optimize features, retaining only the key features that contribute most to the prediction task. This not only improves the operating efficiency of the model, but also greatly reduces the size of the model, making the model more suitable for application scenarios that require rapid response, such as real-time data processing and applications on mobile devices. The advancement of such technologies is of great significance in improving the efficiency and operability of the model.
[0073] The present invention provides an automated assembly anomaly detection method based on machine vision, which aims to improve the feature recognition and anomaly judgment accuracy of screw safety rope images. Two lightweight large models are used for processing, and the method includes the following steps:
[0074] S1. Perform preliminary segmentation processing on the screw safety rope images taken on the assembly line by using the pre-trained data network;
[0075] The present invention selects the first module of the DINO large model to perform feature extraction.
[0076] S2, apply the greedy selection algorithm to assist in the screening of the core feature set, and further cluster the features through the K-means clustering algorithm;
[0077] S3. In order to improve the detail and accuracy of feature extraction, the SAM large model is introduced to supplement and improve the recognition process of image features and realize the independent extraction of screw and safety rope features;
[0078] S4. Determine whether the installation of the screw safety rope meets the preset standards by analyzing the positional relationship of the extracted features.
[0079] In addition, the present invention introduces an abnormality judgment mechanism in the feature extraction and analysis process. When data deviation or feature set abnormality is found in any step, the system will trigger an alarm. Abnormality judgment conditions include but are not limited to:
[0080] 1) Significant deviations in feature clustering results, indicating possible assembly errors;
[0081] 2) The core feature set fails to pass the greedy algorithm screening, indicating potential image damage or occlusion;
[0082] 3) Position relationship analysis shows that the relative position of the screw and the safety rope does not meet the design specifications.
[0083] Accurate detection of these abnormal conditions provides important protection for ensuring assembly quality, thereby significantly improving the efficiency of automated monitoring of the production line.
[0084] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as systems, methods or program products. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, which may be collectively referred to herein as "circuits", "modules" or "platforms".
[0085] In yet another embodiment of the present invention, a machine vision-based automated assembly anomaly detection system is provided, which can be used to implement the above-mentioned machine vision-based automated assembly anomaly detection method. Specifically, the machine vision-based automated assembly anomaly detection system includes an acquisition module, a screening module, a first extraction module, a second extraction module and a detection module.
[0086] Among them, the acquisition module uses the network structure pre-trained by the DINO model to extract features from the collected screw safety rope images, extracts image features through self-supervised learning and knowledge distillation, and generates a core set;
[0087] The screening module uses a greedy selection algorithm to sample and screen the core set;
[0088] The first extraction module clusters the filtered feature set through the Kmeans algorithm, and then uses the fully connected Gaussian conditional random field, threshold segmentation and area screening algorithm to complete the extraction of the safety rope image;
[0089] The second extraction module uses the SAM large model and the obtained safety rope image to input the priori prompt box and complete the extraction of the screw image;
[0090] The detection module uses the position judgment knowledge to judge the installation of the screw safety rope based on the safety rope image and the screw image, and realizes assembly anomaly detection.
[0091] In another embodiment of the present invention, a terminal device is provided, which includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function; the processor described in the embodiment of the present invention can be used for the operation of the automatic assembly anomaly detection method based on machine vision, including:
[0092] The network structure pre-trained by the DINO model is used to extract features from the collected screw safety rope images, and image features are extracted through self-supervised learning and knowledge distillation to generate a core set. The greedy selection algorithm is used to sample the core set, and the core set is screened and clustered to complete the extraction of the safety rope image. The Kmeans algorithm is used to cluster the filtered feature set, and then the fully connected Gaussian conditional random field, threshold segmentation and area screening algorithm are used to complete the extraction of the safety rope image. The SAM large model and the obtained safety rope image are used to input the prior prompt box to complete the extraction of the screw image. According to the extracted safety rope image and screw image, the position judgment knowledge is used to judge the installation of the screw safety rope to achieve assembly anomaly detection.
[0093] In another embodiment of the present invention, the present invention also provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a terminal device for storing programs and data. It is understandable that the computer-readable storage medium here can include both the built-in storage medium in the terminal device and the extended storage medium supported by the terminal device, and can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that more specific examples (non-exhaustive list) of the computer-readable storage medium here include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0094] Computer readable storage media also include data signals propagated in baseband or as part of a carrier wave, which carry readable program codes. Such propagated data signals can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable storage medium can also be any readable medium other than a readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the readable storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0095] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0096] The processor may load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the method for detecting anomalies in automated assembly based on machine vision in the above embodiment; the processor may load and execute the following steps:
[0097] The network structure pre-trained by the DINO model is used to extract features from the collected screw safety rope images, and image features are extracted through self-supervised learning and knowledge distillation to generate a core set. The greedy selection algorithm is used to sample the core set, and the core set is screened and clustered to complete the extraction of the safety rope image. The Kmeans algorithm is used to cluster the filtered feature set, and then the fully connected Gaussian conditional random field, threshold segmentation and area screening algorithm are used to complete the extraction of the safety rope image. The SAM large model and the obtained safety rope image are used to input the prior prompt box to complete the extraction of the screw image. According to the extracted safety rope image and screw image, the position judgment knowledge is used to judge the installation of the screw safety rope to achieve assembly anomaly detection.
[0098] See also Fig.10 , the terminal device is a computer device, and the computer device 60 of this embodiment includes: a processor 61, a memory 62, and a computer program 63 stored in the memory 62 and executable on the processor 61. When the computer program 63 is executed by the processor 61, the method for calculating the composition of fluid in the reservoir transformation wellbore in the embodiment is realized. To avoid repetition, it is not described one by one here. Alternatively, when the computer program 63 is executed by the processor 61, the functions of each model / unit in the calculation system for the composition of fluid in the reservoir transformation wellbore in the embodiment are realized. To avoid repetition, it is not described one by one here.
[0099] The computer device 60 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The computer device 60 may include, but is not limited to, a processor 61 and a memory 62. Those skilled in the art will appreciate that Fig.10 This is only an example of the computer device 60 and does not constitute a limitation of the computer device 60. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the computer device may also include input and output devices, network access devices, buses, etc.
[0100] The processor 61 may be a central processing unit (CPU), or other general-purpose processors, central processing units, graphics processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, data processing logic based on quantum computing, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0101] The memory 62 may be an internal storage unit of the computer device 60, such as a hard disk or memory of the computer device 60. The memory 62 may also be an external storage device of the computer device 60, such as a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. equipped on the computer device 60.
[0102] Furthermore, the memory 62 may include both an internal storage unit of the computer device 60 and an external storage device. The memory 62 is used to store computer programs and other programs and data required by the computer device. The memory 62 may also be used to temporarily store data that has been output or is to be output.
[0103] Any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0104] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto.
[0105] See also Fig.11 The terminal device 600 is an electronic device, and the electronic device is in the form of a general computing device. The components of the electronic device may include but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different platform components (including the storage unit 620 and the processing unit 610), a display unit 640, etc.
[0106] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps according to various exemplary embodiments of the present invention described in the above method section of this specification. For example, the processing unit 610 can perform the following steps: Figure 1 Follow the steps shown in .
[0107] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .
[0108] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0109] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0110] The electronic device 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 660. The network adapter 660 may communicate with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage platforms, etc.
[0111] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention described and shown in the drawings here can usually be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0112] A method for clustering and segmenting safety ropes based on the K-means algorithm (KMeans) pre-trained features of DINO (Self-distillationWithNoLabels), the specific steps are as follows:
[0113] First, a set of normal screw safety rope images χ={x1,x2,...x i};
[0114] Then follow the strategy in the DINO network and use the first block in the pre-trained DINOVisualTransformer-S / 8 model to calculate each image The intermediate feature is expressed as Where (H, W) and (I, J) represent spatial dimensions, and C and D represent channel dimensions;
[0115] For each image’s original feature map f i , the present invention uses its feature vector Stored in memory bank M i Then use the greedy selection algorithm to sample the core set;
[0116] After sampling is completed, the present invention further connects these core sets in series to construct a memory library M, and then executes Kmeans to cluster these feature vectors in M, thereby obtaining K clusters and their central features.
[0117] Then calculate the central feature f Kmeans With the original feature map f i The cosine similarity between them is then interpolated to the original image size to obtain a preliminary segmentation map;
[0118] Then Benfenming uses the fully connected Gaussian conditional random field (CRF) for post-processing, and then obtains the safety rope segmentation map through image threshold binarization and area threshold screening.
[0119] Vision Transformer (ViT) is a deep learning model for computer vision tasks, which introduces the self-attention mechanism into the visual field. The core idea of ViT is to split the input image into fixed-size image blocks and flatten the pixel values of each image block into a vector form as the input sequence.
[0120] These sequences are then processed by stacking Transformer blocks to achieve the extraction and processing of image features. In the ViT model, a "block" refers to a basic component in the Transformer architecture, which consists of multiple layers, including multi-head self-attention layers, feedforward fully connected layers, residual connections, and layer normalization. These blocks are responsible for feature transformation and representation learning of the input sequence. For the first block in ViT, it plays a special role. In the pre-training stage, by converting each image block of the image into a sequence and inputting it into the first block of the model, the global features and structural information of the image can be captured. This is because the first block usually contains a larger receptive field and stronger parameterization ability, which can effectively learn the global features in the image.
[0121] Therefore, the first block of the ViT model can be used to effectively extract image features while retaining global information; DINO is an image feature extraction method based on self-supervised learning, which uses the information of the image itself to learn the feature representation of the image without the need for labeled data; by combining DINO and ViT, the ViT model is trained using self-supervised learning, so that a richer and more general feature representation can be learned on large-scale unlabeled image data; DINO is introduced into the ViT model, so that ViT can learn the feature representation of the image more efficiently and effectively during training; by pre-training the DINOViT model, the parameters of the ViT model are learned using large-scale unlabeled image data, so as to obtain a more generalized image feature extractor.
[0122] Therefore, the present invention uses DINO to pre-train features of the screw safety rope image, and uses the first block in the DINOViT model to extract image features. In addition, since the present invention is mainly aimed at industrial images, which show a higher level of distribution consistency than natural images, and the industrial site has high requirements for detection efficiency, the present invention simplifies the model to a certain extent. In the present invention, image segmentation of screw safety ropes is a key task. Therefore, the model should focus on specific industrial applications rather than over-generalization. For example, in self-supervised DINO training, color enhancement is often used to enhance the model's adaptability to various color changes. Although this has its advantages in a wide range of natural environments, because diverse colors often point to the same semantic category, in the industrial detection of screw safety ropes, ignoring slight changes in color may mask key abnormal signals. In view of this scene difference, the present invention adopts a feature clustering and precise post-processing strategy based on DINO to construct a targeted and efficient segmentation model.
[0123] See also Figure 2 In the DINO network structure model, the input image x is the image of the screw safety rope, g θsFor student networks, g θt is the teacher network, and both networks will output s and p t The probability distribution on the K dimension is represented by the probability P, which is obtained by normalizing the output of the network g using the softmax function. The specific implementation formula is:
[0124]
[0125] Among them, τ s >0 is a temperature parameter that controls the sharpness of the output distribution. A similar formula also applies to the temperature τ t P t By giving a fixed teacher network g θt , by minimizing the student network parameters θ s The associated cross entropy loss learns to match these distributions.
[0126] Student Networkθ s The parameters are:
[0127]
[0128] Among them, H(a,b)=-alogb.
[0129] Formula 2 is applied to the self-supervised learning of the screw safety rope image as follows:
[0130] First, a multi-crop strategy is used to construct different distorted views or crops of the image, that is, a set of different viewing angles V is generated from a given screw safety rope image;
[0131] Two global perspectives in this collection and and several local views with smaller f resolutions; the global view is only passed through the teacher, and the cropped image is passed through the student; minimizing the loss, which is universal and can be applied to any number of views, even only 2, to meet the situation of few defective samples on industrial production lines. But following the standard setting of multi-crop, a resolution of 224 is used. 2 2 global attempts to cover large areas (greater than 50%) of the original image, and several 96-resolution 2 The two networks share the same architecture g, but have different parameter sets θ. s and θ t , the present invention uses formula 3 stochastic gradient descent minimization to learn the parameter θ s .
[0132] Loss function Ls It is expressed as:
[0133]
[0134] The present invention constructs a core set with the collected features. The goal of core set selection is to find a subset S∈A from the existing screw safety rope images, so that a more compact and less time-consuming solution can be found on the subset S, and the solution has the highest degree of similarity with the solution of the full set A, thereby reducing the consumption of the overall algorithm and improving efficiency, meeting the efficiency requirements in actual production, and providing the robustness and generalization ability of the model.
[0135] The overall dataset is M, and the core set covers approximately M C , specifically expressed as follows:
[0136]
[0137] In order to further reduce the time consumption of core set selection, the present invention selects an iterative greedy core set selection algorithm to reduce the dimension of m∈M by random linear projection. In each iteration, the algorithm will find the core set closest to each sample point outside the non-core set and calculate the distance between the two, which is used as the distance between the point and the core set. This strategy aims to retain the local structure of the original data set to the greatest extent, while making the feature distribution similar to the original data set. Then, the sample farthest from the core set is selected as part of the core sample to ensure the diversity and representativeness of the core set. The whole process is specifically implemented by Formula 5:
[0138]
[0139] Among them, M is the total set of image features before core set sampling, M C is the core set after sampling, n is M C A sample in , m is MM C A sample in m i It is the new core set sample found after each algorithm iteration.
[0140] In the implementation of the iterative greedy core set selection algorithm, the memory M and the core set length L are used as inputs. The core set length L is determined by the sampling rate r, that is,
[0141] After experiments, the same screw safety rope image was divided. From left to right, the features of each part of the safety rope image were clustered after core set selection according to different sampling rates. They are the shaft, screw, safety rope and central platform area. When r = 0.1, the model's segmentation of the safety rope and the screw is not thorough enough, but when r = 0.01, the safety rope is effectively segmented. After repeated experiments, r = 0.01 was finally selected as the best effect.
[0142] After completing the core set selection, the selected core sets are connected to build a memory bank M′, and then KMeans is performed to cluster the feature vectors in the memory bank M′ to obtain K clusters and their central features f Kmeans ; KMeans algorithm is widely used in various scenarios, including image recognition, data mining and machine learning. Its main advantages are simplicity and efficiency. This algorithm optimizes the clustering quality through an iterative process, and finally minimizes the distance between the data points in each cluster and their corresponding center points. It can effectively process large data sets and is easy to implement. It converges quickly without excessive hardware requirements and long convergence time. In the detection of screw safety ropes, KMeans can help us identify different operation modes or potential abnormal modes from large-scale detection data. By analyzing the central features of each cluster, specific data points that may need further inspection can be quickly located. It is convenient for the subsequent extraction of target features. At the same time, as an unsupervised learning method, it can organize and classify data without relying on pre-defined category labels. This is particularly important for objects such as screw safety ropes, because it is often difficult to obtain sufficient labeled samples in practical applications. Cluster analysis can reveal the inherent structure and patterns in the data, thus providing a basis for further analysis and decision-making.
[0143] In the present invention, the KMeans clustering algorithm only needs to adjust the parameter of the number of classes k. After experiments, for the experimental sample of screw safety rope, when k=4, the overall effect is the best, and the safety rope image is effectively segmented, providing a reliable basis for whether the subsequent safety rope is correct.
[0144] In the DINO network feature extraction, the present invention causes a certain loss of image features, which leads to blurred boundaries of classified targets. In order to optimize the rough and uncertain marks in the classified image, correct the fragmented misclassified areas, and obtain more detailed segmentation boundaries, the present invention uses a fully connected Gaussian conditional random field (DenseCRF) to optimize the preliminary segmentation map of the screw safety rope.
[0145] Fully Connected Gaussian Conditional Random Field (DenseCRF) is a variant of dense conditional random field, especially used for dense prediction tasks such as image segmentation. Compared with traditional CRF, DenseCRF pays more attention to modeling the spatial relationship between pixels to better capture the dependencies between adjacent pixels in the image.
[0146] Specifically, the “fully connected” in the fully connected Gaussian conditional random field means that there is a connection between every pixel, that is, every pixel is associated with all other pixels in the image.
[0147] The "Gaussian" refers to the use of Gaussian kernel functions to model the relationship between these pixels. In the fully connected Gaussian conditional random field, the label prediction of a pixel is affected not only by its own features, but also by the features and labels of its surrounding pixels. This model can utilize the spatial locality information between pixels in the image and improve the accuracy of pixel-level label prediction by considering the association between adjacent pixels.
[0148] DenseCRF usually defines the relationship between pixel labels through an energy function. This energy function consists of two parts: data term and smoothing term.
[0149] The data term is used to measure the fit between the predicted label and the observed data, while the smoothness term is used to measure the consistency between adjacent pixel labels. In a fully connected Gaussian conditional random field, the smoothness term is usually represented by a Gaussian potential energy, which measures the similarity between pixels based on their distance, thus taking into account spatial relationships.
[0150] The present invention uses DenseCRF to perform multiple iterations to implement CRF, and its specific implementation of the paired potential function is shown in Formula 6:
[0151]
[0152] Among them, f i and f j is a pixel node, p i and p j are their corresponding positions, I i and I j are their corresponding colors, where w (1) , w (2) ,θ α ,θ β ,θ γ is the hyperparameter used in this formula.
[0153] After experiments, when the number of iterations is 2, w (1) =4,w (2) =3,θ α =67,θβ =3,θ γ =1, the experimental effect is best. Figure 3 As shown in the figure, the edge of the segmentation image of the safety rope is clearer after being processed by DenseCRF.
[0154] After DenseCRF processing, the present invention uses a threshold binarization method to further clearly distinguish the safety rope and background in the image. This step converts the image into a black and white format, where pixel values within a preset threshold range of [35,255] are set to white (representing the safety rope) and other values are converted to black (representing the background). This threshold range is selected based on experimental data to minimize misclassification and improve the accuracy of target detection.
[0155] In addition, in order to exclude noise or non-target elements in the image, the present invention introduces an area threshold screening step. In this step, only connected regions with an area within the range of [1000,3000] pixels squared are retained, which is based on the analysis of multiple sample images to ensure that the retained regions are most likely to represent the actual safety rope. In this way, image regions that are too large or too small can be effectively excluded, improving the accuracy and reliability of the final image segmentation.
[0156] The image processing method of the present invention combines DenseCRF optimization with precise post-processing steps, including threshold binarization and area threshold screening, which significantly improves the recognition accuracy and efficiency of safety rope images. The final safety rope extraction result is shown in Figure 2. Figure 4 shown.
[0157] The post-processing method of screw safety rope based on SegmentAnything (SAM) large model is as follows:
[0158] Through the above steps, the screw safety rope extraction image is obtained, but in order to determine whether the safety rope is correct, the screw extraction image is required. The above method often mixes the screw image with the background image and cannot accurately extract the screw image.
[0159] In order to solve this problem, the present invention uses the SAM model here. Under the premise of knowing the safety rope extraction image, a certain prior frame is generated according to its minimum circumscribed rectangle, and it is used as input to extract and visualize the screw features to realize the subsequent judgment of whether the screw safety rope image is correct.
[0160] SAM is a general instance segmentation model based on Transformer, which aims to generate accurate instance segmentation masks for any input image and any prompt at any position. The core idea of SAM is to use the self-attention mechanism of Transformer to capture the relationship between different objects in the image, so as to achieve more accurate instance segmentation.
[0161] See also Figure 5 ,The architecture of SAM consists of three components that work together to return valid ,segmentation masks.
[0162] The first is an image encoder, which uses a MAE pre-trained visual converter and minimizes it. It consists of multiple convolutional layers and pooling layers to extract image features. Each convolutional layer includes operations such as convolution kernels, activation functions, and batch normalization to extract features and reduce the dimension of the input image. The pooling layer is used to downsample the feature map to reduce computation and memory consumption;
[0163] The second is a hint encoder, where the present invention uses the coordinates of the prior box as hint input;
[0164] The third is a lightweight mask decoder, which predicts the segmentation mask by integrating the information provided by the first two information sources. This part consists of multiple deconvolution layers and upsampling layers to restore the feature map to the original image size and generate the segmentation result.
[0165] By using the weights pre-trained with the SA-1B dataset, the present invention directly applies the SAM large model to the screw safety rope image segmentation task. By using the input prior box as a prompt, the two screw parts that are difficult to effectively segment can be directly segmented. The results are shown in Figure 2. Figure 6 shown.
[0166] The threshold binarization segmentation method is used to segment the image into representative binary images according to the pixel value, so that the target object is clearly distinguished from the background, and the safety rope image and the screw image are effectively segmented.
[0167] After successful segmentation, the present invention applies the Minimum Bounding Rectangle (MBR) algorithm to each target object. The MBR algorithm calculates the smallest rectangular area that can cover each segmented object. This step is very important for determining the geometric position and size of the object. The minimum bounding rectangle of each object is mapped back to the original image for further spatial position analysis.
[0168] The spatial position analysis is mainly based on the center position of the screw image. By calculating the geometric center of the minimum circumscribed rectangle of each screw image and comparing these center points with the minimum circumscribed rectangle of the safety rope image, the present invention sets a standard:
[0169] If the centers of the two screws are located on both sides of the minimum circumscribed rectangle of the safety rope, the configuration is considered correct; if this condition is not met, it is considered incorrect.
[0170] The development of this standard is based on the actual application needs of safety ropes and screws in visual systems. For example, in safety inspections or assembly work, ensuring the correct position of the screws is crucial to overall safety.
[0171] See also Figure 7 The specific implementation process is as follows:
[0172] 1) Based on the previous image segmentation and feature extraction results, obtain the specific segmentation map of the screw and safety rope;
[0173] 2) Perform image preprocessing operations, including denoising, contrast enhancement, etc., so as to more accurately identify the contours of screws and fuses;
[0174] 3) Identify the outlines of the screw and safety rope and calculate their minimum circumscribed rectangle;
[0175] 4) Calculate the geometric center (x) of the minimum circumscribed rectangle of each screw and safety rope according to Formula 7 c ,y c );
[0176]
[0177] Among them, x1 and y1 are the horizontal and vertical coordinates of a vertex of the minimum circumscribed rectangle on the original image, and x2 and y2 are the horizontal and vertical coordinates of the vertex diagonally located with respect to the vertex.
[0178] 5) Compare the positional relationship between the geometric centers of the two screws and the geometric center of the safety rope;
[0179] The comparison rules follow the following formula:
[0180]
[0181] If the product of x and y is a positive number, the safety rope is installed in a correct configuration. If the product of x and y is a negative number, the safety rope is installed in an incorrect configuration. If one of the values of x or y is 0, it is also considered to be a normal configuration.
[0182] like Figure 8As shown, the left side is an example of the correct installation of the safety rope. The center coordinates of the minimum circumscribed rectangle of the two screws are located on both sides of the center coordinates of the minimum circumscribed rectangle of the safety rope, which meets the correct installation judgment standard. The right side is an example of the incorrect installation of the safety rope. The center coordinates of the minimum circumscribed rectangle of the two screws are located on the same side as the center coordinates of the minimum circumscribed rectangle of the safety rope, which meets the incorrect installation judgment standard.
[0183] 6) Mark the workpiece according to the result of step 5). If it is determined to be an incorrect configuration, mark the assembly and generate an abnormal report to prompt the operator to make adjustments.
[0184] In summary, the present invention provides an automated assembly anomaly detection method and system based on machine vision, which realizes the precise segmentation of the screw safety rope image and the determination of the installation position relationship through the steps of feature extraction, screening, clustering and position judgment, thereby improving the efficiency and reliability of automated detection.
[0185] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0186] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0187] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0188] In the embodiments provided by the present invention, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0189] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0190] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0191] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0192] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0193] The above contents are only for explaining the technical idea of the present invention and cannot be used to limit the protection scope of the present invention. Any changes made on the basis of the technical solution in accordance with the technical idea proposed by the present invention shall fall within the protection scope of the claims of the present invention.
Claims
1. A method for detecting anomalies in automated assembly based on machine vision, characterized in that: The following steps are involved: S1. Use the network structure pre-trained by the DINO model to extract features from the collected screw safety rope images, extract image features through self-supervised learning and knowledge distillation, and generate a core set; S2, using a greedy selection algorithm to sample the core set, filter and cluster the core set to complete the extraction of the safety rope image; S3, clustering the feature set filtered in step S2 by using the Kmeans algorithm, and then using the fully connected Gaussian conditional random field, threshold segmentation and area screening algorithm to complete the extraction of the safety rope image; S4, using the SAM large model and the safety rope image obtained in step S3, inputting the priori prompt box to complete the extraction of the screw image; S5. According to the safety rope image and the screw image extracted in step S3 and step S4, the installation of the screw safety rope is judged by using the position judgment knowledge to realize assembly abnormality detection.
2. The method for detecting anomalies in automated assembly based on machine vision according to claim 1, characterized in that: Step S1 is specifically as follows: Collect a set of normal screw safety rope images χ; follow the strategy of the DINO network structure model and use the pre-trained DINOVisualTransformer-S / 8 model to calculate each image x i The original feature map f i , the original feature map f i The eigenvector v i Stored in memory bank M i middle.
3. The method for detecting anomalies in automated assembly based on machine vision according to claim 1, characterized in that: In step S2, the core set is sampled using the greedy selection algorithm as follows: M C ←M C ∪{m i } Among them, M is the total set of image features before core set sampling, M C is the core set after sampling, n is M C A sample in , m is MM C A sample in m i It is the new core set sample found after each algorithm iteration.
4. The method for detecting anomalies in automated assembly based on machine vision according to claim 1, characterized in that: Step S3 is specifically as follows: The obtained core sets are concatenated to construct a memory bank M, and Kmeans is executed to cluster the feature vectors in the memory bank M to obtain K clusters and their central features f Kmeans ; Calculate the central feature f Kmeans With the original feature map f i The cosine similarity between them is then interpolated to the original image size to obtain a preliminary segmentation map; The fully connected Gaussian conditional random field is used for post-processing, and the safety rope segmentation map S is obtained by image threshold binarization and area threshold screening.
5. The method for detecting anomalies in automated assembly based on machine vision according to claim 4, characterized in that: Use DenseCRF for multiple iterations to implement CRF. The specific implementation of the pairwise potential function is as follows: Among them, f i and f j is a pixel node, p i and p j are their corresponding positions, I i and I j are their corresponding colors, w (1) , w (2) ,θ α ,θ β ,θ γ is a hyperparameter.
6. The method for detecting anomalies in automated assembly based on machine vision according to claim 1, characterized in that: In step S4, the SAM large model includes: The image encoder, which is made by using the visual transformer pre-trained with MAE and minimizing it, consists of multiple convolutional and pooling layers to extract image features; Hint encoder, by inputting the coordinates of the prior box as hint input; The lightweight mask decoder predicts the segmentation mask by integrating the information provided by the image encoder and the hint encoder, restores the feature map to the original image size, and generates the segmentation result.
7. The method for detecting anomalies in automated assembly based on machine vision according to claim 1, characterized in that: In step S5, if the centers of the two screws are located on both sides of the minimum circumscribed rectangle of the safety rope, the configuration is considered correct; if this condition is not met, it is determined to be wrong.
8. The method for detecting anomalies in automated assembly based on machine vision according to claim 7, characterized in that: The extraction process of the screw image is as follows: According to the image segmentation and feature extraction results, obtain the specific segmentation map of the screw and the safety rope; Perform image preprocessing on the specific segmentation map of the screw and the safety rope, identify the outline of the screw and the fuse, and calculate the geometric center (x c ,y c ); Compare the positional relationship between the geometric centers of the two screws and the geometric center of the safety rope; if the product of x and y is a positive number, the installation method of the safety rope is correctly configured; if the product of x and y is a negative number, the installation method of the safety rope is incorrectly configured; if one of the values of x or y is 0, it is a normal configuration; The workpiece is marked correct based on the judgment result. If it is judged to be an incorrect configuration, the assembly is marked and an abnormal report is generated to prompt the operator to make adjustments.
9. The method for detecting anomalies in automated assembly based on machine vision according to claim 1, characterized in that: In step S3 and step S4, an abnormality judgment mechanism is introduced in the feature extraction and analysis process. When data deviation or feature set abnormality is found, an alarm is triggered. The abnormality judgment conditions are as follows: Significant deviations in feature clustering results, indicating assembly errors; The core feature set fails to pass the greedy algorithm screening, indicating potential image corruption or occlusion; Position relationship analysis shows that the relative position of the screw and the safety rope does not meet the design specifications.
10. An automated assembly anomaly detection system based on machine vision, characterized in that: include: The acquisition module uses the network structure pre-trained by the DINO model to extract features from the collected screw safety rope images, extracts image features through self-supervised learning and knowledge distillation, and generates a core set; The screening module uses a greedy selection algorithm to sample and screen the core set; The first extraction module clusters the filtered feature set through the Kmeans algorithm, and then uses the fully connected Gaussian conditional random field, threshold segmentation and area screening algorithm to complete the extraction of the safety rope image; The second extraction module uses the SAM large model and the obtained safety rope image to input the priori prompt box and complete the extraction of the screw image; The detection module uses the position judgment knowledge to judge the installation of the screw safety rope based on the safety rope image and the screw image, and realizes assembly anomaly detection.
Citation Information
Patent Citations
Method, system and device for retina OCT image anomaly detection and medium
CN116758028A
Electrical equipment defect detection method and system based on self-supervised learning
CN117671587A
System and method for joint detection, localization, segmentation and classification of anomalies in images
WO2024102565A1
Cited By
Bolt assembly detection method and device based on visual large model, computing equipment and storage medium
CN120236244A
Bolt assembly detection method, device, computing equipment and storage medium based on visual large model
CN120236244B
Real-time monitoring method for electrical equipment production assembly line
CN120876459A
Board splicing machine anomaly detection method and system based on vision intelligence
CN121147642A
