Lightweight traffic violation behavior detection method, device and equipment based on automobile data recorder and medium

By implementing a lightweight traffic violation detection method on a dashcam, and utilizing the improved YOLOv7-tiny model and DeepSORT algorithm, the problem of poor adaptability of traditional detection systems in dynamic environments is solved. This achieves efficient and real-time violation recognition, reduces costs, and improves detection accuracy and applicability.

CN120833593AActive Publication Date: 2025-10-24DONGGUAN YIHAO ELECTRONICS TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511320822.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-16
Publication Date
2025-10-24
Estimated Expiration
2045-09-16

AI Technical Summary

Technical Problem

Traditional traffic violation detection systems rely on fixed cameras and geomagnetic sensors, which are difficult to cope with dynamic changes in large-scale road environments. Furthermore, traditional image recognition algorithms are not suitable for real-time operation in embedded environments, resulting in high costs, limited coverage, and low detection efficiency.

Method used

A lightweight traffic violation detection method based on dashcams is adopted. It utilizes an improved YOLOv7-tiny target detection model and DeepSORT algorithm, combined with anchor-based and anchor-free detection strategies, to achieve dual target detection of vehicles and lane lines. Furthermore, the model's generalization ability is improved through a knowledge alignment mechanism, enabling real-time detection on resource-constrained devices.

Benefits of technology

This technology enables efficient and real-time detection of traffic violations on low-power, low-memory dashcams, improving detection accuracy and inference speed, reducing system deployment costs, and making it suitable for various traffic scenarios, thereby enhancing traffic management efficiency and safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120833593A_ABST
    Figure CN120833593A_ABST
Patent Text Reader

Abstract

The invention relates to a lightweight traffic violation behavior detection method and device based on an automobile data recorder, equipment and a medium. The method comprises the following steps: acquiring a traffic scene image frame containing a target vehicle and a target lane line in the automobile data recorder; determining bounding box information of a target vehicle in the traffic scene image frame and a spatial geometric curve coordinate point set of a target lane line according to the traffic violation recognition model trained to a convergence state; calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the bounding box information, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame; and calling a preset traffic violation behavior judgment strategy to carry out traffic violation judgment on the target vehicle so as to determine that the target vehicle is a violation vehicle. According to the method, the target detection precision can be greatly improved in resource-limited equipment, and the reasoning speed is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of intelligent transportation, and in particular to a lightweight traffic violation detection method based on a vehicle event data recorder, a corresponding device, an electronic device and a computer readable storage medium. BACKGROUND

[0002] Under the background of accelerating urbanization, the vehicle density on urban roads has increased significantly, and traffic management is facing great challenges. Frequent traffic violations such as line pressing, forced merging, and reverse driving seriously affect road traffic efficiency and even cause traffic accidents, threatening personal and property safety.

[0003] Traditional violation detection relies on fixed cameras and geomagnetic sensors, which are costly, complex to deploy, and have limited coverage, making it difficult to cope with dynamic changes in large-scale road environments. On the other hand, traditional image recognition algorithms rely on high-performance computing platforms and are not suitable for real-time operation in embedded environments. Current mainstream deep learning models such as Faster R-CNN, YOLOv5, and Transformer-based architectures, while having high accuracy, are not suitable for embedded deployment due to their inference speed and model size.

[0004] With the popularity of vehicle event data recorders, they have become mobile and widely covered data collection terminals. However, due to limitations in hardware resources such as processor performance, power supply, and storage, it is a pressing problem to deploy an efficient and accurate traffic violation detection system on a vehicle event data recorder.

[0005] In summary, to address the problems of traditional violation detection relying on fixed cameras and geomagnetic sensors in existing technologies, which are difficult to cope with dynamic changes in large-scale road environments, and traditional image recognition algorithms relying on high-performance computing platforms, which are not suitable for real-time operation in embedded environments, the present application makes corresponding explorations. SUMMARY

[0006] The present application aims to solve the above problems and provides a lightweight traffic violation detection method based on a vehicle event data recorder, a corresponding device, an electronic device and a computer readable storage medium.

[0007] To achieve the various purposes of the present application, the following technical solutions are adopted: A lightweight traffic violation detection method based on a vehicle event data recorder is proposed to adapt to one of the purposes of the present application, comprising: Obtaining a traffic scene image frame containing a target vehicle and a target lane line in a vehicle event data recorder; The structured re-parameterized convolution module including a main branch convolution module, a first auxiliary branch and a second auxiliary branch is introduced in a preset first traffic violation identification model backbone network, and a BatchNorm layer is introduced after the main branch convolution module, the first auxiliary branch and the second auxiliary branch, a lightweight feature pyramid structure is introduced in a neck network, and a vehicle detection head network adopting an Anchor-based strategy and a lane line detection head network adopting an Anchor-free continuous point segment detection strategy are used to constitute a detection head network, so as to construct a second traffic violation identification model; The traffic scene image frame is input into the second traffic violation identification model trained to a convergent state, so as to determine the center position coordinates, width and height of the bounding box of the target vehicle in the traffic scene image frame, and the spatial geometric curve coordinate point set of the target lane line and the corresponding lane line category thereof; A preset target vehicle tracking algorithm is called, the state vector of the target vehicle in each traffic scene image frame is constructed according to the center position coordinates, width and height of the bounding box, and the target vehicle is tracked according to the state vector and the appearance feature vector of the target vehicle in each traffic scene image frame; A preset traffic violation behavior judgment strategy is called to judge the traffic violation of the target vehicle, so as to determine whether the target vehicle is a solid line violation vehicle, a queue violation vehicle or a reverse violation vehicle, so as to complete the lightweight traffic violation behavior detection based on a driving recorder.

[0008] Optionally, the base network architecture of the first traffic violation identification model is an original YOLOv7-tiny target detection model, and the base network architecture of the second traffic violation identification model is an improved YOLOv7-tiny target detection model, wherein the main branch convolution module is a 3x3 convolution, the first auxiliary branch is a 1x1 convolution, the second auxiliary branch adopts Identity mapping, and the lightweight feature pyramid structure includes an FPN lightweight feature pyramid structure or a Lite-BiFPN lightweight feature pyramid structure. The target vehicle tracking algorithm is an improved DeepSORT algorithm, the traffic violation behavior judgment strategy includes a solid line violation behavior judgment strategy, a queue violation behavior judgment strategy and a reverse violation behavior judgment strategy, the lane line category includes a solid line or a dashed line, and the target vehicle includes a truck, a car or a bus.

[0009] Optionally, the step of training the second traffic violation identification model includes: acquire a sample training set, wherein the sample training set comprises a plurality of training samples and corresponding sample labels, the training samples are traffic scene image frames containing a target vehicle and a target lane line, and the sample labels represent a target vehicle category and a lane line category; The second traffic violation recognition model is used as a student network, a preset visual base model is used as a teacher network, and the plurality of training samples in the sample training set are input into the preset second traffic violation recognition model. The main branch convolution module, the first auxiliary branch, and the second auxiliary branch in the structured re-parameterized convolution module are calculated in parallel, and each branch outputs a fusion after being processed by each BatchNorm layer. A knowledge alignment mechanism is introduced, and an intermediate feature representation provided by the visual base model is used to guide feature learning of the second traffic violation recognition model to determine a total training loss of the second traffic violation recognition model, wherein the total training loss comprises a vehicle detection loss output by a vehicle detection head, a lane line detection loss output by a lane line detection head, and an intermediate layer feature distillation loss between the second traffic violation recognition model and the visual base model. The network parameters of the second traffic violation recognition model are updated based on the total training loss using a back propagation algorithm until the second traffic violation recognition model is trained to a converged state to determine a second traffic violation recognition model that has been trained to a converged state.

[0010] Optionally, a preset target vehicle tracking algorithm is called, a state vector of the target vehicle in each traffic scene image frame is constructed according to the center position coordinates, width, and height of the bounding box, and the target vehicle is tracked according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, comprising: A preset target vehicle tracking algorithm is called to obtain a first state vector of the target vehicle corresponding to a previous traffic scene image frame, wherein the first state vector comprises center position coordinates, an area, and an aspect ratio of a bounding box of the target vehicle in the previous traffic scene image frame. A Kalman filter is used to recursively predict a future state of the target vehicle according to the first state vector to determine a second state vector of the target vehicle corresponding to a current image frame, and a Mahalanobis distance between the first state vector and the second state vector is calculated and determined. An appearance feature vector of the target vehicle is extracted from each traffic scene image, a cosine distance between the appearance feature vector of the target vehicle in the previous traffic scene image frame and the appearance feature vector of the target vehicle in the current traffic scene image frame is calculated and determined, and a matching cost of the target vehicle and other vehicles is calculated and determined according to the Mahalanobis distance and the cosine distance. determine a target matching result of the target vehicle in the current traffic scene image frame according to matching costs of the target vehicle and other vehicles by using a preset Hungarian algorithm; repeating the above steps to perform target tracking on the target vehicle.

