[go: up one dir, main page]

CN115187886A - Vehicle violation detection method and device and electronic equipment - Google Patents

Vehicle violation detection method and device and electronic equipment Download PDF

Info

Publication number
CN115187886A
CN115187886A CN202210261649.3A CN202210261649A CN115187886A CN 115187886 A CN115187886 A CN 115187886A CN 202210261649 A CN202210261649 A CN 202210261649A CN 115187886 A CN115187886 A CN 115187886A
Authority
CN
China
Prior art keywords
motor vehicle
information
lane
illegal
track
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210261649.3A
Other languages
Chinese (zh)
Inventor
张伟
魏健康
史晓蒙
张星
吕晓鹏
毛宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing E Hualu Information Technology Co Ltd
Original Assignee
Beijing E Hualu Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing E Hualu Information Technology Co Ltd filed Critical Beijing E Hualu Information Technology Co Ltd
Priority to CN202210261649.3A priority Critical patent/CN115187886A/en
Publication of CN115187886A publication Critical patent/CN115187886A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Traffic Control Systems (AREA)

Abstract

本发明实施例涉及一种车辆违法行为检测方法,该方法由车辆违规检测系统执行,所述方法包括:获取目标场景的视频帧数据;基于所述视频帧数据,获得所述目标场景中非机动车的轨迹信息;基于所述轨迹信息,判断所述非机动车是否存在违法行为。本方法不仅限于正面非机动车数据,对于多角度、多姿态、多场景下的非机动车均可检测,对于非机动车非法事件的检测清晰、明确,无需人工二次分类;且对非机动车进行了分类,可以判断非机动车的类别,确定存在违法行为的非机动车的具体类别,有利于对特定种类的非机动车辆进行监管,有效解决了现有技术中的难题。

Figure 202210261649

The embodiment of the present invention relates to a method for detecting illegal behavior of vehicles, the method is executed by a vehicle violation detection system, and the method includes: acquiring video frame data of a target scene; Trajectory information of the motor vehicle; based on the trajectory information, determine whether the non-motor vehicle has an illegal act. This method is not limited to frontal non-motor vehicle data, it can detect non-motor vehicles in multi-angle, multi-pose, and multi-scenario situations, and the detection of non-motor vehicle illegal events is clear and clear, without manual secondary classification; The motor vehicle has been classified, which can determine the category of non-motor vehicles, and determine the specific categories of non-motor vehicles with illegal acts, which is conducive to the supervision of specific types of non-motor vehicles, and effectively solves the problems in the existing technology.

Figure 202210261649

Description

一种车辆违规行为检测方法、装置及电子设备A vehicle violation detection method, device and electronic device

技术领域technical field

本发明实施例涉及计算机技术领域,尤其涉及一种车辆违规行为检测方法、装置及电子设备。Embodiments of the present invention relate to the field of computer technologies, and in particular, to a method, device, and electronic device for detecting vehicle violations.

背景技术Background technique

随着文明城市、平安城市建设的进一步落实,努力创造安全、有序、畅通的交通环境已经成为各大城市交通管理部门的首要目标,而集中开展针对机动车、非机动车的一系列交通违法整治工作更成为现阶段交警工作的重中之重。但是,在违法整治工作中,存在以下难题:交警部门已建设的视频资源正面临内容浪费、已建设设备非智能化、手动抓拍人力不足、城市道路供给和需求之间呈现显著的不匹配;随着城市化信息技术的发展,城市智能交通产业规模也在逐年扩大。人工智能赋能交通行业,对加快构建数字交通、交通强国具有重要意义。With the further implementation of the construction of a civilized city and a safe city, efforts to create a safe, orderly and smooth traffic environment have become the primary goal of the traffic management departments of major cities, and a series of traffic violations against motor vehicles and non-motor vehicles are concentrated on Remediation work has become the top priority of traffic police work at this stage. However, in the work of rectifying illegal activities, there are the following problems: the video resources built by the traffic police department are facing waste of content, the built equipment is not intelligent, the manual capture manpower is insufficient, and there is a significant mismatch between the supply and demand of urban roads; With the development of urbanization information technology, the scale of urban intelligent transportation industry is also expanding year by year. Artificial intelligence empowers the transportation industry, which is of great significance to accelerating the construction of digital transportation and a strong transportation country.

发明内容SUMMARY OF THE INVENTION

本发明提供了一种车辆违规行为检测方法、装置及电子设备,用以解决现有技术中非机动车违规造成的交通秩序混乱及人身安全威胁等技术问题,为非机动车的监管提供帮助。The present invention provides a method, device and electronic device for detecting illegal behavior of vehicles, which are used to solve technical problems such as traffic disorder and personal safety threats caused by non-motor vehicle violations in the prior art, and provide assistance for the supervision of non-motor vehicles.

第一方面,本发明提供了一种车辆违法行为检测方法,该方法由车辆违规检测系统执行,该方法包括:In a first aspect, the present invention provides a vehicle violation detection method, the method is executed by a vehicle violation detection system, and the method includes:

获取目标场景的视频帧数据;Get the video frame data of the target scene;

基于视频帧数据,获得目标场景中非机动车的轨迹信息;Based on the video frame data, obtain the trajectory information of the non-motor vehicle in the target scene;

基于轨迹信息,判断非机动车的违法行为。Based on the trajectory information, determine the illegal behavior of non-motor vehicles.

在一个可能的实现方式中,轨迹信息包括非机动车的缩略图数据;基于轨迹信息,判断非机动车的违法行为,具体包括:In a possible implementation manner, the trajectory information includes thumbnail data of non-motor vehicles; based on the trajectory information, the illegal behavior of non-motor vehicles is determined, specifically including:

基于缩略图数据,进行头盔检测;Based on the thumbnail data, perform helmet detection;

若未检测到头盔,获取非机动车驾驶员的头部头像;If no helmet is detected, obtain the head portrait of the non-motor vehicle driver;

并对头部头像进行灰度值分析Perform gray value analysis on the head avatar

若分析结果满足预设阈值,则判断非机动车的驾驶员存在未戴头盔违法行为。If the analysis result satisfies the preset threshold, it is determined that the driver of the non-motor vehicle has an illegal act of not wearing a helmet.

在一个可能的实现方式中,轨迹信息包括非机动车的跟踪框信息;基于轨迹信息,判断非机动车的违法行为,具体包括:In a possible implementation manner, the trajectory information includes tracking frame information of the non-motor vehicle; based on the trajectory information, the illegal behavior of the non-motor vehicle is determined, specifically including:

根据跟踪框信息,获得非机动车的轨迹点;Obtain the track points of non-motor vehicles according to the tracking frame information;

基于视频帧数据,获得目标场景中的车道停止线和红绿灯状态;Obtain the lane stop line and traffic light status in the target scene based on the video frame data;

在红灯状态下,若轨迹点依次出现在车道停止线内,跨过车道停止线及出现在对面路口,则判断非机动车存在闯红灯的违法行为。In the red light state, if the trajectory points appear in the lane stop line in turn, cross the lane stop line and appear at the opposite intersection, it is judged that the non-motor vehicle has an illegal act of running a red light.

在一个可能的实现方式中,轨迹信息包括跟踪框信息和缩略图数据;基于轨迹信息,判断非机动车的违法行为,具体包括:In a possible implementation manner, the track information includes tracking frame information and thumbnail data; based on the track information, the illegal behavior of non-motor vehicles is determined, specifically including:

基于视频帧数据,获得目标场景中的车道线信息;Obtain the lane line information in the target scene based on the video frame data;

根据车道线信息,预设车道方向线;According to the lane line information, preset the lane direction line;

根据跟踪框信息,获得非机动车的轨迹线;Obtain the track line of the non-motor vehicle according to the tracking frame information;

计算轨迹线和预设车道方向线的夹角;Calculate the angle between the track line and the preset lane direction line;

根据缩略图数据,识别非机动车的车头朝向;Identify the head direction of the non-motor vehicle according to the thumbnail data;

若非机动车的车头朝向与车道方向线方向相反,且夹角大于预设阈值,则判断非机动车存在逆行违法行为。If the front direction of the non-motor vehicle is opposite to the direction of the lane direction line, and the included angle is greater than the preset threshold, it is determined that the non-motor vehicle has a wrong-way violation.

在一个可能的实现方式中,轨迹信息包括跟踪框信息;基于轨迹信息,判断非机动车的违法行为,具体包括:In a possible implementation manner, the trajectory information includes tracking frame information; based on the trajectory information, the illegal behavior of non-motor vehicles is determined, specifically including:

