A screw loosening detection method, system, terminal and medium
By setting marking lines on screws and nuts, and utilizing HSV-HIS hybrid color space conversion and edge detection algorithms, the problems of low efficiency and high false alarm rate in screw loosening detection are solved, achieving high-precision and widely adaptable detection results.
Patent Information
- Application Number
- CN202510839182.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2045-06-23
AI Technical Summary
Existing technologies for screw loosening detection suffer from low efficiency, high false alarm rate, and difficulty in adapting to complex working conditions, especially in the case of environmental noise interference and insufficient model generalization ability in industrial settings.
Marking lines are set on screws and nuts. Using image processing technology, HSV-HIS hybrid color space conversion and edge detection algorithm are employed to extract marking line information from color features and edge contours, respectively. The deviation is calculated and fused to verify the looseness of the screws, reducing the impact of noise interference and changes in lighting.
It improves the accuracy and generalization ability of screw loosening detection, adapts to diverse industrial environments, reduces the false judgment rate, and is compatible with various equipment and working conditions.
Smart Images

Figure CN120689332B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and specifically to a method, system, terminal, and medium for detecting loose screws. Background Technology
[0002] With the development of industrial automation and intelligent manufacturing, the structural complexity and operational intensity of mechanical equipment are constantly increasing. As a key component in mechanical connections, loose screws can lead to increased equipment vibration, structural instability, and even serious safety accidents. Traditional screw loosening detection methods mainly rely on manual inspection or threshold judgment based on vibration signals, but these methods suffer from low efficiency, high false alarm rates, and difficulty in adapting to complex working conditions.
[0003] Deep learning models based on vibration signals or image data can automatically extract features and identify the state of loose screws. However, existing methods still face several challenges, including environmental noise interference (in industrial settings, there is a lot of background noise, which affects the effective feature extraction of vibration signals); and insufficient generalization ability (existing models show significant performance degradation when applied across different equipment and working conditions). Summary of the Invention
[0004] To address the aforementioned issues, this invention provides a screw loosening detection method, system, terminal, and medium. The method involves image processing based on marker lines to obtain the reference line deviation of the marker lines, and then checking for screw loosening based on this deviation. During the process, color space conversion and edge extraction are fused together to reduce environmental noise interference, improve detection accuracy, and enhance generalization capabilities.
[0005] In a first aspect, the technical solution of the present invention provides a method for detecting loose screws, comprising the following steps: A marking line is set on both the screw and the nut, and the camera captures images of the target area containing the screw and nut. The target region image is preprocessed to obtain a preprocessed image; The preprocessed image is converted to color space using the HSV-HIS mixed color space conversion model, and two marked line regions are extracted. Two color reference lines are obtained by straight line fitting based on the two marked line regions. The deviation between the two color reference lines is calculated, which are the first angular deviation and the first displacement deviation, respectively. The preprocessed image is processed into a grayscale image. The two marked lines in the grayscale image are extracted using an edge detection algorithm. Then, two grayscale reference lines are obtained by straight line fitting based on the two extracted edges. The deviation between the two grayscale reference lines is calculated, which are the second angle deviation and the second displacement deviation, respectively. Determine whether the screw is loose based on the first angular deviation, the first displacement deviation, the second angular deviation, and the second displacement deviation.
[0006] In an optional implementation, the preprocessed image is color space converted using the HSV-HIS mixed color space conversion model, and two marker line regions are extracted. Specifically, this includes: The preprocessed image is an RGB image. The preprocessed image is converted into an HSV color space to obtain the initial HSV features of each pixel, including hue, saturation, and lightness. The HIS color space enhancement algorithm is used to enhance the saturation and brightness of each pixel to obtain enhanced saturation and enhanced brightness. The initial HSV features are combined with the enhanced saturation and enhanced brightness to obtain the mixed HSV features for each pixel; The feature baseline threshold boundary of the marker line is determined in advance using a machine learning algorithm. Then, the adjustment range is determined based on the average brightness of the current preprocessed image. The feature baseline threshold boundary is adjusted according to the adjustment range to obtain the current feature threshold boundary. The mixed HSV features of each pixel are compared with the current feature threshold boundary. If the mixed HSV features of a pixel are within the current feature threshold range, then the pixel is a pixel within the marker line region. All pixels are traversed to extract two marker line regions.
[0007] In an optional implementation, after the preprocessed image is color space converted using the HSV-HIS hybrid color space conversion model and two marker line regions are extracted, the step further includes processing the marker line regions using a morphological processing chain to remove noise, fill holes, and smooth edges.
[0008] In an optional implementation, two colored reference lines are obtained by performing straight line fitting on the two marked line regions respectively, specifically including: Obtain the spatial coordinates of each pixel within the marked line area; Two color reference lines are obtained by fitting a straight line using the least squares method based on the spatial coordinates of each pixel.
[0009] In an optional implementation, edge extraction is performed on the two marker lines in the grayscale image using an edge detection algorithm, specifically including: The horizontal and vertical gradients of each pixel are calculated using the 5×5 extended Sobel operator. The pixel gradient magnitude and gradient direction are calculated based on the horizontal and vertical gradients to obtain a gradient magnitude map and a gradient direction map. Nonlocal maximum suppression based on quadratic interpolation is performed by traversing each pixel in the gradient magnitude map and comparing the gradient values of the current pixel with those of the two adjacent pixels in the gradient direction. If the gradient value of the current pixel is not a local maximum, the pixel is suppressed and only the local maximum points in the gradient direction are retained to obtain a preliminary edge map. Analyze the gradient histogram features of local regions in the initial edge map, calculate the high and low thresholds of gradient magnitude, traverse the initial edge map, determine points above the high threshold as strong edges, directly suppress points below the low threshold, and retain or suppress points between the high and low thresholds using an edge tracking algorithm to obtain a complete edge map. Based on the prior spatial positions of the screw and nut in the image, the edge pixel set of the two marker lines is separated from the complete edge image, thus extracting the edge of the marker line.
[0010] In an optional implementation, the target region image is preprocessed, including white balance correction and gamma correction.
[0011] In one optional implementation, determining whether the screw is loose based on the first angular deviation, the first displacement deviation, the second angular deviation, and the second displacement deviation specifically includes: The fused angle deviation is obtained by weighted summation of the first angle deviation and the second angle deviation; The first displacement deviation and the second displacement deviation are weighted and summed to obtain the fused displacement deviation. When the fusion angle deviation is less than the first angle threshold and the fusion displacement deviation is less than the first displacement threshold, it is determined to be in a tight state. When the fusion angle deviation is greater than or equal to the first angle threshold and less than the second angle threshold, or the fusion displacement deviation is greater than or equal to the first displacement threshold and less than the second displacement threshold, it is determined to be a warning state. When the fusion angle deviation is greater than the second angle threshold, or the fusion displacement deviation is greater than the second displacement threshold, it is determined to be in a loose state.
[0012] Secondly, the technical solution of the present invention provides a screw loosening detection system, comprising: The area image acquisition module is used to set a marking line on both the screw and the nut, and to receive the target area image containing the screw and nut captured by the camera; The image preprocessing module is used to preprocess the target area image to obtain a preprocessed image; The first deviation calculation module is used to perform color space conversion on the preprocessed image using the HSV-HIS mixed color space conversion model and extract two marker line regions. Based on the two marker line regions, straight line fitting is performed to obtain two color reference lines, and the deviation between the two color reference lines is calculated, which are the first angle deviation and the first displacement deviation, respectively. The second deviation calculation module is used to process the preprocessed image into a grayscale image, extract the edges of the two marker lines in the grayscale image through an edge detection algorithm, and then perform straight line fitting based on the two extracted edges to obtain two grayscale reference lines. The deviation between the two grayscale reference lines is calculated, which are the second angle deviation and the second displacement deviation. The screw status judgment module is used to determine whether the screw is loose based on the first angle deviation, the first displacement deviation, the second angle deviation, and the second displacement deviation.
[0013] Thirdly, the technical solution of the present invention provides a terminal, comprising: The memory is used to store the screw loosening detection program; A processor is configured to implement the steps of the screw loosening detection method as described above when executing the screw loosening detection program.
[0014] Fourthly, the present invention provides a computer-readable storage medium storing a screw loosening detection program, wherein the screw loosening detection program, when executed by a processor, implements the steps of the screw loosening detection method as described in any of the above claims.
[0015] As can be seen from the above technical solutions, this application has the following advantages: Marking lines are pre-set on the screws and nuts; during operation, images are acquired in real time; reference lines for the two marking lines are extracted through two branches; and the screw loosening state is determined based on the displacement and angular deviations between the reference lines. This invention extracts marking line information from two branches: color features and edge contours. The deviation results of these two branches are fused for verification, reducing misjudgments caused by noise, lighting changes, etc., in a single dimension, and improving the accuracy of screw loosening detection. Detection is performed through image processing, allowing for individual processing of the images of each pair of screws and nuts, avoiding interference from multiple screw coupling. The HSV-HIS hybrid color space is more robust to changes in industrial lighting and background noise (such as equipment oil stains and metal reflections). Color conversion highlights the marking line area, and grayscale edge detection combined with an improved algorithm suppresses environmental noise interference in edge extraction. The two branches operate in parallel, covering complex working conditions such as lighting, noise, and stains, adapting to diverse industrial environments. The marking lines are physical features; processing based on the marking lines can adapt to various equipment types and working condition differences. Attached Figure Description
[0016] To more clearly illustrate the technical solution of this application, the accompanying drawings used in the description will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic flowchart of a screw loosening detection method provided in an embodiment of the present invention.
[0018] Figure 2 This is a schematic block diagram of a screw loosening detection system provided in an embodiment of the present invention.
[0019] Figure 3 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present invention. Detailed Implementation
[0020] To make the purpose, features, and advantages of this application more apparent and understandable, specific embodiments and accompanying drawings will be used to clearly and completely describe the technical solution protected by this application. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] Unless otherwise defined, all technical and scientific terms used in this application have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used in this application and in the specification of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
[0022] Figure 1 This is a schematic flowchart of a screw loosening detection method provided by an embodiment of the present invention. Figure 1 The executing entity can be a screw loosening detection system. The screw loosening detection method provided in this embodiment of the invention is executed by a computer device, and correspondingly, the screw loosening detection system runs within the computer device. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.
[0023] like Figure 1 As shown, the method includes the following steps.
[0024] S1, a marking line is set on both the screw and the nut, and the camera captures images of the target area containing the screw and nut.
[0025] Mark a line on the screw and nut beforehand. The line can be red, white, or another suitable color. After the screw is tightened, the marking line on the screw and the marking line on the nut should be aligned.
[0026] During equipment use, images are periodically captured via a camera, including images of screws and nuts. Specifically, an industrial camera is used in conjunction with a ring light source and a diffuser to ensure uniform illumination of the imaging environment. A polarizing filter is also used at the front end of the industrial camera to effectively suppress specular reflection interference from metal surfaces. This stage will collect a large amount of screw data, and overexposed, blurry, or out-of-focus images will be discarded.
[0027] S2, preprocess the target region image to obtain a preprocessed image.
[0028] Specifically, automatic white balance correction and gamma correction are performed on the target area image. Automatic white balance adjusts the image's color channels (R, G, B) to eliminate color deviations caused by differences in light source color temperature, such as images appearing yellowish under warm light and bluish under cool light, ensuring accurate color reproduction of the marker lines and maintaining color consistency across images acquired at different times or from different devices, thus avoiding algorithmic misjudgments due to changes in ambient light. Gamma correction enhances low-contrast details by adjusting brightness non-linearly (typically brightening dark areas when γ < 1 and suppressing highlights when γ > 1), making the edges of the marker lines more clearly visible.
[0029] S3. The preprocessed image is converted to color space using the HSV-HIS mixed color space conversion model, and two marked line regions are extracted. Two color reference lines are obtained by straight line fitting based on the two marked line regions. The deviation between the two color reference lines is calculated, which are the first angle deviation and the first displacement deviation, respectively.
[0030] Steps S3 and S4 are two branches, extracting marker line information from color features and edge contour dimensions, respectively. The color space focuses on distinguishing the marker line color from the background, while the grayscale space enhances the edge geometric features. The deviation results of the two are fused to reduce misjudgments caused by noise, lighting changes, etc. in a single dimension, effectively improving the calculation accuracy of screw loosening angle and displacement deviation.
[0031] This step addresses the needs of color marker recognition by employing the HSV-HIS hybrid color space conversion model. It establishes a machine learning-based adaptive color threshold algorithm (with a dynamically adjustable threshold range of ±15%), coupled with a morphological processing chain (including two iterative erosions of a 3×3 circular kernel, expansion of a 5×5 cross-shaped kernel, and post-processing with non-local mean filtering) to obtain reference lines for the marker lines. Specifically, it includes the following steps.
[0032] S31 uses the HSV-HIS mixed color space conversion model to convert the color space of the preprocessed image and extract two marked line areas.
[0033] S311, the preprocessed image is an RGB image, the preprocessed image is converted into the HSV color space to obtain the initial HSV features of each pixel, including hue, saturation and brightness.
[0034] The conversion formula is as follows:
[0035] in, Pixel hue represents color phase. Pixel saturation represents color purity; a higher value indicates less susceptibility to lighting conditions. To achieve pixel brightness, highlight areas need to be suppressed.
[0036] S312 uses the HIS color space enhancement algorithm to enhance the saturation and brightness of each pixel, resulting in enhanced saturation and enhanced brightness.
[0037] Specifically, saturation and brightness are non-linearly stretched to enhance low-contrast areas, as shown below.
[0038] S313, merges the hue, enhanced saturation, and enhanced brightness from the initial HSV features to obtain the mixed HSV features for each pixel.
[0039] Merging HSV hues ( ) and HIS enhancement channel ( , ), forming a hybrid HSV characteristic .
[0040] S314, the feature base threshold boundary of the marker line is determined in advance through a machine learning algorithm, and then the adjustment range is determined according to the average brightness of the current preprocessed image. The feature base threshold boundary is adjusted according to the adjustment range to obtain the current feature threshold boundary.
[0041] Collect labeled line samples under different lighting conditions and extract hybrid HSV features. Then, using an SVM or random forest classifier, the color threshold boundaries are learned to obtain the feature base threshold boundaries of the marked lines. It should be noted that different colored marked lines need to be trained separately.
[0042] During real-time detection, the adjustment range is determined based on the average brightness of the current preprocessed image. Different average brightness values correspond to different adjustment ranges. For example, if the adjustment range is set to ±15%, then the adjusted threshold boundary will be...
[0043] In the formula, , The baseline threshold is the output of the classifier.
[0044] S315, compare the mixed HSV features of each pixel with the current feature threshold boundary. If the mixed HSV features of a pixel are within the current feature threshold range, then the pixel is a pixel within the marker line region. Traverse all pixels to extract two marker line regions.
[0045] For each pixel, if If the area is within the dynamic threshold range, it is determined to be a marked line area.
[0046] In some alternative implementations, after the marked line region is extracted in step S35, a morphological processing chain is used to process the marked line region to remove noise, fill holes, and smooth edges.
[0047] S32, two colored reference lines are obtained by performing straight line fitting on the two marked line areas respectively.
[0048] S321, obtain the spatial coordinates of each pixel within the marked line area.
[0049] S322 uses the least squares method to fit a straight line using the spatial coordinates of each pixel to obtain two color reference lines.
[0050] For connected regions in a binary image, the equation of a straight line can be directly fitted using the least squares method:
[0051] In the formula, The slope The intercept is... These are pixel space coordinates.
[0052] Among them, slope The formula is,
[0053] In the formula, This represents the number of pixels involved in the calculation.
[0054] S33, calculate the deviation between the two colored reference lines, which are the first angular deviation and the first displacement deviation, respectively.
[0055] The slope difference between the two colored reference lines, i.e., the first angular deviation, is calculated using the following formula. ,
[0056] In the formula, The slope of the colored reference line for the markings on the screw. The slope of the colored reference line for the markings on the nut.
[0057] The distance between the center points of the two colored reference lines, i.e., the first displacement deviation, is calculated using the following formula.
[0058] In the formula, The coordinates of the center point of the colored reference line for the markings on the screw. The coordinates of the center point of the colored reference line for the markings on the nut.
[0059] S4. The preprocessed image is processed into a grayscale image. The two marked lines in the grayscale image are extracted using an edge detection algorithm. Then, two grayscale reference lines are obtained by straight line fitting based on the two extracted edges. The deviation between the two grayscale reference lines is calculated, which are the second angle deviation and the second displacement deviation, respectively.
[0060] An improved multi-scale Canny edge detection algorithm is employed. First, a 5×5 extended convolution kernel is constructed based on the Sobel operator. Gradient calculation is then performed using this kernel, calculating the first-order partial derivatives in both the x and y directions. Floating-point operations are used to precisely solve for the gradient magnitude (accuracy up to 0.01 grayscale level) and orientation angle (quantized to four main directions: 0°, 45°, 90°, and 135°) of each pixel. Subsequently, a nonlocal maximum suppression technique based on quadratic interpolation is introduced. By eliminating points with small gradient direction change rates, edge contours can be more clearly depicted, avoiding interference. Sub-pixel precision extreme value localization is performed along the gradient direction, effectively suppressing false edges while preserving the detailed features of real edges (edge localization accuracy better than 0.3 pixels). Notably, the algorithm also incorporates an adaptive dual-threshold mechanism. By analyzing the gradient histogram features of local image regions, high and low thresholds are dynamically calculated (threshold ratio maintained between 1:2.5 and 1:3), and an edge tracking algorithm is used to connect broken edges, ensuring the integrity and continuity of reference line detection. The specific steps include the following:
[0061] S41, perform grayscale processing on the preprocessed image to obtain a grayscale image.
[0062] First, the preprocessed image is converted to grayscale for subsequent edge extraction. After grayscale conversion, Gaussian filtering can also be applied.
[0063] S42 uses an edge detection algorithm to extract the edges of the two marker lines in the grayscale image.
[0064] S421, use the 5×5 extended Sobel operator to calculate the horizontal and vertical gradients of each pixel, and calculate the pixel gradient magnitude and gradient direction based on the horizontal and vertical gradients to obtain the gradient magnitude map and gradient direction map.
[0065] The horizontal and vertical gradients of each pixel are calculated using the 5×5 extended Sobel operator, and are represented as follows:
[0066] In the formula, For horizontal gradient, For vertical gradient, This is the grayscale value.
[0067] The gradient magnitude is The gradient direction is The gradient direction is quantized to four main directions: 0°, 45°, 90°, and 135°.
[0068] S422, based on nonlocal maxima suppression using quadratic interpolation, traverses each pixel in the gradient magnitude map, compares the gradient value of the current pixel with the gradient values of the two adjacent pixels in the gradient direction, and if the gradient value of the current pixel is not a local maximum, then the pixel is suppressed, and only the local maximum points in the gradient direction are retained to obtain the preliminary edge map.
[0069] It should be noted that suppressing a pixel means setting the pixel's gradient magnitude to 0.
[0070] S423: Analyze the gradient histogram features of the local region of the initial edge map, calculate the high and low thresholds of the gradient magnitude, traverse the preliminary edge map, determine the points above the high threshold as strong edges, directly suppress the points below the low threshold, and retain or suppress the points between the high and low thresholds in combination with the edge tracking algorithm to obtain the complete edge map.
[0071] Specifically, the initial edge map is divided into multiple local regions. Then, the gradient histograms of these local regions are analyzed, and high and low thresholds are assigned proportionally. For example, the top 15% quantiles of gradient values are used as the high threshold, and one-third of the high threshold is used as the low threshold. Strong edges are preserved, while weak edges are only preserved if they are connected to strong edges (edge tracking algorithm).
[0072] S424: Based on the prior spatial position of the screw and nut in the image, the edge pixel set of the two marker lines is separated from the complete edge map, thus extracting the edge of the marker line.
[0073] In some optional implementations, after separating the edge pixel set of the marker lines, a binarized edge image can be obtained. This image can then be processed by line segment detection based on the Hough transform to extract the marker lines on the screws and nuts. Specifically, edge points are mapped to polar coordinate parameter space, votes are counted in an accumulator, the line parameters corresponding to the peak values are found, the top N sets of polar coordinate parameter spaces with the highest vote counts are extracted, converted into line equations, and short line segments (length < 1 / 5 of the screw diameter) and overlapping line segments are filtered to obtain a new set of marker lines.
[0074] S43, two grayscale reference lines are obtained by performing straight line fitting on the two extracted edges respectively.
[0075] S44 calculates the deviation between the two grayscale reference lines, which are the second angle deviation and the second displacement deviation, respectively.
[0076] Steps S43 and S44 are similar to steps S32 and S33 described above, and will not be repeated here.
[0077] S5. Determine whether the screw is loose based on the first angular deviation, the first displacement deviation, the second angular deviation, and the second displacement deviation.
[0078] S51, the first angle deviation and the second angle deviation are weighted and summed to obtain the fused angle deviation.
[0079] S52, the first displacement deviation and the second displacement deviation are weighted and summed to obtain the fused displacement deviation.
[0080] S53, when the fusion angle deviation is less than the first angle threshold and the fusion displacement deviation is less than the first displacement threshold, it is determined to be in a tight state.
[0081] S54, when the fusion angle deviation is greater than or equal to the first angle threshold and less than the second angle threshold, or the fusion displacement deviation is greater than or equal to the first displacement threshold and less than the second displacement threshold, it is determined to be a warning state.
[0082] S55, when the fusion angle deviation is greater than the second angle threshold, or the fusion displacement deviation is greater than the second displacement threshold, it is determined to be in a loose state.
[0083] The weights of the two branches are set in advance as needed, and the displacement and angle deviations are fused according to the weight coefficients.
[0084] For example, a three-level judgment threshold can be set: when the angle deviation is less than 2° and the position offset is less than 1mm, it is judged as "tight" (confidence > 99%); when the angle deviation is between 2° and 5° or the position offset is between 1mm and 2mm, it is judged as "warning" (confidence 85%-95%); when the angle deviation exceeds 5° or the position offset exceeds 2mm, it is judged as "loose" (confidence > 97%).
[0085] In particular, a dynamic compensation mechanism is integrated to automatically correct system errors by analyzing historical test data, and a temperature compensation algorithm is used to eliminate the impact of thermal deformation on the measurement results.
[0086] The above text provides a detailed description of an embodiment of a screw loosening detection method. Based on the screw loosening detection method described in the above embodiment, this invention also provides a screw loosening detection system corresponding to the method.
[0087] Figure 2 This is a schematic block diagram of a screw loosening detection system provided in an embodiment of the present invention. In this embodiment, the screw loosening detection system 200 can be divided into multiple functional modules according to the functions it performs. A module, as referred to in this invention, is a series of computer program segments that can be executed by at least one processor and perform a fixed function, and is stored in memory.
[0088] The area image acquisition module 210 is used to set a marking line on each of the screw and nut, and to receive the target area image containing the screw and nut captured by the camera.
[0089] The image preprocessing module 220 is used to preprocess the target area image to obtain a preprocessed image.
[0090] The first deviation calculation module 220 is used to perform color space conversion on the preprocessed image using the HSV-HIS mixed color space conversion model and extract two marker line regions. Based on the two marker line regions, two color reference lines are obtained by performing straight line fitting. The deviation between the two color reference lines is calculated, which are the first angle deviation and the first displacement deviation.
[0091] The second deviation calculation module 240 is used to process the preprocessed image into a grayscale image, extract the edges of the two marker lines in the grayscale image through an edge detection algorithm, and then perform straight line fitting on the two extracted edges to obtain two grayscale reference lines. The deviation between the two grayscale reference lines is calculated, which are the second angle deviation and the second displacement deviation, respectively.
[0092] The screw status judgment module 250 is used to determine whether the screw is loose based on the first angle deviation, the first displacement deviation, the second angle deviation, and the second displacement deviation.
[0093] The screw loosening detection system of this embodiment is used to implement the aforementioned screw loosening detection method. Therefore, the specific implementation of this system can be found in the embodiment section of the screw loosening detection method above. Thus, the specific implementation can be referred to the description of the corresponding embodiments, and will not be elaborated here.
[0094] Furthermore, since the screw loosening detection system in this embodiment is used to implement the aforementioned screw loosening detection method, its function corresponds to the function of the above method, and will not be described again here.
[0095] Figure 3 A schematic diagram of a terminal 300 provided in an embodiment of the present invention includes: a processor 310, a memory 320, and a communication unit 330. The processor 310 is used to implement the following steps when executing a screw loosening detection program stored in the memory 320: A marking line is set on both the screw and the nut, and the camera captures images of the target area containing the screw and nut. The target region image is preprocessed to obtain a preprocessed image; The preprocessed image is converted to color space using the HSV-HIS mixed color space conversion model, and two marked line regions are extracted. Two color reference lines are obtained by straight line fitting based on the two marked line regions. The deviation between the two color reference lines is calculated, which are the first angular deviation and the first displacement deviation, respectively. The preprocessed image is processed into a grayscale image. The two marked lines in the grayscale image are extracted using an edge detection algorithm. Then, two grayscale reference lines are obtained by straight line fitting based on the two extracted edges. The deviation between the two grayscale reference lines is calculated, which are the second angle deviation and the second displacement deviation, respectively. Determine whether the screw is loose based on the first angular deviation, the first displacement deviation, the second angular deviation, and the second displacement deviation.
[0096] The terminal 300 includes a processor 310, a memory 320, and a communication unit 330. These components communicate via one or more buses. Those skilled in the art will understand that the server structure shown in the figure does not constitute a limitation of the present invention. It can be a bus topology or a star topology, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0097] The memory 320 can be used to store the execution instructions of the processor 310. The memory 320 can be implemented by any type of volatile or non-volatile memory terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. When the execution instructions in the memory 320 are executed by the processor 310, the terminal 300 is able to perform some or all of the steps in the above method embodiments.
[0098] The processor 310 serves as the control center of the storage terminal, connecting various parts of the electronic terminal via various interfaces and lines. It executes software programs and / or modules stored in the memory 320, and calls data stored in the memory to perform various functions of the electronic terminal and / or process data. The processor can be composed of integrated circuits (ICs), such as a single packaged IC or multiple packaged ICs with the same or different functions connected together. For example, the processor 310 may consist only of a central processing unit (CPU). In this embodiment of the invention, the CPU may have a single processing core or include multiple processing cores.
[0099] The communication unit 330 is used to establish a communication channel, enabling the storage terminal to communicate with other terminals. It can receive user data sent by other terminals or send user data to other terminals.
[0100] The present invention also provides a computer storage medium, which may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.
[0101] The present invention also provides a computer storage medium, which may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.
[0102] The computer storage medium stores a screw loosening detection program, which performs the following steps when executed by the processor: A marking line is set on both the screw and the nut, and the camera captures images of the target area containing the screw and nut. The target region image is preprocessed to obtain a preprocessed image; The preprocessed image is converted to color space using the HSV-HIS mixed color space conversion model, and two marked line regions are extracted. Two color reference lines are obtained by straight line fitting based on the two marked line regions. The deviation between the two color reference lines is calculated, which are the first angular deviation and the first displacement deviation, respectively. The preprocessed image is processed into a grayscale image. The two marked lines in the grayscale image are extracted using an edge detection algorithm. Then, two grayscale reference lines are obtained by straight line fitting based on the two extracted edges. The deviation between the two grayscale reference lines is calculated, which are the second angle deviation and the second displacement deviation, respectively. Determine whether the screw is loose based on the first angular deviation, the first displacement deviation, the second angular deviation, and the second displacement deviation.
[0103] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or other media capable of storing program code. It includes several instructions to cause a computer terminal (which may be a personal computer, server, or a second terminal, network terminal, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0104] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0105] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0106] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0107] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those 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 invention. Therefore, the invention is not to 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 method for detecting loose screws, characterized in that, Includes the following steps: A marking line is set on both the screw and the nut, and the camera captures images of the target area containing the screw and nut. The target region image is preprocessed to obtain a preprocessed image; The preprocessed image is converted to color space using the HSV-HIS mixed color space conversion model, and two marked line regions are extracted. Two color reference lines are obtained by straight line fitting based on the two marked line regions. The deviation between the two color reference lines is calculated, which are the first angular deviation and the first displacement deviation, respectively. The preprocessed image is processed into a grayscale image. The two marked lines in the grayscale image are extracted using an edge detection algorithm. Then, two grayscale reference lines are obtained by straight line fitting based on the two extracted edges. The deviation between the two grayscale reference lines is calculated, which are the second angle deviation and the second displacement deviation, respectively. Determine whether the screw is loose based on the first angular deviation, the first displacement deviation, the second angular deviation, and the second displacement deviation; The HSV-HIS mixed color space conversion model is used to perform color space conversion on the preprocessed image and extract two marked line regions, specifically including: The preprocessed image is an RGB image. The preprocessed image is converted into an HSV color space to obtain the initial HSV features of each pixel, including hue, saturation, and brightness. The HIS color space enhancement algorithm is used to enhance the saturation and brightness of each pixel to obtain enhanced saturation and enhanced brightness. The initial HSV features are combined with the enhanced saturation and enhanced brightness to obtain the mixed HSV features for each pixel; The feature baseline threshold boundary of the marker line is determined in advance using a machine learning algorithm. Then, the adjustment range is determined based on the average brightness of the current preprocessed image. The feature baseline threshold boundary is adjusted according to the adjustment range to obtain the current feature threshold boundary. The mixed HSV features of each pixel are compared with the current feature threshold boundary. If the mixed HSV features of a pixel are within the current feature threshold range, then the pixel is a pixel within the marker line region. All pixels are traversed to extract two marker line regions. Determining whether a screw is loose based on the first angular deviation, the first displacement deviation, the second angular deviation, and the second displacement deviation includes: The fused angle deviation is obtained by weighted summation of the first angle deviation and the second angle deviation; The first displacement deviation and the second displacement deviation are weighted and summed to obtain the fused displacement deviation. When the fusion angle deviation is less than the first angle threshold and the fusion displacement deviation is less than the first displacement threshold, it is determined to be in a tight state. When the fusion angle deviation is greater than or equal to the first angle threshold and less than the second angle threshold, or the fusion displacement deviation is greater than or equal to the first displacement threshold and less than the second displacement threshold, it is determined to be a warning state. When the fusion angle deviation is greater than the second angle threshold, or the fusion displacement deviation is greater than the second displacement threshold, it is determined to be in a loose state.
2. The screw loosening detection method according to claim 1, characterized in that, After converting the preprocessed image to color space and extracting two marker line regions using the HSV-HIS hybrid color space conversion model, the process also includes a step of processing the marker line regions using a morphological processing chain to remove noise, fill holes, and smooth edges.
3. The screw loosening detection method according to claim 1, characterized in that, Two colored reference lines are obtained by fitting straight lines to the two marked line regions respectively, specifically including: Obtain the spatial coordinates of each pixel within the marked line area; Two color reference lines are obtained by using the least squares method to fit a straight line based on the spatial coordinates of each pixel.
4. The screw loosening detection method according to claim 1, characterized in that, Edge extraction is performed on two marker lines in a grayscale image using an edge detection algorithm, specifically including: The horizontal and vertical gradients of each pixel are calculated using the 5×5 extended Sobel operator. The pixel gradient magnitude and gradient direction are calculated based on the horizontal and vertical gradients to obtain a gradient magnitude map and a gradient direction map. Nonlocal maximum suppression based on quadratic interpolation is performed by traversing each pixel in the gradient magnitude map and comparing the gradient values of the current pixel with those of the two adjacent pixels in the gradient direction. If the gradient value of the current pixel is not a local maximum, the pixel is suppressed and only the local maximum points in the gradient direction are retained to obtain a preliminary edge map. Analyze the gradient histogram features of local regions in the initial edge map, calculate the high and low thresholds of gradient magnitude, traverse the initial edge map, determine points above the high threshold as strong edges, directly suppress points below the low threshold, and retain or suppress points between the high and low thresholds using an edge tracking algorithm to obtain a complete edge map. Based on the prior spatial positions of the screw and nut in the image, the edge pixel set of the two marker lines is separated from the complete edge image, thus extracting the edge of the marker line.
5. The screw loosening detection method according to claim 1, characterized in that, The target region image is preprocessed, including white balance correction and gamma correction.
6. A screw loosening detection system, characterized in that, include: The area image acquisition module is used to set a marking line on both the screw and the nut, and to receive the target area image containing the screw and nut captured by the camera; The image preprocessing module is used to preprocess the target area image to obtain a preprocessed image; The first deviation calculation module is used to perform color space conversion on the preprocessed image using the HSV-HIS mixed color space conversion model and extract two marker line regions. Based on the two marker line regions, straight line fitting is performed to obtain two color reference lines, and the deviation between the two color reference lines is calculated, which are the first angle deviation and the first displacement deviation, respectively. The second deviation calculation module is used to process the preprocessed image into a grayscale image, extract the edges of the two marker lines in the grayscale image through an edge detection algorithm, and then perform straight line fitting based on the two extracted edges to obtain two grayscale reference lines. The deviation between the two grayscale reference lines is calculated, which are the second angle deviation and the second displacement deviation. The screw status judgment module is used to determine whether the screw is loose based on the first angle deviation, the first displacement deviation, the second angle deviation, and the second displacement deviation. The HSV-HIS mixed color space conversion model is used to perform color space conversion on the preprocessed image and extract two marked line regions, specifically including: The preprocessed image is an RGB image. The preprocessed image is converted into an HSV color space to obtain the initial HSV features of each pixel, including hue, saturation, and brightness. The HIS color space enhancement algorithm is used to enhance the saturation and brightness of each pixel to obtain enhanced saturation and enhanced brightness. The initial HSV features are combined with the enhanced saturation and enhanced brightness to obtain the mixed HSV features for each pixel; The feature baseline threshold boundary of the marker line is determined in advance using a machine learning algorithm. Then, the adjustment range is determined based on the average brightness of the current preprocessed image. The feature baseline threshold boundary is adjusted according to the adjustment range to obtain the current feature threshold boundary. The mixed HSV features of each pixel are compared with the current feature threshold boundary. If the mixed HSV features of a pixel are within the current feature threshold range, then the pixel is a pixel within the marker line region. All pixels are traversed to extract two marker line regions. Determining whether a screw is loose based on the first angular deviation, the first displacement deviation, the second angular deviation, and the second displacement deviation includes: The fused angle deviation is obtained by weighted summation of the first angle deviation and the second angle deviation; The first displacement deviation and the second displacement deviation are weighted and summed to obtain the fused displacement deviation. When the fusion angle deviation is less than the first angle threshold and the fusion displacement deviation is less than the first displacement threshold, it is determined to be in a tight state. When the fusion angle deviation is greater than or equal to the first angle threshold and less than the second angle threshold, or the fusion displacement deviation is greater than or equal to the first displacement threshold and less than the second displacement threshold, it is determined to be a warning state. When the fusion angle deviation is greater than the second angle threshold, or the fusion displacement deviation is greater than the second displacement threshold, it is determined to be in a loose state.
7. A terminal, characterized in that, include: The memory is used to store the screw loosening detection program; A processor is configured to implement the steps of the screw loosening detection method as described in any one of claims 1 to 5 when executing the screw loosening detection program.
8. A computer-readable storage medium, characterized in that, The readable storage medium stores a screw loosening detection program, which, when executed by a processor, implements the steps of the screw loosening detection method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Bolt looseness detection method, device and equipment and storage medium
CN112419297A
Bolt looseness detection method based on machine vision
CN119672393A
