Belt buckle life analysis algorithm based on machine vision technology
By using a belt buckle life analysis algorithm based on machine vision technology, the problems of low efficiency and insufficient accuracy in belt buckle detection have been solved, enabling real-time and accurate detection and life assessment of belt buckles, thereby improving detection efficiency and production continuity.
Patent Information
- Application Number
- CN202510329646.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-03-18
AI Technical Summary
In existing technologies, belt buckle detection relies on manual inspection or simple sensors, which is inefficient and has limited accuracy. It is difficult to detect subtle defects in belt buckles in a timely and accurate manner in complex industrial environments. Furthermore, belt buckle anomaly data is scarce, which limits the training and optimization of machine learning models. How to accurately locate the belt buckle area in anomaly detection has become a key challenge.
A belt buckle life analysis algorithm based on machine vision technology is adopted, which includes steps such as image acquisition and processing, region semantic analysis, visual correction, belt buckle segmentation, edge analysis, line detection and life analysis. The FastSCNN model and HoughLines algorithm are used to achieve accurate localization of belt buckle area and life assessment.
It improves the real-time performance, accuracy, and efficiency of belt buckle anomaly detection, reduces false alarm rate, provides accurate life assessment, provides timely decision support for the control center, and ensures the continuous and stable operation of the belt conveyor.
Smart Images