基于视频帧数据,确定目标场景中的机动车道;Determine the motor vehicle lane in the target scene based on the video frame data;

根据跟踪框信息,获得非机动车的轨迹点;Obtain the track points of non-motor vehicles according to the tracking frame information;

分析轨迹点和机动车道的位置;Analyze the location of trajectory points and motor vehicle lanes;

若轨迹点出现在机动车道内,则判断非机动车存在占用机动车道的违法行为。If the trajectory point appears in the motor vehicle lane, it is judged that the non-motor vehicle has the illegal act of occupying the motor vehicle lane.

在一个可能的实现方式中,轨迹信息包括跟踪框信息;基于轨迹信息,判断非机动车的违法行为,具体包括:In a possible implementation manner, the trajectory information includes tracking frame information; based on the trajectory information, the illegal behavior of non-motor vehicles is determined, specifically including:

基于视频帧数据,确定目标场景中的机动车道;Determine the motor vehicle lane in the target scene based on the video frame data;

根据跟踪框信息,获得非机动车的轨迹点;Obtain the track points of non-motor vehicles according to the tracking frame information;

分析轨迹点和机动车道的位置;Analyze the location of trajectory points and motor vehicle lanes;

若轨迹点出现在机动车道内,则计算轨迹点占用机动车道的数量;If the trajectory point appears in the motor vehicle lane, calculate the number of the motor vehicle lane occupied by the trajectory point;

若数量大于预设阈值,则判断非机动车存在横穿道路的违法行为。If the number is greater than the preset threshold, it is determined that the non-motor vehicle has an illegal act of crossing the road.

在一个可能的实现方式中,轨道信息包括非机动车的分类信息;在基于轨迹信息,判断非机动车的违法行为之后还包括:In a possible implementation manner, the track information includes classification information of non-motor vehicles; after judging the illegal behavior of non-motor vehicles based on the track information, it also includes:

根据非机动车的分类信息,确定存在违法行为的非机动车所属平台。According to the classification information of non-motor vehicles, determine the platform to which the non-motor vehicles that have violated the law belong.

第二方面,本发明提供了一种车辆违法行为检测装置,装置包括:In a second aspect, the present invention provides a vehicle violation detection device, the device comprising:

视频帧数据模块:用于获取目标场景的视频帧数据;Video frame data module: used to obtain video frame data of the target scene;

轨迹信息模块,用于基于视频帧数据,获得目标场景中非机动车的轨迹信息;The trajectory information module is used to obtain the trajectory information of the non-motor vehicle in the target scene based on the video frame data;

违法行为判断模块,用于基于轨迹信息,判断非机动车的违法行为。The illegal behavior judgment module is used to judge the illegal behavior of non-motor vehicles based on the trajectory information.

第三方面,本发明提供了一种电子设备,电子设备承载车辆违法行为检测系统,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;In a third aspect, the present invention provides an electronic device, the electronic device carries a vehicle illegal behavior detection system, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface, and the memory complete the communication between each other through the communication bus. communication;

存储器,用于存放计算机程序;memory for storing computer programs;

处理器,用于执行存储器上所存放的程序时,实现第一方面任一项的车辆违法行为检测方法的步骤。The processor is configured to implement the steps of any one of the vehicle violation detection methods of the first aspect when executing the program stored in the memory.

第四方面,本发明提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现如第一方面任一项的车辆违法行为检测方法的步骤。In a fourth aspect, the present invention provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the steps of the vehicle violation detection method according to any one of the first aspect.

本发明实施例提供的上述技术方案与现有技术相比具有如下优点:Compared with the prior art, the above-mentioned technical solutions provided by the embodiments of the present invention have the following advantages:

本发明实施例提供的技术方案,不仅限于正面非机动车数据,对于多角度、多姿态、多场景下的非机动车均可检测,对于非机动车非法事件的检测清晰、明确,无需人工二次分类;且对非机动车进行了分类,可以判断非机动车的类别,确定存在违法行为的非机动车的具体类别,有利于对车辆进行监管,有效解决了现有技术中的难题。The technical solutions provided by the embodiments of the present invention are not limited to frontal non-motor vehicle data, and can detect non-motor vehicles in multi-angle, multi-pose, and multi-scenario situations, and the detection of non-motor vehicle illegal incidents is clear and definite, without the need for manual secondary The classification of non-motor vehicles is carried out, the category of non-motor vehicles can be judged, and the specific categories of non-motor vehicles with illegal acts can be determined, which is conducive to the supervision of vehicles and effectively solves the problems in the prior art.

附图说明Description of drawings

图1为本发明实施例提供的一种车辆违法行为检测方法流程示意图;1 is a schematic flowchart of a method for detecting illegal behavior of vehicles according to an embodiment of the present invention;

图2为本发明实施例提供的未戴头盔违法行为检测方法流程示意图;2 is a schematic flowchart of a method for detecting illegal behavior without a helmet provided by an embodiment of the present invention;

图3为本发明实施例提供的闯红灯违法行为检测方法流程示意图;3 is a schematic flowchart of a method for detecting illegal acts of running a red light provided by an embodiment of the present invention;

图4为本发明实施例提供的逆行违法行为检测方法流程示意图;4 is a schematic flowchart of a method for detecting a retrograde illegal act provided by an embodiment of the present invention;

图5为本发明实施例提供的占用机动车道违法行为检测方法流程示意图;5 is a schematic flowchart of a method for detecting illegal acts of occupying motor vehicle lanes provided by an embodiment of the present invention;

图6为本发明实施例提供的横穿道路违法行为检测方法流程示意图;6 is a schematic flowchart of a method for detecting violations of road crossings provided by an embodiment of the present invention;

图7为本发明实施例提供的一种车辆违法行为检测装置结构示意图;7 is a schematic structural diagram of a vehicle illegal behavior detection device provided by an embodiment of the present invention;

图8为本发明实施例提供的另一种车辆违法行为检测装置结构示意图;8 is a schematic structural diagram of another vehicle illegal behavior detection device provided by an embodiment of the present invention;

图9本发明实施例提供一种电子设备结构示意图。FIG. 9 provides a schematic structural diagram of an electronic device according to an embodiment of the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

为便于对本发明实施例的理解,下面将结合附图以具体实施例做进一步的解释说明,实施例并不构成对本发明实施例的限定。In order to facilitate the understanding of the embodiments of the present invention, further explanation will be given below with specific embodiments in conjunction with the accompanying drawings, and the embodiments do not constitute limitations to the embodiments of the present invention.

在使用车辆外出过程中,很容易出现违法事件,尤其是随着经济和交通的发展,非机动车的违法事件也日渐增多,比如未戴头盔、闯红灯、逆行、占用机动车道和横穿马路等,给交通和人身安全均造成了不良影响,针对上述问题,本发明实施例提供了一种车辆违法行为检测方法,具体参见图1所示。In the process of using vehicles to go out, it is easy to cause illegal incidents, especially with the development of economy and traffic, the illegal incidents of non-motor vehicles are also increasing day by day, such as not wearing a helmet, running a red light, running the wrong way, occupying a motor vehicle lane and crossing the road, etc. , causing adverse effects on both traffic and personal safety. In view of the above problems, an embodiment of the present invention provides a method for detecting illegal behavior of vehicles, as shown in FIG. 1 for details.

本发明提供的基于深度学习的车辆违法行为检测方法,在检测前构建相应的算法模型,具体的,首先,采集实际场景中的非机动车图像作为基础数据集,建立大规模训练数据集使其既具有非机动车各角度、场景下样本,又具有其详细特征。然后采用深度学习在训练数据集上训练适用于实际场景的非机动车检测模型。同时根据非机动车数据集,进行非机动车分类模型训练,建立非机动车种类分类模型。实际使用时,对视频流进行抽帧,然后进行非机动车检测,对于检测到的非机动车进行分类,根据实际需求对待检测种类的非机动车进行后续处理,通过跟踪算法,得到非机动车的轨迹信息,利用非机动车的轨迹信息、车道线信息、及红绿灯状态信息,对非机动车行驶过程进行监控,判断其行驶过程是否存在未戴头盔、闯红灯、逆行、占用机动车车道、横穿道路等违法行为。In the deep learning-based vehicle illegal behavior detection method provided by the present invention, a corresponding algorithm model is constructed before detection. Specifically, first, non-motor vehicle images in actual scenes are collected as a basic data set, and a large-scale training data set is established to make it It not only has samples from various angles and scenes of non-motor vehicles, but also has its detailed characteristics. Then, deep learning is used to train a non-motor vehicle detection model suitable for practical scenarios on the training dataset. At the same time, according to the non-motor vehicle data set, the non-motor vehicle classification model is trained, and the non-motor vehicle type classification model is established. In actual use, the video stream is framed, and then non-motorized vehicles are detected, the detected non-motorized vehicles are classified, and the non-motorized vehicles of the type to be detected are subsequently processed according to the actual needs, and the non-motorized vehicles are obtained through the tracking algorithm. Using the track information, lane line information, and traffic light status information of non-motor vehicles to monitor the driving process of non-motor vehicles, and determine whether there are no helmets, running red lights, running the wrong way, occupying the motor vehicle lane, crossing the road or not during the driving process. Illegal acts such as crossing the road.