[0011] Optionally, the step of determining the target vehicle as a solid line violation vehicle, a cutting-in violation vehicle or a reverse driving violation vehicle by calling a preset traffic violation judgment strategy includes: calling a preset solid line violation judgment strategy to obtain vehicle trajectory data of the target vehicle in a preset time range and lane line data, wherein the vehicle trajectory data represents center position coordinates of the target vehicle at each time, and the lane line data represents a set of spatial geometric curve coordinate points of the target lane line and a corresponding lane line category of the target lane line; calculating a minimum distance between the vehicle trajectory of the target vehicle and the target lane line according to the vehicle trajectory data and the lane line data, and determining the target vehicle as a potential solid line vehicle if the minimum distance is less than a preset distance threshold; when the target vehicle is determined as a potential solid line vehicle, selecting any two consecutive time points, and determining the target vehicle as a cross-line driving vehicle if the center position coordinates of the target vehicle at the two time points are on different sides relative to the target lane line; when the target vehicle is determined as a cross-line driving vehicle, determining the target vehicle as a solid line violation vehicle if the cross-line driving behavior of the target vehicle continuously occurs in multiple traffic scene images and the lane line category of the target lane line is a solid line.

[0012] Optionally, the step of determining the target vehicle as a solid line violation vehicle, a cutting-in violation vehicle or a reverse driving violation vehicle by calling a preset traffic violation judgment strategy includes: calling a preset cutting-in violation judgment strategy to obtain center position coordinates of the target vehicle, a first vehicle and a second vehicle at each time, wherein the first vehicle represents a front vehicle of the target vehicle, and the second vehicle represents a rear vehicle of the target vehicle; calculating a first relative distance between the target vehicle and the first vehicle at each time according to the center position coordinates of the target vehicle and the first vehicle at each time, and calculating a second relative distance between the target vehicle and the second vehicle at each time according to the center position coordinates of the target vehicle and the second vehicle at each time; The first difference between the first relative distance and the second relative distance of the target vehicle at the cut-in moment is calculated, and if the first difference is less than a preset safety distance, the target vehicle is determined as a cut-in illegal vehicle.

[0013] Optionally, the step of calling a preset traffic violation judgment strategy to determine the target vehicle as a solid line illegal vehicle, a cut-in illegal vehicle, or a reverse driving illegal vehicle comprises: The central position coordinates of the target vehicle at each moment are obtained by calling a preset reverse driving illegal behavior judgment strategy. The unit motion direction vector of the target vehicle is calculated and determined according to the central position coordinates of the target vehicle at each moment. The motion directions of the historical driving vehicles in the lane where the target vehicle is located are clustered to determine the main passing direction unit vector of the lane where the target vehicle is located. The dot product between the unit motion direction vector and the main passing direction unit vector is calculated, and if the dot product between the unit motion direction vector and the main passing direction unit vector in a preset number of continuous traffic scene images is less than a preset threshold, the target vehicle is determined as a reverse driving illegal vehicle.

[0014] Another object of the present application is to provide a lightweight traffic violation detection device based on a driving recorder, which comprises: An image frame acquisition module is configured to acquire traffic scene images containing a target vehicle and target lane lines in a driving recorder. An identification model construction module is configured to introduce a structured re-parameterized convolution module including a main branch convolution module, a first auxiliary branch, and a second auxiliary branch into the backbone network of a preset first traffic violation identification model, and introduce a BatchNorm layer after the main branch convolution module, the first auxiliary branch, and the second auxiliary branch, introduce a lightweight feature pyramid structure into the neck network, adopt an Anchor-based vehicle detection head network, and adopt an Anchor-free continuous point segment detection strategy lane line detection head network to form a detection head network, so as to construct a second traffic violation identification model. A target identification module is configured to input the traffic scene images into the second traffic violation identification model trained to a convergent state to determine the central position coordinates, width, and height of the bounding box of the target vehicle in the traffic scene images, and the spatial geometric curve coordinate point set of the target lane line and its corresponding lane line category. a target tracking module configured to invoke a preset target vehicle tracking algorithm to construct a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and to perform target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame; a traffic violation vehicle determination module configured to invoke a preset traffic violation determination strategy to determine the target vehicle as a solid line violation vehicle, a queue violation vehicle or a reverse violation vehicle to complete the dashcam-based lightweight traffic violation detection.

[0015] An electronic device is also provided to adapt to another object of the present application, comprising a central processing unit and a memory, wherein the central processing unit is configured to invoke a computer program stored in the memory to execute the steps of the dashcam-based lightweight traffic violation detection method.

[0016] A computer readable storage medium is also provided to adapt to another object of the present application, which stores a computer program implemented according to the dashcam-based lightweight traffic violation detection method in the form of computer readable instructions, and the computer program is invoked to run by a computer to execute the steps included in the corresponding method.

[0017] Compared with the prior art, the present application addresses the problems in the prior art that the conventional violation detection relies on fixed cameras and geomagnetic sensors, which are difficult to cope with dynamic changes in large-scale road environments, and the conventional image recognition algorithm relies on high-performance computing platforms, which is not suitable for real-time operation in embedded environments. The present application includes but is not limited to the following beneficial effects: Firstly, the dashcam is a common vehicle-mounted device, and its popularity and low-cost advantage make this detection method widely applicable in daily traffic management. Traditional traffic monitoring systems require high equipment installation and maintenance costs, while the present application uses existing dashcams without additional hardware investment, effectively reducing system deployment costs. Traditional traffic violation detection algorithms usually rely on high-performance computing platforms such as servers or specialized computer hardware to run efficiently. The present application designs a lightweight improved YOLOv7-tiny target detection model that can adapt to resource-constrained devices such as dashcams, which enables efficient operation even on low-power and low-memory dashcams, greatly improving the popularity and convenience of practical applications.

[0018] Secondly, the improved YOLOv7-tiny target detection model can greatly improve the target detection accuracy in resource-limited devices such as driving recorders, and also significantly improves the inference speed, which enables efficient identification and positioning of illegal vehicles even in complex traffic environments. With the help of lightweight neural network design, the inference process is accelerated, and real-time traffic violation detection can be realized in practical applications. For example, the system can identify illegal behaviors such as line pressing, queuing, and reverse driving in real time without waiting for long calculation and processing, which is of great significance for timely response and accident prevention of traffic management.

[0019] Thirdly, the improved DeepSORT algorithm can solve the problems of occlusion and target loss, making the tracking of target vehicles more stable and accurate in complex traffic environments, improving the continuity and reliability of vehicle tracking. Fourthly, the application can determine traffic violations such as line pressing, queuing, and reverse driving by combining detected lane lines, target vehicle positions, and motion trajectories, which not only improves the detection accuracy of illegal behaviors but also increases the stability of the system in complex traffic scenarios.

[0021] Fifthly, by integrating vehicle detection, lane line detection, and traffic violation recognition strategies, the application can handle multiple traffic violation detection tasks and is suitable for various traffic scenarios. This multi-target and full-scenario adaptability enables the method to be widely applied to various urban roads, expressways, and highways. Thanks to lightweight design and modular structure, the system can be optimized and expanded as needed.

[0022] Sixthly, by introducing a structured reparameterization convolution module into the original YOLOv7-tiny network, the model size can be effectively compressed, the inference speed can be improved, and the detection accuracy can be guaranteed. This enables the system to maximize its performance with limited hardware resources. With lightweight FPN or Lite-BiFPN structure, the system can effectively extract multi-scale features and improve detection capability in complex traffic scenarios. This enables accurate identification of vehicles in different sizes and perspectives and effective handling of various complex traffic situations.

[0023] Seventh, the application can realize efficient traffic violation detection on a driving recorder, which has important practical application value for urban traffic management, traffic accident prevention, intelligent city construction and other fields. By detecting and judging traffic violations in real time, the application not only improves the efficiency of traffic management, but also effectively reduces the incidence of traffic accidents, ensures public safety, timely identification and response to violations help reduce accidents, especially for high-risk behaviors such as line compression, queue and reverse, which can intervene in time to avoid potential dangers. BRIEF DESCRIPTION OF DRAWINGS

[0024] The above and / or additional aspects and advantages of the present application will become apparent and more readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, in which: Figure 1 A flowchart of a lightweight traffic violation detection method based on a driving recorder in an embodiment of the present application; Figure 2 A flowchart of training a second traffic violation identification model in an embodiment of the present application; Figure 3 A flowchart of target tracking of the target vehicle in an embodiment of the present application; Figure 4 A flowchart of determining that the target vehicle is a line compression violation vehicle in an embodiment of the present application; Figure 5 A flowchart of determining that the target vehicle is a queue violation vehicle in an embodiment of the present application; Figure 6 A flowchart of determining that the target vehicle is a reverse violation vehicle in an embodiment of the present application; Figure 7 A principle block diagram of a lightweight traffic violation detection device based on a driving recorder in an embodiment of the present application; Figure 8 A structural diagram of a computer device in an embodiment of the present application. DETAILED DESCRIPTION

[0025] The embodiments of the present application are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference signs represent the same or similar elements or elements with the same or similar functions throughout. The embodiments described below by reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as a limitation of the present application.

[0026] Unless otherwise indicated herein, the various disclosed embodiments can be combined in any and all permutations. It is intended that the following claims be construed to include all such embodiments.

