Guide rail surface defect detection method based on illumination conditions and related equipment

By determining the area of ​​the guide rail to be inspected and changing the lighting sequence to collect image data, combined with preprocessing and defect detection models, the problems of low lighting adjustment efficiency and poor robustness in the existing technology are solved, and efficient and accurate guide rail defect detection is achieved.

CN119574441BActive Publication Date: 2025-09-12SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411747486.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-09-12
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

Existing guide rail surface defect detection methods rely on manual adjustment of lighting conditions, which is inefficient and costly. Traditional lighting equipment cannot be adjusted in real time, resulting in poor detection robustness and the occurrence of false positives and false negatives.

Method used

By determining the area to be inspected on the target guide rail, changing the illumination sequence to collect image datasets, and inputting them into the defect detection model after preprocessing, the illumination parameters are adjusted in real time to detect defects. The encoder is used to extract multi-scale feature information, and the decoder performs anomaly score analysis and automatic threshold selection.

Benefits of technology

The accuracy and efficiency of guide rail defect detection are improved, the detection cost is reduced, the robustness and adaptability of the detection system are enhanced, and the system is suitable for various computing device environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119574441B_ABST
    Figure CN119574441B_ABST
Patent Text Reader

Abstract

The present application provides a guide rail surface defect detection method based on lighting conditions and related equipment. When it is necessary to detect the defects of the target guide rail, the method provided in the embodiment of the present application can determine the defect conditions of the target guide rail by analyzing the image data of the target guide rail to be detected under different lighting sequences. Through the lighting equipment, it is effective to adjust the lighting parameters of the lighting equipment in real time during the detection of the target guide rail to collect different image data. The defect conditions of the target guide rail can be analyzed more comprehensively, and the cost of detecting the defects of the target guide rail can be effectively reduced. Compared with the existing technical solutions, the method provided in the embodiment of the present application can improve the accuracy of the detection results of the target guide rail and have better performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of guide rail equipment detection, and in particular to a guide rail surface defect detection method based on lighting conditions and related equipment. Background Art

[0002] In practical applications, guide rails, as a critical mechanical component, are widely used in various fields. Their surface quality directly impacts the performance and service life of the entire equipment. During production and use, various types of defects, such as scratches, pits, corrosion, and cracks, may appear on the guide rail surface. These defects not only reduce the guide rail's accuracy but can also cause equipment failure or even downtime. In recent years, image processing-based methods have gradually become a trend in guide rail surface defect detection. Due to factors such as the smoothness, strong reflectivity, and complex texture of the guide rail surface, lighting conditions have a significant impact on the appearance of guide rail surface defects, posing a challenge to image processing algorithms.

[0003] Currently, the lighting conditions for guide rail surface defect inspection primarily rely on manual adjustment and regular maintenance. This not only results in low adjustment efficiency and high costs, but also introduces subjective judgment errors. Because lighting equipment includes parameters such as the position of the lighting unit, light intensity, and light color temperature, inspectors need to spend a considerable amount of time debugging the lighting equipment before inspection. Traditional lighting equipment lacks adaptive adjustment capabilities, making it impossible to adjust lighting parameters in real time during the guide rail inspection process. This results in a large number of false positives and false negatives, reducing the robustness of the inspection system and impacting the performance and service life of the equipment. Therefore, a lightweight, fast-inference method for optimizing lighting conditions for guide rail surface defect inspection is a requirement for both production and use. Summary of the Invention

[0004] The present application aims to solve at least one of the above-mentioned technical defects. In view of this, the present application provides a guide rail surface defect detection method based on lighting conditions and related equipment, which are used to solve the technical defect of difficult guide rail defect detection in the existing technology.

[0005] A guide rail surface defect detection method based on illumination conditions, comprising:

[0006] Determine the area to be inspected of the target guide rail;

[0007] changing a lighting sequence for the area to be inspected of the target guide rail, and collecting first image data sets of the area to be inspected of the target guide rail under different lighting sequences, wherein the first image data sets include first image data of at least one area to be inspected of the target guide rail corresponding to each lighting sequence, wherein the lighting sequence includes a position of a lighting unit, an intensity of the lighting, and a color temperature of the lighting;

[0008] Preprocessing the first image data set to obtain a second image data set;

[0009] The second image data set is input into a preset defect detection model for detection to obtain a detection result of the target guide rail, wherein the detection result of the target guide rail includes the location of the defect in the target guide rail. The preset defect detection model is trained using the image data set corresponding to the area to be detected of the training guide rail as a training sample and the detection result corresponding to the image data set corresponding to the area to be detected of the training guide rail as a sample label.

[0010] Preferably, the detection result of the target guide rail further includes a probability that the target guide rail presents a defect, and the method further includes:

[0011] Analyzing the inspection results of the target guide rail in the area to be inspected, and determining all peaks in the probability of the target guide rail presenting defects included in the inspection results of the target guide rail;

[0012] According to all peaks in the probability of the target guide rail presenting defects, a lighting sequence for re-detecting defects of the target guide rail is set.

[0013] Preferably, the preprocessing of the first image dataset to obtain the second image dataset includes:

[0014] Performing a first color space conversion process on each first image data of the first image data set to obtain a first target image data set;

[0015] performing histogram equalization processing on the image data in the first target image data set to obtain a second target image data set;

[0016] Performing a second color space conversion process on the image data of the second target image data set to obtain a third target image data set as the second image data set.

[0017] Preferably, performing histogram equalization processing on the image data in the first target image data set includes:

[0018] Calculate the probability distribution result of each brightness value in the V channel of each image data in the first target image data set, wherein the calculation formula of the probability distribution result of each brightness value in the V channel of each image data in the first target image data set is: p(v k) is the probability distribution function of each brightness value in the V channel of each image data in the first target image dataset, nk is the number of pixels with brightness value vk in the V channel of each image data in the first target image dataset, and n is the total number of pixels of each image data in the first target image dataset;

[0019] Based on the probability distribution result of each brightness value in the V channel of each image data in the first target image data set, the cumulative distribution result of each brightness value in the V channel of each image data in the first target image data set is calculated, wherein the calculation formula for calculating the cumulative distribution result of each brightness value in the V channel of each image data in the first target image data set is: C(v k ) is the cumulative distribution function of each brightness value in the V channel of each image data in the first target image data set, and i and k are indexes in the calculation process;

[0020] Based on the cumulative distribution result of each brightness value in the V channel of each image data in the first target image data set, each brightness value in the V channel of each image data in the first target image data set is mapped to a new equalized brightness value, wherein the mapping relationship between each brightness value in the V channel of each image data in the first target image data set and the equalized brightness value in a mapping relationship therewith is v' k =(F-1)·C(v k ), where v k A new equalized brightness value corresponds to each brightness value in the V channel of each image data in the first target image data set, and F is the maximum brightness value of each image data in the first target image data set.

[0021] Preferably, analyzing the inspection results of the target guide rail in the area to be inspected and determining all peaks in the inspection results of the target guide rail, which are included in the probability of the target guide rail presenting a defect, comprises:

[0022] multi-scale analysis of the probability of the target guide rail presenting a defect included in the inspection result of the target guide rail's area to be inspected, so as to smooth the data of the probability of the target guide rail presenting a defect at different scales to generate a multi-scale target signal;

[0023] Performing local peak detection on the target signal at each scale, marking the positions of the target rails corresponding to all local maxima in the target signal at each scale;

[0024] Counting the occurrence frequencies of local peaks at the same position of the target guide rail at different scales to generate a defect peak frequency distribution result of the target guide rail;

[0025] According to the defect peak frequency distribution result of the target guide rail, the peaks that meet the preset conditions at each scale are determined as all peaks of the probability that the target guide rail presents a defect.

[0026] Preferably, the preset defect detection model includes an encoder and a decoder;

[0027] Wherein, the encoder is used to extract multi-scale feature information of image data of the object to be detected under different lighting conditions;

[0028] The decoder is used to perform an anomaly score analysis on the multi-scale feature information extracted by the encoder based on a likelihood value anomaly score analysis method, and generate an anomaly map corresponding to the pixel level of the object to be detected; and calculate the false positive data of the generated anomaly map corresponding to the pixel level of the object to be detected, and perform automatic threshold selection and anomaly segmentation processing on the generated anomaly map;

[0029] The formula for calculating the anomaly score of the multi-scale feature information extracted by the encoder is: Wherein, AS(i,j) represents the abnormality score of the pixel point with coordinates (i,j); (i,j) represents the pixel position coordinate information in the image data corresponding to the object to be detected extracted by the encoder; represents the white Gaussian embedding generated by the normalized data stream, corresponding to the embedding value of the kth channel of the pixel (i, j) in the image data corresponding to the object to be detected extracted by the encoder at the lth scale, which obeys the standard normal distribution; L represents the total number of scales extracted by the multi-scale features of the image data corresponding to the object to be detected extracted by the encoder; C l Indicates the number of channels at the lth scale;

[0030] The formula for calculating the false positive data of the abnormality map corresponding to the pixel level of the object to be detected and performing automatic threshold selection and abnormality segmentation processing on it is:

[0031]