除上述介绍的模型训练外,系统还构建了目标跟踪模型,下面对个别模型及其涉及到的知识点进行简单介绍:In addition to the model training described above, the system also builds a target tracking model. The following is a brief introduction to individual models and the knowledge points involved:

(1)建立非机动车检测数据集(1) Establish a non-motor vehicle detection data set

采集实际交通场景下的非机动车图片图像,从多个场景、多时间段采集多角度样本,每个图片要求目标清晰容易分辨,目标的像素值大于 100*100,构建大型非机动车检测数据集。对该非机动车数据集进行处理,比如采用多种数据增强方式,如mosaic增强、随机擦除、加入噪声等,进一步扩大数据集。针对得到的处理后的数据集,人工标定非机动车矩形框,作为训练数据集。Collect non-motor vehicle pictures and images in actual traffic scenes, and collect multi-angle samples from multiple scenes and multiple time periods. Each image requires the target to be clear and easy to distinguish, and the pixel value of the target is greater than 100*100 to construct large-scale non-motor vehicle detection data. set. The non-motor vehicle data set is processed, such as using a variety of data enhancement methods, such as mosaic enhancement, random erasure, adding noise, etc., to further expand the data set. For the obtained processed data set, the non-motor vehicle rectangular frame is manually calibrated as a training data set.

(2)非机动车检测模型训练优化(2) Non-motor vehicle detection model training optimization

基于上述(1)中得到的训练数据集,采用yolov5结构化模型,对实际应用场景下的非机动车进行模型训练,提升该模型在实际应用场景中的泛化性。Based on the training data set obtained in (1) above, the yolov5 structured model is used to train the model for non-motor vehicles in practical application scenarios to improve the generalization of the model in practical application scenarios.

具体的,yolov5结构化模型训练的基本原理是,基于大规模的预训练数据集进行微调,首先从各种场景采集大量的非机动车数据,然后基于这些数据训练一版模型得到预训练权重,当模型要部署到新的场景时,从该场景收集少量的包含非机动车的数据,然后在已有的预训练权重上进行微调,由于预训练权重是基于不同的场景数据训练的,保证了数据的多样性,可以大幅提高模型的泛化能力,而基于特定场景的微调也进一步提升模型在该场景下的表现能力。Specifically, the basic principle of yolov5 structured model training is to perform fine-tuning based on large-scale pre-training data sets. First, collect a large amount of non-motor vehicle data from various scenes, and then train a version of the model based on these data to obtain pre-training weights. When the model is to be deployed to a new scene, a small amount of data including non-motor vehicles is collected from the scene, and then fine-tuned on the existing pre-training weights. Since the pre-training weights are trained based on different scene data, it is guaranteed that The diversity of data can greatly improve the generalization ability of the model, and the fine-tuning based on a specific scene also further improves the performance of the model in this scene.

(3)构建非机动车分类数据集(3) Constructing a non-motor vehicle classification dataset

基于上述(1)中的训练数据集,裁剪非机动车区域得到大量的缩略图,然后按照非机动车的不同种类进行划分,最终获得不同种类的非机动车分类数据集。Based on the training data set in (1) above, crop the non-motor vehicle area to obtain a large number of thumbnails, and then divide them according to different types of non-motor vehicles, and finally obtain different types of non-motor vehicle classification data sets.

(4)非机动车种类分类模型训练优化(4) Non-motor vehicle type classification model training optimization

以获得不同种类的非机动车分类数据集为训练数据集,采用 EfficientNet-b5分类模型进行训练,同时为解决数据集类别之间存在的失衡问题,因此使用focal loss作为训练的损失函数,为了确保模型学习到正确的特征,使用grad-cam可视化卷积的最后一层来理解模型在分类时最关注的特征区域。In order to obtain different types of non-motor vehicle classification data sets as training data sets, the EfficientNet-b5 classification model is used for training. At the same time, in order to solve the imbalance problem between data set categories, focal loss is used as the training loss function. In order to ensure that The model learns the correct features, and grad-cam is used to visualize the last layer of the convolution to understand the feature regions that the model pays most attention to when classifying.

在分类模型中也同时加入了位置注意力(spatial attention)模块,注意力模块可以捕捉对分类结果更有利的特征,如不同种类的非机动车中车身各个部分存在一些细节的差异,而使用注意力模块使模型更关注这些区域的特征从而更有利于最终的分类效果。A spatial attention module is also added to the classification model. The attention module can capture features that are more favorable to the classification results. For example, there are some differences in details in various parts of the body in different types of non-motor vehicles. The force module makes the model pay more attention to the features of these regions and is more conducive to the final classification effect.

为了解决数据集的类别不平衡问题,这里使用聚焦损失(focal loss),由于待分类的非机动车有多种种类,因此这里将二分类的focal loss修改为多分类的focal loss,然后使用相应类别样本数量的相关权重来进一步优化该损失,从而提高样本数量少的类别和困难样本在训练模型中的比重,最终保持各个类别准确率的平衡。In order to solve the problem of class imbalance in the dataset, focal loss is used here. Since there are many types of non-motor vehicles to be classified, the focal loss of two classifications is modified to the focal loss of multiclassification, and then the corresponding focal loss is used. The relevant weight of the number of class samples is used to further optimize the loss, thereby increasing the proportion of classes with a small number of samples and difficult samples in the training model, and finally maintaining the balance of the accuracy of each class.

同时在分类模型的训练过程中加入了标签平滑(label smooth)、随机权重平均(Stochastic Weight Averaging)和余弦学习率衰减等方式来提升模型的泛化能力。At the same time, label smoothing, Stochastic Weight Averaging and cosine learning rate decay are added in the training process of the classification model to improve the generalization ability of the model.

(5)目标跟踪模型(5) Target tracking model

在整个违法事件检测系统中跟踪模型是核心模块,这里使用的是 DeepSort多目标跟踪模型,该模型主要分为两个部分(1)Reid外观重识别模型部分(2)Sort轨迹分配部分The tracking model is the core module in the entire illegal event detection system. The DeepSort multi-target tracking model is used here. The model is mainly divided into two parts (1) Reid appearance re-identification model part (2) Sort trajectory allocation part

1.reid重识别模型1.reid re-identification model

Reid重识别模型常应用于跨摄像头行人重识别中,该模型可以识别不同对象的外观特征并用特定的向量来表征,然后通过比较特征向量间的距离来判断不同对象的相似程度,在此处的非机动车违法事件检测中只需要对同一个摄像头设备下非机动车进行识别即可,因此首先构建同一摄像头设备下的非机动车Reid数据集,然后基于这些数据重新训练Reid模型,在Reid模型中使用Resnet50作为骨干网络,并使用512维度的特征向量来表征物体,最终的效果是相同的非机动车间特征向量的距离远小于不同的非机动车间的特征向量距离。The Reid re-identification model is often used in cross-camera pedestrian re-identification. This model can identify the appearance features of different objects and represent them with specific vectors, and then judge the similarity of different objects by comparing the distances between the feature vectors. In the detection of non-motor vehicle violations, it is only necessary to identify non-motor vehicles under the same camera device. Therefore, first build a non-motor vehicle Reid data set under the same camera device, and then retrain the Reid model based on these data. Resnet50 is used as the backbone network, and 512-dimensional feature vectors are used to characterize objects. The final effect is that the distance between the feature vectors of the same non-motor vehicle is much smaller than the distance between the feature vectors of different non-motor vehicles.

2.Sort轨迹分配部分2. Sort track assignment part

在Sort部分中使用了卡尔曼滤波和匈牙利匹配算法,卡尔曼滤波根据线性运动模型来更新对象轨迹的位置等相关信息,而匈牙利匹配则负责轨迹框和检测框的匹配问题,这里主要是针对特定场景对运动模型的状态方程进行调整,使用运动对象的中心点、宽高比以及高度作为运动模型的状态空间参数,并对位置和速度参数进行整定,从而对当前场景下非机动车的运动进行更精确的建模。In the Sort part, the Kalman filter and the Hungarian matching algorithm are used. The Kalman filter updates the position and other related information of the object trajectory according to the linear motion model, while the Hungarian matching is responsible for the matching of the trajectory frame and the detection frame. The scene adjusts the state equation of the motion model, uses the center point, aspect ratio and height of the moving object as the state space parameters of the motion model, and adjusts the position and speed parameters, so as to adjust the motion of the non-motor vehicle in the current scene. More accurate modeling.

