Vision-based truck axle number detection false alarm elimination method
By combining Hough transform, K-Means clustering and YOLOv7 object detection algorithm, the problem of high false alarm rate in complex traffic scenarios is solved, and higher detection accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202411661556.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-14
AI Technical Summary
The existing truck axle detection system has a high false alarm rate in complex traffic scenarios, especially in the case of image blur, lighting changes, vehicle surface stains and computer vision models insufficient performance, resulting in insufficient detection accuracy and robustness.
The visual-based false alarm elimination method is used, combined with the Hough transform, K-Means clustering algorithm and YOLOv7 object detection algorithm, false alarms are eliminated through slope measurement and parallel line comparison, improving the accuracy and robustness of the detection.
It significantly reduces the false alarm rate in truck axle detection, improves the accuracy and reliability of the detection, and provides a more cost-effective, easy to maintain and more accurate solution.
Smart Images

Figure CN119625058A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of intelligent traffic monitoring and vehicle detection, and in particular relates to a method for eliminating false alarms in truck axle number detection based on vision. Background Art
[0002] At present, the truck axle number detection system mainly relies on dynamic detection equipment. However, the traditional axle number detection method faces many challenges in practical application and is prone to false alarms, resulting in incorrect axle number judgment, which in turn affects the accuracy and fairness of toll collection. The existing detection system is not only expensive and complex to maintain, but also its detection accuracy will be significantly affected when there is heavy traffic and high vehicle speeds.
[0003] In the existing technology, the detection of the number of axles of trucks mostly relies on physical sensors, such as pressure sensors, laser radar, etc. These technologies are easily affected by external factors such as road conditions, weather conditions, and vehicle status during actual application, resulting in a high false alarm rate, affecting the detection effect and the accuracy of data collection, and further affecting the operating efficiency of the toll collection system and traffic management system.
[0004] In order to solve these problems, some studies have begun to explore truck axle number detection methods based on vision technology. This method uses a camera to obtain vehicle images and analyze vehicle features to identify the number of truck axles. This type of method has obvious advantages in improving equipment flexibility and reducing costs. However, existing vision-based detection systems still have a high false alarm rate in complex traffic scenes, especially in cases of image blur, lighting changes, vehicle surface stains, and insufficient computer vision model performance, resulting in insufficient detection accuracy and robustness.
[0005] Hough transform is a common image processing algorithm, which is widely used in the field of line detection. It can identify the straight line features in the vehicle image and detect the main direction reference line of the carriage to assist in the calculation of the number of wheels of the truck. However, the existing method based on direct tire counting lacks an effective false alarm elimination mechanism when dealing with interference similar to parallel structures, which is prone to detection errors.
[0006] Therefore, there is an urgent need for an improved vision-based truck axle number detection method that can combine Hough transform straight line detection, K-Means clustering algorithm, and YOLOv7 target detection algorithm to eliminate false positives through slope measurement and parallel line comparison, thereby improving the accuracy and robustness of detection. This improved technology will provide a more cost-effective, easy-to-maintain, and more accurate solution for the truck axle number detection system. Summary of the invention
[0007] This paper proposes a vision-based method for eliminating false alarms in truck axle number detection, aiming to solve the problem of false alarms caused by interference from the environment, equipment or other external factors, thereby improving the accuracy and stability of truck axle number detection. By introducing computer vision-based image processing technology, the accuracy of truck axle number detection is effectively improved and the false alarm rate is greatly reduced.
[0008] A method for eliminating false alarms in truck axle number detection based on vision comprises the following steps:
[0009] Step S1: preprocessing the collected image, using Gaussian filtering algorithm to reduce fine noise in the image and improve clarity;
[0010] Step S2: Use the Canny edge detection algorithm to extract the edge contour of the entire image to obtain an edge image E(x, y);
[0011] Step S3: Detect the carriage straight lines in the image through Hough transform, and extract the slopes of all detected straight lines;
[0012] Step S4: Perform K-Means clustering on the detected straight lines to identify the main straight line direction, and rotate the image to align the direction with the image coordinate axis to ensure the truck posture is standardized;
[0013] Step S5: In the corrected image, detect and extract the longest straight line as a reference line for subsequent analysis;
[0014] Step S6: applying the YOLOv7 target detection algorithm to identify the tire positions of the truck and calibrate the center point of each tire;
[0015] Step S7: Determine whether there is a false alarm in the number of truck axles by comparing the slope of the tire center point connection line with the reference line.
[0016] Preferably, in step S1 of the present invention, Gaussian filtering is used Noise removal is performed, where σ is the standard deviation, which determines the smoothness of the filter.
[0017] Preferably, in step S2 of the present invention, the system first performs grayscale processing on the image, and simplifies the image data by converting the color image into a grayscale image. The formula is as follows:
[0018] Gray(x,y)=0.299·R(x,y)+0.587·G(x,y)+0.114·B(x,y)
[0019] Among them, R(x,y), G(x,y), and B(x,y) are the red, green, and blue channel values of the pixel points respectively; after grayscale conversion, Gaussian filtering is used to remove noise; then the Canny edge detection algorithm or Sobel operator is used to extract the edge information in the image.
[0020] Preferably, in step S3 of the present invention, Hough transform is used to detect the straight line in the image. The Hough transform represents the straight line in the image through a polar coordinate system, and the straight line equation is:
[0021] ρ=xcosθ+ysinθ
[0022] Among them, ρ represents the distance from the point to the origin, and θ represents the angle between the line and the horizontal axis. The system traverses all pixel points (x, y) in the image and votes for each point to accumulate the line parameters (ρ, θ). The voting formula is:
[0023] A(ρ,θ)=∑I(x,y)
[0024] Among them, A(ρ,θ) is the cumulative voting value, and I(x,y) is the intensity value of the pixel in the image. By setting the cumulative threshold T, all line parameters (ρ,θ) whose A(ρ,θ) is greater than or equal to T are selected to obtain all the lines detected in the image.
[0025] Preferably, in step S4 of the present invention, the detected straight lines are classified using a K-Means clustering algorithm to identify the main straight line directions; the K-Means clustering algorithm distributes the straight line slopes into k classes by minimizing the objective function J, and the objective function formula is:
[0026]
[0027] Among them, k represents the slope of each straight line, C i is the i-th cluster, μ i is the mean value of the slope of the clustered straight line; by classifying the straight line direction through the clustering algorithm, the main posture direction of the vehicle can be automatically identified; using the image rotation algorithm, the image rotation angle θ is calculated as:
[0028] θ=atan2(y2-y1,x2-x1)
[0029] Where (x1, y1) and (x2, y2) are the coordinates of the two endpoints of the line; the image is rotated to align the main straight line direction with the horizontal or vertical coordinate axis of the image to achieve standardization of the vehicle posture. This can effectively reduce the impact of posture changes on subsequent axis number detection and improve detection accuracy.
[0030] Preferably, in step S5 of the present invention, in the posture-normalized image, the longest straight line is detected and extracted by analyzing the length L of the straight line, and the length calculation formula is:
[0031]
[0032] Among them, (x1, y1) and (x2, y2) are the coordinates of the two endpoints of the straight line, and the longest straight line is used as the reference line for subsequent analysis; this reference line is usually parallel to the contour or axis of the vehicle chassis and is a key reference for axle number detection. Through this reference line, a stable benchmark can be provided for subsequent tire center point calibration and false alarm detection.
[0033] Preferably, in step S6 of the present invention, the YOLOv7 target detection algorithm is used to automatically identify the position of the truck tires and calibrate the center point (x c ,y c ).
[0034] Preferably, in step S7 of the present invention, the system first calculates the slope k of the line connecting the tire center points. tire for:
[0035]
[0036] This slope will be the same as the reference line slope k extracted in step (5). ref For comparison:
[0037] Δθ=|atan(k tire )-atan(k ref )
[0038] When the slope deviation △θ exceeds the set threshold of 5 degrees, the system determines it as a false alarm and triggers the false alarm elimination mechanism; the false alarm elimination mechanism optimizes the detection result by calculating the angle difference between the tire center point connection line and the reference line; when the angle difference is less than 5 degrees, the recognition results at both ends of the connection line are retained; if the angle difference is greater than 5 degrees, the recognition results that are not connected to the connection line with an angle difference of less than 5 degrees are discarded, and the rest are retained. Effectively eliminate the detection results with large errors to ensure the accuracy and reliability of axle number detection.
[0039] The vision-based truck axle number detection false alarm elimination method of the present invention collects truck images through a camera, combines image preprocessing, Canny edge detection, Hough transform line detection and K-Means clustering algorithm to standardize the truck posture; then uses the YOLOv7 target detection algorithm to locate the tire center point, and compares the slope of the tire center line with the reference line to determine the truck axle number. By introducing a false alarm elimination mechanism, the false alarm rate of axle number recognition in vehicle weight detection is significantly reduced, and the reliability and accuracy of detection are improved.
[0040] The technical solution of the present invention has the following unique advantages compared with the prior art:
[0041] (1) High accuracy: The Hough transform, K-Means clustering, and YOLOv7 target detection algorithms are used to perform multi-level analysis of the truck chassis structure, effectively reducing interference from the external environment and ensuring high accuracy of axle number detection.
[0042] (2) Low false alarm rate: By utilizing the parallel line detection and structure verification mechanism in multiple frame images, the slope of the tire center point and the reference line are accurately compared, combined with the restriction that the error is less than 5 degrees, the false alarm rate is significantly reduced.
[0043] (3) Strong real-time performance: The system can quickly process high-resolution images and use efficient image processing algorithms to ensure real-time detection in complex traffic environments. It is suitable for high-traffic scenarios such as highways.
[0044] (4) Low cost: Compared with traditional detection technology, the present invention adopts a visual detection solution, which makes equipment installation and maintenance easier, and the system structure is flexible, reducing the overall investment cost.
[0045] (5) Strong environmental adaptability: The system is designed to have strong environmental adaptability and can maintain high detection accuracy under different weather conditions and complex road conditions, reducing the impact of external factors on the detection effect.
[0046] The present invention uses image processing technology to extract parallel line information from truck compartment images, and combines K-Means clustering, slope calculation and false alarm elimination mechanisms to provide an efficient, accurate and stable truck axle number detection method. This method is not only suitable for truck axle number detection, but can also be further extended to other vehicle identification and intelligent traffic management fields, providing technical support for the upgrade of intelligent transportation systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 is a flow chart of the overall method in an embodiment of the present invention;
[0048] Figure 2 is an image of a truck taken by a camera in an embodiment of the present invention;
[0049] Figure 3 The edge contour map of the entire image extracted by the Canny edge detection algorithm in the embodiment of the present invention;
[0050] Figure 4 is a reference line diagram of the main direction of the carriage of the corrected image in an embodiment of the present invention;
[0051] Figure 5It is a wheel detection and wheel center point connection diagram based on YOLOv7 in an embodiment of the present invention;
[0052] Figure 6 This is an example diagram of false alarm detection in an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The purpose of the present invention is to provide a vision-based method for eliminating false alarms in truck axle number detection, aiming to improve the accuracy of axle number detection and reduce false alarms. To achieve this goal, the present invention combines the YOLOv7 target detection algorithm of deep learning with the strategy of traditional image processing technology (such as Hough transform and K-Means clustering), and significantly improves the detection accuracy and reliability of the system through multi-level data fusion and false alarm elimination mechanism.
[0054] The core of the present invention is to extract the key structural features of trucks through image preprocessing technology, and combine the slope calculation with the analysis of the tire center point connection line, and use the false alarm elimination mechanism to accurately identify the number of truck axles. By comparing the slope of the tire center point connection line with the main direction line of the carriage, the system can effectively eliminate false alarms, ensure the accuracy and robustness of the detection results, and thus cope with the detection challenges in complex environments.
[0055] The terms used in the present invention are shown in Table 1:
[0056] Table 1
[0057]
[0058] The invention is further described below with reference to the accompanying drawings and embodiments:
[0059] The truck axle number detection system of the present invention is mainly composed of a camera module, an image processing unit, a YOLOv7 target detection model, a false alarm elimination module, and a data storage and management unit. The camera module uses a high-resolution camera, which can clearly capture images of trucks passing on the road under various lighting conditions, ensuring the detail integrity and applicability of the image.
[0060] The image processing unit consists of two submodules: the image preprocessing module and the feature extraction module. The image preprocessing module is responsible for the preliminary processing of the acquired images, including grayscale, noise removal, and edge detection, to improve the quality and usability of the images. Through the preprocessed images, the feature extraction module can more effectively extract the key structural features of the truck, such as the parallel lines of the wheels and the carriage.
[0061] In the present invention, the YOLOv7 model is used as the core target detection algorithm to identify the key components of trucks. YOLOv7 performs end-to-end target detection through a single network structure, and can accurately identify the tire position of the truck in real time and calibrate the center point of each tire. The model has significant advantages in processing speed and detection accuracy, and is particularly suitable for real-time vehicle detection applications on highways.
[0062] In order to reduce the false alarm rate, the present invention also designs a false alarm elimination module. This module applies a post-processing algorithm to perform false alarm elimination by combining the output results of the image processing unit and the YOLOv7 model. First, the Hough transform is used to detect the straight lines in the image, and the main direction of the vehicle chassis is identified through K-Means clustering to correct the truck posture in the image. Then, by comparing the slope of the tire center point connection line with the main direction reference line of the car body, it is determined whether there is a false alarm. If the slope error exceeds the set threshold, it is regarded as a false alarm and eliminated. Finally, only the detection results that are parallel to the reference line or the error is within the allowable range are retained, thereby improving the accuracy of axle number detection.
[0063] Finally, the data storage and management unit is responsible for storing and managing the detection data and building a database system. By further analyzing and counting the data, the system can continuously optimize its performance and ensure the accuracy and reliability of the detection results. The present invention effectively solves the problem of false alarms in truck axle number detection by combining visual detection with YOLOv7 target detection technology, and is applicable to a variety of complex traffic scenarios.
[0064] The present invention provides a method for eliminating false positives in truck axle number detection based on vision, and the overall process is as follows: Figure 1 shown.
[0065] (1) In the present invention, image preprocessing is to improve the slope detection accuracy in the subsequent steps and reduce noise and irrelevant information in the image. The image processing unit of the present invention adopts a classic image processing method to improve the accuracy of the detection result, including noise removal, grayscale, edge detection and other steps.
[0066] (a) Noise Removal
[0067] High-frequency noise in the image is removed by Gaussian filtering. The Gaussian filter is a linear smoothing filter whose weight is determined by the Gaussian distribution function:
[0068]
[0069] Among them, σ is the standard deviation, which determines the smoothness of the filter.
[0070] (b) Grayscale processing
[0071] The purpose of converting a color image into a grayscale image is to reduce the amount of calculation and remove the interference of color information on edge detection. The grayscale formula is as follows:
[0072] Gray(x,y)=0.299·R(x,y)+0.587·G(x,y)+0.114·B(x,y)
[0073] Among them, R(x,y), G(x,y), and B(x,y) are the red, green, and blue channel values of the pixel respectively; after grayscale conversion, Gaussian filtering is used to remove noise; then the Canny edge detection algorithm or Sobel operator is used to extract the edge information in the image.
[0074] (c) Edge detection
[0075] The Canny edge detection algorithm is used to extract the edge information of the entire image. The algorithm calculates the most significant part of the local change through the image gradient, thereby extracting the edge contour of the car.
[0076] like Figure 3 As shown, after image preprocessing, the system obtains a clear image of the edge of the truck compartment, preparing for the subsequent Hough transform.
[0077] (2) Hough transform is a commonly used method for detecting straight lines. Its basic principle is to transform points in an image into straight lines in parameter space. The parametric equation of a straight line is:
[0078] ρ=xcosθ+ysinθ
[0079] Among them, ρ represents the distance from the point to the origin, and θ is the angle between the line and the horizontal axis. In Hough space, the line is determined by cumulative voting, and the position with the highest number of votes corresponds to the line in the image.
[0080] By calculating the cumulative voting results in the Hough space, the system can obtain multiple straight lines and calculate the slope k of each straight line. The slope formula is as follows:
[0081]
[0082] The slopes of the multiple straight lines will be used in the subsequent parallel line detection.
[0083] (3) After detecting multiple straight lines, the system uses the K-Means clustering algorithm to cluster the directions of these straight lines to identify the main direction lines of the truck. The basic idea of K-Means clustering is to divide these angles into k clusters (usually k = 2, because we assume that there are mainly two directions of straight lines). First, the algorithm randomly selects k initial cluster centers, each center represents the direction of a cluster. Next, the algorithm calculates the distance between the angle of each straight line and the cluster center, and assigns the straight line to the cluster to which the nearest center belongs. The distance is usually calculated using the Euclidean distance, that is, x i -C j ‖ 2 , where x i is the angle of a line, C j is the current cluster center.
[0084] After the assignment is completed, the system will update the cluster center of each cluster by calculating the average of the angles of all the lines belonging to the cluster. This average value will be used as the new cluster center, replacing the previous initial value. The updated cluster center better reflects the overall direction of the lines in the cluster. The K-Means algorithm gradually stabilizes the center of each cluster by repeatedly iterating this assignment and update process, that is, reaching convergence.
[0085] When clustering is completed, the system obtains two main directions, which represent the average angles of the line groups. In order to keep the image rotation as horizontal or vertical as possible, the angle with the smaller absolute value is usually selected as the image rotation reference angle. If the direction with the larger angle is closer to the vertical direction, it needs to be adjusted additionally. For example, if the larger angle is θ2, it can be adjusted to a horizontal reference direction by subtracting 90 degrees.
[0086] Once the rotation angle is determined, the system uses the rotation matrix Rotate the image, such as Figure 4 In this way, all the main direction lines of the carriages will be aligned in the horizontal or vertical direction, making the subsequent wheel detection more accurate and efficient.
[0087] (4) Figure 5 As shown in the figure, the system uses the wheel detection algorithm based on YOLOv7 to accurately detect the wheel position. The center point coordinates of each wheel are extracted through the regression model to obtain the center point (x c ,y c ). The arrangement of the truck wheels is determined by comparing the slope of the line connecting the wheel centers with the reference line.
[0088] (5) By connecting the detected wheel center points, a center point line is formed, and the slope is compared with the previously identified main direction line of the carriage. The system determines whether there is a false alarm based on the slope difference. When the slope difference between the center point line and the main direction line exceeds the set threshold of 5 degrees, it is considered that there may be a false alarm, and the subsequent false alarm elimination mechanism is activated.
[0089] (6) In the actual detection process, the system may generate false alarms due to image noise or changes in vehicle shape. To this end, the present invention designs a false alarm elimination module, which combines the comparison of multiple frames of images to determine whether there is a false alarm and corrects the detection result by recalculating the slope difference. Figure 6 shown.
[0090] (7) After completing the truck axle number detection and false alarm elimination, the system stores the detection results in the database of the data storage and management unit 5 as a basis for subsequent traffic management and law enforcement. The stored content includes key information such as the truck image sequence, the number of detected axles, and the detection time.
[0091] In this way, the system can provide accurate data support to traffic management departments and effectively identify and manage overloaded vehicles.
[0092] The present invention provides a vision-based method for eliminating false alarms in truck axle number detection. By combining image processing technology and deep learning models, the accuracy of truck axle number detection is effectively improved and false alarms are reduced. Through multi-level data fusion and optimization strategies, the present invention not only improves the performance of the detection system, but also provides a reliable solution for the intelligent traffic management system. Although the present invention has been described in detail with specific embodiments, those skilled in the art can make appropriate modifications and adjustments based on the technical solution of the present invention, and these modifications and adjustments are still within the scope of protection of the present invention.
Claims
1. A method for eliminating false alarms in truck axle number detection based on vision, characterized in that: The following steps are involved: Step S1: preprocessing the collected image, using Gaussian filtering algorithm to reduce fine noise in the image and improve clarity; Step S2: Use the Canny edge detection algorithm to extract the edge contour of the entire image to obtain an edge image E(x, y); Step S3: Detect the carriage straight lines in the image through Hough transform, and extract the slopes of all detected straight lines; Step S4: Perform K-Means clustering on the detected straight lines to identify the main straight line direction, and rotate the image to align the direction with the image coordinate axis to ensure the truck posture is standardized; Step S5: In the corrected image, detect and extract the longest straight line as a reference line for subsequent analysis; Step S6: applying the YOLOv7 target detection algorithm to identify the tire positions of the truck and calibrate the center point of each tire; Step S7: Determine whether there is a false alarm in the number of truck axles by comparing the slope of the tire center point connection line with the reference line.
2. The method for eliminating false positives in truck axle number detection based on vision according to claim 1 is characterized in that: In step S1, Gaussian filtering is used Noise removal is performed, where σ is the standard deviation, which determines the smoothness of the filter.
3. The method for eliminating false positives in truck axle number detection based on vision according to claim 2 is characterized in that: In step S2, the system first grayscales the image. By converting the color image into a grayscale image, the image data is simplified. The formula is as follows: Gray(x,y)=0.299·R(x,y)+0.587·G(x,y)+0.114·B(x,y) Among them, R(x,y), G(x,y), and B(x,y) are the red, green, and blue channel values of the pixel points respectively; after grayscale conversion, Gaussian filtering is used to remove noise; then the Canny edge detection algorithm or Sobel operator is used to extract the edge information in the image.
4. The method for eliminating false positives in truck axle number detection based on vision according to claim 3 is characterized in that: In step S3, the straight line in the image is detected using Hough transform. The Hough transform represents the straight line in the image using a polar coordinate system. The straight line equation is: ρ=xcosθ+ysinθ Among them, ρ represents the distance from the point to the origin, and θ represents the angle between the line and the horizontal axis. The system traverses all pixel points (x, y) in the image and votes for each point to accumulate the line parameters (ρ, θ). The voting formula is: A(ρ,θ)=∑I(x,y) Among them, A(ρ,θ) is the cumulative voting value, I(x,y) is the intensity value of the pixel in the image; by setting the cumulative threshold T, all line parameters (ρ,θ) whose A(ρ,θ) is greater than or equal to T are selected to obtain all the lines detected in the image.
5. The method for eliminating false positives in truck axle number detection based on vision according to claim 4 is characterized in that: In step S4, the detected straight lines are classified using the K-Means clustering algorithm to identify the main straight line directions; the K-Means clustering algorithm distributes the straight line slopes into k classes by minimizing the objective function J. The objective function formula is: Among them, k represents the slope of each straight line, C i is the i-th cluster, μ i is the mean value of the slope of the clustered straight line; by classifying the straight line direction through the clustering algorithm, the main posture direction of the vehicle can be automatically identified; using the image rotation algorithm, the image rotation angle θ is calculated as: θ=atan2(y2-y1,x2-x1) Where (x1, y1) and (x2, y2) are the coordinates of the two endpoints of the straight line; the image is rotated to a state where the main straight line direction is aligned with the horizontal or vertical coordinate axis of the image to achieve standardized processing of the vehicle posture.
6. The method for eliminating false positives in truck axle number detection based on vision according to claim 5, characterized in that: In step S5, in the posture-normalized image, the longest straight line is detected and extracted by analyzing the length L of the straight line. The length calculation formula is: Among them, (x1, y1) and (x2, y2) are the coordinates of the two endpoints of the straight line respectively. The longest straight line is used as the reference line for subsequent analysis. This reference line is usually parallel to the contour or axis of the vehicle chassis and is the key reference for axle number detection.
7. The method for eliminating false positives in truck axle number detection based on vision according to claim 6, characterized in that: In step S6, the YOLOv7 target detection algorithm is used to automatically identify the location of the truck tires and calibrate the center point (x c ,y c ).
8. The method for eliminating false positives in truck axle number detection based on vision according to claim 7, characterized in that: In step S7, the system first calculates the slope k of the line connecting the tire center points tire for: This slope will be the same as the reference line slope k extracted in step (5). ref For comparison: Δθ=|attan(k tire )-watch(k ref ) When the slope deviation △θ exceeds the set threshold of 5 degrees, the system determines it as a false alarm and triggers the false alarm elimination mechanism; the false alarm elimination mechanism optimizes the detection result by calculating the angle difference between the tire center point connection line and the reference line; when the angle difference is less than 5 degrees, the recognition results at both ends of the connection line are retained; if the angle difference is greater than 5 degrees, the recognition results that are not connected to the connection line with an angle difference less than 5 degrees are discarded, and the rest are retained.