[0032] in, Represents the characteristic information of the image; k represents the index in the calculation process; NFA(E) represents the number of false alarms function; u(i,j) is a defined variable, that is, a mapping function representing the abnormality score, which has a degree of freedom of C l Chi-square distribution of x 2 (C l ); is the probability that pixel (i, j) is abnormal under the background model H0; is the degree of freedom C lThe cumulative distribution function (CDF) of the chi-square distribution; t is the potential characteristic The threshold of the sum of squares; N T is the number of all possible connected components.

[0033] Preferably, the calculation formula of the total loss function of the preset defect detection model is: T represents the total loss function of the preset defect detection model; A distillation loss representing anomaly scores of multi-scale feature information of the object to be detected extracted by the encoder of the preset defect detection model; represents false positive data of anomaly maps corresponding to the pixel level of the object to be detected generated by the decoder of the preset defect detection model; L CE represents the cross entropy loss; α, β and γ are L CE The weight coefficient of .

[0034] A guide rail surface defect detection device based on illumination conditions, comprising:

[0035] A unit for determining an area to be inspected, used for determining an area to be inspected of a target guide rail;

[0036] an illumination sequence setting unit, configured to change an illumination sequence for the area to be inspected of the target guide rail, and collect first image data sets of the area to be inspected of the target guide rail under different illumination sequences, wherein the first image data sets include first image data of at least one area to be inspected of the target guide rail corresponding to each illumination sequence, wherein the illumination sequence includes a position of an illumination unit, an intensity of illumination, and a color temperature of illumination;

[0037] a data preprocessing unit, configured to preprocess the first image data set to obtain a second image data set;

[0038] A defect detection unit is used to input the second image data set into a preset defect detection model for detection to obtain a detection result of the target guide rail, wherein the detection result of the target guide rail includes the location of the defect in the target guide rail, and the preset defect detection model is trained using the image data set corresponding to the to-be-detected area of ​​the training guide rail as a training sample and the detection result corresponding to the image data set corresponding to the to-be-detected area of ​​the training guide rail as a sample label.

[0039] A guide rail surface defect detection device based on lighting conditions includes: one or more processors, and a memory; the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the guide rail surface defect detection method based on lighting conditions as described in any of the above introductions are implemented.

[0040] A readable storage medium stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors implement the steps of the guide rail surface defect detection method based on lighting conditions as described in any of the above introductions.

[0041] It can be seen from the technical solutions introduced above that when it is necessary to detect the defects of the target guide rail, the method provided in the embodiment of the present application can determine the area to be detected of the target guide rail; and by changing the illumination sequence for the area to be detected of the target guide rail, the first image data set of the area to be detected of the target guide rail under different illumination sequences is collected, so that the defects of the target guide rail can be detected by analyzing the image data of the area to be detected of the target guide rail under different illumination conditions, wherein the first image data set may include the first image data of the area to be detected of at least one target guide rail corresponding to each set of illumination sequences, wherein the illumination sequence may include the position of the illumination unit, the intensity of the illumination and the color temperature of the illumination; since the collected image data There may be some redundant or missing data in the image data. Therefore, in order to improve the analysis efficiency and accuracy, after collecting the first image data set of the target guide rail's area to be inspected under different lighting sequences, the first image data set can be further preprocessed to obtain a second image data set; the second image data set is input into a preset defect detection model for detection, and the detection result of the target guide rail can be obtained, wherein the detection result of the target guide rail may include the location of the defect in the target guide rail. The preset defect detection model can be trained using the image data set corresponding to the area to be inspected of the training guide rail as a training sample, and the detection result corresponding to the image data set corresponding to the area to be inspected of the training guide rail as a sample label.

[0042] From the above introduction, it can be seen that when it is necessary to detect the defects of the target guide rail, the method provided in the embodiment of the present application can determine the defects of the target guide rail by analyzing the image data of the target guide rail to be detected under different lighting sequences. Through the lighting equipment, it is effective to adjust the lighting parameters of the lighting equipment in real time during the detection of the target guide rail to collect different image data. The defects of the target guide rail can be analyzed more comprehensively, and the cost of detecting the defects of the target guide rail can be effectively reduced. Compared with the existing technical solutions, the method provided in the embodiment of the present application can improve the accuracy of the detection results of the target guide rail and have better performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work. Figure 1 A flowchart of a method for detecting guide rail surface defects based on illumination conditions provided in an embodiment of the present application; Figure 2 A schematic diagram of a lighting device provided in an embodiment of the present application; Figure 3 A schematic diagram of an original image of a straight guide rail provided in an embodiment of the present application under a certain lighting condition; Figure 4 A schematic diagram of analyzing the effect of a guide rail defect provided in an embodiment of the present application; Figure 5 Schematic diagram of the defect detection system structure of the optimal lighting equipment provided by this application; Figure 6 This is a schematic structural diagram of a guide rail surface defect detection device based on illumination conditions according to an embodiment of the present application; Figure 7 This is a hardware structure block diagram of a guide rail surface defect detection device based on lighting conditions disclosed in an embodiment of the present application. DETAILED DESCRIPTION

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

[0045] In recent years, deep learning technology has made significant progress in various fields. However, the inference process of most defect detection models consumes a lot of computing resources, and the inference speed is difficult to meet practical requirements, making it difficult to deploy on embedded devices. This makes it difficult and expensive to integrate lighting optimization algorithms into lighting equipment. Therefore, there is an urgent need to develop a lightweight and fast lighting optimization method for guide rail surface defect detection to meet the needs of production and use. Given that most of the current guide rail surface defect detection solutions based on lighting conditions are difficult to adapt to complex and changing business needs, the applicant has studied a guide rail surface defect detection solution based on lighting conditions. When it is necessary to detect the defects of the target guide rail, the method provided in the embodiment of the present application can determine the defects of the target guide rail by analyzing the image data of the target guide rail to be detected under different lighting sequences. Through the lighting equipment, it is effective to adjust the lighting parameters of the lighting equipment in real time during the detection of the target guide rail to collect different image data. The defects of the target guide rail can be analyzed more comprehensively, and the cost of detecting the defects of the target guide rail can be effectively reduced. Compared with the existing technical solutions, the method provided in the embodiment of the present application can improve the accuracy of the detection results of the target guide rail and have better performance. The method provided in the embodiment of the present application can be used in many general or special computing device environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor devices, distributed computing environments including any of the above devices or devices, etc. An embodiment of the present application provides a guide rail surface defect detection method based on lighting conditions. The method can be applied to various guide rail detection systems and can also be applied to various computer terminals or smart terminals. The execution entity can be the processor or server of the computer terminal or smart terminal.

[0046] The following combination Figure 1 , introduces the process of the guide rail surface defect detection method based on lighting conditions given in the embodiment of the present application, such as Figure 1 As shown, the process can include the following steps:

[0047] Step S101: determine the area to be inspected of the target guide rail.

[0048] Specifically, in practical applications, determining the target guide rail's inspection area is essential for improving detection efficiency and effectiveness when inspecting defects. This helps effectively focus on key areas of the target guide rail, improving detection efficiency. For example, in practical applications, different parts of a guide rail experience varying levels of stress and wear during operation. For example, in a machine tool guide rail, the area near the tool's machining position is more susceptible to wear due to cutting forces. By determining the target guide rail's inspection area, the inspection can focus on key areas of the target guide rail prone to problems, avoiding indiscriminate, comprehensive inspection of the entire target guide rail, thereby saving inspection time and costs. For long-distance guide rails, such as conveyor rails on automated production lines, the connection points at both ends and the support points in the middle are particularly critical. Connection points may become loose or deformed due to frequent docking and disassembly, while support points are subject to significant pressure. Identifying these inspection areas allows for more targeted detection of potential hazards. Furthermore, in practical applications, both inspection equipment and manpower are limited resources. By determining the area of ​​the target rail to be inspected, it is possible to rationally allocate inspection equipment and professionals based on the importance of the area and the probability of possible problems.

[0049] For example, for areas requiring high precision, high-precision testing equipment and experienced technicians can be deployed for inspection. For less critical areas, more conventional inspection methods can be used. This maximizes inspection resources and improves inspection efficiency. Identifying the target guide rail's inspection areas can also accurately identify problems and effectively ensure the rail's performance. For example, in actual applications, the inspection areas of a guide rail are often the most indicative of its operating condition. For example, in elevator guide rails, the wear of specific areas of the car's running track (such as the guide rail locations corresponding to the car's landing floors) directly affects the elevator's operational smoothness and safety. By identifying these inspection areas and conducting detailed inspections, parameters such as guide rail wear and flatness can be accurately assessed, thereby determining whether the guide rail still meets normal operating requirements. For another example, for linear guide rails, surface roughness and hardness variations in areas where the slider frequently moves have a critical impact on the rail's accuracy and service life. Testing these inspection areas can help determine whether the guide rail is experiencing problems such as fatigue wear and corrosion, allowing for timely maintenance measures to ensure performance. In practice, many rail failures begin in localized areas. For example, in automated warehousing systems, if a tiny crack in a rack rail in an area with frequent goods movement goes undetected, it can expand over time and under the constant impact of goods, eventually causing the rail to break and potentially leading to serious accidents such as rack collapse. Identifying and regularly inspecting areas to be inspected can identify these potential problems early, allowing for repairs or component replacements to be made in advance, effectively preventing failures and ensuring the proper functioning of the equipment. Therefore, when analyzing a target rail for defects, it's helpful to first identify the area to be inspected so that the condition of the target rail can be directly analyzed.