在匈牙利匹配中使用对象之间的特征相似性、交并比IOU和马氏距离来更精确地匹配跟踪框和检测框,从而提高跟踪的准确性。Feature similarity and intersection between objects are used in Hungarian matching to match tracking and detection boxes more accurately than IOU and Mahalanobis distance, thereby improving tracking accuracy.

此外,除上述涉及到的模型外,本发明还涉及到用以识别车头、车尾等非机动车属性的多属性分类模型、用以对红绿灯进行分类的红绿灯分类模型及非机动车驾驶员未戴头盔检测模型,这里就不在一一赘述。In addition, in addition to the above-mentioned models, the present invention also relates to a multi-attribute classification model for identifying attributes of non-motor vehicles such as the front and rear of a vehicle, a traffic light classification model for classifying traffic lights, and non-motor vehicle drivers Wearing a helmet detection model will not be repeated here.

在详细介绍上述描述的模型推理前,先介绍,车辆违法行为检测系统用到的模型及用途汇总,具体如表1:Before introducing the model reasoning described above in detail, first introduce the models and their uses used by the vehicle violation detection system, as shown in Table 1:

表1车辆违法行为检测系统用到的模型及用途汇总Table 1 Summary of models and uses used in the vehicle violation detection system

模型名称model name 用途use Yolov5s结构化模型Yolov5s structured model 检测非机动车Detection of non-motor vehicles Efficientnet-b5分类模型Efficientnet-b5 classification model 识别不同种类的非机动车Identify different types of non-motorized vehicles DeepSort模型DeepSort model 多目标跟踪multi-target tracking Yolov5s头盔检测模型Yolov5s helmet detection model 未戴头盔检测No helmet detection Mobilenet分类模型Mobilenet classification model 红绿灯分类Classification of traffic lights resnet50多属性分类模型resnet50 multi-attribute classification model 识别非机动车车头、车尾等属性 Identify attributes such as front and rear of non-motor vehicles

使用tensorrt作为模型的推理后端优化模型的推理速度并降低对显存资源的消耗,并使用多进程和多线程技术优化违法事件检测的判断逻辑,从而进一步优化整个系统的执行效率,最终提高系统的并发性能,当前待检测种类的非机动车违法事件检测系统在Tesla P4上测试的平均检测速度为52.35ms。Use tensorrt as the inference backend of the model to optimize the inference speed of the model and reduce the consumption of video memory resources, and use multi-process and multi-thread technology to optimize the judgment logic of illegal event detection, so as to further optimize the execution efficiency of the entire system and ultimately improve the system. Concurrent performance, the average detection speed of the current non-motor vehicle violation detection system to be detected on Tesla P4 is 52.35ms.

下面详细介绍本发明提供的一种车辆违法行为检测方法,具体的,图 1为本发明实施例提供的一种车辆违法行为检测方法流程示意图,如图1 所示,该方法由车辆违法行为检测系统执行,该方法步骤具体包括:A method for detecting illegal behavior of vehicles provided by the present invention is described in detail below. Specifically, FIG. 1 is a schematic flowchart of a method for detecting illegal behaviors of vehicles provided by an embodiment of the present invention. As shown in FIG. The system executes, and the method steps specifically include:

步骤110,获取目标场景的视频帧数据。Step 110, acquiring video frame data of the target scene.

步骤120,基于视频帧数据,获得目标场景中非机动车的轨迹信息。Step 120 , based on the video frame data, obtain the track information of the non-motor vehicle in the target scene.

具体的,使用Yolov5s结构化模型检测当前场景中的非机动车,若存在非机动车,则使用Efficientnet-b5分类模型识别非机动车的分类信息,确定非机动车的具体类别。场景中出现待检测类别的非机动车,则系统进入跟踪状态,并使用DeepSort算法进行非机动车目标跟踪,最后得到完整的非机动车轨迹信息,这里的轨迹信息包括当前非机动车的轨迹编号、非机动车的跟踪框信息,非机动车的缩略图数据及当前所非机动车的分类信息,如果当前场景中没有非机动车,系统进入检测状态,只有当系统处于跟踪状态时,才对非机动车进行跟踪。Specifically, the Yolov5s structured model is used to detect non-motor vehicles in the current scene. If there are non-motor vehicles, the Efficientnet-b5 classification model is used to identify the classification information of non-motor vehicles and determine the specific category of non-motor vehicles. When a non-motor vehicle of the category to be detected appears in the scene, the system enters the tracking state, and uses the DeepSort algorithm to track the non-motor vehicle target, and finally obtains the complete non-motor vehicle trajectory information, where the trajectory information includes the current non-motor vehicle track number. , the tracking frame information of non-motor vehicles, the thumbnail data of non-motor vehicles and the classification information of the current non-motor vehicles. If there is no non-motor vehicle in the current scene, the system enters the detection state. Only when the system is in the tracking state, will the Non-motorized vehicles are tracked.

系统在跟踪状态时获取了各个非机动车的轨迹信息,而每个非机动车都有唯一的轨迹号,即轨迹编号,因此,可以减少时序视频帧车辆信息的重复利用达到去重的目的,根据轨迹信息并结合逻辑判断等方式可以判断非机动车存在的违法行为。The system obtains the track information of each non-motor vehicle in the tracking state, and each non-motor vehicle has a unique track number, that is, the track number. Therefore, it can reduce the reuse of vehicle information in time series video frames to achieve the purpose of deduplication. According to the trajectory information combined with logical judgment, the illegal behavior of non-motor vehicles can be judged.

步骤130,基于轨迹信息,判断非机动车的违法行为。Step 130, based on the trajectory information, determine the illegal behavior of the non-motor vehicle.

在对违法行为的检测进行介绍前,先对非机动车的轨迹信息进行简单说明,如上面介绍,轨迹信息包括:非机动车的轨迹编号、跟踪框数据、缩略图数据和非机动车的分类信息,其中,跟踪框数据包括每帧中非机动车的中心坐标点信息,因此可以通过跟踪框数据,获得非机动车的每帧的轨迹点,以及非机动车的轨迹线。Before introducing the detection of illegal behaviors, the track information of non-motor vehicles is briefly explained. As described above, the track information includes: track numbers of non-motor vehicles, tracking frame data, thumbnail data and classification of non-motor vehicles. information, wherein the tracking frame data includes the center coordinate point information of the non-motor vehicle in each frame, so the track point of each frame of the non-motor vehicle and the trajectory line of the non-motor vehicle can be obtained through the tracking frame data.

非机动车的违法行为包括:非机动车的驾驶员未佩戴头盔、非机动车闯红灯、非机动车逆行、非机动车占用机动车道、非机动车横穿道路,下面对每种违法行为的检测进行介绍:The violations of non-motor vehicles include: non-motor vehicles drivers do not wear helmets, non-motor vehicles run red lights, non-motor vehicles run the wrong way, non-motor vehicles occupy motor vehicle lanes, non-motor vehicles cross the road, and the following are the penalties for each illegal act. Introduce the detection:

(1)未佩戴头盔检测(1) Detection of not wearing a helmet

图2是本发明实施例提供的未戴头盔违法行为检测方法流程示意图,如图2所示,对未佩戴头盔的违法行为的检测步骤为:Fig. 2 is a schematic flowchart of a method for detecting illegal behavior without a helmet provided by an embodiment of the present invention. As shown in Fig. 2, the steps for detecting an illegal behavior without wearing a helmet are:

步骤210,基于缩略图数据,进行头盔检测。Step 210, based on the thumbnail data, perform helmet detection.

步骤220,若未检测到头盔,则获取非机动车驾驶员的头部图像;Step 220, if the helmet is not detected, obtain the head image of the non-motor vehicle driver;

步骤230,对头部头像进行灰度值分析;Step 230, performing gray value analysis on the head portrait;

步骤240,若分析结果满足预设阈值,则判断非机动车的驾驶员存在未戴头盔违法行为。Step 240, if the analysis result satisfies the preset threshold, it is determined that the driver of the non-motor vehicle has an illegal act of not wearing a helmet.