[0027] Please refer to Figure 1 The light traffic violation detection method based on the vehicle event data recorder in an embodiment of the present application comprises the following steps: Step S10, acquiring a traffic scene image frame containing a target vehicle and a target lane line in the vehicle event data recorder; The light traffic violation detection system in the vehicle event data recorder can acquire a traffic scene image frame containing a target vehicle and a target lane line. The light traffic violation detection system comprises a video data acquisition and synchronization module, an image preprocessing module, a light target detection module, a multi-target tracking and trajectory management module, a traffic violation judgment module, and a result recording module, etc. Specifically, the light traffic violation detection system can extract a traffic scene image frame containing a target vehicle and a target lane line from a video stream captured by the vehicle event data recorder. The target vehicle refers to a motor vehicle that needs to be monitored in the current scene, and the target vehicle includes a truck, a car, a bus, etc. The target lane line refers to a marking line on the road for dividing lanes, and the target lane line includes a solid line or a dashed line. The target vehicle and the target lane line are the core basis for subsequent violation behavior recognition. The motion trajectory of the target vehicle and the positional relationship with the target lane line can determine whether the target vehicle has a violation behavior such as lane encroachment, cutting in, and reverse driving.

[0028] In some embodiments, in the video data acquisition and synchronization module, to ensure the robustness and timeliness of the system end-to-end, the video acquisition parameters of the video acquisition module are first defined, which include: First, the resolution of the traffic scene video stream is set, which can be set to 1280x720, taking into account the definition and processing load; Second, the frame rate of the traffic scene video stream is selected, which can be set to 25 frames per second to ensure at least 25 frames per second of spatiotemporal continuity; Third, the traffic scene image frame is time-stamped and synchronized, and the system real-time clock (Real Time Clock) is used to record the time label corresponding to each frame So that the image sequence meets the strict time monotonicity, this timestamp synchronization mechanism provides a reliable time reference for subsequent target tracking and traffic violation judgment, and is the basis for the system to analyze the dynamic traffic scene in time sequence, which is expressed as: (1) wherein, , is the timestamp of the traffic scene image frame sequence.

[0029] In addition, in order to improve the image quality under night or backlight conditions, the acquisition end supports HDR synthesis, and uses the CLAHE algorithm for local contrast enhancement, avoiding the influence of image blur or distortion on detection accuracy. The traffic scene image frame sequence output by this module is sent to the downstream module, which is formalized as: (2) wherein, denotes the timestamp t corresponding to the RGB image tensor, t is the timestamp, denotes the complete traffic scene image frame set, denotes the RGB color space, denotes the height of the image; denotes the width of the image.

[0030] In further embodiments, in order to reduce the computational pressure of target detection on the edge device, the image preprocessing module undertakes the image regularization task, including image normalization, resolution scaling, etc.

[0031] In order to make the neural network easier to train and converge, the traffic scene image frames transmitted in the above steps are normalized by image normalization, the mean and variance of the three channels of the image are calculated respectively, and then the image is normalized, and the calculation formula is expressed as: (3) wherein, denotes the normalized image pixel value, denotes the original image pixel value, denotes the mean of the three channels of the image; denotes the variance of the three channels of the image.

[0032] To ensure that the subsequent target detection model can achieve a balance between detection accuracy and inference speed, it is necessary to scale the resolution of the normalized image. However, the traditional direct scaling algorithm is easy to deform the target to be detected in the image, thereby destroying the semantic information of the image. Therefore, the present application uses a non-deformation scaling algorithm (LetterBox Resize) to scale the image to a resolution of 416*416. The implementation of the non-deformation scaling algorithm is very simple. First, the longest side of the image is scaled to 416, and then the shortest side is padded to make it scale to 416 in length, thereby not changing the structural information of the image.

[0033] Step S20, introducing a structured re-parameterized convolution module including a main branch convolution module, a first auxiliary branch and a second auxiliary branch into the backbone network of the preset first traffic violation identification model, and introducing a BatchNorm layer after the main branch convolution module, the first auxiliary branch and the second auxiliary branch, introducing a lightweight feature pyramid structure in the neck network, adopting an Anchor-based strategy vehicle detection head network and an Anchor-free continuous point segment detection strategy lane line detection head network to constitute a detection head network, so as to construct a second traffic violation identification model; Step S30, inputting the traffic scene image frame into the second traffic violation identification model trained to a convergent state to determine the center position coordinates, width and height of the target vehicle in the traffic scene image frame, and the spatial geometric curve coordinate point set of the target lane line and the corresponding lane line category thereof; After obtaining the traffic scene image frame containing the target vehicle and the target lane line in the driving recorder, The present application designs a lightweight target detection model with good inference efficiency and detection accuracy for the dual target detection task of vehicles and lane lines. The model introduces a structured re-parameterization mechanism in the training stage to improve the expression ability, and realizes inference simplification through operator fusion in the inference stage. At the same time, with the help of knowledge alignment technology, high-level semantic features are transferred from a powerful teacher network, so that accurate identification of complex targets can still be realized under a lightweight network architecture.

[0034] The present application improves the original YOLOv7-tiny target detection model to construct an improved YOLOv7-tiny target detection model as the second traffic violation identification model of the present application. The overall network of the second traffic violation identification model of the present application adopts a double-branch design to adapt to the vehicle target and lane line detection task, mainly including: First, the backbone network (Backbone) is constructed based on a structured re-parameterized lightweight convolution to extract multi-scale image semantics. Secondly, a FPN lightweight feature pyramid structure or a Lite-BiFPN lightweight feature pyramid structure is introduced into the neck network (Neck) for semantic integration. Thirdly, a head network (Head) is set, which includes a vehicle detection head network and a lane line detection head network. The vehicle detection head network adopts an Anchor-based strategy, and the lane line detection head network adopts an Anchor-free continuous point segment detection strategy. Fourthly, a knowledge alignment module is introduced. In the training stage, a teacher network is introduced to guide the representation learning of a student network to improve the generalization performance. In the testing stage, the knowledge alignment module and the teacher network are removed without increasing the inference burden.

[0035] In the preset main network of the first traffic violation identification model, a structured re-parameterized convolution module including a main branch convolution module, a first auxiliary branch, and a second auxiliary branch is introduced, and a BatchNorm layer is introduced after the main branch convolution module, the first auxiliary branch, and the second auxiliary branch. A lightweight feature pyramid structure is introduced in the neck network, a vehicle detection head network adopting an Anchor-based strategy, and a lane line detection head network adopting an Anchor-free continuous point segment detection strategy constitute a detection head network to construct a second traffic violation identification model. The traffic scene image frame is input into the second traffic violation identification model trained to a convergent state to determine the center position coordinates, width, and height of the bounding box of the target vehicle in the traffic scene image frame, and the spatial geometric curve coordinate point set of the target lane line and the corresponding lane line category. The base network architecture of the first traffic violation identification model is an original YOLOv7-tiny target detection model, and the base network architecture of the second traffic violation identification model is an improved YOLOv7-tiny target detection model. The main branch convolution module is a 3×3 convolution, the first auxiliary branch is a 1×1 convolution, the second auxiliary branch adopts an Identity mapping, and the lightweight feature pyramid structure includes a FPN lightweight feature pyramid structure or a Lite-BiFPN lightweight feature pyramid structure. The lane line category includes a solid line or a dashed line, and the target vehicle includes a truck, a car, a bus, or the like.

[0036] In some embodiments, referring to Figure 2 , the step of training the second traffic violation identification model includes: Step S201, acquiring a sample training set, wherein the sample training set includes a plurality of training samples and corresponding sample labels. The training sample is a traffic scene image frame containing a target vehicle and a target lane line, and the sample label represents a target vehicle category and a lane line category. Step S202, inputting a plurality of training samples in the sample training set into the preset second traffic violation identification model, and performing parallel calculation on the main branch convolution module, the first auxiliary branch and the second auxiliary branch in the structured re-parameterizable convolution module, and fusing the outputs of each branch after processing by each BatchNorm layer; Step S203, introducing a knowledge alignment mechanism, and using the intermediate feature representation provided by training the visual base model to guide the feature learning of the second traffic violation identification model to determine a total training loss of the second traffic violation identification model, wherein the total training loss includes a vehicle detection loss output by a vehicle detection head, a lane line detection loss output by a lane line detection head, and an intermediate layer feature distillation loss between the second traffic violation identification model and the visual base model; Step S204, updating the network parameters of the second traffic violation identification model based on the total training loss using a back propagation algorithm until the second traffic violation identification model is trained to a converged state to determine the second traffic violation identification model trained to the converged state.

[0037] Specifically, in the training phase, to enhance the non-linear modeling capability of the convolution block, the structured re-parameterizable convolution module (RPCB) in the backbone network of the second traffic violation identification model of the present application is based on the RepVGG architecture idea, which includes a main branch convolution module, a first auxiliary branch and a second auxiliary branch. The main branch convolution module is a 3x3 convolution, and the first auxiliary branch is a 1x1 convolution for improving local response. The second auxiliary branch adopts Identity mapping for preserving original features; and the lightweight feature pyramid structure includes an FPN lightweight feature pyramid structure or a Lite-BiFPN lightweight feature pyramid structure.