[0050] In actual application, the area to be inspected of the target rail can be determined based on the following methods:

[0051] 1. Determine the target rail's inspection area based on the principle of functional importance:

[0052] (1) Prioritize critical working areas: For guide rails, the areas that are directly involved in the working process and play a key role in work accuracy and stability are the focus of consideration. For example, in a machine tool guide rail, when the tool cuts the workpiece, the guide rail area below and around the tool is directly affected by the cutting force and is the key to ensuring machining accuracy. Any slight deformation or wear in these areas may lead to dimensional errors, poor surface roughness, and other problems in the workpiece.

[0053] (2) Focus on the connection and interface areas: The connection parts of the guide rails, such as the joints between different guide rail sections, and the interface positions between the guide rails and other components (such as sliders, brackets, etc.) are also extremely important. Taking the conveyor guide rails on an automated production line as an example, if the connection points of adjacent guide rails are loose or have height differences, it will cause the conveyed items to be bumped or even fall when passing. In elevator guide rails, the contact area between the guide rails and the car guide shoes, its flatness and lubrication directly affect the smoothness and comfort of the car operation.

[0054] 2. Determine the target rail inspection area based on the vulnerability principle:

[0055] (1) Focus on high-wear areas: Areas prone to wear should be identified as areas to be inspected. This typically includes areas where moving parts frequently rub against each other, such as the track where the slider frequently slides in a linear guide. As the slider repeatedly moves on the guide rail, the friction generated will gradually wear away the surface material of the guide rail, especially in high-speed, high-load motion conditions, where the wear rate will be faster. Inspection of these high-wear areas is crucial for evaluating the service life and performance degradation of the guide rail.

[0056] (2) Consideration of corrosion-prone areas: If the guide rail is in a harsh working environment, such as a humid environment or one with corrosive gases or liquids, the areas that are susceptible to corrosion need special attention. For example, the guide rails of a port crane operating at the seaside are easily corroded due to the high salt content in the air. Material conveying guide rails in chemical production workshops may also be exposed to various chemicals. Once the protective layer on the surface is damaged, corrosion will occur at the damaged area, affecting the strength and accuracy of the guide rail.

[0057] 3. Consider the historical fault area principle to determine the target rail area to be inspected:

[0058] (1) Review of frequently failed areas: Areas where failures have occurred in the past should be given high attention. If a section of the guide rail has repeatedly experienced excessive wear, deformation, or fatigue cracks, then this area should always be listed as a candidate for inspection in subsequent inspections. This is because these areas are likely to have inherent weaknesses due to their own structural characteristics, working conditions, and other factors. Even after repair, the probability of problems occurring again is relatively high.

[0059] (2) Reference for fault areas under similar working conditions: The areas where faults frequently occur under similar working conditions for the same type of guide rails should also be used as a reference for determining the areas to be inspected. For example, if a specific guide rail area on a certain model of machine tool within the same series of machine tool guide rails frequently fails when processing a certain material, then the same area on other machines of the same model under similar processing conditions should also be inspected as a priority.

[0060] 4. Determine the target guide rail inspection area based on regulations and standards

[0061] (1) Areas specified by industry regulations: Different industries have corresponding regulations and standards for guide rail inspection. For example, in the elevator industry, there are strict safety standards that specify the inspection area, inspection cycle, and inspection indicators for elevator guide rails. These standards are based on extensive experiments and practical experience to ensure the safety of elevator operation. Determining the inspection area in accordance with these regulations and standards is the basic prerequisite for ensuring that the guide rails meet safety and quality requirements.

[0062] (2) Coordination of internal quality standards: In addition to industry standards, companies may also develop stricter or more targeted inspection area specifications based on their own product characteristics and quality control requirements. For example, high-end precision instrument manufacturers may set higher than industry standards for the inspection area and accuracy of their equipment’s guide rails to ensure high performance and reliability.

[0063] Step S102 : changing the illumination sequence for the area to be inspected of the target guide rail, and collecting first image data sets of the area to be inspected of the target guide rail under different illumination sequences.

[0064] Specifically, in practical applications, different types of defects appear differently under different lighting sequences. For example, when oblique side lighting is used on a guide rail with surface cracks, a distinct shadow forms at the crack. This is because the presence of the surface crack causes light to refract and reflect differently at its edges, resulting in a line with contrasting light and dark in the image. For example, in a metal guide rail, when the oblique side lighting angle is 30°-60°, the depth and direction of the surface crack can be clearly revealed through the shape and length of the shadow. Moreover, the shadow color is darker for deeper cracks, which helps to intuitively judge the severity of the surface crack. Under strong vertical lighting, surface cracks may appear as interrupted reflections. Due to the uneven surface inside the crack, light is not reflected as regularly as on a flat surface, resulting in a different reflection intensity in the crack area than on the surrounding normal surface. For fine cracks, a series of dot-like areas of reduced reflection may appear; for wider cracks, a large interrupted reflection band may appear. If there are corrosion pits on the rail, they will show a clear outline under strong vertical light. Strong light can enhance the shadow effect at the bottom and edge of the pit, clearly showing the shape, size and depth of the pit.

[0065] For example, on a guide rail surface after chemical corrosion, pits may appear dark due to changes in light reflection angle, while the edges of the pits may appear as bright lines due to the concentrated light, outlining the pit's extent. Using diffused light to illuminate a defective guide rail makes it easier to observe the overall shape and distribution of corrosion pits. Diffuse light evenly illuminates the surface, making the positional relationships and relative sizes of individual pits clear in the image. However, compared to bright light, the depth of pits may be less clear under diffused light because diffused light reduces shadows and minimizes the brightness difference between the inside and outside of the pit. When a guide rail exhibits wear, side lighting is very effective for detecting these signs. When a guide rail surface is worn, the surface roughness and flatness of the worn area change. Under side lighting, the worn area produces irregular reflections due to its microscopic surface undulations. For example, in the sliding area of ​​a linear guide, the worn surface will appear as patches of uneven reflections under side lighting. The boundaries of these areas can help determine the extent of the wear. Furthermore, the intensity and distribution of reflections vary with the degree of wear, with severely worn areas exhibiting more scattered reflections. When backlit, signs of wear may appear as differences in light transmittance. For guide rails made of transparent or translucent materials (such as some plastic rails), the worn portion will appear brighter in backlight due to its reduced thickness. For opaque metal rails, backlighting can highlight changes in the surface texture of the worn area, making scratches and dents caused by wear appear more distinct in the image because the reflected light from the worn area contrasts with that from the surrounding normal areas.

[0066] Therefore, after determining the target guide rail's inspection area, the illumination sequence for the target guide rail's inspection area can be changed, and first image data sets of the target guide rail's inspection area under different illumination sequences can be collected. This allows analysis of defects in the target guide rail by analyzing the image data of the target guide rail under different illumination sequences. The first image data set can include first image data of at least one target guide rail's inspection area under each illumination sequence.

[0067] For example, the first image dataset may include image data of the target rail's inspection area under oblique lighting conditions and image data under vertical strong lighting conditions. The lighting sequence represents the parameters of the lighting device and may include the position of the lighting unit, the intensity of the lighting, and the color temperature of the lighting. In actual applications, a lighting sequence represents a lighting condition, and images captured under that lighting condition can be understood as corresponding to a set of image data.

[0068] In actual application, a high-precision area array camera can be used to collect image data of the target guide rail. You can refer to using a dome light source as a lighting device. Figure 2 As shown, Figure 2 A lighting device that can be used in experiments using the method provided in the embodiments of the present application. The lighting device has multiple LED lamp groups that can be controlled independently. The positions of the lighting units in the aforementioned lighting sequence represent the positions of the corresponding lamp groups. The lighting conditions can be changed by controlling the color temperature and intensity of the lamp groups at various positions of the lighting device. Therefore, in actual applications, the aforementioned lighting sequence can include the position information of all independently controllable lamps of the lighting device, the light intensity of the LEDs, and the color temperature.

[0069] In actual application, the process of changing the lighting sequence for the target rail can be as follows:

[0070] According to the actual production, some change sequences are pre-set. During operation, the position of the lamp bead group of the lighting equipment can be changed according to the preset setting change sequence. For example, during the inspection process, multi-angle inspection can be adopted: using side light divided into upper, lower, left and right (that is, controlling the light intensity of the light-emitting unit on one side of the dome light source to be greater) or controlling the light intensity on both sides of the ring light source to be stronger and the light intensity of the dome to be weaker, forming a lighting effect similar to that of a strip light source. Because the structure of the dome light source is high in the middle and gradually decreases towards the periphery. In actual application, the light source can also be controlled to achieve low-angle double side light. For each angle of light, such as low-angle side light, a small range of adjustment can be made. For example, the light intensity of the light-emitting unit can be changed in sequence in a clockwise order. For example, the light intensity can be increased by 10 each time. The purpose of this is to increase the number of analysis samples, which is convenient for the subsequent use of the automatic multi-scale peak detection algorithm to find all defects.