具体的,基于对应轨迹编号的非机动车的缩略图数据,使用yolov5模型进行头盔检测,如果检测到头盔就直接返回,如果没有检测到头盔,为防止检测错误,会进行第二次识别,获取非机动车驾驶员的头部图像,利用图像灰度直方图对驾驶员头部图像进行灰度值分析,如果其直方图分布满足预设的阈值,则表示该分布与未戴头盔的特征分布一致,直接输出未戴头盔事件,即判断非机动车的驾驶员存在未戴头盔违法行为。Specifically, based on the thumbnail data of the non-motor vehicle corresponding to the track number, the yolov5 model is used for helmet detection. If the helmet is detected, it will return directly. If the helmet is not detected, in order to prevent detection errors, a second identification will be performed to obtain For the head image of a non-motor vehicle driver, use the image grayscale histogram to analyze the gray value of the driver's head image. If the histogram distribution satisfies the preset threshold, it means the distribution and the characteristic distribution of the non-helmeted Consistent, the event of not wearing a helmet is directly output, that is, it is judged that the driver of a non-motor vehicle has an illegal act of not wearing a helmet.

(2)闯红灯检测(2) Detection of running a red light

图3为本发明实施例提供的闯红灯违法行为检测方法流程示意图,如图3所示,对闯红灯的违法行为的检测步骤为:3 is a schematic flowchart of a method for detecting the illegal behavior of running a red light provided by an embodiment of the present invention. As shown in FIG. 3 , the detection steps for the illegal behavior of running a red light are:

步骤310,根据跟踪框信息,获得非机动车的轨迹点。Step 310: Obtain the track points of the non-motor vehicle according to the tracking frame information.

步骤320,基于视频帧数据,获得目标场景中的车道停止线和红绿灯状态。Step 320, based on the video frame data, obtain the lane stop line and the traffic light status in the target scene.

步骤330,在红灯状态下,若轨迹点依次出现在车道停止线内,跨过车道停止线及出现在对面路口,则判断非机动车存在闯红灯的违法行为。Step 330: In the red light state, if the trajectory points appear in the lane stop line, cross the lane stop line, and appear at the opposite intersection in sequence, it is determined that the non-motor vehicle has an illegal act of running a red light.

具体的,从视频帧数据中预先获取目标场景中红路灯区域信息并裁剪得到红路灯图像,并使用Mobilenet分类模型识别红绿灯类别,如果当前状态为红灯,则进行后续的闯红灯判断,否则直接返回。Specifically, the information of the red street light area in the target scene is obtained in advance from the video frame data, and the red street light image is obtained by cropping, and the Mobilenet classification model is used to identify the traffic light category. If the current state is a red light, the subsequent red light running judgment is performed, otherwise, it returns directly. .

根据对应轨迹编号的坐标点信息,依次判断轨迹点是否出现在非机动车的车道停止线内、跨过车道停止线、出现在对面的路口,如果三个条件全满足并且整个过程中都是红灯,则判定为闯红灯,并输出事件。即判断非机动车存在在闯红灯的违法行为。According to the coordinate point information of the corresponding track number, it is judged whether the track point appears in the lane stop line of non-motor vehicles, crosses the lane stop line, and appears at the opposite intersection. If all three conditions are satisfied and the whole process is red If the light is on, it is judged to be running a red light, and an event is output. That is, it is judged that there is an illegal act of running a red light by a non-motor vehicle.

(3)逆行检测(3) Retrograde detection

图4为本发明实施例提供的逆行违法行为检测方法流程示意图,如图 4所示,对逆行的违法行为的检测步骤为:FIG. 4 is a schematic flowchart of a method for detecting retrograde illegal acts provided by an embodiment of the present invention. As shown in FIG. 4 , the steps for detecting retrograde illegal acts are:

步骤410,基于视频帧数据,获得目标场景中的车道线信息。Step 410 , obtain lane line information in the target scene based on the video frame data.

步骤420,根据车道线信息,预设车道方向线。Step 420, preset lane direction lines according to lane line information.

步骤430,根据跟踪框信息,获得非机动车的轨迹线。Step 430: Obtain the trajectory line of the non-motor vehicle according to the tracking frame information.

步骤440,计算轨迹线和预设车道方向线的夹角。Step 440: Calculate the angle between the trajectory line and the preset lane direction line.

步骤450,根据缩略图数据,识别非机动车的车头朝向。Step 450 , according to the thumbnail data, identify the head direction of the non-motor vehicle.

步骤460,若非机动车的车头朝向与车道方向线方向相反,且夹角大于预设阈值,则判断非机动车存在逆行违法行为。Step 460: If the head of the non-motor vehicle is facing in the opposite direction to the direction line of the lane, and the included angle is greater than the preset threshold, it is determined that the non-motor vehicle has a wrong-way violation.

具体的,获得非机动车的轨迹线和缩略图数据,根据目标场景中车道的实际方向来预设车道方向线,即根据实际场景中的车道线信息,来预设车道线方向,然后计算轨迹线和车道方向线的夹角,如果夹角大于预先设置的阈值,则继续判断,否则直接返回。使用resnet50多属性分类模型来识别非机动车是否为车头或车尾,如果车头的朝向与车道方向线方向相反,并且前面计算的预设阈值,则输出逆行事件,即为判断非机动车存在逆行违法行为,否则直接返回。Specifically, the trajectory line and thumbnail data of the non-motor vehicle are obtained, the lane direction line is preset according to the actual direction of the lane in the target scene, that is, the lane line direction is preset according to the lane line information in the actual scene, and then the trajectory is calculated. The angle between the line and the lane direction line, if the angle is greater than the preset threshold, continue to judge, otherwise return directly. Use the resnet50 multi-attribute classification model to identify whether the non-motor vehicle is the front or the rear of the vehicle. If the direction of the front of the vehicle is opposite to the direction of the lane direction line, and the preset threshold calculated earlier, the retrograde event will be output, which is to judge that the non-motor vehicle has retrograde Illegal behavior, otherwise return directly.

(4)占用机动车道检测(4) Occupied motor vehicle lane detection

图5为本发明实施例提供的占用机动车道违法行为检测方法流程示意图,如5所示,对逆行的违法行为的检测步骤为:5 is a schematic flow chart of a method for detecting illegal acts of occupying motor vehicle lanes provided by an embodiment of the present invention. As shown in 5, the steps for detecting illegal acts in the wrong direction are:

步骤510,基于视频帧数据,确定目标场景中的机动车道。Step 510, based on the video frame data, determine a motor vehicle lane in the target scene.

步骤520,根据跟踪框信息,获得非机动车的轨迹点。Step 520: Obtain the track points of the non-motor vehicle according to the tracking frame information.

步骤530,分析轨迹点和机动车道的位置。Step 530, analyze the position of the track point and the vehicle lane.

步骤540,若轨迹点出现在机动车道内,则判断非机动车存在占用机动车道的违法行为。Step 540, if the trajectory point appears in the motor vehicle lane, it is determined that the non-motor vehicle has an illegal act of occupying the motor vehicle lane.

具体的,根据机动车道的实际位置预先设置机动车道区域多边形框,然后判断非机动车的轨迹点是否出现在机动车道框内,如果出现则表示占用机动车道,输出违法事件,即判断非机动车存在占用机动车道的违法行为,否则直接返回。Specifically, the polygon frame of the motor vehicle lane area is preset according to the actual position of the motor vehicle lane, and then it is judged whether the track point of the non-motor vehicle appears in the motor vehicle lane frame. There is an illegal act of occupying the motor vehicle lane, otherwise, return directly.

(5)横穿道路检测(5) Cross-road detection

图6为本发明实施例提供的横穿道路违法行为检测方法流程示意图,如图6所示,对横穿道路的违法行为的检测步骤为:FIG. 6 is a schematic flowchart of a method for detecting illegal behaviors crossing roads provided by an embodiment of the present invention. As shown in FIG. 6 , the steps for detecting illegal behaviors crossing roads are:

步骤610,基于视频帧数据,确定目标场景中的机动车道。Step 610, based on the video frame data, determine a motor vehicle lane in the target scene.

步骤620,根据跟踪框信息,获得非机动车的轨迹点。Step 620: Obtain the track points of the non-motor vehicle according to the tracking frame information.

步骤630,分析轨迹点和机动车道的位置。Step 630, analyze the position of the track point and the vehicle lane.

步骤640,若轨迹点出现在机动车道内,则计算轨迹点占用机动车道的数量;Step 640, if the trajectory point appears in the motor vehicle lane, calculate the number of the motor vehicle lane occupied by the trajectory point;