Figure CN120259229B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of visual inspection technology, and more specifically to a lifespan analysis algorithm for belt buckles based on machine vision technology. Background Technology
[0002] As a key component of belt conveyors, belt buckles are responsible for connecting belts into a closed loop, ensuring the normal operation of the conveyor. However, in actual use, belt buckles are prone to damage such as broken teeth due to uneven stress, wear, or inherent quality defects. Once a belt buckle is damaged, it can potentially lead to the failure of the entire belt conveyor, thereby affecting the entire production process and causing adverse consequences such as production stoppage and economic losses.
[0003] Currently, the main methods for inspecting belt buckles rely on manual inspection or simple sensors. Manual inspection is not only inefficient but also highly susceptible to human error, resulting in limited accuracy. Simple sensors, in complex industrial environments, cannot detect subtle defects in belt buckles in a timely and accurate manner, making it difficult to effectively predict malfunctions. This leads to frequent belt conveyor downtime and other problems, severely impacting production efficiency and business profitability.
[0004] With the development of machine vision technology, various anomaly detection methods for key components based on machine vision have been proposed. However, in the field of belt buckle detection, many challenges remain. First, anomalies such as broken teeth in belt buckles occur infrequently, resulting in scarce anomaly data, which greatly limits the training and optimization of machine learning models, making it difficult to build high-precision detection models. Second, belt conveyors often operate in harsh environments such as dim lighting and humidity, making belt buckles prone to problems such as shadows and surface contamination, which places high demands on the ability of machine vision inspection to eliminate interference factors. Third, when the belt is running at high speed, clearly capturing the belt buckle area becomes a key challenge; how to accurately locate the belt buckle area in anomaly detection is an urgent problem to be solved. Summary of the Invention
[0005] The purpose of this invention is to provide a life analysis algorithm for belt buckles based on machine vision technology, which solves the technical problems mentioned in the background art.
[0006] The objective of this invention can be achieved through the following technical solutions:
[0007] The lifespan analysis algorithm for belt buckles based on machine vision technology includes the following steps:
[0008] Step 1: Image Acquisition and Processing
[0009] The video stream of the belt buckle in operation is acquired by an industrial camera, and then video frames containing the belt buckle are extracted from the video stream and recorded as belt buckle images.
[0010] Step 2: Region semantic analysis:
[0011] The buckle region pixels are manually labeled on multiple buckle images to obtain sample images. Then, the FastSCNN model is trained using the sample images. Subsequently, the collected buckle images are input into the trained model, and a binarized mask is obtained after thresholding to determine the buckle region image.
[0012] Step 3: Visual Correction
[0013] Place a square grid in the same shooting scene as the belt buckle image, mark the pixel coordinates of its four vertices in the video frame, and adjust the vertices according to the principle of projection transformation, so that the bounding rectangle has the same side length and the four corners are 90 degrees, thus completing the visual correction of the belt buckle image.
[0014] Step 4: Cutting the belt buckle:
[0015] Extract the visually corrected belt buckle area image, mark the coordinates of its upper left and lower right corners, calculate the lengths in the x and y directions, determine the cutting side lengths based on the long and short sides, calculate the number of cuts, and cut out the corresponding number of small squares from the upper left corner downwards. Cut the belt buckle area image according to the small squares.
[0016] Step 5, Edge Analysis:
[0017] Edge detection is performed on the input binary mask image using the Canny method. The process involves first smoothing the image with Gaussian filtering, then calculating the gradients in the x and y directions using the Sobel operator, followed by non-maximum suppression to refine the edges, determining the edges based on high and low thresholds, and finally performing dilation and erosion operations to determine the edge image.
[0018] Step 6: Line detection:
[0019] The HoughLines line detection algorithm is used to detect lines in the edge image and obtain multiple sets of lines and their corresponding endpoint coordinates.
[0020] Step 7: Suppression of nonmaxima in a straight line:
[0021] Calculate the length of the line based on the coordinates of the endpoints of the line and sort them. Select the longest line segment as the candidate line. Then calculate the slope and intercept of each group of lines. Based on the slope and intercept, retain the two longest non-intersecting lines.
[0022] Step 8: Measuring line spacing:
[0023] Obtain the slope and intercept of the two non-intersecting lines determined in step seven, and then calculate the line spacing between them.
[0024] Step 9: Lifetime Analysis
[0025] Extract the vertical distances of the corresponding straight lines from multiple video frames to form a data sequence, calculate the average and standard deviation, and compare them with the preset vertical distance threshold to determine whether the belt buckle is damaged; if it is not damaged, use linear fitting to calculate the historical width change rate, substitute the threshold and average to calculate the maximum and current usage time respectively, and subtract them to obtain the remaining lifespan.
[0026] As a further aspect of the present invention, the belt buckle image extraction method is as follows:
[0027] Step A1: Select two adjacent video frames from the video stream, and label the pixel values of the pixels located at coordinates (x, y) in the two video frames as S. n (x, y) and S n+1 (x, y);
[0028] Where x represents the horizontal coordinate of a pixel in a video frame, represents the vertical coordinate of a pixel in a video frame, and n represents the sequence number of the video frame;
[0029] Step A2: Select a column of pixels, that is, pixels with fixed x values and different y values;
[0030] First, we use: S0(x, y) = |S n (x, y)-S n+1 (x, y)|, calculates the difference in pixel values between two adjacent video frames along the y-axis;
[0031] The differences in the pixel values of this column are then accumulated along the y-axis to obtain the accumulated difference value;
[0032] The formula for calculating the cumulative difference is:
[0033] In the formula, y = 1, 2, ..., h, where h is the height of the video frame;
[0034] Step A3: Following the method in Step A2, calculate the cumulative difference value for each column;
[0035] Then, the peak value of the accumulated difference is extracted from the accumulated difference value of each column;
[0036] Among them, the peak value of the accumulated difference value represents the position where the difference value between two adjacent video frames in the corresponding column is the largest;
[0037] Step A4: Extract the pre-set cumulative difference threshold;
[0038] When the peak value of the accumulated difference is greater than the accumulated difference threshold, the peak value generated by each frame of the image is tracked and recorded until it returns to the normal level.
[0039] Then, all peak values within the corresponding shooting time of the video stream are recorded, and the size of all peak values is compared. The frame corresponding to the largest peak value is then taken as the buckle image.
[0040] As a further aspect of the present invention, the specific method of region semantic analysis is as follows:
[0041] Step B1: Manually mark the pixels of the belt buckle area on multiple pre-prepared images containing belt buckles, and obtain a belt buckle sample image;
[0042] Step B2: Then, multiple belt buckle sample images are used as the training dataset, and the model is trained using the pre-built FastSCNN model.
[0043] Step B3: Next, input the belt buckle image collected in the first step into the trained FastSCNN model. The FastSCNN model outputs a probability map of each pixel belonging to the "belt buckle" or "non-belt buckle" category.
[0044] Step B4: Then, by thresholding the probability map, a binarized mask map is obtained, which is the belt buckle area image.
[0045] In the binary mask image, 1 represents the belt buckle area, and 0 represents the non-belt buckle area.
[0046] As a further aspect of this invention: FastSCNN is a lightweight semantic segmentation network, mainly composed of three modules:
[0047] Learn the downsampling module, which is used to quickly reduce the resolution of the input image and reduce the amount of subsequent computation;
[0048] It consists of three convolutional layers: one ordinary convolutional layer and two depthwise separable convolutional layers.
[0049] A global feature extractor is used to extract global features using inverted residual blocks;
[0050] The inverted residual block is first increased in dimensionality through pointwise convolution, then depthwise convolution, and finally reduced in dimensionality through pointwise convolution.
[0051] The feature fusion module is used to fuse the output of the learning downsampling module and the output of the global feature extractor;
[0052] The process involves first performing bilinear interpolation upsampling on the output of the global feature extractor to make its resolution consistent with the output of the learning downsampling module, then concatenating the two, and finally performing feature fusion through a convolutional layer.
[0053] A classifier is used to perform convolution operations on the fused feature map and output a probability map of each pixel belonging to different categories.
[0054] As a further aspect of the present invention, the specific method of visual correction is as follows:
[0055] Prepare a 1m x 1m square grid and place it in the same scene as when the belt buckle image was taken;
[0056] The industrial camera captured images of the square grid and the belt buckle area.
[0057] In the acquired video frames, the pixel coordinates of the four vertices of the square grid in the image coordinate system are manually marked.
[0058] Based on the four vertices of the square grid obtained from the annotation, the belt buckle image is visually corrected using the principle of projection transformation.
[0059] The visual correction method is as follows: in the video frame, adjust the four vertices of the square grid until the side length of the rectangle formed by the four vertices is all the same and the four corners of the rectangle are 90 degrees. At this time, the visual correction of the belt buckle image is completed.
[0060] As a further aspect of the present invention: the method for adjusting the four vertices of the square grid is as follows:
[0061] The projection transformation algorithm is used to map the vertices of quadrilaterals in the image to a new coordinate system, so that the quadrilaterals appear to be closer to squares in the new coordinate system. Then, by adjusting the parameters of the transformation matrix, the vertices of the quadrilaterals satisfy the conditions of consistent side length and 90-degree angles after the transformation.
[0062] As a further aspect of the present invention, the specific method for cutting the belt buckle is as follows:
[0063] Step W1: Extract the visually corrected belt buckle area image, and then extract the coordinates of the upper left corner and lower right corner of the belt buckle area in the belt buckle area image, and label them as (x0, y0) and (x1, y1) respectively.
[0064] Step W2: Then, calculate the length W of the belt buckle area in the x-axis direction and the length H in the y-axis direction using W = x1 - x0 and H = y1 - y0, respectively.
[0065] Step W3: Then, based on the lengths W and H, calculate the number of segments in the belt buckle area image;
[0066] The method is as follows:
[0067] When H > W, then the length W in the x-axis direction is taken as the side length, and through... Calculate the number of segments N in the belt buckle region image;
[0068] When W > H, then the length H in the y-axis direction is taken as the side length, and through... Calculate the number of segments N in the belt buckle region image;
[0069] In the formula, This is a round-down operation;
[0070] Step W4: When the length W along the x-axis is taken as the side length, starting from the top left corner of the belt buckle area image, cut out N small squares with a side length of W in sequence. The top left corner coordinates of each small square are (x0, y0+i×W), and the bottom right corner coordinates are (x0+W, y0+(i+1)×W).
[0071] Step W5: Then, divide the belt buckle area image into smaller squares.
[0072] As a further aspect of the present invention, the specific method of edge analysis is as follows:
[0073] Step U1: Smooth the binarized mask image using a Gaussian filter;
[0074] Step U2: Use the Sobel operator to calculate the gradient values of the image in the x and y directions, and denote them as Gx and Gy, respectively.
[0075] Step U3: Perform non-maximum suppression on the gradient magnitude, retaining only the pixels with the local maximum gradient value to refine the edges;
[0076] Specifically, for each pixel, check the two adjacent pixels in its gradient direction. If the gradient magnitude of the pixel is not a local maximum, then set its gradient magnitude to 0.
[0077] Step U4: Determine the edge based on the preset low and high thresholds;
[0078] A pixel whose gradient magnitude is greater than a high threshold is defined as a strong edge pixel;
[0079] Pixels whose gradient magnitude is between the low threshold and the high threshold are defined as weak edge pixels;
[0080] Among them, weak edge pixels connected to strong edge pixels are determined to be retained edge pixels;
[0081] Step U5: Then, use a 5×5 core to perform expansion and erosion operations;
[0082] The Canny method is an existing technology.
[0083] Step U6: Then, based on the pixels of all foreground areas, determine the edge image;
[0084] As a further aspect of the present invention: the dilation operation is as follows: the foreground region in the binarized mask image is expanded, that is, the region of white pixels, and then the structuring element is slid on the image. If the structuring element overlaps with the foreground region in the image, the pixel corresponding to the center of the structuring element is set as the pixel of the foreground region.
[0085] The structural element is a 5×5 core;
[0086] The erosion operation is the opposite of the dilation operation. It shrinks the foreground region in the image and then slides the structuring element across the image. Only when the structuring element is completely contained within the foreground region of the image is the pixel corresponding to the center of the structuring element set as the pixel of the foreground region.
[0087] As a further aspect of the present invention: Step 6, the straight line detection method is as follows:
[0088] The edge image is a binary image, where white dots represent edge pixels and black dots represent non-edge pixels.
[0089] Step C1: Construct the accumulator matrix:
[0090] First, establish the equation of the straight line in the polar coordinate system: ρ=xcosθ+ysinθ
[0091] Where ρ is the distance from the line to the top left corner of the image, and θ is the angle between the line and the x-axis;
[0092] Then, ρ is discretized into values with a step size of 1, and θ is discretized into values with a step size of 1 degree.
[0093] Next, the size of the accumulator matrix is determined to be Q×G, where Q is the range of values for ρ and G is the range of values for θ.
[0094] Step C2, Parameter Voting:
[0095] For each edge pixel in the edge detection result, according to the polar coordinate equation ρ=xcosθ+ysinθ, a series of corresponding ρ values are calculated as θ changes from 0° to 180° in steps of 1 degree.
[0096] For each group (ρ, θ), increment the value of the corresponding position (ρ, θ) in the accumulator matrix by 1, and then obtain the number of votes for each [ρ, θ] combination recorded in the accumulator matrix;
[0097] Step C3, Peak Detection:
[0098] Find the local maximum value in the accumulator matrix where the number of votes exceeds a preset voting threshold;
[0099] Among them, the local maximum value indicates that, under the corresponding (ρ, θ) combination, there are a large number of edge points supporting the existence of the line;
[0100] Step C4, Line Length Filtering:
[0101] For each detected straight line, the length of the relevant straight line in the edge image is obtained by finding the intersection point of the straight line and the image boundary in the edge image, and then calculating the distance between the two intersection points using the Euclidean distance formula.
[0102] The length of the relevant line in the edge image is then compared with the preset minimum line length: if the length in the edge image is greater than or equal to the minimum line length, the line is retained; otherwise, it is not retained.
[0103] Finally, obtain the retained straight line and its corresponding endpoint coordinates, and save them.
[0104] As a further aspect of the present invention, the specific method for suppressing non-maximum values of a straight line is as follows:
[0105] Step Y1: Based on the coordinates of the endpoints of the multiple sets of straight lines, calculate the length of each set of straight lines using the Euclidean distance formula. Then, sort all the straight lines in descending order of their lengths and select the longest line segment as the candidate line.
[0106] The Euclidean distance formula is as follows:
[0107]
[0108] In the formula, L j Let be the length of the j-th line, (xa) j ya j ) and (xb j yb j Let be the coordinates of the two endpoints of the j-th line, where j is the line number;
[0109] Step Y2: Then, based on the coordinates of the two endpoints of the line, calculate the slope and intercept of the line using the two-point formula.
[0110] The formula for calculating the slope is as follows:
[0111]
[0112] In the formula, E j Let be the slope of the j-th line;
[0113] The formula for calculating the intercept is as follows:
[0114] B j =yb j -E j ×xb j
[0115] In the formula, B j Let be the slope of the j-th line;
[0116] Step Y3: Then iterate through the sorted list of lines, and for each candidate line, compare it with other lines.
[0117] If the slope difference between a candidate line and another line is less than 0.02 or the intercept difference is less than 10 pixels, then the candidate line and another line are considered to belong to the same line.
[0118] Step 4: Finally, keep the two longest non-intersecting lines.
[0119] As a further aspect of the present invention, the line spacing is calculated as follows:
[0120] Obtain the slope and intercept of two non-intersecting lines, and label them as E1, E2, B1, and B2 respectively;
[0121] Then through:
[0122] Calculate the perpendicular distance D between the two non-intersecting lines.
[0123] As a further aspect of the present invention, the specific method for lifetime analysis is as follows:
[0124] Step H1: Following the steps from step 2 to step 8, extract the perpendicular distance between two corresponding non-intersecting lines in multiple video frames and group them into a time-varying line spacing data sequence, which is then labeled as D0 = {D1, D2, ..., Dg}, where g is the number of multiple video frames.
[0125] Step H2: Next, calculate the mean and standard deviation of all vertical distances in the line spacing data sequence;
[0126] The calculation method is as follows:
[0127]
[0128] In the formula, s is the sequence number of multiple video frames, and s = 1, 2, ... g, Ds is the vertical distance corresponding to the s-th video frame, and D1 and D2 are the average and standard deviation of all vertical distances in the line spacing data sequence, respectively.
[0129] Step H3: Extract the pre-set vertical distance threshold value Dy, which represents the vertical distance threshold at which the buckle is damaged or worn.
[0130] Then, the average value D1 of all vertical distances in the line spacing data sequence measured within the current video stream's corresponding shooting time is compared with the vertical distance threshold Dy;
[0131] If D1 > Dy, then the belt buckle is determined to be damaged or worn.
[0132] If D1≤Dy, then each vertical distance Ds in the line spacing data sequence is compared with the vertical distance threshold Dy. If there is a set of Ds>Dy, then the buckle is determined to be damaged or worn; otherwise, the buckle is determined to be undamaged or unworn.
[0133] Simultaneously, extract the pre-set fluctuation threshold Dz of the vertical distance;
[0134] If D2 > Dz, it indicates that the line spacing data fluctuates greatly, the wear of the belt buckle may be unstable, and there is a risk of abnormal wear.
[0135] If D2≤Dz, it indicates that the line spacing data is relatively stable and the wear of the belt buckle is relatively uniform.
[0136] Step H4: When the belt buckle is not damaged, calculate the historical width change rate of the belt buckle based on the linear fitting method.
[0137] The method is as follows:
[0138] The relationship between vertical distance and time is represented by the linear fitting equation y = ax + b.
[0139] Where x represents the time sequence number of the video frame and y represents the vertical distance;
[0140] Then, the least squares method is used to solve for a and b in the linear fitting equation; where a is the historical width change rate corresponding to the belt buckle;
[0141] Step H5: Extract the critical vertical distance Dy corresponding to the damage of the belt buckle, then substitute it into the linear fitting equation y=ax+b, and record the obtained x value as the maximum usage time;
[0142] Then, the average value D1 of all vertical distances in the line spacing data sequence measured within the current video stream shooting time is substituted into the linear fitting equation y=ax+b, and the resulting x value is recorded as the current usage time;
[0143] Then subtract the current usage time from the maximum usage time to calculate the remaining lifespan of the belt buckle.
[0144] The beneficial effects of this invention are:
[0145] Significantly Improved Real-Time Performance: Traditional belt buckle detection methods rely heavily on manual inspections, making it difficult to monitor the belt buckle's operational status in real time and prone to delays in fault detection. This invention utilizes machine vision technology to capture the belt buckle area in real time during belt conveyor operation. Through rapid analysis of the video stream, it can promptly detect belt buckle anomalies and quickly feed the results back to the control center. This provides strong support for the control center to make timely decisions, greatly shortening the time interval from fault occurrence to detection, effectively improving the real-time performance of belt buckle anomaly detection, and ensuring the continuous and stable operation of the belt conveyor.
[0146] Precise Region Capture and Localization: An innovative differential analysis method is proposed to efficiently capture and accurately locate the belt buckle area. Compared to traditional methods, this approach can more accurately extract belt buckles from complex belt movement backgrounds, avoiding detection errors caused by inaccurate region localization. This lays a solid foundation for subsequent detection steps and significantly improves detection accuracy.
[0147] Accurate region identification: The belt buckle region is identified using a semantic segmentation method. This method can clearly distinguish the belt buckle from other background parts, accurately identify the boundary and range of the belt buckle, further improve the detection accuracy of the belt buckle, reduce false alarms and missed alarms caused by inaccurate identification, and ensure the reliability of the detection results.
[0148] Accurate lifespan detection: The lifespan detection method based on the edge line spacing of belt buckles can accurately assess the wear degree and lifespan status of belt buckles by detecting the target straight line, calculating the line spacing, and performing linear regression analysis on the changes in line spacing in the time domain. This provides a precise basis for belt buckle replacement and maintenance, avoiding premature or late replacement of belt buckles due to inaccurate lifespan assessment, and improving the operating efficiency and safety of equipment.
[0149] Significantly improved inspection efficiency: Traditional belt buckle inspection methods typically require substantial manpower and time for segment-by-segment checks, resulting in low efficiency. This invention's automated inspection method enables rapid, continuous inspection of belt buckles without manual intervention, greatly shortening the inspection cycle and improving efficiency. Furthermore, by rapidly processing large amounts of video stream data, it can complete comprehensive inspection of belt buckles throughout the entire belt operation process in a short time, enhancing the continuity and efficiency of production operations.
[0150] Reduced false alarm rate: Through learning from large amounts of data and precise algorithm design in feature extraction, model training, and anomaly comparison analysis, the system can accurately distinguish between normal and abnormal states of belt buckles, effectively reducing the false alarm rate. Compared with traditional detection methods, this invention reduces unnecessary alarms caused by human error or inaccurate detection methods, improves the reliability of detection results, and avoids unnecessary interference and losses to production caused by false alarms.
[0151] Provides decision support: Real-time feedback of test results provides the control center with comprehensive and accurate information on the belt buckle's operating status, helping the control center to make timely and scientific decisions. For example, when a belt buckle malfunctions, the control center can promptly arrange maintenance personnel to handle the issue based on the test results, preventing the fault from escalating further; when a belt buckle is nearing the end of its lifespan, preparations for replacement can be made in advance to ensure smooth production. Attached Figure Description
[0152] The invention will now be further described with reference to the accompanying drawings.
[0153] Figure 1 This is a system block diagram of the belt buckle life analysis algorithm based on machine vision technology of the present invention.
[0154] Figure 2 This is a schematic diagram of a belt buckle image obtained from image acquisition and processing in the belt buckle life analysis algorithm based on machine vision technology of this invention.
[0155] Figure 3 This is a binarized mask image obtained from region semantic analysis in the belt buckle life analysis algorithm based on machine vision technology of this invention;
[0156] Figure 4 This is a schematic diagram of belt buckle images before and after visual correction in the belt buckle life analysis algorithm based on machine vision technology of the present invention.
[0157] Figure 5 This is a schematic diagram of belt buckle segmentation in the belt buckle life analysis algorithm based on machine vision technology of this invention. Detailed Implementation
[0158] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0159] Example 1
[0160] Please see Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 As shown, this invention is a lifespan analysis algorithm for belt buckles based on machine vision technology, including the following steps:
[0161] Step 1: Image Acquisition and Processing
[0162] The video stream of the belt buckle in operation is acquired by an industrial camera, and then video frames containing the belt buckle are extracted from the video stream and recorded as belt buckle images.
[0163] Step 2: Region semantic analysis:
[0164] The buckle region pixels are manually labeled on multiple buckle images to obtain sample images. Then, the FastSCNN model is trained using the sample images. Subsequently, the collected buckle images are input into the trained model, and a binarized mask is obtained after thresholding to determine the buckle region image.
[0165] The specific method is as follows:
[0166] Step B1: Manually mark the pixels of the belt buckle area on multiple pre-prepared images containing belt buckles, and obtain a belt buckle sample image;
[0167] Step B2: Then, multiple belt buckle sample images are used as the training dataset, and the model is trained using the pre-built FastSCNN model.
[0168] Step B3: Next, input the belt buckle image collected in the first step into the trained FastSCNN model. The FastSCNN model outputs a probability map of each pixel belonging to the "belt buckle" or "non-belt buckle" category.
[0169] Step B4: Then, threshold processing is performed on the probability map. In this embodiment, if the pixel with a probability greater than 0.5 is determined to be the belt buckle pixel, a binarized mask map is obtained, thereby determining the specific area of the belt buckle in the video frame, that is, obtaining the belt buckle area image.
[0170] In the binary mask image, 1 represents the belt buckle area and 0 represents the non-belt buckle area;
[0171] Step 3: Visual Correction
[0172] Place a square grid in the same shooting scene as the belt buckle image, mark the pixel coordinates of its four vertices in the video frame, and adjust the vertices according to the principle of projection transformation, so that the bounding rectangle has the same side length and the four corners are 90 degrees, thus completing the visual correction of the belt buckle image.
[0173] The specific method is as follows:
[0174] Prepare a 1m x 1m square grid and place it in the same scene as when the belt buckle image was taken;
[0175] The industrial camera captured images of the square grid and the belt buckle area.
[0176] In the acquired video frames, the pixel coordinates of the four vertices of the square grid in the image coordinate system are manually marked.
[0177] Based on the four vertices of the square grid obtained from the annotation, the belt buckle image is visually corrected using the principle of projection transformation.
[0178] The visual correction method is as follows: in the video frame, adjust the four vertices of the square grid until the side length of the rectangle formed by the four vertices is all the same and the four corners of the rectangle are 90 degrees. At this time, the visual correction of the belt buckle image is completed.
[0179] Step 4: Cutting the belt buckle:
[0180] Extract the visually corrected belt buckle area image, mark the coordinates of its upper left and lower right corners, calculate the lengths in the x and y directions, determine the cutting side lengths based on the long and short sides, calculate the number of cuts, and cut out the corresponding number of small squares from the upper left corner downwards. Cut the belt buckle area image according to the small squares.
[0181] The specific method is as follows:
[0182] Step W1: Extract the visually corrected belt buckle area image, and then extract the coordinates of the upper left corner and lower right corner of the belt buckle area in the belt buckle area image, and label them as (x0, y0) and (x1, y1) respectively.
[0183] Step W2: Then, calculate the length W of the belt buckle area in the x-axis direction and the length H in the y-axis direction using W = x1 - x0 and H = y1 - y0, respectively.
[0184] Step W3: Then, based on the lengths W and H, calculate the number of segments in the belt buckle area image;
[0185] The method is as follows:
[0186] When H > W, then the length W in the x-axis direction is taken as the side length, and through... Calculate the number of segments N in the belt buckle region image;
[0187] When W > H, then the length H in the y-axis direction is taken as the side length, and through... Calculate the number of segments N in the belt buckle region image;
[0188] In the formula, This is a round-down operation;
[0189] Step W4: When the length W along the x-axis is taken as the side length, starting from the top left corner of the belt buckle area image, cut out N small squares with a side length of W in sequence. The top left corner coordinates of each small square are (x0, y0+i×W), and the bottom right corner coordinates are (x0+W, y0+(i+1)×W).
[0190] Step W5: Then, divide the belt buckle area image into smaller squares;
[0191] Step 5, Edge Analysis:
[0192] Edge detection is performed on the input binary mask image using the Canny method. The process involves first smoothing the image with Gaussian filtering, then calculating the gradients in the x and y directions using the Sobel operator, followed by non-maximum suppression to refine the edges, determining the edges based on high and low thresholds, and finally performing dilation and erosion operations to determine the edge image.
[0193] The specific method is as follows:
[0194] Step U1: Smooth the binarized mask image using a Gaussian filter;
[0195] Step U2: Use the Sobel operator to calculate the gradient values of the image in the x and y directions, and denote them as Gx and Gy, respectively.
[0196] Step U3: Perform non-maximum suppression on the gradient magnitude, retaining only the pixels with the local maximum gradient value to refine the edges;
[0197] Specifically, for each pixel, check the two adjacent pixels in its gradient direction. If the gradient magnitude of the pixel is not a local maximum, then set its gradient magnitude to 0.
[0198] Step U4: Determine the edge based on the preset low and high thresholds;
[0199] A pixel whose gradient magnitude is greater than a high threshold is defined as a strong edge pixel;
[0200] Pixels whose gradient magnitude is between the low threshold and the high threshold are defined as weak edge pixels;
[0201] Among them, weak edge pixels connected to strong edge pixels are determined to be retained edge pixels;
[0202] Step U5: Then, use a 5×5 core to perform expansion and erosion operations;
[0203] The dilation operation is as follows: the foreground region in the binarized mask image is expanded, that is, the region of white pixels. Then, the structuring element is slid on the image. If the structuring element overlaps with the foreground region in the image, the pixel corresponding to the center of the structuring element is set as the pixel of the foreground region.
[0204] The structural element is a 5×5 core;
[0205] The erosion operation is the opposite of the dilation operation. It shrinks the foreground region in the image and then slides the structuring element on the image. Only when the structuring element is completely contained within the foreground region of the image is the pixel corresponding to the center of the structuring element set as the pixel of the foreground region.
[0206] The Canny method is an existing technology.
[0207] Step U6: Then, based on the pixels of all foreground areas, determine the edge image;
[0208] Step 6: Line detection:
[0209] The HoughLines line detection algorithm is used to detect lines in the edge image and obtain multiple sets of lines and their corresponding endpoint coordinates.
[0210] In this embodiment, before performing line detection, it is necessary to ensure that the edge detection step has been completed and the edge detection result image has been obtained; the result image is a binary image, where white dots represent edge pixels and black dots represent non-edge pixels;
[0211] The line detection method is as follows:
[0212] Step C1: Construct the accumulator matrix:
[0213] First, establish the equation of the straight line in the polar coordinate system: ρ=xcosθ+ysinθ
[0214] Where ρ is the distance from the line to the top left corner of the image, and θ is the angle between the line and the x-axis, with a range of 0°-180°;
[0215] Then, ρ is discretized into values with a step size of 1, and θ is discretized into values with a step size of 1 degree.
[0216] Next, the size of the accumulator matrix is determined to be Q×G, where Q is the range of values for ρ and G is the range of values for θ.
[0217] In this embodiment, for a 1920×1080 image, the maximum possible value of ρ is the length of the image diagonal, which is approximately... Considering both positive and negative values, the range of ρ is approximately from -2202 to 2202, for a total of 4405 values;
[0218] In this embodiment, for ease of calculation, M is set to 1920 × 1080 = 2073600; the value of θ is in the range of 0°-180° with a step size of 1 degree, so the value of N is 180.
[0219] Therefore, the accumulator matrix is a 2073600×180 matrix;
[0220] For edge images of different sizes, the value of M needs to be adjusted according to the length and width of the edge image.
[0221] Step C2, Parameter Voting:
[0222] For each edge pixel in the edge detection result, according to the polar coordinate equation ρ=xcosθ+ysinθ, a series of corresponding ρ values are calculated as θ changes from 0° to 180° in steps of 1 degree.
[0223] For each group (ρ, θ), increment the value of the corresponding position (ρ, θ) in the accumulator matrix by 1, and then obtain the number of votes for each [ρ, θ] combination recorded in the accumulator matrix;
[0224] Step C3, Peak Detection:
[0225] Find the local maximum value in the accumulator matrix where the number of votes exceeds a preset voting threshold;
[0226] Among them, the local maximum value indicates that, under the corresponding (ρ, θ) combination, there are a large number of edge points supporting the existence of the line;
[0227] In this embodiment, it is assumed that the voting threshold is set to 60, that is, only when the value of [ρ, θ] is greater than or equal to 60 is the combination of (ρ, θ) considered to correspond to a straight line in the image space.
[0228] Step C4, Line Length Filtering:
[0229] For each detected straight line, the length of the relevant straight line in the edge image is obtained by finding the intersection point of the straight line and the image boundary in the edge image, and then calculating the distance between the two intersection points using the Euclidean distance formula.
[0230] The length of the relevant line in the edge image is then compared with the preset minimum line length: if the length in the edge image is greater than or equal to the minimum line length, the line is retained; otherwise, it is not retained.
[0231] In this embodiment, assuming the preset minimum length of a straight line is 300, only straight lines with a length greater than or equal to 300 will be retained.
[0232] Finally, obtain the retained straight line and its corresponding endpoint coordinates, and save them;
[0233] Step 7: Suppression of nonmaxima in a straight line:
[0234] Calculate the length of the line based on the coordinates of the endpoints of the line and sort them. Select the longest line segment as the candidate line. Then calculate the slope and intercept of each group of lines. Based on the slope and intercept, retain the two longest non-intersecting lines.
[0235] The specific method is as follows:
[0236] Step Y1: Based on the coordinates of the endpoints of the multiple sets of straight lines, calculate the length of each set of straight lines using the Euclidean distance formula. Then, sort all the straight lines in descending order of their lengths and select the longest line segment as the candidate line.
[0237] The Euclidean distance formula is as follows:
[0238]
[0239] In the formula, L j Let be the length of the j-th line, (xa) j ya j ) and (xb j yb j Let be the coordinates of the two endpoints of the j-th line, where j is the line number;
[0240] Step Y2: Then, based on the coordinates of the two endpoints of the line, calculate the slope and intercept of the line using the two-point formula.
[0241] The formula for calculating the slope is as follows:
[0242]
[0243] In the formula, E j Let be the slope of the j-th line;
[0244] The formula for calculating the intercept is as follows:
[0245] B j =yb j -E j ×xb j
[0246] In the formula, B j Let be the slope of the j-th line;
[0247] Step Y3: Then iterate through the sorted list of lines, and for each candidate line, compare it with other lines.
[0248] If the slope difference between a candidate line and another line is less than 0.02 or the intercept difference is less than 10 pixels, then the candidate line and another line are considered to belong to the same line.
[0249] Step Y4: Finally, keep the two longest non-intersecting lines;
[0250] Step 8: Measuring line spacing:
[0251] Obtain the slope and intercept of the two non-intersecting lines determined in step seven, and then calculate the line spacing between them.
[0252] The line spacing is calculated as follows:
[0253] Obtain the slope and intercept of two non-intersecting lines, and label them as E1, E2, B1, and B2 respectively;
[0254] Then through:
[0255] Calculate the perpendicular distance D between the two non-intersecting lines;
[0256] In this embodiment, since the two lines are parallel, their slopes are equal, i.e., E1 = E2;
[0257] Step 9: Lifetime Analysis
[0258] Extract the vertical distances of the corresponding straight lines from multiple video frames to form a data sequence, calculate the average and standard deviation, and compare them with the preset vertical distance threshold to determine whether the belt buckle is damaged; if it is not damaged, use linear fitting to calculate the historical width change rate, substitute the threshold and average to calculate the maximum and current usage time respectively, and subtract them to obtain the remaining lifespan;
[0259] The specific method is as follows:
[0260] Step H1: Following the steps from step 2 to step 8, extract the perpendicular distance between two corresponding non-intersecting lines in multiple video frames and group them into a time-varying line spacing data sequence, which is then labeled as D0 = {D1, D2, ..., Dg}, where g is the number of multiple video frames.
[0261] Step H2: Next, calculate the mean and standard deviation of all vertical distances in the line spacing data sequence;
[0262] The calculation method is as follows:
[0263]
[0264] In the formula, s is the sequence number of multiple video frames, and s = 1, 2, ... g, Ds is the vertical distance corresponding to the s-th video frame, and D1 and D2 are the average and standard deviation of all vertical distances in the line spacing data sequence, respectively.
[0265] Step H3: Extract the pre-set vertical distance threshold value Dy, which represents the vertical distance threshold at which the buckle is damaged or worn.
[0266] Then, the average value D1 of all vertical distances in the line spacing data sequence measured within the current video stream's corresponding shooting time is compared with the vertical distance threshold Dy;
[0267] If D1 > Dy, then the belt buckle is determined to be damaged or worn.
[0268] If D1≤Dy, then each vertical distance Ds in the line spacing data sequence is compared with the vertical distance threshold Dy. If there is a set of Ds>Dy, then the buckle is determined to be damaged or worn; otherwise, the buckle is determined to be undamaged or unworn.
[0269] Simultaneously, extract the pre-set fluctuation threshold Dz of the vertical distance;
[0270] If D2 > Dz, it indicates that the line spacing data fluctuates greatly, the wear of the belt buckle may be unstable, and there is a risk of abnormal wear.
[0271] If D2≤Dz, it indicates that the line spacing data is relatively stable and the wear of the belt buckle is relatively uniform.
[0272] This embodiment acquires video streams and extracts frame images using an industrial camera. Regional semantic analysis accurately identifies the belt buckle area, and visual correction using square grids makes the image more regular. Reasonable segmentation of the belt buckle area image facilitates detailed analysis. The Canny method and HoughLines algorithm are used for edge and line detection, respectively. Line non-maximum suppression reduces redundancy, and line spacing is accurately measured. By calculating the statistical value of the vertical distance data sequence and comparing it with preset values, combined with linear fitting, the remaining lifespan is calculated. This achieves a scientific, systematic, and accurate analysis of belt buckle lifespan, providing a reliable basis for belt buckle maintenance and replacement.
[0273] Example 2
[0274] Please see Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 As shown, as a second embodiment of the present invention, in specific implementation, the technical solution of this embodiment differs from that of embodiment one only in that the belt buckle image extraction method is as follows:
[0275] Step A1: Select two adjacent video frames from the video stream, and label the pixel values of the pixels located at coordinates (x, y) in the two video frames as S. n (x, y) and S n+1 (x, y);
[0276] Where x represents the horizontal coordinate of a pixel in a video frame, represents the vertical coordinate of a pixel in a video frame, and n represents the sequence number of the video frame;
[0277] Step A2: Select a column of pixels, that is, pixels with fixed x values and different y values;
[0278] First, we use: S0(x, y) = |S n (x, y)-S n+1 (x, y)|, calculates the difference in pixel values between two adjacent video frames along the y-axis;
[0279] The differences in the pixel values of this column are then accumulated along the y-axis to obtain the accumulated difference value;
[0280] The formula for calculating the cumulative difference is:
[0281] In the formula, y = 1, 2, ..., h, where h is the height of the video frame;
[0282] Step A3: Following the method in Step A2, calculate the cumulative difference value for each column;
[0283] Then, the peak value of the accumulated difference is extracted from the accumulated difference value of each column;
[0284] The peak value of the accumulated difference value represents the position where the difference value between two adjacent video frames in the corresponding column is the largest. In this embodiment, the peak value of the accumulated difference value is the position where the belt buckle passes the industrial camera.
[0285] Step A4: Extract the pre-set cumulative difference threshold;
[0286] When the peak value of the accumulated difference is greater than the accumulated difference threshold, the peak value generated by each frame of the image is tracked and recorded until it returns to the normal level.
[0287] Then, all peak values within the corresponding shooting time of the video stream are recorded, and the size of all peak values is compared. The frame corresponding to the largest peak value is then taken as the buckle image.
[0288] This embodiment employs a unique belt buckle image extraction method. By calculating the pixel value difference and accumulating the difference value in the y-axis direction of adjacent video frames, the peak value is extracted to determine the location where the belt buckle passes. This allows for the selection of more representative images, effectively improving the accuracy and reliability of image acquisition and making subsequent analysis based on the image more targeted and accurate.
[0289] Example 3
[0290] Please see Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 As shown, as a third embodiment of the present invention, in specific implementation, compared with embodiments one and two, the technical solution of this embodiment is to combine the solutions of embodiments one and two. The difference between the technical solution of this embodiment and embodiments one and two is only in this embodiment: FastSCNN is a lightweight semantic segmentation network, mainly composed of three modules:
[0291] Learn the downsampling module, which is used to quickly reduce the resolution of the input image and reduce the amount of subsequent computation;
[0292] It consists of three convolutional layers: one ordinary convolutional layer and two depthwise separable convolutional layers.
[0293] A global feature extractor is used to extract global features using inverted residual blocks;
[0294] The inverted residual block is first increased in dimensionality through pointwise convolution, then depthwise convolution, and finally reduced in dimensionality through pointwise convolution.
[0295] The feature fusion module is used to fuse the output of the learning downsampling module and the output of the global feature extractor;
[0296] The process involves first performing bilinear interpolation upsampling on the output of the global feature extractor to make its resolution consistent with the output of the learning downsampling module, then concatenating the two, and finally performing feature fusion through a convolutional layer.
[0297] A classifier is used to perform convolution operations on the fused feature map and output a probability map of each pixel belonging to different categories.
[0298] In this embodiment, the FastSCNN lightweight semantic segmentation network quickly reduces image resolution to reduce computation by learning the downsampling module, effectively extracts belt buckle features using a global feature extractor with inverted residual blocks, enhances feature representation by the feature fusion module, and accurately outputs pixel category probability maps by the classifier, thus achieving efficient and accurate semantic segmentation of belt buckle images and providing high-quality feature information for subsequent analysis.
[0299] Example 4
[0300] Please see Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 As shown, as the fourth embodiment of the present invention, in specific implementation, compared with the first, second and third embodiments, the difference between this embodiment and the first, second and third embodiments is only that in this embodiment: the four vertices of the square grid are adjusted by: using a projection transformation algorithm to map the quadrilateral vertices in the image to a new coordinate system, so that the quadrilateral presents a shape closer to a square in the new coordinate system; then by adjusting the parameters of the transformation matrix, the vertices of the quadrilateral satisfy the conditions of consistent side length and 90 degrees at the four corners after the transformation.
[0301] This embodiment utilizes a projection transformation algorithm to map the vertices of the square grid quadrilaterals to a new coordinate system and adjusts the parameters to ensure that the quadrilaterals meet the side length and angle conditions. This further improves the accuracy of visual correction of the belt buckle image, making the image more in line with the standards and requirements of subsequent analysis, and helps to improve the accuracy and reliability of the entire analysis process.
[0302] Example 5
[0303] Please see Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 As shown, as Embodiment 5 of the present invention, in specific implementation, compared with Embodiments 1, 2, 3, and 4, the technical solution of this embodiment is to combine the solutions of Embodiments 1, 2, 3, and 4. The difference between this embodiment and Embodiments 1, 2, 3, and 4 is only that in this embodiment, the lifetime analysis step also includes the following:
[0304] Step H4: When the belt buckle is not damaged, calculate the historical width change rate of the belt buckle based on the linear fitting method.
[0305] The method is as follows:
[0306] The linear fitting equation y = ax + b represents the relationship between the vertical distance and time.
[0307] Where x represents the time sequence number of the video frame and y represents the vertical distance;
[0308] Then, the least squares method is used to solve for a and b in the linear fitting equation; where a is the historical width change rate corresponding to the belt buckle;
[0309] Step H5: Extract the critical vertical distance Dy corresponding to the damage of the belt buckle, then substitute it into the linear fitting equation y=ax+b, and record the obtained x value as the maximum usage time;
[0310] Then, the average value D1 of all vertical distances in the line spacing data sequence measured within the current video stream shooting time is substituted into the linear fitting equation y=ax+b, and the resulting x value is recorded as the current usage time;
[0311] Then subtract the current usage time from the maximum usage time to calculate the remaining lifespan of the belt buckle.
[0312] In the life analysis stage, this embodiment calculates the historical width change rate based on linear fitting when the belt buckle is not damaged. It can clearly grasp the wear trend, substitute the vertical distance critical value and the current average value into the linear fitting equation to calculate the maximum and current usage time, thereby obtaining the remaining life, providing an accurate time reference for belt buckle maintenance and replacement, facilitating reasonable planning of maintenance plans, and reducing the risk of equipment failure due to belt buckle problems.
[0313] Example 6
[0314] Please see Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 As shown, as a sixth embodiment of the present invention, in specific implementation, compared with embodiments one, two, three, four and five, the technical solution of this embodiment is to combine the solutions of embodiments one, two, three, four and five.
[0315] This embodiment integrates the advantages of the previous five embodiments to form a complete, comprehensive, and accurate belt buckle life analysis system. All aspects from image acquisition to life assessment have been optimized and improved, enabling a more comprehensive and in-depth analysis of belt buckle life and wear conditions. This provides stronger and more reliable technical support for practical applications and effectively ensures the stability and reliability of equipment operation.
[0316] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters and thresholds in the formulas are set by those skilled in the art according to the actual situation.
[0317] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A lifespan analysis algorithm for belt buckles based on machine vision technology, characterized in that, Includes the following steps: The video stream of belt buckles in operation is acquired using an industrial camera. Video frames containing belt buckles are extracted and recorded as belt buckle images. Then, the pixels in the belt buckle area are manually labeled to obtain sample images. Subsequently, the FastSCNN model is trained. The belt buckle image is input, and the FastSCNN model outputs a probability map of each pixel belonging to the category of "belt buckle" or "non-belt buckle". The probability map is thresholded to obtain a binarized mask map, which is the belt buckle area image. Square grids are placed in the same shooting scene, and their vertex pixel coordinates are marked. Then, the vertices are adjusted using a projection transformation algorithm to complete the image visual correction. After that, the corrected belt buckle area image is extracted, and the boundary coordinates are marked. Then, the segmentation side length and number are calculated to segment out small squares. The edge detection of the binary mask image is performed using the Canny method. The edge image is determined by Gaussian filtering, Sobel operator calculation, non-maximum suppression, threshold determination, and dilation and erosion operation. Then, the HoughLines algorithm is used to detect lines in the edge image to obtain the line and endpoint coordinates. The line length is then calculated and sorted using the endpoint coordinates of the line. The longest line segment is selected as a candidate, and the slope and intercept are calculated. The two longest non-intersecting lines are retained. Based on the slope and intercept of two non-intersecting straight lines, calculate their perpendicular distance; then extract the perpendicular distances of the straight lines to form a data sequence, and then calculate the mean and standard deviation of the data sequence, and use them to determine whether the belt buckle is damaged. If the belt buckle is not damaged, calculate its remaining lifespan. The method for extracting belt buckle images is as follows: Step A1: Select two adjacent video frames from the video stream, and label the pixel values of the pixels located at coordinates (x, y) in the two video frames as S. n (x, y) and S n+1 (x, y); Where x represents the horizontal coordinate of a pixel in a video frame, represents the vertical coordinate of a pixel in a video frame, and n represents the sequence number of the video frame; Step A2: Select a column of pixels, that is, pixels with fixed x values and different y values; Firstly, through: Calculate the difference in pixel values along the y-axis between two adjacent video frames; The differences in the pixel values of this column are then accumulated along the y-axis to obtain the accumulated difference value; Step A3: Following the method in Step A2, calculate the cumulative difference value for each column; Then, the peak value of the accumulated difference value is extracted from the accumulated difference value of each column. The peak value of the accumulated difference value represents the position where the difference value between two adjacent video frames in the corresponding column is the largest. Step A4: Extract the pre-set cumulative difference threshold; When the peak value of the accumulated difference is greater than the accumulated difference threshold, the peak value generated by each frame of the image is tracked and recorded until it returns to the normal level. Then, all peak values within the corresponding shooting time of the video stream are recorded, and the size of all peak values is compared. The frame corresponding to the largest peak value is then taken as the buckle image. The specific methods for lifetime analysis are as follows: Step H1: Extract the perpendicular distance between two non-intersecting lines in multiple video frames and group them into a time-varying line spacing data sequence, and label it as D0={D1, D2, ..., Dg}, where g is the number of multiple video frames; Step H2: Next, calculate the mean and standard deviation of all vertical distances in the line spacing data sequence, and label them as D1 and D2 respectively. Step H3: Extract the pre-set vertical distance threshold value Dy, which represents the vertical distance threshold at which the buckle is damaged or worn. Then, the average value D1 of all vertical distances in the line spacing data sequence measured within the current video stream's corresponding shooting time is compared with the vertical distance threshold Dy; If D1 > Dy, then the belt buckle is determined to be damaged or worn. If D1≤Dy, then each vertical distance Ds in the line spacing data sequence is compared with the vertical distance threshold Dy. If there is a set of Ds>Dy, then the buckle is determined to be damaged or worn; otherwise, the buckle is determined to be undamaged or unworn. Simultaneously, extract the pre-set fluctuation threshold Dz of the vertical distance; If D2 > Dz, it indicates that there is a risk of abnormal wear on the belt buckle; If D2≤Dz, it indicates that the wear of the belt buckle is relatively uniform; Step H4: When the belt buckle is not damaged, calculate the historical width change rate of the belt buckle based on the linear fitting method. The method is as follows: The relationship between vertical distance and time is represented by the linear fitting equation y=ax+b. Where x represents the time sequence number of the video frame and y represents the vertical distance; Then, the least squares method is used to solve for a and b in the linear fitting equation; where a is the historical width change rate corresponding to the belt buckle; Step H5: Extract the critical vertical distance Dy corresponding to the damage of the belt buckle, then substitute it into the linear fitting equation y=ax+b, and record the obtained x value as the maximum usage time; Then, the average value D1 of all vertical distances in the line spacing data sequence measured within the current video stream shooting time is substituted into the linear fitting equation y=ax+b, and the resulting x value is recorded as the current usage time. Then subtract the current usage time from the maximum usage time to calculate the remaining lifespan of the belt buckle.
2. The lifespan analysis algorithm for belt buckles based on machine vision technology according to claim 1, characterized in that, The specific methods of region semantic analysis are as follows: Step B1: Manually mark the pixels of the belt buckle area on multiple pre-prepared images containing belt buckles, and obtain a belt buckle sample image; Step B2: Then, multiple belt buckle sample images are used as the training dataset, and the model is trained using the pre-built FastSCNN model. Step B3: Next, input the belt buckle image collected in the first step into the trained FastSCNN model. The FastSCNN model outputs a probability map of each pixel belonging to the "belt buckle" or "non-belt buckle" category. Step B4: Then, by thresholding the probability map, a binarized mask map is obtained, which is the belt buckle area image. In the binary mask image, 1 represents the belt buckle area, and 0 represents the non-belt buckle area.
3. The lifespan analysis algorithm for belt buckles based on machine vision technology according to claim 1, characterized in that, The specific methods of vision correction are as follows: Prepare a 1m x 1m square grid and place it in the same scene as when the belt buckle image was taken; In the acquired video frames, the pixel coordinates of the four vertices of the square grid in the image coordinate system are manually marked. Based on the four vertices of the square grid obtained from the annotation, the belt buckle image is visually corrected using the principle of projection transformation. The visual correction method is as follows: adjust the four vertices of the square grid in the video frame until the side length of the rectangle formed by the four vertices is all the same and the four corners of the rectangle are 90 degrees. At this time, the visual correction of the belt buckle image is completed.
4. The lifespan analysis algorithm for belt buckles based on machine vision technology according to claim 1, characterized in that, The specific method for cutting belt buckles is as follows: Step W1: Extract the visually corrected belt buckle area image, and then extract the coordinates of the upper left corner and lower right corner of the belt buckle area in the belt buckle area image, and label them as (x0, y0) and (x1, y1) respectively. Step W2: Then, calculate the length W of the belt buckle area in the x-axis direction and the length H in the y-axis direction using W=x1-x0 and H=y1-y0 respectively. Step W3: Then, based on the lengths W and H, calculate the number of segments in the belt buckle area image; The method is as follows: When H > W, then the length W in the x-axis direction is taken as the side length, and through... Calculate the number of segments N in the belt buckle region image; When W > H, then the length H in the y-axis direction is taken as the side length, and through... Calculate the number of segments N in the belt buckle region image; In the formula, This is a round-down operation; Step W4: When the length W along the x-axis is taken as the side length, starting from the top left corner of the belt buckle area image, cut out N small squares with a side length of W downwards in sequence. The top left corner coordinates of each small square are (x0, y0+i×W), and the bottom right corner coordinates are (x0+W, y0+(i+1)×W). Step W5: Then, the belt buckle area image is segmented according to the small squares after segmentation.
5. The lifespan analysis algorithm for belt buckles based on machine vision technology according to claim 1, characterized in that, The specific methods of edge analysis are as follows: Step U1: Smooth the binarized mask image using a Gaussian filter; Step U2: Use the Sobel operator to calculate the gradient values of the image in the x and y directions, and denote them as Gx and Gy, respectively. Step U3: Perform non-maximum suppression on the gradient magnitude, retaining only the pixels with the local maximum gradient value to refine the edges; Specifically, for each pixel, check the two adjacent pixels in its gradient direction. If the gradient magnitude of the pixel is not a local maximum, then set its gradient magnitude to 0. Step U4: Determine the edge based on the preset low and high thresholds; A pixel whose gradient magnitude is greater than a high threshold is defined as a strong edge pixel; Pixels whose gradient magnitude is between the low threshold and the high threshold are defined as weak edge pixels; Among them, weak edge pixels connected to strong edge pixels are determined to be retained edge pixels; Step U5: Then, use a 5×5 core to perform expansion and erosion operations; Step U6: Then, based on the pixels of all foreground areas, determine the edge image.
6. The lifespan analysis algorithm for belt buckles based on machine vision technology according to claim 1, characterized in that, The line detection method is as follows: The edge image is a binary image, where white dots represent edge pixels and black dots represent non-edge pixels. Step C1: Construct the accumulator matrix: First, establish the equation of the straight line in polar coordinates: ; Where ρ is the distance from the line to the top left corner of the image, and θ is the angle between the line and the x-axis; Then, ρ is discretized into values with a step size of 1, and θ is discretized into values with a step size of 1 degree. Next, the size of the accumulator matrix is determined to be Q×G, where Q is the range of values for ρ and G is the range of values for θ. Step C2, Parameter Voting: For each edge pixel in the edge detection result, according to the polar coordinate equation When θ changes from 0° to 180° in steps of 1 degree, a series of corresponding ρ values are calculated. For each group (ρ, θ), increment the value of the corresponding position (ρ, θ) in the accumulator matrix by 1, and then obtain the number of votes for each [ρ, θ] combination recorded in the accumulator matrix; Step C3, Peak Detection: Find the local maximum value in the accumulator matrix where the number of votes exceeds a preset voting threshold; The local maximum value represents the line with the most edge points under the corresponding (ρ, θ) combination; Step C4, Line Length Filtering: For each detected straight line, the length of the relevant straight line in the edge image is obtained by finding the intersection point of the straight line and the image boundary in the edge image, and then calculating the distance between the two intersection points using the Euclidean distance formula. The length of the relevant line in the edge image is then compared with the preset minimum line length: if the length in the edge image is greater than or equal to the minimum line length, the line is retained; otherwise, it is not retained. Finally, obtain the retained straight line and its corresponding endpoint coordinates, and save them.
7. The lifespan analysis algorithm for belt buckles based on machine vision technology according to claim 1, characterized in that, The specific methods for suppressing nonmaxima on a straight line are as follows: Step Y1: Based on the coordinates of the endpoints of the multiple sets of straight lines, calculate the length of each set of straight lines using the Euclidean distance formula. Then, sort all the straight lines in descending order of their lengths and select the longest line segment as the candidate line. Step 2: Then, based on the coordinates of the two endpoints of the line, calculate the slope and intercept of the line using the two-point formula. Step Y3: Then iterate through the sorted list of lines, and for each candidate line, compare it with other lines. If the slope difference between a candidate line and another line is less than 0.02 or the intercept difference is less than 10 pixels, then the candidate line and another line are considered to belong to the same line. Step 4: Finally, keep the two longest non-intersecting lines.
8. The lifespan analysis algorithm for belt buckles based on machine vision technology according to claim 1, characterized in that, The vertical distance D is calculated as follows: Obtain the slope and intercept of two non-intersecting lines, and label them as E1, E2, B1, and B2 respectively; Then through: ; Calculate the perpendicular distance D between the two non-intersecting lines.
Citation Information
Patent Citations
Anti-counterfeiting identification method based on automobile parts
CN115100210A
Real-time detection and early warning method for abrasion state of parts of high-speed elevator
CN116703924A