[0071] By capturing first image datasets of the target guide rail's inspection area under different illumination sequences and analyzing its defects, defect detection capabilities can be enhanced, highlighting different types of defects. For example, different illumination sequences can be used to visualize various defects in the target guide rail's inspection area in different ways. For example, when using oblique side lighting, tiny surface cracks create distinct shadows in the image, making them easier to identify. Conversely, when using strong vertical illumination, the depth and contours of corrosion pits are clearly revealed. By varying the illumination sequence, the captured first image dataset encompasses defect characteristics under various lighting conditions, facilitating comprehensive detection and differentiation of different defect types. Under certain lighting conditions, defects can be confused with the rail's normal surface texture. For example, under uniform diffuse lighting, some shallow scratches can be difficult to distinguish due to their similar reflection to the surface. However, when illuminated from a specific angle using a point light source, the scratch's reflection pattern changes, making it more prominent in the image. This method of varying the illumination sequence can effectively improve the distinction between defects and normal surfaces and reduce false positives. The surface of a target guide rail may have different textures, such as machining marks and variations in roughness. By varying the illumination sequence, it is possible to capture the variations in these textures under different illumination conditions. For example, in a dimly lit environment, rougher textured areas may absorb more light and appear darker; whereas in a brightly lit environment, these textures become more pronounced due to the increased reflected light. Acquiring image datasets under different illumination sequences can provide rich material for subsequent texture analysis and help more accurately describe the microscopic features of the guide rail surface. For guide rails with a specific shape and spatial structure, different illumination sequences can help reconstruct their three-dimensional features. For example, by capturing images from different angles and intensities of illumination, the variations in light and shadow can be used to infer the unevenness of the guide rail surface. This illumination-based 3D reconstruction method can provide a more intuitive and accurate basis for assessing guide rail deformation, wear, and other aspects, and is particularly important for the inspection of high-precision guide rails.

[0072] In actual use, guide rails typically operate under diverse lighting conditions. For example, outdoor guide rail equipment may be subject to variations in brightness due to direct sunlight or cloud cover. Indoor guide rail equipment may experience varying lighting conditions due to factors such as the layout and power of lighting fixtures. By acquiring image datasets using varying lighting sequences, these lighting variations in real working environments can be simulated, enabling the inspection system to better adapt to guide rail inspection in diverse environments and improving the versatility and reliability of inspection results. Understanding the variation patterns of guide rail images under different lighting sequences helps distinguish image changes caused by ambient lighting interference from true guide rail defects during actual inspection. For example, if the inspection environment exhibits flickering or uneven lighting, image anomalies caused by these environmental factors may be mistaken for guide rail defects if images under different lighting sequences are not analyzed. By pre-collecting image datasets under different lighting sequences, an effective discrimination method can be established to mitigate the negative impact of ambient lighting interference on inspection results.

[0073] Step S103: preprocess the first image data set to obtain a second image data set.

[0074] Specifically, in actual application, the first image data set collected may contain some redundant image data or unclear image data. For example, in the process of collecting the first image data set, the image may contain noise due to environmental factors (such as unstable lighting, electromagnetic interference, etc.) or the influence of the equipment itself (such as thermal noise of the camera sensor). These noises will make the image blurred or granular spots appear, interfering with the subsequent accurate judgment of the guide rail defects. For example, in some industrial environments, the operation of the motor or the electromagnetic radiation of other equipment may cause salt and pepper noise in the image. Therefore, in order to improve the image quality, the first image data set can be preprocessed to obtain the second image data set. The filtering operations in the preprocessing (such as median filtering, Gaussian filtering, etc.) can effectively reduce these noises, make the image clearer, and highlight the true features of the guide rail surface.

[0075] Furthermore, during the acquisition of the first image dataset, the original images may have insufficient contrast, making it difficult to discern certain details in the guide rail, such as minor wear marks or shallow cracks. Preprocessing the first image dataset, such as performing histogram equalization or contrast stretching, can adjust the grayscale distribution of the images in the first image dataset, thereby enhancing the contrast. For example, for images with uneven lighting, histogram equalization can redistribute pixel grayscale values, making the difference between originally darker defective areas and surrounding normal areas more pronounced, making them easier to detect. Furthermore, the first image dataset may have been acquired using different camera settings or in different inspection scenarios, and the image sizes may also vary. A consistent image size is crucial for subsequent image analysis of the first image dataset. For example, deep learning-based defect detection algorithms typically require fixed-size image input. Image scaling during preprocessing can resize all images to the same size, ensuring proper algorithm operation and preventing erroneous judgments due to image size differences. In particular, if the images in the first image dataset are color images, these images may use different color spaces (such as RGB, HSV, etc.). In actual applications, different color spaces have different conveniences for analyzing guide rail surface features. By preprocessing the first image dataset, the color spaces of each image in the first image dataset can be unified into a standard color space, which can simplify subsequent image processing and analysis steps. For example, in some cases, converting RGB images to the HSV color space may be more intuitive and convenient for detecting discoloration on the guide rail surface (such as color changes caused by corrosion). Furthermore, preprocessing the first image dataset can achieve data standardization. This includes normalizing pixel values ​​to a specific range (such as [0, 1] or [-1, 1]), which can make the data distribution of different images more reasonable. Doing so helps improve the performance and stability of some machine learning-based detection algorithms. For example, in classification algorithms such as support vector machines (SVM), standardized data can enable the algorithm to converge faster and more accurately classify guide rail defects in images.

[0076] In practical applications, preprocessing the first image data is more conducive to extracting valuable image features. For example, applying an edge detection algorithm (such as Canny edge detection) to the preprocessed image can more clearly extract the edge features of rail surface defects. If the original image is of poor quality and has not been preprocessed, the effectiveness of edge detection may be affected, resulting in an inability to accurately extract defect edge information, which in turn affects the determination of the defect type and severity.

[0077] The process of preprocessing the first image dataset to obtain the second image dataset may include the following steps:

[0078] Step S1031 : performing a first color space conversion process on each first image data of the first image data set to obtain a first target image data set.

[0079] Specifically, for example, each first image data of the first image data set may be converted from an RGB color space to an HSV color space.

[0080] Step S1032 : performing histogram equalization processing on the image data in the first target image data set to obtain a second target image data set.

[0081] Specifically, the process of performing histogram equalization processing on the image data in the first target image data set may include the following steps:

[0082] Step S10321 , calculating the probability distribution result of each brightness value in the V channel of each image data in the first target image data set.

[0083] Specifically, the calculation formula for the probability distribution result of each brightness value in the V channel of each image data in the first target image data set can be shown in the following formula (1):

[0084]

[0085] p(v k ) may be a probability distribution function of each brightness value in the V channel of each image data in the first target image data set;

[0086] n k The brightness value in the V channel of each image data in the first target image data set can be v k The number of pixels;

[0087] n may be the total number of pixels of each image data in the first target image data set;

[0088] Step S10322: Calculate the cumulative distribution result of each brightness value in the V channel of each image data in the first target image data set based on the probability distribution result of each brightness value in the V channel of each image data in the first target image data set.

[0089] Specifically, the calculation formula for calculating the cumulative distribution result of each brightness value in the V channel of each image data in the first target image data set can be shown as the following formula (2):

[0090]

[0091] Among them, C(v k ) may be a cumulative distribution function of each brightness value in the V channel of each image data in the first target image data set;

[0092] i and k are the indices used in the calculation. For example, if there are F brightness levels, then v k It represents a brightness level, p(v k ) represents the normalized data. For example, if there is a 4×4 image, then n=16, and there are 5 brightness levels, 0 to 4, and k is the index traversing 0 to 4.

[0093] Step S10323 : Mapping each brightness value in the V channel of each image data in the first target image data set to a new equalized brightness value based on the cumulative distribution result of each brightness value in the V channel of each image data in the first target image data set.

[0094] The mapping relationship between each brightness value in the V channel of each image data in the first target image data set and the equalized brightness value in a mapping relationship therewith can be shown in the following formula (3):

[0095] v' k =(F-1)·C(v k ) (3)

[0096] Among them, v' k A new equalized brightness value may be corresponding to each brightness value in the V channel of each image data in the first target image data set;

[0097] F may be the maximum value of brightness among the image data in the first target image data set.

[0098] Step S1033 : performing a second color space conversion process on the image data of the second target image data set to obtain a third target image data set as the second image data set.

[0099] Specifically, from the above introduction, it can be seen that the second target image data set is converted from RGB color space to HSV color space. Further, the image data of the second target image data set can be converted from HSV color space to RGB color space, and the third target image data set obtained by the conversion is used as the second image data set.

[0100] Step S104: input the second image data set into a preset defect detection model for detection to obtain a detection result of the target guide rail.

[0101] Specifically, as described above, preprocessing the first image dataset yields a relatively high-quality second image dataset. This second image dataset includes image data of the target guide rail's inspected area under different illumination sequences. Therefore, by analyzing the individual images in the second image dataset, it is possible to understand the different types of defects exhibited by the target guide rail under different illumination sequences. Therefore, after obtaining the second image dataset, to improve the efficiency and accuracy of target guide rail inspection, the second image dataset can be input into a pre-set defect detection model for inspection, thereby obtaining the target guide rail's inspection results.