步骤650,若数量大于预设阈值,则判断非机动车存在横穿道路的违法行为。Step 650, if the number is greater than the preset threshold, it is determined that the non-motor vehicle has an illegal act of crossing the road.

具体的,根据机动车道的实际位置为每个车道设置单独的多边形框,然后判断非机动车的轨迹点在各个机动车车道的占用情况,如果占用车道的数量大于设定的阈值则表示车辆横穿了道路,直接输出违法事件,即为判断非机动车存在横穿道路的违法行为,否则直接输出。Specifically, a separate polygon frame is set for each lane according to the actual position of the motor vehicle lane, and then the occupancy of the track points of non-motor vehicles in each motor vehicle lane is determined. If the number of occupied lanes is greater than the set threshold, it means that the vehicle lateral After crossing the road, the illegal events are directly output, that is, it is judged that the non-motor vehicle has the illegal behavior of crossing the road, otherwise it is directly output.

在一个示例中,在根据非机动车的轨迹信息,判断非机动车的违法行为之后,还包括:根据非机动车的分类信息,确定存在违法行为的非机动车类别。即可以根据非机动车的分类信息,确定存在违法行为的非机动车的具体类别。In an example, after judging the illegal behavior of the non-motor vehicle according to the track information of the non-motor vehicle, the method further includes: determining the category of the non-motor vehicle with the illegal behavior according to the classification information of the non-motor vehicle. That is, according to the classification information of non-motor vehicles, the specific categories of non-motor vehicles with illegal acts can be determined.

本发明实施例提供的检测方法,该方法不仅限于正面非机动车数据,对于多角度、多姿态、多场景下的非机动车均可检测,对于非机动车非法事件的检测清晰、明确,无需人工二次分类;且该方法对非机动车进行了分类,可以判断非机动车的类别,确定存在违法行为的非机动车的具体类别,有利于对特定种类的非机动车辆进行监管,有效解决了现有技术中的难题。The detection method provided by the embodiment of the present invention is not limited to frontal non-motor vehicle data, but can detect non-motor vehicles in multi-angle, multi-pose, and multi-scenario situations, and the detection of non-motor vehicle illegal events is clear and clear, without the need for Manual secondary classification; and this method classifies non-motor vehicles, can determine the category of non-motor vehicles, and determine the specific category of non-motor vehicles that have illegal acts, which is conducive to the supervision of specific types of non-motor vehicles and effectively solves the problem. problems in the prior art.

以上,为本发明所提供的车辆违法行为检测方法实施例,下文中则介绍说明本发明所提供的车辆违法行为检测其他实施例,具体参见如下。The above are the embodiments of the vehicle illegal behavior detection method provided by the present invention, and the following describes other embodiments of the vehicle illegal behavior detection provided by the present invention. For details, refer to the following.

图7为本发明实施例提供的一种车辆违法行为检测装置结构示意图,该装置包括:视频帧数据模块701、轨迹信息模块702,以及违法行为判断模块703。FIG. 7 is a schematic structural diagram of a vehicle illegal behavior detection device according to an embodiment of the present invention. The device includes: a video frame data module 701 , a trajectory information module 702 , and an illegal behavior judgment module 703 .

视频帧数据模块701:用于获取目标场景的视频帧数据;Video frame data module 701: used to obtain video frame data of the target scene;

轨迹信息模块702,用于基于视频帧数据,获得目标场景中非机动车的轨迹信息;A trajectory information module 702, configured to obtain the trajectory information of the non-motor vehicle in the target scene based on the video frame data;

违法行为判断模块703,用于基于轨迹信息,判断非机动车的违法行为。The illegal behavior judgment module 703 is used for judging the illegal behavior of the non-motor vehicle based on the trajectory information.

违法行为判断模块703具体用于:The illegal behavior judgment module 703 is specifically used for:

基于缩略图数据,进行头盔检测;Based on the thumbnail data, perform helmet detection;

若未检测到头盔,则获取非机动车驾驶员的头部图像;If the helmet is not detected, obtain the head image of the non-motor vehicle driver;

对头部图像进行灰度值分析;Perform gray value analysis on the head image;

若分析结果满足预设阈值,则判断非机动车的驾驶员存在未戴头盔违法行为。If the analysis result satisfies the preset threshold, it is determined that the driver of the non-motor vehicle has an illegal act of not wearing a helmet.

违法行为判断模块703具体用于:The illegal behavior judgment module 703 is specifically used for:

根据跟踪框信息,获得非机动车的轨迹点;Obtain the track points of non-motor vehicles according to the tracking frame information;

基于视频帧数据,获得目标场景中的车道停止线和红绿灯状态;Obtain the lane stop line and traffic light status in the target scene based on the video frame data;

在红灯状态下,若轨迹点依次出现在车道停止线内,跨过车道停止线及出现在对面路口,则判断非机动车存在闯红灯的违法行为。In the red light state, if the trajectory points appear in the lane stop line in turn, cross the lane stop line and appear at the opposite intersection, it is judged that the non-motor vehicle has an illegal act of running a red light.

违法行为判断模块703具体用于:The illegal behavior judgment module 703 is specifically used for:

基于视频帧数据,获得目标场景中的车道线信息;Obtain the lane line information in the target scene based on the video frame data;

根据车道线信息,预设车道方向线;According to the lane line information, preset the lane direction line;

根据跟踪框信息,获得非机动车的轨迹线;Obtain the track line of the non-motor vehicle according to the tracking frame information;

计算轨迹线和预设车道方向线的夹角;Calculate the angle between the track line and the preset lane direction line;

根据缩略图数据,识别非机动车的车头朝向;Identify the head direction of the non-motor vehicle according to the thumbnail data;

若非机动车的车头朝向与车道方向线方向相反,且夹角大于预设阈值,则判断非机动车存在逆行违法行为。If the front direction of the non-motor vehicle is opposite to the direction of the lane direction line, and the included angle is greater than the preset threshold, it is determined that the non-motor vehicle has a wrong-way violation.

违法行为判断模块703具体用于:The illegal behavior judgment module 703 is specifically used for:

基于视频帧数据,确定目标场景中的机动车道;Determine the motor vehicle lane in the target scene based on the video frame data;

根据跟踪框信息,获得非机动车的轨迹点;Obtain the track points of non-motor vehicles according to the tracking frame information;

分析轨迹点和机动车道的位置;Analyze the location of trajectory points and motor vehicle lanes;

若轨迹点出现在机动车道内,则判断非机动车存在占用机动车道的违法行为。If the trajectory point appears in the motor vehicle lane, it is judged that the non-motor vehicle has the illegal act of occupying the motor vehicle lane.

违法行为判断模块703具体用于:The illegal behavior judgment module 703 is specifically used for:

基于视频帧数据,确定目标场景中的机动车道;Determine the motor vehicle lane in the target scene based on the video frame data;

根据跟踪框信息,获得非机动车的轨迹点;Obtain the track points of non-motor vehicles according to the tracking frame information;

分析轨迹点和机动车道的位置;Analyze the location of trajectory points and motor vehicle lanes;

若轨迹点出现在机动车道内,则计算轨迹点占用机动车道的数量;If the trajectory point appears in the motor vehicle lane, calculate the number of the motor vehicle lane occupied by the trajectory point;

若数量大于预设阈值,则判断非机动车存在横穿道路的违法行为。If the number is greater than the preset threshold, it is determined that the non-motor vehicle has an illegal act of crossing the road.

在一个示例中,图8为本发明实施例提供的另一种车辆违法行为检测装置结构示意图,如图8所示,该装置还包括确定模块704,用于根据非机动车的分类信息,确定存在违法行为的非机动车类别。In an example, FIG. 8 is a schematic structural diagram of another vehicle illegal behavior detection device provided by an embodiment of the present invention. As shown in FIG. 8 , the device further includes a determination module 704 for determining, according to the classification information of non-motor vehicles, The category of non-motor vehicles with violations.

本发明实施例提供的车辆违法行为检测装置中各部件所执行的功能均已在上述任一方法实施例中做了详细的描述,因此这里不再赘述。The functions performed by each component in the device for detecting illegal behavior of vehicles provided in the embodiments of the present invention have been described in detail in any of the above method embodiments, and therefore are not repeated here.