[0038] The second traffic violation identification model of the present application performs parallel calculation on the main branch convolution module, the first auxiliary branch and the second auxiliary branch in the structured re-parameterizable convolution module in the training phase, and fuses the outputs of each branch after processing by each BatchNorm layer, and the calculation formula is represented as: (4) wherein, represents the output of the main branch convolution module (3x3 convolution); represents the output of the first auxiliary branch (1x1 convolution); represents the output of the second auxiliary branch (Identity mapping). represents the three-branch fusion result.

[0039] Further, in the inference stage, the above main branch convolution module, the first auxiliary branch and the second auxiliary branch are equivalently converted into a single 3x3 convolution structure by using a structured re-parameterization fusion technique, which is represented as: (5) wherein, represents the fused single 3x3 convolution; represents the input feature; represents the output feature.

[0040] (6) wherein, represents the fused single 3x3 convolution; represents the identity mapping weight; represents the weight of the 3x3 convolution in the training stage; represents the weight of the 1x1 convolution in the training stage; represents the padding operation, which extends the weight of the 1x1 convolution in the training stage and the identity mapping weight to 3x3 size, thereby realizing structural fusion and avoiding the delay caused by multi-path inference. This module effectively improves the model expression ability in the training stage and significantly reduces the parameter and computing power overhead in the inference stage.

[0041] Further, in the knowledge alignment module, in order to alleviate the expression ability limitation under the lightweight architecture, the application introduces a knowledge alignment mechanism in the training process, guides the feature learning of the student network by means of the intermediate representation provided by the training teacher network, and introduces an intermediate layer distillation loss function in the feature extraction stage, so that the intermediate features of the student network are aligned with the teacher network features. The calculation formula is represented as: (7) wherein, represents the number of features; represents the feature extracted by the teacher network at the layer; represents the feature extracted by the student network at the layer; represents the gradient truncation operator, which only transmits the feature without transmitting the gradient; represents the feature size adjustment module, which is used to unify the channel number and spatial dimension, so as to ensure that the channel number and spatial dimension are consistent; represents the norm operation, which is used to measure the feature difference. The advantage of this processing is that a large-scale pre-trained visual base model can be used without training a neural network as a teacher network.

[0042] It can be known from the above calculation formula (7) that the generalization ability of the lightweight student model is improved by using the high-order semantic knowledge of the teacher network to constrain the alignment of the intermediate features of the student network and the teacher network.

[0043] Further, a knowledge alignment mechanism is introduced, and the intermediate feature representation provided by the training of the visual base model is used to guide the feature learning of the second traffic violation recognition model to determine the total training loss of the second traffic violation recognition model, wherein the total training loss includes a vehicle detection loss output by a vehicle detection head, a lane line detection loss output by a lane line detection head, and an intermediate layer feature distillation loss between the second traffic violation recognition model and the visual base model, and the calculation formula of the final total training loss function is represented as: (8) Wherein, is the vehicle detection loss output by the vehicle detection head, is the lane line detection loss output by the lane line detection head, represents the intermediate layer feature distillation loss between the second traffic violation recognition model and the visual base model; 、 and are balance coefficients for adjusting the weights of each loss.

[0044] It can be known from the above calculation formula (8) that the generalization ability of the second traffic violation recognition model is improved by using the high-order semantic knowledge of the visual base model to constrain the alignment of the intermediate features of the second traffic violation recognition model and the visual base model.

[0045] In some embodiments, to adapt to the detection needs of lane lines and vehicle targets, a double-task detection head is designed, which includes a vehicle detection head network and a lane line detection head network, wherein the vehicle detection head network adopts an Anchor-based strategy, which outputs the bounding box position, target vehicle category and confidence of the target vehicle, and the expression of the prediction format is: (9) Wherein, represents the center position coordinates of the bounding box of the th target vehicle; represents the width of the bounding box of the th target vehicle; represents the height of the bounding box of the th target vehicle; represents the confidence of the vehicle category (such as truck, car); represents the confidence of the target existence; The number of detected vehicles is represented.

[0046] As can be seen from the above calculation formula (9), the vehicle detection head network outputs the position, size and confidence information of the vehicle, thereby providing basic data for multi-target tracking.

[0047] The lane line detection head network adopts an Anchor-free continuous point segment detection strategy, and outputs a plurality of curve point sets and their attribution labels. The prediction format is represented as: (10) Among them, represents the coordinate of the i-th discrete point of the m-th lane line; represents the number of discrete points; represents the coordinate of the i-th discrete point of the m-th lane line; represents the number of discrete points; represents the coordinate of the i-th discrete point of the m-th lane line; represents the coordinate of the i-th discrete point of the m-th lane line.

[0048] As can be seen from the above calculation formula (10), the lane line detection head network outputs the spatial geometric curve coordinate point set of the lane line, in combination with the lane line category (solid line or dashed line), thereby providing a basis for the violation judgment of compaction line violation behavior.

[0049] In step S40, a preset target vehicle tracking algorithm is called to construct a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and to perform target tracking on the target vehicle according to the state vector and the appearance feature vector of the target vehicle in each traffic scene image frame. After the center position coordinates, width and height of the bounding box of the target vehicle and the spatial geometric curve coordinate point set of the target lane line and the corresponding lane line category in the traffic scene image frame are determined, a preset target vehicle tracking algorithm is called to construct a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and to perform target tracking on the target vehicle according to the state vector and the appearance feature vector of the target vehicle in each traffic scene image frame. The target vehicle tracking algorithm is an improved DeepSORT algorithm.

[0050] In some embodiments, referring to Figure 3 , the step of calling a preset target vehicle tracking algorithm to construct a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and to perform target tracking on the target vehicle according to the state vector and the appearance feature vector of the target vehicle in each traffic scene image frame, includes: Step S401, a preset target vehicle tracking algorithm is called to obtain a first state vector of the target vehicle corresponding to a previous traffic scene image frame, wherein the first state vector includes a center position coordinate of a bounding box of the target vehicle in the previous traffic scene image frame, an area of the target vehicle, and an aspect ratio of the bounding box; Step S402, a Kalman filter is used to recursively predict a future state of the target vehicle according to the first state vector to determine a second state vector of the target vehicle corresponding to a current traffic scene image frame, and a Mahalanobis distance between the first state vector and the second state vector is calculated and determined; Step S403, an appearance feature vector of the target vehicle is extracted from each traffic scene image, a cosine distance between the appearance feature vector of the target vehicle in the previous traffic scene image frame and the appearance feature vector of the target vehicle in the current traffic scene image frame is calculated and determined, and a matching cost of the target vehicle and other vehicles is calculated and determined according to the Mahalanobis distance and the cosine distance; Step S404, a preset Hungarian algorithm is used to determine a target matching result of the target vehicle in the current traffic scene image frame according to the matching cost of the target vehicle and other vehicles; Step S405, the above steps S401 to S404 are repeated to track the target vehicle.

[0051] Specifically, in the multi-target tracking and trajectory management module of the lightweight traffic violation detection system of the present application, in order to realize stable tracking of multiple motor vehicles in a complex traffic scene, the present application improves the DeepSORT algorithm to determine an improved DeepSORT algorithm as the target vehicle tracking algorithm of the present application, to focus on solving the problems of short-term occlusion, frequent lane changing and target re-identification in high-frequency traffic environment, and to ensure the consistency of the target and the continuity of the trajectory in the process of modeling the violation behavior.

[0052] The present application models the corresponding state vector of each target vehicle , which includes the two-dimensional position, speed, size and proportion of the target vehicle, and is specifically defined as: (11) wherein, represents the center position coordinate of the bounding box of the target vehicle; represents the area of the target vehicle, which is determined by the width and height of the bounding box of the target vehicle; represents the aspect ratio of the bounding box of the target vehicle; is the first derivative of position and scale, representing the speed.

[0053] From the above calculation formula (11), by modeling the motion state of the target vehicle, input is provided for the prediction and update of the Kalman filter, supporting the continuity of target tracking.

[0054] Further, a linear Kalman filter is used to predict and update the corresponding state vector of the target vehicle to capture the motion trend and estimate the position of the target vehicle during occlusion. The filter state transition matrix F and the observation matrix H are constructed in accordance with the standard form, and the output of the prediction stage is and the covariance matrix thereof for subsequent data association module.

[0055] Further, in order to realize accurate matching of the detection result and the historical trajectory, the system uses a ResNet-18 network as a feature extractor to extract the appearance feature vector of each target vehicle from each frame of image, which is used for identity maintenance and occlusion recovery between targets at different time frames. The present application combines motion consistency and appearance embedding features to construct a joint similarity measurement function, which is represented as: (12) Among them, represents the matching cost of the target vehicle and the target vehicle ; represents the Kalman predicted state vector of the historical trajectory of the target vehicle ; represents the observation vector of the target vehicle , which includes the center position coordinates, width and height of the bounding box of the target vehicle ; represents the appearance feature vector of the target vehicle ; represents the appearance feature vector of the target vehicle , is the appearance feature vector obtained by global average pooling after the intermediate layer feature output by the above-mentioned second traffic violation identification model; represents the Mahalanobis distance between the first state vector corresponding to the target vehicle in the previous image frame and the second state vector corresponding to the target vehicle in the current image frame, which is used to measure the motion similarity to measure the motion consistency; represents the cosine distance between the appearance feature vector of the target vehicle in the previous image frame and the appearance feature vector of the target vehicle in the current image frame, which is used to measure the appearance similarity; are weighting coefficients used to control the relative contribution of motion and appearance information, may be 0.6.

[0056] As can be seen from the above calculation formula (12), the matching cost of the target vehicle and the target vehicle provides a basis for the optimal matching of the Hungarian algorithm, ensuring the consistency of the identity of the target vehicle.

[0057] Further, the matching of the target vehicle is completed by the Hungarian algorithm (Hungarian Algorithm) to perform minimum cost allocation, and low confidence matching pairs are suppressed by setting a distance threshold. The Kalman filter is used to recursively predict the future state of the target vehicle according to the first state vector of the target vehicle , to determine the Mahalanobis distance between the first state vector and the second state vector corresponding to the current image frame, to calculate the cosine distance between the appearance feature vector of the target vehicle in the previous traffic scene image frame and the appearance feature vector of the target vehicle in the current traffic scene image frame, and to calculate the matching cost of the target vehicle and the target vehicle according to the Mahalanobis distance and the cosine distance. Then, the Hungarian algorithm is used to determine the target matching result of the target vehicle in the current traffic scene image frame according to the matching cost of the target vehicle and the target vehicle . The above steps are repeated to track the target vehicle.

[0058] Further, the step of calling the preset target tracking algorithm to track the target vehicle further comprises: Step 4001, when the target vehicle is not detected in consecutive multiple image frames, but the motion trajectory predicted by the Kalman filter is still coherent with the historical trajectory, the target vehicle is marked as an occluded state; Step S4002, when the target vehicle is marked as an occluded state, a preset appearance memory library mechanism is called to compare the historical appearance features of the target vehicle, to determine whether the newly detected target is the occluded target vehicle, and if so, the identity ID is restored.

[0059] Specifically, in a traffic scene, a situation of temporary occlusion of vehicles may easily occur, such as large vehicles occluding small vehicles, etc. The traditional tracking algorithm is prone to ID drift or target loss at this stage. Therefore, the present application introduces the following two mechanisms: (1) Occlusion detection mechanism: if the target vehicle is continuously undetected but the Kalman predicted motion trajectory is still continuous with the historical trajectory, the target vehicle is marked as "occluded state"; (2) Feature Memory Bank mechanism: each target vehicle retains a historical ReID feature set, which is a set of appearance features used in the occluded vehicle re-identification task, which are used to represent and distinguish different target vehicle identities; when the detector re-detects a possible target, a feature comparison mechanism is used to determine whether it is an occlusion recovery, the historical appearance features of the target vehicle are compared to determine whether the re-detected target is an occluded target vehicle, if so, its identity ID is restored. This mechanism effectively improves the occlusion recovery success rate and identity ID retention rate, and avoids track interruption caused by short-term frame loss.

[0060] Further, to ensure efficient use of system resources and target tracking quality, the trajectory management adopts the following state machine mechanism: (1) Tentative state: the target is detected for the first time, and needs to be continuously matched for a certain number of times before entering the confirmed state; (2) Confirmed state: enter stable tracking; (3) Lost state: continuously unmatched frames, temporarily not removed; (4) Deleted state: if the target is not updated for more than frames, the trajectory is terminated and removed.

[0061] In addition, each trajectory is recorded with its complete spatial path as the basic input of the subsequent traffic violation judgment module.

[0062] Step S50, calling a preset traffic violation behavior judgment strategy to perform traffic violation judgment on the target vehicle to determine whether the target vehicle is a solid line violation vehicle, a queue violation vehicle, or a reverse violation vehicle, to complete the lightweight traffic violation behavior detection based on the car recorder.

[0063] The preset target vehicle tracking algorithm is called to construct the state vector of the target vehicle in each traffic scene image frame based on the center position coordinates, width, and height of the bounding box. After tracking the target vehicle based on the state vector and the appearance feature vector of the target vehicle in each traffic scene image frame, the preset traffic violation judgment strategy is called to judge the target vehicle for traffic violations, so as to determine whether the target vehicle is a vehicle violating the solid line, a vehicle violating the lane-cutting violation, or a vehicle violating the traffic flow in the wrong direction, thereby completing lightweight traffic violation detection based on the driving recorder. The traffic violation judgment strategy includes a strategy for violating the solid line, a strategy for violating the lane-cutting violation, and a strategy for violating the traffic flow in the wrong direction.

[0064] In some embodiments, see Figure 4 The steps of calling a preset traffic violation behavior determination strategy to perform traffic violation determination on the target vehicle to determine whether the target vehicle is a solid line violation vehicle, a lane-cutting violation vehicle, or a wrong-way violation vehicle include: Step S51: Invoke a preset compaction line violation determination strategy to obtain vehicle trajectory data and lane line data of a target vehicle within a preset time range, wherein the vehicle trajectory data represents the center position coordinates of the target vehicle at each moment, and the lane line data represents a set of spatial geometric curve coordinate points of the target lane line and its corresponding lane line category; Step S52: Calculate and determine the minimum distance between the target vehicle's trajectory and the target lane line based on the vehicle trajectory data and the lane line data; if the minimum distance is less than a preset distance threshold, determine the target vehicle as a potential compaction line vehicle; Step S53: When the target vehicle is determined to be a potential lane-crossing vehicle, if the center position coordinates of the target vehicle are on different sides relative to the target lane line at any two consecutive moments, the target vehicle is determined to be a lane-crossing vehicle. Step S54: When the target vehicle is determined to be a vehicle crossing the lane, if the crossing-lane behavior of the target vehicle continues to appear in multiple frames of traffic scene images, it is determined whether the lane line category of the target lane line is a solid line. If so, the target vehicle is determined to be a vehicle that crosses the solid line in violation of traffic regulations.

[0065] Specifically, the Traffic Violation Determination Module, the core reasoning unit of this application, is designed to determine whether a vehicle has violated traffic regulations based on the target trajectory data and traffic semantic information provided by the Tracking Module. This module primarily targets three typical types of violations: crossing the solid line, cutting in, and driving against traffic, establishing corresponding rule models and decision logic. To enhance the system's practicality and robustness, the rule design takes into account non-ideal factors in the actual road environment, such as incomplete lane markings, dense vehicle obstruction, and camera distortion.

[0066] For each target vehicle that is identified and tracked , which is in the time interval The driving trajectory in is expressed as: (13) in, Indicates the target vehicle The coordinates of the center position at each moment in the image space; Represents the target vehicle The instantaneous speed can be obtained by predicting the Kalman filter in the above steps; Represents the target vehicle The heading angle, in radians, is defined relative to the image coordinate system or map direction coordinates.

[0067] As can be seen from the above calculation formula (13), it records the complete driving trajectory of the vehicle and provides time series data for the analysis of illegal behaviors such as crossing the line, cutting in, and driving against traffic.

[0068] In addition to managing the data structure of target vehicles with different IDs, it is also necessary to manage the different lane lines predicted by the second traffic violation recognition model mentioned above. This is to prepare for calculating the relationship between lane lines and target vehicles and determining the type of traffic violation. The relevant data structure of lane lines can be represented as follows: (14) in, Indicates the A target lane line, including its spatial geometric curve coordinate point set and lane line type (solid line or dashed line); For the The unit vector of the main traffic direction of each road is obtained from the historical vehicle movement direction statistics. This input definition facilitates the formal expression of subsequent rule logic and adapts to various visual semantic configurations that may appear in different traffic scenarios.

[0069] From the above calculation formula (14), it can be seen that it provides the geometry and type information of the lane line, as well as the road direction reference, providing a semantic basis for violation judgment.

[0070] Further, the compaction line behavior refers to a situation where a vehicle drives into the opposite side of the lane line without permission to change lanes or turn around, thereby violating the constraint of the traffic passing boundary. The solid line is usually used in the scene where lane changing is prohibited, such as a bridge section, before the ramp exit, etc. Crossing the solid line may bring safety risks. The lane line in the visual image is a pixel-level curve, and therefore, the detection of the “crossing line behavior” needs to be assisted by geometric reasoning means.

[0071] The preset compaction line violation behavior judgment strategy is called to calculate and determine the minimum distance between the vehicle trajectory of the target vehicle and the target lane line according to the vehicle trajectory data and the lane line data. If the minimum distance is less than a preset distance threshold, the target vehicle is determined as a potential compaction line vehicle. The preset distance threshold can be a pixel distance corresponding to 0.5 meters, etc. The calculation formula for calculating and determining the minimum distance between the vehicle trajectory data and the lane line data is represented as: (15) wherein, represents the minimum distance between the vehicle trajectory of the target vehicle and the first target lane line; represents the vehicle trajectory of the target vehicle; represents the first target lane line; represents the vertical distance between the center position coordinates of the target vehicle at each moment in the image space and the target lane line; represents the center position coordinates of the target vehicle at each moment in the image space. According to the above calculation formula (15), the minimum distance between the vehicle trajectory of the target vehicle and the target lane line can be calculated and determined. If the minimum distance is less than a preset distance threshold, it is judged that the target vehicle approaches the target lane line, and the target vehicle is determined as a potential compaction line vehicle. Further, when the target vehicle is determined as a potential compaction line vehicle, any two consecutive moments are selected. If the center position coordinates of the target vehicle at the two moments are on different sides relative to the target lane line, the target vehicle is determined as a crossing line driving vehicle. Specifically, for any two consecutive moments t1 and t2, if the center position coordinates of the target vehicle at the two moments are on different sides relative to the target lane line, it is defined as:

[0072]

[0073] Further, when the target vehicle is determined as a potential compaction line vehicle, any two consecutive moments are selected. If the center position coordinates of the target vehicle at the two moments are on different sides relative to the target lane line, the target vehicle is determined as a crossing line driving vehicle. Specifically, for any two consecutive moments t1 and t2, if the center position coordinates of the target vehicle at the two moments are on different sides relative to the target lane line, it is defined as: ​​​​​​​​​​(16) wherein, is a symbol function, which determines which side of the lane line the point is on based on the lane line normal vector; represents the center position coordinates of the target vehicle at time ; represents the center position coordinates of the target vehicle at time ; represents the center position coordinates of the target vehicle at any two consecutive times and are on different sides relative to the target lane line, so as to determine whether the vehicle crosses from one side of the lane line to the other side, and the target vehicle is determined to be a line-crossing vehicle.

[0074] Further, when the target vehicle is determined to be a line-crossing vehicle, if the line-crossing behavior of the target vehicle continues to appear in multiple frames of traffic scene images, it is determined whether the lane line category of the target lane line is a solid line, and if so, the target vehicle is determined to be a solid line violation vehicle. Specifically, the line-crossing behavior must continue to appear within a continuous time window , wherein, , which can be set to 3 frames, about 0.12 seconds, to exclude short-term visual misjudgment or image distortion errors.

[0075] When the line-crossing behavior of the vehicle must continue to appear in multiple consecutive frames of images, it is determined whether the lane line category of the target lane line is a solid line, and if so, the target vehicle is determined to be a solid line violation vehicle; only when the corresponding lane line is a solid line is it determined to be a line violation, and a dashed line crossing is not processed.

[0076] In some embodiments, referring to Figure 5 , the step of calling a preset traffic violation behavior determination strategy to determine the target vehicle as a solid line violation vehicle, a queue violation vehicle, or a reverse driving violation vehicle includes: Step S501, calling a preset queue violation behavior determination strategy to obtain the center position coordinates of the target vehicle and a first vehicle and a second vehicle to be queued by the target vehicle at each time, wherein the first vehicle represents a front vehicle to be queued by the target vehicle, and the second vehicle represents a rear vehicle to be queued by the target vehicle; Step S502, according to the center position coordinates of the target vehicle and the first vehicle at each time, the first relative distance between the target vehicle and the first vehicle at each time is calculated and determined, and according to the center position coordinates of the target vehicle and the second vehicle at each time, the second relative distance between the target vehicle and the second vehicle at each time is calculated and determined. Step S503, the first difference between the first relative distance and the second relative distance of the target vehicle at the cutting-in time is calculated and determined, if the first difference is less than the preset safety distance, the target vehicle is determined as a cutting-in illegal vehicle.

[0077] Specifically, the cutting-in illegal behavior is essentially an impolite and unreasonable behavior, which often occurs at congested road sections or ramp entrances. The traditional cutting-in illegal behavior is difficult to judge by static images, and needs to be combined with the relative trajectory evolution between target vehicles, and the relative speed and position change between target vehicles provide effective criteria, and the determination steps of the cutting-in illegal behavior of the target vehicle include: The preset cutting-in illegal behavior determination strategy is called, and the center position coordinates of the target vehicle and the first vehicle and the second vehicle which the target vehicle intends to cut in at each time are obtained, wherein the first vehicle represents the front vehicle of the target vehicle which the target vehicle intends to cut in, and the second vehicle represents the rear vehicle of the target vehicle which the target vehicle intends to cut in; according to the center position coordinates of the target vehicle and the first vehicle (the front vehicle of the target vehicle ) at each time, the first relative distance between the target vehicle and the first vehicle (the front vehicle of the target vehicle ) at each time is calculated and determined, wherein the calculation formula of the first relative distance between the target vehicle and the front vehicle of the target vehicle which the target vehicle intends to cut in at time is represented as: wherein, represents the first relative distance between the target vehicle and the front vehicle of the target vehicle which the target vehicle intends to cut in at time ; represents the horizontal coordinate of the center position coordinate of the target vehicle at time ; represents the horizontal coordinate of the center position coordinate of the target vehicle at time​​​ The vertical coordinate of the center position coordinate; Indicates the target vehicle The car ahead intending to cut in At the moment The horizontal coordinate of the center position coordinate; Indicates the target vehicle The car ahead intending to cut in At the moment The vertical coordinate of the center position coordinate; Further, according to the target vehicle , the second vehicle (target vehicle The car behind intends to cut in ) at each moment, calculate and determine the target vehicle and the second vehicle (target vehicle The car behind intends to cut in ) The second relative distance at each moment, where the target vehicle With the target vehicle The car behind intends to cut in At the moment The calculation formula of the second relative distance is expressed as: (18) in, Indicates the target vehicle With the target vehicle The car behind intends to cut in At the moment The second relative distance; Indicates the target vehicle At the moment The horizontal coordinate of the center position coordinate; Indicates the target vehicle At the moment The vertical coordinate of the center position coordinate; Indicates the target vehicle The car behind intends to cut in At the moment The horizontal coordinate of the center position coordinate; Indicates the target vehicle The car behind intends to cut in At the moment The vertical coordinate of the center position coordinate.

[0078] Furthermore, the first difference between the first relative distance and the second relative distance of the target vehicle at the time of cutting in is calculated and determined. If the first difference is less than the preset safety distance, the target vehicle is determined to be a vehicle that cuts in illegally. The preset safety distance can be 20 meters, 30 meters or 50 meters, etc., which can be determined by those skilled in the art according to actual business scenarios and is not limited here. Specifically, the target vehicle is calculated and determined. At the time of jamming The first difference between the first relative distance and the second relative distance is calculated as follows: (19) in, Indicates the target vehicle With the target vehicle The car ahead intending to cut in At the time of jamming relative distance; Indicates the target vehicle With the target vehicle The car behind intends to cut in At the time of jamming relative distance; Indicates the preset safety distance. When, it means at time If the relative distance between the target vehicle and the vehicle in front and behind becomes significantly smaller and the target vehicle fails to maintain lateral following behavior, it constitutes a lane-cutting violation and the target vehicle will be determined as a lane-cutting violation vehicle.

[0079] From the above calculation formulas (17) to (19), we can know that by calculating the time when the vehicle is cutting in, The relative distance to the front and rear vehicles, combined with the safety distance threshold, is used to determine whether the vehicle is cutting in. This provides a basis for determining lane-cutting violations from a mathematical quantification perspective, making the identification of lane-cutting behavior more objective and operational.

[0080] In some embodiments, see Figure 6 The steps of calling a preset traffic violation behavior determination strategy to perform traffic violation determination on the target vehicle to determine whether the target vehicle is a solid line violation vehicle, a lane-cutting violation vehicle, or a wrong-way violation vehicle include: Step S5001: calling a preset wrong-way traffic violation judgment strategy to obtain the center position coordinates of the target vehicle at each time; Step S5002: Calculate and determine the unit motion direction vector of the target vehicle based on the center position coordinates of the target vehicle at each moment; Step S5003: Clustering the movement directions of historical vehicles in the lane where the target vehicle is located to determine the main travel direction unit vector of the lane where the target vehicle is located; Step S5004: Calculate and determine the dot product between the unit motion direction vector and the main traffic direction unit vector. If, in a continuous preset number of frames of traffic scene images, the dot product between the unit motion direction vector of the target vehicle and the main traffic direction unit vector is less than a preset threshold, the target vehicle is determined to be a wrong-way illegal vehicle.

[0081] Specifically, wrong-way traffic violations pose a great threat to traffic safety and are a key regulatory target. This application performs wrong-way traffic identification based on heading vector angle information to avoid image direction errors. The steps for determining whether a target vehicle is a wrong-way traffic violation include: Call the preset wrong-way violation behavior judgment strategy to obtain the center position coordinates of the target vehicle at each time; calculate and determine the unit motion direction vector of the target vehicle based on the center position coordinates of the target vehicle at each time, wherein the target vehicle The calculation formula of the unit motion direction vector is expressed as: (20) in, Indicates the target vehicle At the moment At the time The unit motion direction vector is obtained by calculating the position change of the target vehicle in adjacent frames and is used to measure the vehicle's motion direction; Indicates the target vehicle At the moment The horizontal coordinate of the center position coordinate; Indicates the target vehicle At the moment The vertical coordinate of the center position coordinate; Indicates the target vehicle At the moment The horizontal coordinate of the center position coordinate; Indicates the target vehicle At the moment The vertical coordinate of the center position coordinate; Represents the norm operation.