[0102] The detection result of the target guide rail may include the location of defects in the target guide rail and probability data of defects in the target guide rail.

[0103] The preset defect detection model can be trained using the image data set corresponding to the area to be inspected of the training guide rail as training samples and the detection results corresponding to the image data set corresponding to the area to be inspected of the training guide rail as sample labels.

[0104] For example, in practical applications, image dataset A corresponding to the training track under different lighting conditions can be collected and preprocessed to obtain image dataset B. A STU-Flow model is then constructed as a teacher model based on the Swin Transformer model and the Normalizing Flow (NF). The constructed teacher model is then trained using the preprocessed image dataset B corresponding to the training track. The sliding window transformer structure in the teacher model can perform self-attention calculations. The Swin Transformer structure in the teacher model is a hierarchical structure capable of multi-scale feature learning. The Swin Transformer structure in the teacher model employs a hierarchical design similar to that of CNNs, constructing feature maps at different levels through progressive downsampling. At each stage, it divides the input feature map into different windows and performs self-attention calculations within these windows. This hierarchical structure enables the model to effectively learn features at different scales, making it more adaptable to various visual tasks. For example, in image classification tasks, the model can focus on both global and local features of the image to improve classification accuracy; in target detection tasks, it can better detect targets of different sizes. As the network deepens, the resolution of the feature map gradually decreases and the number of channels gradually increases, which allows the model to capture feature information of different levels of abstraction at different levels. This flexible feature expression capability helps the model better understand and process complex visual data. Among them, the Swin Transformer structure can be used as the encoder of the teacher model to extract multi-scale feature information of image data of the training guide under different lighting conditions; the Normalizing Flow (NF) structure can be used as the decoder of the teacher model, and the multi-scale feature information can be input into the decoder, and anomaly scores are constructed based on the likelihood values ​​to generate pixel-level anomaly maps.

[0105] Therefore, the preset defect detection model can include an encoder and a decoder. The encoder can be used to extract multi-scale feature information from image data of the object to be detected under different lighting conditions; the decoder can be used to perform anomaly score analysis on the multi-scale feature information extracted by the encoder based on the likelihood value anomaly score analysis method, and generate an anomaly map corresponding to the pixel level of the object to be detected;

[0106] The formula for calculating the abnormality score of the multi-scale feature information extracted by the encoder can be shown in the following formula (4):

[0107]

[0108] Among them, AS(i,j) can represent the abnormal score of the pixel with coordinates (i,j);

[0109] (i, j) can represent the pixel position coordinate information in the image data corresponding to the object to be detected extracted by the encoder;

[0110] It can represent the white Gaussian embedding generated by the normalized data stream (NF), which corresponds to the embedding value of the kth channel of the pixel (i, j) in the image data corresponding to the object to be detected extracted by the encoder, and obeys the standard normal distribution;

[0111] L may represent the total number of scales extracted by the encoder from the multi-scale features of the image data corresponding to the object to be detected;

[0112] C l The number of channels that can represent the lth scale;

[0113] After calculating the anomaly score of the multi-scale feature information extracted by the encoder, the false positive data of the anomaly map corresponding to the pixel level of the generated object to be detected can be calculated based on the hypothesis test in the acontrario framework, and automatic threshold selection and anomaly segmentation processing can be performed on it. The formulas for calculating the false positive data of the anomaly map corresponding to the pixel level of the generated object to be detected and performing automatic threshold selection and anomaly segmentation processing on it can be shown in the following equations (5)-(8):

[0114]

[0115]

[0116] in, In formula (8), l represents the scale, r represents the number of pixels in the connected area, and H l ×W l is the image resolution at the lth scale. α1 and β1 are constants, which can be 0.316915 and 4.062570 respectively;

[0117] Among them, C l The number of channels that can represent the lth scale; It can represent the characteristic information of the image; k can represent the index in the calculation process; NFA(E) can represent the number of false alarms function; u(i,j) can be a defined variable, which can be specifically expressed as a mapping function of the anomaly score, and the variable obeys the degree of freedom C l Chi-square distribution of x 2 (C l ); It can be the probability that pixel (i, j) is abnormal under the background model H0; is the degree of freedom C l The cumulative distribution function (CDF) of the chi-square distribution; t is the potential characteristic The threshold of the sum of squares; N T The number of all possible connected components that need to be detected in the entire image, that is, the data of the candidate region to be tested, can be obtained by controlling the value of NFA to obtain an unsupervised detection threshold to ensure that no more than a certain number of false positive detections are generated in normal images.

[0118] In practical applications, once the NFA value of each connected component is calculated, the final step is to perform anomaly detection under a set threshold. Typically, the threshold used is NFA ≤ 1, which means that only connected components that are not accidental are detected; these areas are considered anomalous. In practical applications, due to the large variety of guide rail surface defects and the relatively small number of defect samples, the self-supervised model can be constructed and trained based on positive samples. By calculating pixel-level anomaly scores and performing anomaly segmentation, it is possible to detect and locate a variety of defects.

[0119] Through experiments, it was found that the created teacher model can analyze the image data of the inspection area of ​​the training guide rail under different lighting conditions to determine the defect location and presentation probability data of the training guide rail.

[0120] In actual applications, SwinTransformer and TinyViT have many differences in performance:

[0121] 1. Accuracy: SwinTransformer is a very powerful visual Transformer model that can achieve excellent performance on various visual tasks. For example, the SwinTransformer model pre-trained on a large-scale dataset can achieve very high accuracy on datasets such as ImageNet. Taking Swin-B as an example, it can achieve a high top-1 accuracy on ImageNet, providing a powerful basic model for many downstream tasks. TinyViT also performs well in terms of accuracy. Through techniques such as knowledge distillation, TinyViT can still achieve high accuracy while significantly reducing the number of parameters. For example, TinyViT with 21M parameters can achieve a top-1 accuracy of 84.8% on ImageNet-1k, and even 86.5% accuracy at higher resolutions, which is close to or even exceeds some larger-scale Transformer models.

[0122] 2. Parameter and computational complexity: Although Swin Transformer offers excellent performance, its complex architecture and multi-layered design result in a relatively large number of parameters and computations. This makes it challenging to deploy on resource-constrained devices. For example, on mobile devices or in edge computing scenarios, high computing and storage resources may be required to run the model.

[0123] TinyViT is a miniaturized visual Transformer model. Its parameter count and computational complexity have been carefully optimized, making it significantly smaller than the Swin Transformer. This makes TinyViT more suitable for resource-constrained environments, enabling efficient execution on devices with limited hardware resources and facilitating rapid model inference and deployment.

[0124] 3. Data adaptability: After pre-training on large-scale datasets, Swin Transformer can learn rich image features and has good adaptability to large-scale image data. However, for small-scale or field-specific datasets, further fine-tuning or optimization may be required to adapt to the characteristics of the data. TinyViT is designed to focus on adaptability to small-scale data. Through techniques such as knowledge distillation, TinyViT can learn common image features from large-scale pre-trained models, while also being able to converge quickly on small-scale data and achieve good performance. This gives TinyViT certain advantages in scenarios with limited data.

[0125] 4. Model complexity and scalability: The Swin Transformer has a high model complexity, and its architectural design includes multiple stages and modules, such as the window attention mechanism and hierarchical structure, which makes the model training and optimization process relatively complex. However, this complex architecture also provides the model with powerful representation capabilities, capable of handling a variety of complex visual tasks. The TinyViT model has relatively low model complexity and a relatively simple structure, making it easy to train and optimize. At the same time, the design of the TinyViT model also has a certain degree of scalability. By adjusting the model parameters and structure, it can adapt to different task requirements and hardware environments.

[0126] Therefore, based on the advantages presented by TinyViT, in order to further improve the computing power of the teacher model and improve the detection efficiency of the model, TinyViT (Micro Visual Transformation Structure) can be used to replace the Swin Transformer network in the STU-Flow model (i.e., the created teacher model) to construct the TVU-Flow model as the student model. Therefore, the preset defect detection model can also include the TinyViT structure (Micro Visual Transformation Structure).

[0127] After building the student model, to make its performance more similar to the teacher model, we can further construct a total loss function and utilize a response-based knowledge distillation method to minimize the output difference between the teacher model (STU-Flow model) and the student model (TVU-Flow model). This allows the student model (TVU-Flow model) to further train its detection and analysis results, ensuring that the student model's detection and analysis results are closer to the expected values. TinyViT and Swin Transformer are both Transformer architectures, serving only as feature extraction within the model. Using TinyViT instead of Swin Transformer can reduce the model size, improve inference efficiency, and reduce the difficulty of deployment on embedded devices.

[0128] Therefore, the calculation formula of the total loss function of the preset defect detection model can be described by the following formula (9):

[0129]

[0130] T can represent the total loss function of the preset defect detection model;

[0131] It can represent the distillation loss of the abnormality score of the multi-scale feature information of the object to be detected extracted by the encoder of the preset defect detection model, that is, In order to calculate the distillation loss of the anomaly score based on the mean square error (MSE) between the pixel-level anomaly scores of the teacher model and the student model introduced above, the calculation formula can be shown as follows (10):