本发明实施例提供的一种车辆违法行为检测装置,不仅限于正面非机动车数据,对于多角度、多姿态、多场景下的非机动车均可检测,对于非机动车非法事件的检测清晰、明确,无需人工二次分类;且对非机动车进行了分类,可以判断非机动车的类别,确定存在违法行为的非机动车具体类别,有利于对特定种类的非机动车辆进行监管,有效解决了现有技术中的难题。The vehicle illegal behavior detection device provided by the embodiment of the present invention is not limited to frontal non-motor vehicle data, but can detect non-motor vehicles in multi-angle, multi-pose, and multi-scenario situations, and can detect non-motor vehicle illegal events clearly and accurately. It is clear that there is no need for manual secondary classification; and the classification of non-motor vehicles can determine the category of non-motor vehicles and determine the specific categories of non-motor vehicles with illegal acts, which is conducive to the supervision of specific types of non-motor vehicles and effectively solve the problem. problems in the prior art.

图9本发明实施例提供一种电子设备结构示意图,如图9所示,本发明实施例提供了一种电子设备,电子设备包括处理器111、通信接口112、存储器113和通信总线114,其中,处理器111,通信接口112,存储器113 通过通信总线114完成相互间的通信。FIG. 9 provides a schematic structural diagram of an electronic device according to an embodiment of the present invention. As shown in FIG. 9 , an embodiment of the present invention provides an electronic device. The electronic device includes a processor 111 , a communication interface 112 , a memory 113 and a communication bus 114 , wherein , the processor 111 , the communication interface 112 , and the memory 113 communicate with each other through the communication bus 114 .

存储器113,用于存放计算机程序;a memory 113 for storing computer programs;

在本发明一个实施例中,处理器111,用于执行存储器113上所存放的程序时,实现前述任意一个方法实施例提供的车辆违法行为检测方法,包括:In an embodiment of the present invention, the processor 111 is configured to implement the vehicle illegal behavior detection method provided by any one of the foregoing method embodiments when executing the program stored in the memory 113, including:

获取目标场景的视频帧数据;Get the video frame data of the target scene;

基于视频帧数据,获得目标场景中非机动车的轨迹信息;Based on the video frame data, obtain the trajectory information of the non-motor vehicle in the target scene;

基于轨迹信息,判断非机动车的违法行为。Based on the trajectory information, determine the illegal behavior of non-motor vehicles.

可选地,轨迹信息包括非机动车的缩略图数据;基于轨迹信息,判断非机动车的违法行为,具体包括:Optionally, the trajectory information includes thumbnail data of non-motor vehicles; based on the trajectory information, the illegal behavior of non-motor vehicles is determined, specifically including:

基于缩略图数据,进行头盔检测;Based on the thumbnail data, perform helmet detection;

若未检测到头盔,则获取非机动车驾驶员的头部图像;If the helmet is not detected, obtain the head image of the non-motor vehicle driver;

对头部图像进行灰度值分析;Perform gray value analysis on the head image;

若分析结果满足预设阈值,则判断非机动车的驾驶员存在未戴头盔违法行为。If the analysis result satisfies the preset threshold, it is determined that the driver of the non-motor vehicle has an illegal act of not wearing a helmet.

可选地,轨迹信息包括非机动车的跟踪框信息;基于轨迹信息,判断非机动车的违法行为,具体包括:Optionally, the trajectory information includes the tracking frame information of the non-motor vehicle; based on the trajectory information, the illegal behavior of the non-motor vehicle is determined, specifically including:

根据跟踪框信息,获得非机动车的轨迹点;Obtain the track points of non-motor vehicles according to the tracking frame information;

基于视频帧数据,获得目标场景中的车道停止线和红绿灯状态;Obtain the lane stop line and traffic light status in the target scene based on the video frame data;

在红灯状态下,若轨迹点依次出现在车道停止线内,跨过车道停止线及出现在对面路口,则判断非机动车存在闯红灯的违法行为。In the red light state, if the trajectory points appear in the lane stop line in turn, cross the lane stop line and appear at the opposite intersection, it is judged that the non-motor vehicle has an illegal act of running a red light.

可选地,轨迹信息包括跟踪框信息和缩略图数据;基于轨迹信息,判断非机动车的违法行为,具体包括:Optionally, the track information includes tracking frame information and thumbnail data; based on the track information, the illegal behavior of non-motor vehicles is determined, specifically including:

基于视频帧数据,获得目标场景中的车道线信息;Obtain the lane line information in the target scene based on the video frame data;

根据车道线信息,预设车道方向线;According to the lane line information, preset the lane direction line;

根据跟踪框信息,获得非机动车的轨迹线;Obtain the track line of the non-motor vehicle according to the tracking frame information;

计算轨迹线和预设车道方向线的夹角;Calculate the angle between the track line and the preset lane direction line;

根据缩略图数据,识别非机动车的车头朝向;Identify the head direction of the non-motor vehicle according to the thumbnail data;

若非机动车的车头朝向与车道方向线方向相反,且夹角大于预设阈值,则判断非机动车存在逆行违法行为。If the front direction of the non-motor vehicle is opposite to the direction of the lane direction line, and the included angle is greater than the preset threshold, it is determined that the non-motor vehicle has a wrong-way violation.

可选地,轨迹信息包括跟踪框信息;基于轨迹信息,判断非机动车的违法行为,具体包括:Optionally, the track information includes tracking frame information; based on the track information, the illegal behavior of the non-motor vehicle is determined, specifically including:

基于视频帧数据,确定目标场景中的机动车道;Determine the motor vehicle lane in the target scene based on the video frame data;

根据跟踪框信息,获得非机动车的轨迹点;Obtain the track points of non-motor vehicles according to the tracking frame information;

分析轨迹点和机动车道的位置;Analyze the location of trajectory points and motor vehicle lanes;

若轨迹点出现在机动车道内,则判断非机动车存在占用机动车道的违法行为。If the trajectory point appears in the motor vehicle lane, it is judged that the non-motor vehicle has the illegal act of occupying the motor vehicle lane.

可选地,轨迹信息包括跟踪框信息;基于轨迹信息,判断非机动车的违法行为,具体包括:Optionally, the track information includes tracking frame information; based on the track information, the illegal behavior of the non-motor vehicle is determined, specifically including:

基于视频帧数据,确定目标场景中的机动车道;Determine the motor vehicle lane in the target scene based on the video frame data;

根据跟踪框信息,获得非机动车的轨迹点;Obtain the track points of non-motor vehicles according to the tracking frame information;

分析轨迹点和机动车道的位置;Analyze the location of trajectory points and motor vehicle lanes;

若轨迹点出现在机动车道内,则计算轨迹点占用机动车道的数量;If the trajectory point appears in the motor vehicle lane, calculate the number of the motor vehicle lane occupied by the trajectory point;

若数量大于预设阈值,则判断非机动车存在横穿道路的违法行为。If the number is greater than the preset threshold, it is determined that the non-motor vehicle has an illegal act of crossing the road.

可选地,轨道信息包括非机动车的分类信息;在基于轨迹信息,判断非机动车的违法行为之后还包括:Optionally, the track information includes classification information of non-motor vehicles; after judging the illegal behavior of non-motor vehicles based on the track information, it also includes:

根据非机动车的分类信息,确定存在违法行为的非机动车所属平台。本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现如前述任意一个方法实施例提供的车辆违法行为检测方法的步骤。According to the classification information of non-motor vehicles, determine the platform to which the non-motor vehicles that have violated the law belong. Embodiments of the present invention further provide a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the steps of the vehicle violation detection method provided by any one of the foregoing method embodiments.

需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as "first" and "second" etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these There is no such actual relationship or sequence between entities or operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion such that a process, method, article or device comprising a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article, or device that includes the element.

以上仅是本发明的具体实施方式,使本领域技术人员能够理解或实现本发明。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所申请的原理和新颖特点相一致的最宽的范围。The above are only specific embodiments of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims (10)