[0082] Furthermore, the target vehicle The movement directions of historical vehicles in the lane are clustered to determine the target vehicle The main traffic direction unit vector of the lane ; Calculate and determine the unit motion direction vector with the main travel direction unit vector If the dot product between the unit motion direction vector of the target vehicle and the unit vector of the main traffic direction in the traffic scene image of the consecutive preset frame number T is less than the preset threshold , then the target vehicle Determined as a wrong-way illegal vehicle, wherein the preset frame number T can be 3 or 5, etc., and those skilled in the art can determine it as needed according to the actual business scenario requirements, and no limitation is made here. Specifically, if the following conditions are met in the continuous T-frame traffic scene image, the target vehicle is considered Going in reverse, the target vehicle The expression for judging a vehicle as driving against traffic rules is: (twenty one) in, Indicates the target vehicle At the moment At the time The unit motion direction vector is obtained by calculating the position change of the target vehicle in adjacent frames and is used to measure the vehicle's motion direction; Indicates the target vehicle The main travel direction unit vector of the lane; The value can be -0.8, which corresponds to an angle of 143°.

[0083] In some embodiments, the result recording module is responsible for recording event information and triggering an alarm after a traffic violation is detected. Specifically, once it is determined that a vehicle has violated traffic rules such as crossing the line, cutting in, or driving in the wrong direction, the system will record key information such as the timestamp, frame number, violation type, vehicle location, and image when the violation occurred, and encrypt it and save it to a local storage device, while also supporting backup to the cloud. In terms of alarms, the system can remind the driver through the voice module of the dashcam and push the violation information to the remote traffic management platform in real time. Data transmission uses an encryption protocol to ensure security and supports multiple methods such as Wi-Fi, 4G / 5G, etc. In addition, the user interface allows drivers to view event lists and details, and also supports data export functions. This module provides drivers and traffic management departments with timely violation feedback and strong technical support, which helps to improve the level of road traffic safety management.

[0084] As can be seen from the above embodiments, compared with the prior art, the present application addresses the following issues: conventional violation detection in the prior art mostly relies on fixed cameras and geomagnetic sensors, which are difficult to cope with dynamic changes in large-scale road environments; and traditional image recognition algorithms rely on high-performance computing platforms and are not suitable for real-time operation in embedded environments. The present application includes but is not limited to the following beneficial effects: Firstly, as a common vehicle-mounted device, the popularity and low-cost advantage of the driving recorder enable this detection method to be widely applied in daily traffic management. The traditional traffic monitoring system requires high equipment installation and maintenance costs, while the present application effectively reduces the system deployment cost by utilizing existing driving recorders without additional hardware investment. Traditional traffic violation detection algorithms usually rely on high-performance computing platforms such as servers or specialized computer hardware to run efficiently. The present application designs a lightweight improved YOLOv7-tiny target detection model, which can adapt to resource-constrained devices such as driving recorders, making it possible to run efficiently even on low-power and low-memory driving recorders, greatly improving the popularity and convenience of practical applications.

[0085] Secondly, the improved YOLOv7-tiny target detection model of the present application can greatly improve the target detection accuracy in resource-constrained devices such as driving recorders, and also significantly improve the inference speed. This makes it possible to efficiently identify and locate vehicles violating traffic regulations even in complex traffic environments, thanks to the lightweight neural network design, the inference process is accelerated, and real-time traffic violation detection can be achieved in practical applications. For example, the system can identify violations such as lane violations, queueing, and reverse driving in real time without waiting for long calculations and processing, which is of great significance for timely response and accident prevention in traffic management.

[0086] Thirdly, the improved DeepSORT algorithm of the present application can solve the problems of occlusion and target loss, making the tracking of target vehicles more stable and accurate in complex traffic environments, improving the continuity and reliability of vehicle tracking.

[0087] Fourthly, the present application can determine traffic violations such as lane violations, queueing, and reverse driving by combining the detected lane lines, target vehicle positions, and motion trajectories, which not only improves the detection accuracy of violations, but also increases the stability of the system in complex traffic scenarios.

[0088] Fifthly, by integrating vehicle detection, lane line detection, and traffic violation behavior recognition strategies, the present application can handle multiple traffic violation detection tasks and is suitable for various traffic scenarios. This multi-target and full-scene adaptability enables the method to be widely applied in various urban roads, expressways, and highways, and thanks to the lightweight design and modular structure, the system can be optimized and expanded as needed.

[0089] Sixthly, by introducing the structured reparameterization convolution module in the original YOLOv7-tiny network, the model volume can be effectively compressed, the inference speed can be improved, and the high detection accuracy can be ensured, so that the system can play the maximum performance under the limited hardware resources. Through the lightweight FPN or Lite-BiFPN structure, the effective extraction of multi-scale features is ensured, and the detection ability in complex traffic scenes can be improved, which enables the vehicle to accurately identify in different sizes and different perspectives, and effectively cope with various complex traffic situations.

[0090] Seventhly, the application can realize efficient traffic violation detection on the car recorder, which has important practical application value in the fields of urban traffic management, traffic accident prevention, intelligent city construction, etc. By real-time detection and judgment of traffic violations, the application not only can improve the efficiency of traffic management, but also can effectively reduce the incidence of traffic accidents and protect public safety. The timely identification and response of illegal behavior can help reduce accidents, especially for high-risk behaviors such as line pressure, jamming and reverse, which can be intervened in time to avoid potential dangers.

[0091] Please refer to Figure 7, provided by one of the purposes of the application, a lightweight traffic violation detection device based on a driving recorder, comprising an image frame acquisition module 1100, an identification model construction module 1200, a target identification module 1300, a target tracking module 1400 and a violation vehicle determination module 1500. Wherein, the image frame acquisition module 1100 is arranged to acquire traffic scene image frames containing target vehicles and target lane lines in the driving recorder; the identification model construction module 1200 is arranged to introduce a structured re-parameterized convolution module including a main branch convolution module, a first auxiliary branch and a second auxiliary branch into the backbone network of the preset first traffic violation identification model, and introduce a BatchNorm layer after the main branch convolution module, the first auxiliary branch and the second auxiliary branch, introduce a lightweight feature pyramid structure in the neck network, and adopt an Anchor-based vehicle detection head network and an Anchor-free continuous point segment detection strategy lane line detection head network to constitute a detection head network, so as to construct a second traffic violation identification model; the target identification module 1300 is arranged to input the traffic scene image frames into the second traffic violation identification model trained to a convergent state, to determine the center position coordinates, width and height of the bounding box of the target vehicle in the traffic scene image frames, and the spatial geometric curve coordinate point set of the target lane line and its corresponding lane line category; the target tracking module 1400 is arranged to call a preset target vehicle tracking algorithm, construct a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and perform target tracking on the target vehicle according to the state vector and the appearance feature vector of the target vehicle in each traffic scene image frame; the violation vehicle determination module 1500 is arranged to call a preset traffic violation behavior determination strategy to determine the target vehicle as a solid line violation vehicle, a queue violation vehicle or a reverse violation vehicle, so as to complete the lightweight traffic violation behavior detection based on the driving recorder.

[0092] On the basis of any embodiment of the present application, please refer to Figure 8 Another embodiment of the present application also provides an electronic device, which can be realized by a computer device, such as Figure 8As shown, the internal structure diagram of the computer device is shown. The computer device includes a processor, a computer readable storage medium, a memory and a network interface connected by a system bus. Among them, the computer readable storage medium of the computer device stores an operating system, a database and computer readable instructions, the database can store control information sequence, the computer readable instructions are executed by the processor, and the processor can realize a lightweight traffic violation detection method based on the vehicle event data recorder. The processor of the computer device is used to provide computing and control capability to support the operation of the whole computer device. The memory of the computer device can store computer readable instructions, and the computer readable instructions are executed by the processor to enable the processor to execute the lightweight traffic violation detection method based on the vehicle event data recorder. The network interface of the computer device is used to connect and communicate with the terminal. Those skilled in the art can understand, Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.

[0093] The processor in the embodiment is used to execute the specific functions of each module in Figure 7 The memory stores the program codes and various data required to execute the above-mentioned modules. The network interface is used for data transmission between the user terminal or the server. The memory in the embodiment stores the program codes and data required to execute all modules in the lightweight traffic violation detection device based on the vehicle event data recorder. The server can call the program codes and data of the server to execute the functions of all modules.

[0094] The present application also provides a storage medium storing computer readable instructions, which are executed by one or more processors to enable the one or more processors to execute the steps of the lightweight traffic violation detection method based on the vehicle event data recorder described in any embodiment of the present application.

[0095] The present application also provides a computer program product including computer programs / instructions, which are executed by one or more processors to implement the steps of the lightweight traffic violation detection method based on the vehicle event data recorder described in any embodiment of the present application.

[0096] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments of the application can be completed by a computer program instructing relevant hardware, and the computer program can be stored in a computer readable storage medium. When the program is executed, the processes of the above-mentioned embodiments of the methods can be included. The storage medium can be a computer readable storage medium such as a magnetic disc, an optical disc, a read-only memory (ROM), or a random access memory (RAM).

[0097] The above only describes some embodiments of the application. It should be pointed out that those skilled in the art can make some improvements and refinements without departing from the principles of the application, and these improvements and refinements should also be considered as the protection scope of the application.

Claims

1. A lightweight traffic violation detection method based on a dashcam, characterized in that, The method comprises the steps of: acquiring a traffic scene image frame containing a target vehicle and a target lane line in a driving recorder; introducing a structured re-parameterized convolution module including a main branch convolution module, a first auxiliary branch, and a second auxiliary branch into a preset first traffic violation identification model backbone network, and introducing a BatchNorm layer after the main branch convolution module, the first auxiliary branch, and the second auxiliary branch, introducing a lightweight feature pyramid structure into a neck network, and adopting an Anchor-based strategy vehicle detection head network and an Anchor-free continuous point segment detection strategy lane line detection head network to constitute a detection head network, so as to construct a second traffic violation identification model; inputting the traffic scene image frame into the second traffic violation identification model trained to a convergent state, so as to determine the center position coordinates, width, and height of the bounding box of the target vehicle in the traffic scene image frame, and the spatial geometric curve coordinate point set of the target lane line and the corresponding lane line category thereof; calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width, and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and the appearance feature vector of the target vehicle in each traffic scene image frame; calling a preset traffic violation behavior judgment strategy to perform traffic violation judgment on the target vehicle, so as to determine whether the target vehicle is a solid line violation vehicle, a queue violation vehicle, or a reverse violation vehicle, so as to complete the lightweight traffic violation behavior detection based on the driving recorder.

2. The dashcam-based lightweight traffic violation detection method of claim 1, wherein, The basic network architecture of the first traffic violation identification model is an original YOLOv7-tiny target detection model, and the basic network architecture of the second traffic violation identification model is an improved YOLOv7-tiny target detection model, wherein the main branch convolution module is a 3×3 convolution, the first auxiliary branch is a 1×1 convolution, the second auxiliary branch adopts Identity mapping, and the lightweight feature pyramid structure includes an FPN lightweight feature pyramid structure or a Lite-BiFPN lightweight feature pyramid structure; The target vehicle tracking algorithm is an improved DeepSORT algorithm, the traffic violation behavior judgment strategy includes a solid line violation behavior judgment strategy, a queue violation behavior judgment strategy, and a reverse violation behavior judgment strategy, and the lane line category includes a solid line or a dashed line, and the target vehicle includes a truck, a car, or a bus.

3. The dashcam-based lightweight traffic violation detection method of claim 2, wherein, The steps of training the second traffic violation identification model comprise: acquiring a sample training set, wherein the sample training set includes a plurality of training samples and corresponding sample labels, the training samples are traffic scene image frames containing target vehicles and target lane lines, and the sample labels represent target vehicle categories and lane line categories; The second traffic violation identification model is taken as a student network, a preset visual base model is taken as a teacher network, a plurality of training samples in the sample training set are input into the preset second traffic violation identification model, main branch convolution modules in a structured re-parameterized convolution module, a first auxiliary branch and a second auxiliary branch are calculated in parallel, and each branch outputs a fusion after being processed by each BatchNorm layer; A knowledge alignment mechanism is introduced, and an intermediate feature representation provided by the visual base model is used to guide feature learning of the second traffic violation identification model to determine a total training loss of the second traffic violation identification model, wherein the total training loss includes a vehicle detection loss output by a vehicle detection head, a lane line detection loss output by a lane line detection head, and an intermediate layer feature distillation loss between the second traffic violation identification model and the visual base model; The network parameters of the second traffic violation identification model are updated based on the total training loss using a back propagation algorithm until the second traffic violation identification model is trained to a converged state to determine a second traffic violation identification model that has been trained to a converged state.

4. The dashcam-based lightweight traffic violation detection method of claim 2, wherein, The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include:

5. The dashcam-based lightweight traffic violation detection method of claim 2, wherein, The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of the bounding box, and performing target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame, include: The steps of calling a preset target vehicle tracking algorithm, constructing a state vector of the target vehicle in each traffic scene image frame according to the center position coordinates, width and height of Call a preset compaction line violation behavior judgment strategy, obtain vehicle trajectory data and lane line data of a target vehicle in a preset time range, wherein the vehicle trajectory data represents the central position coordinates of the target vehicle at each time, and the lane line data represents a set of spatial geometric curve coordinate points of the target lane line and a corresponding lane line category thereof; According to the vehicle trajectory data and the lane line data, the minimum distance between the vehicle trajectory of the target vehicle and the target lane line is calculated and determined, and if the minimum distance is less than a preset distance threshold, the target vehicle is determined as a potential compaction line vehicle; When the target vehicle is determined as a potential compaction line vehicle, any two consecutive time points are selected, and if the central position coordinates of the target vehicle at the two time points are on different sides relative to the target lane line, the target vehicle is determined as a cross-line driving vehicle; When the target vehicle is determined as a cross-line driving vehicle, if the cross-line driving behavior of the target vehicle continuously occurs in multiple frames of traffic scene images, it is judged whether the lane line category of the target lane line is a solid line, and if so, the target vehicle is determined as a compaction line violation vehicle.

6. The dashcam-based lightweight traffic violation detection method of claim 2, wherein, The steps of calling a preset traffic violation behavior judgment strategy to determine whether the target vehicle is a compaction line violation vehicle, a cutting-in violation vehicle, or a reverse driving violation vehicle, include: Call a preset cutting-in violation behavior judgment strategy to obtain the central position coordinates of the target vehicle and the first vehicle and the second vehicle that the target vehicle intends to cut in at each time, wherein the first vehicle represents the front vehicle that the target vehicle intends to cut in, and the second vehicle represents the rear vehicle that the target vehicle intends to cut in; According to the central position coordinates of the target vehicle, the first vehicle, and the second vehicle at each time, the first relative distance between the target vehicle and the first vehicle at each time is calculated and determined, and the second relative distance between the target vehicle and the second vehicle at each time is calculated and determined; Calculate the first difference between the first relative distance and the second relative distance of the target vehicle at the cutting-in time, and if the first difference is less than a preset safety distance, the target vehicle is determined as a cutting-in violation vehicle.

7. The dashcam-based lightweight traffic violation detection method of claim 2, wherein, The steps of calling a preset traffic violation behavior judgment strategy to determine whether the target vehicle is a compaction line violation vehicle, a cutting-in violation vehicle, or a reverse driving violation vehicle, include: Call a preset reverse driving violation behavior judgment strategy to obtain the central position coordinates of the target vehicle at each time; According to the central position coordinates of the target vehicle at each time, the unit motion direction vector of the target vehicle is calculated and determined; The motion directions of the historical driving vehicles on the lane where the target vehicle is located are clustered to determine the main passing direction unit vector of the lane where the target vehicle is located; The dot product between the unit motion direction vector of the target vehicle and the unit vector of the main traffic direction is calculated, and if the dot product between the unit motion direction vector of the target vehicle and the unit vector of the main traffic direction in a preset number of continuous traffic scene images is less than a preset threshold, the target vehicle is determined as a reverse illegal vehicle.

8. A dashcam-based lightweight traffic violation detection device, characterized in that, The method comprises: an image frame acquisition module configured to acquire a traffic scene image frame containing a target vehicle and a target lane line in a driving recorder; a recognition model construction module configured to introduce a structured re-parameterized convolution module including a main branch convolution module, a first auxiliary branch, and a second auxiliary branch into a backbone network of a preset first traffic violation recognition model, and introduce a BatchNorm layer after the main branch convolution module, the first auxiliary branch, and the second auxiliary branch, introduce a lightweight feature pyramid structure into a neck network, and adopt an Anchor-based vehicle detection head network and an Anchor-free continuous point segment detection strategy lane line detection head network to constitute a detection head network, so as to construct a second traffic violation recognition model; a target recognition module configured to input the traffic scene image frame into the second traffic violation recognition model trained to a convergent state, so as to determine a center position coordinate, a width, and a height of a bounding box of the target vehicle in the traffic scene image frame, and a set of spatial geometric curve coordinate points of the target lane line and a corresponding lane line category thereof; a target tracking module configured to call a preset target vehicle tracking algorithm, construct a state vector of the target vehicle in each traffic scene image frame according to the center position coordinate, the width, and the height of the bounding box, and perform target tracking on the target vehicle according to the state vector and an appearance feature vector of the target vehicle in each traffic scene image frame; a violation vehicle determination module configured to call a preset traffic violation behavior determination strategy to determine the target vehicle as a solid line violation vehicle, a queue violation vehicle, or a reverse violation vehicle, so as to complete lightweight traffic violation behavior detection based on a driving recorder.

9. An electronic device comprising a central processing unit and a memory, characterized in that The central processing unit is configured to call and run a computer program stored in the memory to perform the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer program implemented according to the method of any one of claims 1 to 7 is stored in the form of computer readable instructions, and when the computer program is called and run by a computer, the steps included in the corresponding method are performed.

Citation Information

Patent Citations

  • Front vehicle line-crossing violation behavior automatic detection method and system based on vehicle-mounted machine vision

    CN111179345A

  • Night vehicle target detection method based on YOLOv8 model optimization

    CN118298399A

  • Foggy-day pedestrian and vehicle detection method based on improved YOLO11

    CN120472429A