[0132]

[0133] Among them, A t (i, j) and A s (i, j) are the pixel-level anomaly scores of the teacher model and the student model, respectively. H and W represent the height and width of the image, respectively.

[0134] It can represent the false positive data of the abnormality map corresponding to the pixel level of the object to be detected generated by the decoder of the preset defect detection model, that is, is the distillation loss for the number of false positives calculated based on the mean squared error between the number of false positives of the teacher model and the student model introduced above, The calculation formula is shown as follows (11):

[0135]

[0136] Among them, NFA t (i, j) and NFA s (i, j) represents the number of false positives of the teacher model and the student model at pixel (i, j) respectively; L CE It can be expressed as cross entropy loss, that is, L CE The cross entropy loss is calculated by generating pseudo labels through self-supervised learning of the teacher model and based on the class probability predicted by the student model; the calculation formula can be shown as follows (12):

[0137]

[0138] in, is the pseudo label generated by self-supervised learning, p s (i, j) is the class prediction probability of the student model at pixel (i, j). α, β, and γ can be weight coefficients, that is, α, β, and γ are the weight coefficients of the self-supervised cross entropy loss, anomaly score distillation loss, and false positive number distillation loss, respectively.

[0139] In practical applications, the student model is trained using positive and negative samples and a response-based knowledge distillation method. This allows the student model to achieve performance close to that of the teacher model, but with significantly fewer parameters, computational complexity, and storage requirements, reducing the model's complexity.

[0140] For example, the method provided in the examples of this application is used to analyze Figure 3 The original image data shown can be obtained as Figure 4 The defect effect diagram shown in Figure 4 In the figure, the white area is the detection area. Figure 3 The location of the defect determined by the original image data shown is known from experiments. Figure 4 The white area in the middle is indeed the area where the film is flooded in the object to be inspected. Therefore, it can be seen that the method provided by the embodiment of the present application can well determine the specific location of the defects in the object to be inspected. In particular, the method provided by the embodiment of the present application can be applied to Figure 5 In the system architecture shown, Figure 5This is a schematic diagram of the defect detection system structure of the optimization lighting device provided in this application. The system includes a high-precision area array camera, an edge computing device, a controller, and a ring lighting device. The edge computing device is connected to the controller via a high-speed serial port, sending a lighting sequence to control the ring lighting device and change the lighting conditions. The optimization model for the lighting conditions of the guide rail surface defect detection is deployed on the edge computing device. The edge computing device has a storage device for storing the image data and corresponding lighting sequence of each round of optimization. The next round of optimization will overwrite the data of the previous round. After each round of optimization, if an abnormal sample is detected, the optimal lighting sequence and corresponding image data showing the defect will be output to the next-level defect detection system for defect category identification and abnormality segmentation.

[0141] It should be noted that Figure 5 The structural diagram of the defect detection system of the optimal lighting equipment shown is only a system structural diagram of this embodiment. This application is not limited to this framework, and the next-level defect detection system is not limited to the identification of defect categories and anomaly segmentation; the frequency of optimization in the embodiment can be changed according to actual production requirements.

[0142] Step S105 : analyzing the inspection results of the target guide rail in the area to be inspected, and determining all peaks in the probability of the target guide rail presenting defects included in the inspection results of the target guide rail.

[0143] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can determine the detection results of the area to be inspected of the target guide rail, wherein the detection results of the area to be inspected of the target guide rail can include the probability that the target guide rail presents defects.

[0144] In actual applications, all peaks in the probability of a target rail exhibiting a defect are correlated with the defects present. For example, peaks represent areas with a high probability of defects. Peaks in the probability distribution of a target rail exhibiting a defect indicate that the defect is most likely to be detected under those specific lighting sequences. This is because different lighting sequences highlight the characteristics of the rail surface in different ways. For example, under certain combinations of lighting angle and intensity, defects such as cracks, wear, or corrosion on the rail surface will contrast sharply with the normal surface, resulting in peaks in the probability distribution. The lighting sequences corresponding to these peaks maximize the exposure of the defect, much like shining a flashlight at a specific angle in the dark can best reveal surface flaws.

[0145] Therefore, after determining the inspection results of the target guide rail's area to be inspected, the inspection results of the target guide rail's area to be inspected can be analyzed to determine all peaks in the probability of the target guide rail exhibiting a defect included in the inspection results of the target guide rail. The process of analyzing the inspection results of the target guide rail's area to be inspected and determining all peaks in the probability of the target guide rail exhibiting a defect included in the inspection results of the target guide rail can include the following steps:

[0146] Step S1051 , performing a multi-scale analysis on the probability of the target guide rail presenting a defect included in the inspection result of the target guide rail's area to be inspected, so as to smooth the data of the probability of the target guide rail presenting a defect at different scales and generate a multi-scale target signal.

[0147] For example, in practical applications, an automatic multi-scale peak detection algorithm (also known as the AMPD algorithm) can be used to perform a multi-scale analysis of the probability of a target guide rail exhibiting defects, as included in the inspection results of the target guide rail's inspected area. AMPD (Accelerated Multi-Dimensional Peak Detection) is an accelerated multi-dimensional peak detection algorithm. It is primarily used to efficiently detect peaks in a dataset and is particularly useful when processing complex multidimensional data (such as signal processing, image data, and sensor data). This algorithm searches for peaks based on the local characteristics of the data. Typically, the algorithm compares the magnitude of a data point with its neighbors. If a data point's value within its local neighborhood (for example, within a certain window range) is larger than that of all surrounding data points, then that data point is likely a peak. By cleverly setting parameters such as the window size and step size, AMPD rapidly scans the data, reducing unnecessary computation and achieving accelerated peak detection.

[0148] The algorithm sets a window that is used to determine the local neighborhood of the data point. The choice of window size is critical and depends on the characteristics of the data and the type of peak you want to detect. For example, a smaller window may be used when detecting narrow peaks in the signal, while a larger window may be required for wider peaks. The algorithm then starts from one end of the data and moves the window according to the set step size, analyzing the data within each window. For the central data point in the window, if its value is greater than the values ​​of other data points in the window and meets certain threshold conditions (such as greater than a preset minimum peak height), then this data point is determined to be a potential peak. Setting the threshold can help filter out small fluctuations caused by some noise and improve the accuracy of peak detection.

[0149] After initial peak detection, some post-processing steps may be required. For example, multiple adjacent data points that may belong to the same peak can be merged or adjusted to obtain more accurate peak location and intensity information. This is particularly important when dealing with noise interference or large data fluctuations. In image edge detection, image edges can be viewed as peaks in brightness or color changes. The AMPD algorithm can locate edges by detecting peaks in image pixel values.

[0150] Step S1052 : performing local peak detection on the target signal at each scale, and marking the positions of the target guide rails corresponding to all local maximum values ​​in the target signal at each scale.

[0151] Step S1053 , counting the occurrence frequencies of local peaks at the same position of the target guide rail at different scales, and generating a defect peak frequency distribution result of the target guide rail.

[0152] Step S1054 , based on the defect peak frequency distribution result of the target guide rail, peaks meeting preset conditions at each scale are determined as all peaks of the probability of the target guide rail presenting a defect.

[0153] For example, let a signal be x, whose length is N, and the length of the sliding window k1 corresponds to different scales. The window length k1 ranges from 1 to a maximum value h, where That is half the length of the signal.

[0154] For each scale k1, the local maximum is calculated. For each sliding window, if the value of the center point is larger than the values ​​at both ends of the window, the point is considered to be a "local maximum".

[0155] This multi-scale detection process generates a matrix of local maxima, called a local maximum spectrogram (LMS), by detecting local maxima at different window lengths (scales). Each row of this matrix M represents a scale (different sliding window sizes), and each column represents a point in the signal. The value of the element in the matrix indicates whether the point is a local maximum at that scale.

[0156] By summing the rows of the local maximum spectrum M, we obtain a vector γ1, in which each element represents the total number of local maxima at a certain scale. In the vector γ1, we find the scale λ corresponding to the global minimum. The scale λ indicates that the distribution of local maxima at this scale is the sparsest, which usually corresponds to the "true" peak in the signal. From the local maximum spectrum, we delete the parts with scales greater than λ and retain the local maxima below the scale λ to obtain a new local maximum matrix. By calculating the standard deviation of the columns of the new matrix, we find the columns with a standard deviation of zero. The indices corresponding to these columns are the peak positions of the signal. This is because at these positions, the signal exhibits local maxima at multiple scales, so these positions can be considered to be the true peaks of the signal.

[0157] Step S106 : setting a lighting sequence for re-detecting defects of the target guide rail according to all peak values ​​in the probability of the target guide rail presenting defects.

[0158] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can determine all peaks of the probability of the target guide rail presenting a defect. In actual application, each defect type has its own unique geometric shape, depth and surface texture changes. By analyzing the illumination sequence corresponding to the peak of the probability of presenting the defect of the target guide rail, the illumination conditions that are most suitable for displaying a specific defect can be found. For example, for a defect with a tiny pit on the surface, it may be that under a certain oblique lighting sequence, the combination of the shadow and reflection of the pit makes the defect most easy to be found, and the probability corresponding to this oblique lighting sequence will have a peak. By analyzing all peaks in the probability of the target guide rail presenting a defect, the accuracy and efficiency of re-detection can be effectively improved. For example, by re-detecting the target guide rail using an illumination sequence set according to all peaks in the probability of the target guide rail presenting a defect, the target guide rail defect can be located more accurately. Since these illumination sequences are the conditions that are most likely to display defects after analysis, they can reduce misjudgments and missed judgments during the detection process.

[0159] For example, in complex industrial production environments, guide rail surfaces may harbor interference factors such as oil, dust, and other contaminants. An appropriate lighting sequence can penetrate or avoid these interferences, directly focusing on defects, enabling inspectors or automated inspection systems to quickly and accurately identify the location and type of defects. When re-inspecting target guide rails, using a targeted lighting sequence can avoid unnecessary lighting combinations, saving inspection time and energy. Indiscriminately using various lighting sequences for repeated inspections not only increases inspection costs but can also interfere with defect detection due to excessive invalid information. However, a lighting sequence designed based on probability peaks can prioritize inspection efforts, concentrating on the most effective lighting conditions and improving inspection efficiency.

[0160] Therefore, after all peaks in the probability of the target guide rail presenting defects are determined, a lighting sequence for re-detecting defects of the target guide rail may be set according to all peaks in the probability of the target guide rail presenting defects.

[0161] For example, in an automotive production plant, numerous automated devices transport auto parts via guide rails. The accuracy of these guide rails is crucial to ensuring smooth production line operation. For example, in an auto body welding workshop, welding robots move along guide rails to perform welding operations. Minor defects in the guide rails can cause weld position deviations. In practical applications, preliminary inspections of guide rails reveal a peak probability of surface wear defects when using a lighting sequence with a side lighting angle of approximately 45° and moderate intensity. This is because under this lighting sequence, the difference in reflectivity between the worn and normal areas of the worn rail surface is greatest, clearly revealing signs of wear. This lighting sequence is then prioritized for re-inspection. Inspectors can use visual inspection or machine vision systems to more accurately determine the extent and scope of wear, such as whether the wear exceeds the allowable tolerance range, and thus determine whether the guide rail needs repair or replacement. Using this probability-based illumination sequence for re-inspection can effectively improve the accuracy of wear defect detection, reduce weld quality issues caused by guide rail wear, and improve the overall quality and efficiency of automotive production.

[0162] For example, in practical applications, the safe operation of elevators depends on the good condition of their guide rails. Over long-term use, elevator guide rails may develop defects such as cracks and corrosion. For example, in high-rise buildings in coastal areas, corrosion is a prominent problem for elevator guide rails due to the humid sea breeze and salt erosion. During inspection, preliminary testing reveals that corrosion defects in elevator guide rails peak when illuminated with strong vertical light and a small amount of developer is applied to the rail surface (to enhance the contrast between corroded and normal areas). This is because the developer can clearly define the outlines of corrosion pits, creating a sharp contrast between the shadows within the pits and the reflections at the edges. During re-inspection, maintenance personnel follow this illumination sequence and procedure, using tools such as endoscopes to inspect the guide rails deep within the elevator shaft. This targeted illumination sequence helps maintenance personnel more accurately assess the depth and extent of corrosion and promptly identify potential safety hazards. For early-stage corrosion defects, preventative measures such as repainting and anti-corrosion treatment can be implemented to extend the service life of the guide rails and ensure safe elevator operation.

[0163] For example, in automated warehousing systems, goods are stored and handled using shelf rails. Shelf rails frequently bear the weight of goods and the impact of handling equipment, making them prone to defects such as deformation and cracks. For example, in large e-commerce warehouses, large numbers of packages are transported in and out daily, placing high demands on shelf rails. During initial inspection of the shelf rails, it was found that the probability of surface cracks peaked when using multi-angle ring lighting (e.g., simultaneous illumination from above and on both sides at angles of 30° and 60°, etc.) with a gradually increasing intensity. This is because multi-angle ring lighting causes cracks to produce distinct shadow and reflection variations at different angles, with these variations becoming more pronounced as the intensity increases. During re-inspections, warehouse maintenance personnel regularly inspect shelf rails using inspection equipment equipped with this lighting setup. This approach allows for more timely detection of cracks in shelf rails, allowing them to be repaired or replaced before they propagate and cause shelf collapse, thus ensuring the safe and efficient operation of the warehousing system.

[0164] From the technical solutions introduced above, it can be seen that the method provided by the embodiment of the present application has a powerful multi-scale feature extraction capability, which improves the accuracy of defect detection on the guide rail. The defect detection model of the Transformer architecture used by the method provided by the embodiment of the present application adopts a hierarchical structure in the process of extracting the features of the guide rail. The image blocks (Tokens) at each layer can capture spatial features of different scales. The bottom layer Tokens focus on local details, while the high-level Tokens can capture global information, thereby realizing multi-scale feature extraction. Secondly, the defect detection model provided by the embodiment of the present application has an adaptive attention mechanism, which can dynamically adjust the area and scale of its attention according to the different input data, and can adaptively extract features at different levels to ensure that it can effectively pay attention to macroscopic global information and microscopic local details. It is also lightweight and has a fast inference speed, which is convenient for deployment in embedded devices. Based on the pre-trained high-performance teacher model, the student model is subjected to knowledge distillation, which improves the performance of the model while optimizing the model inference speed and memory.

[0165] Furthermore, the method provided in the embodiment of the present application can also effectively reduce the cost of detection. By using a self-supervised algorithm, there is no need to label a large amount of data. During the experiment, only positive samples are used in the teacher model training process, and a small number of negative samples are used in the knowledge distillation process, which effectively reduces costs and solves the problem of scarce negative samples. In addition, it replaces the traditional lighting condition adjustment method and can adjust the lighting conditions in real time. Furthermore, the method provided in the embodiment of the present application also has the ability to provide optimal lighting conditions for a variety of defects. The method of constructing a model based on positive samples and segmenting defects by calculating anomaly scores has the ability to detect a variety of defects, and locates all peaks in the defect probabilities predicted by the model through an automatic multi-scale peak detection algorithm, thereby determining the optimal lighting conditions for a variety of defects.

[0166] It can be seen from this that when it is necessary to detect the defects of the target guide rail, the method provided in the embodiment of the present application can determine the defects of the target guide rail by analyzing the image data of the target guide rail to be detected under different lighting sequences. Through the lighting equipment, it is effective to adjust the lighting parameters of the lighting equipment in real time during the detection of the target guide rail to collect different image data, which can more comprehensively analyze the defects of the target guide rail and effectively reduce the cost of detecting the defects of the target guide rail. Compared with the existing technical solutions, the method provided in the embodiment of the present application can improve the accuracy of the detection results of the target guide rail and has better performance.

[0167] The following describes the guide rail surface defect detection device based on illumination conditions provided by the embodiment of the present application. The guide rail surface defect detection device based on illumination conditions described below and the guide rail surface defect detection method based on illumination conditions described above can be referenced to each other. Figure 6 , Figure 6 This is a schematic diagram of the structure of a guide rail surface defect detection device based on lighting conditions disclosed in an embodiment of the present application. Figure 6 As shown, the guide rail surface defect detection device based on lighting conditions may include:

[0168] The to-be-inspected area determining unit 101 is configured to determine the to-be-inspected area of ​​the target guide rail;

[0169] an illumination sequence setting unit 102, configured to change an illumination sequence for the target guide rail's area to be inspected, and collect first image data sets of the target guide rail's area to be inspected under different illumination sequences, wherein the first image data sets include first image data of at least one target guide rail's area to be inspected corresponding to each illumination sequence, wherein the illumination sequence includes a position of an illumination unit, an intensity of illumination, and a color temperature of illumination;

[0170] A data preprocessing unit 103 is configured to preprocess the first image data set to obtain a second image data set;

[0171] The defect detection unit 104 is used to input the second image data set into a preset defect detection model for detection to obtain a detection result of the target guide rail, wherein the detection result of the target guide rail includes the location of the defect in the target guide rail. The preset defect detection model is trained using the image data set corresponding to the to-be-detected area of ​​the training guide rail as a training sample and the detection result corresponding to the image data set corresponding to the to-be-detected area of ​​the training guide rail as a sample label.

[0172] Among them, the specific processing flow of each unit included in the above-mentioned guide rail surface defect detection device based on lighting conditions can refer to the relevant introduction of the guide rail surface defect detection method based on lighting conditions in the previous article, and will not be repeated here.

[0173] The guide rail surface defect detection device based on illumination conditions provided in the embodiment of the present application can be applied to guide rail surface defect detection equipment based on illumination conditions, such as terminals: mobile phones, computers, etc. Optionally, Figure 7 The hardware structure diagram of the guide rail surface defect detection device based on lighting conditions is shown. Figure 7 The hardware structure of the guide rail surface defect detection device based on illumination conditions may include: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4. In an embodiment of the present application, the number of the processor 1, the communication interface 2, the memory 3 and the communication bus 4 is at least one, and the processor 1, the communication interface 2 and the memory 3 communicate with each other through the communication bus 4. The processor 1 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiment of the present application; the memory 3 may include a high-speed RAM memory, or may also include a non-volatile memory (non-volatile memory), such as at least one disk memory; wherein the memory stores a program, and the processor can call the program stored in the memory, and the program is used to: implement the various processing flows in the guide rail surface defect detection solution based on illumination conditions of the aforementioned terminal. The embodiment of the present application also provides a readable storage medium, which can store a program suitable for execution by the processor, and the program is used to: implement the various processing flows in the guide rail surface defect detection solution based on illumination conditions of the aforementioned terminal.

[0174] Finally, it should be noted that, in this document, relational terms such as first and second are used solely to distinguish one entity or operation from another, and do not necessarily require or imply any actual relationship or order between these entities or operations. Furthermore, the terms "comprise," "include," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or device comprising a set of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. Without further limitation, an element defined by the phrase "comprising a..." does not preclude the presence of other identical elements in the process, method, article, or device comprising the recited elements. The various embodiments are described in this specification in a progressive manner, with each embodiment focusing on the differences from the other embodiments. Similar or identical parts between the various embodiments may be referenced for clarity. The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. The various embodiments may be combined with one another. Thus, the present application will not be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A guide rail surface defect detection method based on illumination conditions, characterized in that: include: Determine the area to be inspected of the target guide rail; changing a lighting sequence for the area to be inspected of the target guide rail, and collecting first image data sets of the area to be inspected of the target guide rail under different lighting sequences, wherein the first image data sets include first image data of at least one area to be inspected of the target guide rail corresponding to each lighting sequence, wherein the lighting sequence includes a position of a lighting unit, an intensity of the lighting, and a color temperature of the lighting; Preprocessing the first image data set to obtain a second image data set; Inputting the second image data set into a preset defect detection model for detection to obtain a detection result of the target guide rail, wherein the detection result of the target guide rail includes a location of a defect in the target guide rail, and the preset defect detection model is trained using the image data set corresponding to the to-be-detected area of ​​the training guide rail as a training sample and the detection results corresponding to the image data set corresponding to the to-be-detected area of ​​the training guide rail as sample labels; multi-scale analysis of the probability of the target guide rail presenting a defect included in the inspection result of the target guide rail's area to be inspected, so as to smooth the data of the probability of the target guide rail presenting a defect at different scales to generate a multi-scale target signal; Performing local peak detection on the target signal at each scale, marking the positions of the target rails corresponding to all local maxima in the target signal at each scale; Counting the occurrence frequencies of local peaks at the same position of the target guide rail at different scales to generate a defect peak frequency distribution result of the target guide rail; According to the defect peak frequency distribution result of the target guide rail, the peaks meeting the preset conditions at each scale are determined as all the peaks of the probability of the target guide rail presenting a defect; According to all peaks in the probability of the target guide rail presenting defects, a lighting sequence for re-detecting defects of the target guide rail is set.

2. The method according to claim 1, characterized in that The preprocessing of the first image dataset to obtain a second image dataset includes: Performing a first color space conversion process on each first image data of the first image data set to obtain a first target image data set; performing histogram equalization processing on the image data in the first target image data set to obtain a second target image data set; Perform a second color space conversion process on the image data of the second target image data set to obtain a third target image data set as the second image data set.

3. The method according to claim 2, characterized in that The performing histogram equalization processing on the image data in the first target image data set includes: Calculate the probability distribution result of each brightness value in the V channel of each image data in the first target image data set, wherein the calculation formula of the probability distribution result of each brightness value in the V channel of each image data in the first target image data set is: , is the probability distribution function of each brightness value in the V channel of each image data in the first target image data set, The brightness value of the V channel of each image data in the first target image data set is The number of pixels, is the total number of pixels of each image data in the first target image data set; Based on the probability distribution result of each brightness value in the V channel of each image data in the first target image data set, the cumulative distribution result of each brightness value in the V channel of each image data in the first target image data set is calculated, wherein the calculation formula for calculating the cumulative distribution result of each brightness value in the V channel of each image data in the first target image data set is: , is the cumulative distribution function of each brightness value in the V channel of each image data in the first target image data set, and is the index in the calculation process; Based on the cumulative distribution result of each brightness value in the V channel of each image data in the first target image data set, each brightness value in the V channel of each image data in the first target image data set is mapped to a new equalized brightness value, wherein the mapping relationship between each brightness value in the V channel of each image data in the first target image data set and the equalized brightness value in a mapping relationship therewith is: ,in, A new equalized brightness value is corresponding to each brightness value in the V channel of each image data in the first target image data set, is the maximum value of brightness among the image data in the first target image data set.

4. The method according to claim 1, wherein The preset defect detection model includes an encoder and a decoder; Wherein, the encoder is used to extract multi-scale feature information of image data of the object to be detected under different lighting conditions; The decoder is used to perform an anomaly score analysis on the multi-scale feature information extracted by the encoder based on a likelihood value anomaly score analysis method, and generate an anomaly map corresponding to the pixel level of the object to be detected; and calculate the false positive data of the generated anomaly map corresponding to the pixel level of the object to be detected, and perform automatic threshold selection and anomaly segmentation processing on the generated anomaly map; The formula for calculating the anomaly score of the multi-scale feature information extracted by the encoder is: ,in, The coordinates are The abnormality score of the pixel point; Represents pixel position coordinate information in the image data corresponding to the object to be detected extracted by the encoder; represents the white Gaussian embedding generated by the normalized data stream, corresponding to the pixel in the image data corresponding to the object to be detected extracted by the encoder In the The first scale The embedding value of each channel follows a standard normal distribution; represents the total number of scales extracted by the encoder from the multi-scale features of the image data corresponding to the object to be detected; Indicates the The number of channels at each scale; The formula for calculating the false positive data of the abnormality map corresponding to the pixel level of the object to be detected and performing automatic threshold selection and abnormality segmentation processing on it is: ; ; ; in, Represents the characteristic information of the image; Indicates the index in the calculation process; represents the false alarm number function; To define a variable, that is, a mapping function representing the anomaly score, the variable has a degree of freedom of Chi-square distribution of ; For the background model Next, pixel The probability of anomalies occurring; is the degree of freedom The cumulative distribution function (CDF) of the chi-square distribution; It is a potential feature The threshold value of the sum of squares; is the number of all possible connected components.

5. The method according to claim 4, characterized in that The calculation formula of the total loss function of the preset defect detection model is: ; T represents the total loss function of the preset defect detection model; A distillation loss representing anomaly scores of multi-scale feature information of the object to be detected extracted by the encoder of the preset defect detection model; False positive data representing an anomaly map corresponding to the pixel level of the object to be detected generated by the decoder of the preset defect detection model; represents the cross entropy loss; 、 and They are 、 、 The weight coefficient of .

6. A guide rail surface defect detection device based on lighting conditions, characterized in that: include: A unit for determining an area to be inspected, used for determining an area to be inspected of a target guide rail; an illumination sequence setting unit, configured to change an illumination sequence for the area to be inspected of the target guide rail, and collect first image data sets of the area to be inspected of the target guide rail under different illumination sequences, wherein the first image data sets include first image data of at least one area to be inspected of the target guide rail corresponding to each illumination sequence, wherein the illumination sequence includes a position of an illumination unit, an intensity of illumination, and a color temperature of illumination; a data preprocessing unit, configured to preprocess the first image data set to obtain a second image data set; a defect detection unit, configured to input the second image data set into a preset defect detection model for detection to obtain a detection result of the target guide rail, wherein the detection result of the target guide rail includes a location of a defect in the target guide rail, and the preset defect detection model is trained using the image data set corresponding to the to-be-detected area of ​​the training guide rail as a training sample and the detection results corresponding to the image data set corresponding to the to-be-detected area of ​​the training guide rail as sample labels; a multi-scale analysis unit, configured to perform multi-scale analysis on the probability of the target guide rail presenting a defect, included in the inspection result of the target guide rail's inspected area, so as to smooth the data on the probability of the target guide rail presenting a defect at different scales to generate a multi-scale target signal; a marking unit, configured to perform local peak detection on the target signal at each scale, and mark the positions of the target guide rails corresponding to all local maxima in the target signal at each scale; A result generating unit is used to count the occurrence frequencies of local peaks at the same position of the target guide rail at different scales to generate a defect peak frequency distribution result of the target guide rail; a peak determination unit, configured to determine, based on the defect peak frequency distribution result of the target guide rail, peaks that meet preset conditions at each scale as all peaks of the probability that the target guide rail presents a defect; The setting unit is configured to set a lighting sequence for re-detecting defects of the target guide rail according to all peak values ​​in the probability of the target guide rail presenting defects.

7. A guide rail surface defect detection device based on lighting conditions, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, which, when executed by the one or more processors, implement the steps of the guide rail surface defect detection method based on lighting conditions as described in any one of claims 1 to 5.

8. A readable storage medium, characterized in that: The readable storage medium stores computer-readable instructions, which, when executed by one or more processors, enable the one or more processors to implement the steps of the guide rail surface defect detection method based on lighting conditions as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Steel rail surface defect detection method and device based on few-sample learning

    CN112330591A

  • Appearance defect detection method and system based on adaptive illumination

    CN118408939A