1. A vehicle violation detection method performed by a vehicle violation detection system, the method comprising:
acquiring video frame data of a target scene;
obtaining track information of the non-motor vehicle in the target scene based on the video frame data;
and judging the illegal behaviors of the non-motor vehicle based on the track information.
2. The method of claim 1, wherein the trajectory information includes thumbnail data of the non-motor vehicle; the judging of the illegal action of the non-motor vehicle based on the track information specifically comprises the following steps:
performing helmet detection based on the thumbnail data;
if the helmet is not detected, acquiring a head image of the non-motor vehicle driver;
performing gray value analysis on the head image;
and if the analysis result meets a preset threshold value, judging that the driver of the non-motor vehicle has an illegal behavior of not wearing a helmet.
3. The method of claim 1, wherein the trajectory information comprises tracking frame information of the non-motor vehicle; the judging the illegal behavior of the non-motor vehicle based on the track information specifically comprises the following steps:
obtaining track points of the non-motor vehicle according to the tracking frame information;
obtaining lane stop lines and traffic light states in the target scene based on the video frame data;
and under the red light state, if the track points sequentially appear in the lane stop line, cross over the lane stop line and appear at the opposite intersection, judging that the non-motor vehicle has illegal behavior of running the red light.
4. The method of claim 1, wherein the trajectory information includes tracking frame information and thumbnail data; the judging of the illegal action of the non-motor vehicle based on the track information specifically comprises the following steps:
acquiring lane line information in the target scene based on the video frame data;
presetting a lane direction line according to the lane line information;
obtaining a track line of the non-motor vehicle according to the tracking frame information;
calculating an included angle between the trajectory line and the preset lane direction line;
identifying the head orientation of the non-motor vehicle according to the thumbnail data;
and if the direction of the head of the non-motor vehicle is opposite to the direction of the lane direction line and the included angle is larger than a preset threshold value, judging that the non-motor vehicle has a reverse illegal behavior.
5. The method of claim 1, wherein the trajectory information comprises tracking box information; the judging the illegal behavior of the non-motor vehicle based on the track information specifically comprises the following steps:
determining a lane of vehicles in the target scene based on the video frame data;
obtaining track points of the non-motor vehicle according to the tracking frame information;
analyzing the positions of the track points and the motor vehicle lane;
and if the track point appears in the motor vehicle lane, judging that the non-motor vehicle has illegal behaviors of occupying the motor vehicle lane.
6. The method of claim 1, wherein the trajectory information comprises tracking box information; the judging of the illegal action of the non-motor vehicle based on the track information specifically comprises the following steps:
determining a lane of vehicles in the target scene based on the video frame data;
obtaining track points of the non-motor vehicle according to the tracking frame information;
analyzing the positions of the track points and the motor vehicle lane;
if the track points appear in the motor vehicle lane, calculating the number of the track points occupying the motor vehicle lane;
and if the number is larger than a preset threshold value, judging that the non-motor vehicle has illegal behaviors crossing the road.
7. The method according to any one of claims 1-6, wherein the track information includes classification information of the non-motor vehicle; after the determining the unlawful act of the non-motor vehicle based on the track information, the method further comprises the following steps:
and determining the non-motor vehicle category with illegal behaviors according to the classification information of the non-motor vehicles.
8. A vehicle law violation detection device, comprising:
a video frame data module: the method comprises the steps of obtaining video frame data of a target scene;
the track information module is used for obtaining track information of the non-motor vehicle in the target scene based on the video frame data;
and the illegal behavior judging module is used for judging the illegal behavior of the non-motor vehicle based on the track information.
9. An electronic device is characterized in that the electronic device bears the vehicle illegal behavior detection system and comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the steps of the method for detecting vehicle unlawful behaviour according to any of claims 1-7 when executing a program stored in a memory.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method for detecting vehicle unlawful behaviour according to any one of claims 1-7.
CN202210261649.3A 2022-03-16 2022-03-16 Vehicle violation detection method and device and electronic equipment Pending CN115187886A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210261649.3A CN115187886A (en) 2022-03-16 2022-03-16 Vehicle violation detection method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210261649.3A CN115187886A (en) 2022-03-16 2022-03-16 Vehicle violation detection method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN115187886A true CN115187886A (en) 2022-10-14

Family

ID=83512421

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210261649.3A Pending CN115187886A (en) 2022-03-16 2022-03-16 Vehicle violation detection method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN115187886A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115375978A (en) * 2022-10-27 2022-11-22 北京闪马智建科技有限公司 Behavior information determination method and apparatus, storage medium, and electronic apparatus
CN115762162A (en) * 2022-11-18 2023-03-07 同济大学 Method, system, electronic equipment and medium for detecting red light running of non-motor vehicle
CN116246231A (en) * 2023-03-10 2023-06-09 酷哇科技有限公司 Real-time traffic violation detection method and system based on deep learning
CN116416554A (en) * 2023-03-20 2023-07-11 京东科技控股股份有限公司 Object detection method, device and automation equipment
CN117315632A (en) * 2023-09-18 2023-12-29 合肥湛达智能科技有限公司 Non-motor vehicle dangerous driving behavior detection method and system based on time sequence data
CN121170838A (en) * 2025-07-14 2025-12-19 宁波市鑫穗交安科技有限公司 Confidence-based non-motor vehicle driver identity recognition method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101118652A (en) * 2007-09-06 2008-02-06 上海交通大学 3D Modeling and Optimal Reproduction Method of Bicycle Collision Accident
WO2015089867A1 (en) * 2013-12-17 2015-06-25 东莞中国科学院云计算产业技术创新与育成中心 Traffic violation detection method
CN109949579A (en) * 2018-12-31 2019-06-28 上海眼控科技股份有限公司 A kind of illegal automatic auditing method that makes a dash across the red light based on deep learning
CN113160575A (en) * 2021-03-15 2021-07-23 超级视线科技有限公司 Traffic violation detection method and system for non-motor vehicles and drivers

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101118652A (en) * 2007-09-06 2008-02-06 上海交通大学 3D Modeling and Optimal Reproduction Method of Bicycle Collision Accident
WO2015089867A1 (en) * 2013-12-17 2015-06-25 东莞中国科学院云计算产业技术创新与育成中心 Traffic violation detection method
CN109949579A (en) * 2018-12-31 2019-06-28 上海眼控科技股份有限公司 A kind of illegal automatic auditing method that makes a dash across the red light based on deep learning
CN113160575A (en) * 2021-03-15 2021-07-23 超级视线科技有限公司 Traffic violation detection method and system for non-motor vehicles and drivers

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115375978A (en) * 2022-10-27 2022-11-22 北京闪马智建科技有限公司 Behavior information determination method and apparatus, storage medium, and electronic apparatus
CN115762162A (en) * 2022-11-18 2023-03-07 同济大学 Method, system, electronic equipment and medium for detecting red light running of non-motor vehicle
CN116246231A (en) * 2023-03-10 2023-06-09 酷哇科技有限公司 Real-time traffic violation detection method and system based on deep learning
CN116416554A (en) * 2023-03-20 2023-07-11 京东科技控股股份有限公司 Object detection method, device and automation equipment
CN117315632A (en) * 2023-09-18 2023-12-29 合肥湛达智能科技有限公司 Non-motor vehicle dangerous driving behavior detection method and system based on time sequence data
CN121170838A (en) * 2025-07-14 2025-12-19 宁波市鑫穗交安科技有限公司 Confidence-based non-motor vehicle driver identity recognition method
CN121170838B (en) * 2025-07-14 2026-01-30 宁波市鑫穗交安科技有限公司 Confidence-based non-motor vehicle driver identity recognition method

Similar Documents

Publication Publication Date Title
CN111553205B (en) Vehicle weight recognition method, system, medium and video monitoring system without license plate information
CN115187886A (en) Vehicle violation detection method and device and electronic equipment
CN111368687B (en) Sidewalk vehicle illegal parking detection method based on target detection and semantic segmentation
CN107563372B (en) License plate positioning method based on deep learning SSD frame
CN109190444B (en) Method for realizing video-based toll lane vehicle feature recognition system
CN108921083B (en) Illegal mobile vendor identification method based on deep learning target detection
CN108509954A (en) A kind of more car plate dynamic identifying methods of real-time traffic scene
CN102054176B (en) Method used for establishing semantic scene models for scene images of moving targets by utilizing computer
CN107316010A (en) A kind of method for recognizing preceding vehicle tail lights and judging its state
CN106934378B (en) Automobile high beam identification system and method based on video deep learning
CN106384100A (en) Component-based fine vehicle model recognition method
CN103279738B (en) Automatic identification method and system for vehicle logo
CN106446834A (en) An image-based vehicle identification method and device
CN111209880A (en) Vehicle behavior identification method and device
Ketcham et al. Recognizing the illegal parking patterns of cars on the road in front of the bus stop using the support vector machine
CN103679214B (en) Vehicle checking method based on online Class area estimation and multiple features Decision fusion
Alam et al. Faster RCNN based robust vehicle detection algorithm for identifying and classifying vehicles
CN111274886A (en) Deep learning-based pedestrian red light violation analysis method and system
Bichkar et al. Traffic sign classification and detection of Indian traffic signs using deep learning
CN106886757A (en) A kind of multiclass traffic lights detection method and system based on prior probability image
Singh et al. Intelligent traffic management system
Xu et al. Deep learning based vehicle violation detection system
CN117456482B (en) Abnormal event identification method and system for traffic monitoring scene
CN116246227A (en) Non-motor vehicle driving violation detection method, device and embedded device
CN116524210A (en) Automatic driving data screening method, system, electronic device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination