Driving behavior detection method and system based on YOLOv8
Through the YOLOv8-based driving behavior detection method, the facial and hand target results are used to identify fatigue and dangerous driving behaviors, and the problem of difficult detection accuracy and efficiency in the prior art is solved, and efficient and accurate in multiple environments is achieved Testing reduces the probability of traffic accidents.
Patent Information
- Application Number
- CN202410929938.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-11-05
AI Technical Summary
Existing object detection technology cannot take into account both detection accuracy and efficiency, and it is difficult to accurately identify fatigue driving and dangerous driving behaviors in multiple driving environments.
Using the driving behavior detection method based on YOLOv8, the images are extracted frame by frame by frame by obtaining driving video, and the trained object detection model is input after preprocessing. Fatigue and dangerous driving behavior are identified using facial and hand target results, combining data augmentation and feature extraction Modules improve the robustness and generalization capabilities of the model.
Efficient and accurate detection in various driving environments is achieved, effectively reducing the probability of traffic accidents caused by fatigue driving behavior and dangerous driving behavior.
Smart Images

Figure CN118898829A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision, and more specifically, to a driving behavior detection method and system based on YOLOv8. Background Art
[0002] Image classification is one of the basic tasks in the field of computer vision. The goal of image classification is to divide different images into different categories and achieve the minimum classification error. The process of image classification mainly includes image preprocessing, image feature extraction, and image classification using a classifier, among which image feature extraction is a crucial step. Object detection is to achieve multi-target classification and real-time reasoning based on image classification. It is also the basis of many computer vision tasks such as image segmentation, image description, and target tracking. Object detection has application requirements in many fields, such as monitoring security, traffic monitoring, danger warning, and autonomous driving. Object detection usually detects some predefined categories of target instances, such as people and cars. Before deep learning methods were applied to the field of object detection, traditional methods mainly relied on manual feature design and extraction, and their development was relatively slow. The application of convolutional neural networks has greatly improved the effect of image classification tasks. The combination of deep learning and object detection tasks has led to the rapid development of the field of object detection. Object detection based on deep learning is divided into two-stage detection and single-stage detection according to the detection method. Among them, single-stage detection directly classifies each region of interest as background or target object, so that the category probability and position coordinate value of the target object can be directly given in only one stage. The two-stage detection has higher positioning and target recognition accuracy, while the single-stage detection is faster. Summary of the invention
[0003] In order to overcome the defect that the above-mentioned existing target detection technology cannot take into account both detection accuracy and efficiency, the present invention provides a driving behavior detection method and system based on YOLOv8.
[0004] In order to solve the above technical problems, the technical solution of the present invention is as follows:
[0005] The present invention provides a driving behavior detection method based on YOLOv8, which is characterized by comprising:
[0006] S1: Obtain the driving video of the driver to be detected and extract the driving image frame by frame;
[0007] S2: performing a preprocessing operation on the driving image to obtain a preprocessed driving image;
[0008] S3: inputting the preprocessed driving image into a trained target detection model to obtain a facial target result and a hand target result of the driver to be detected;
[0009] S4: Identify fatigue driving behavior and dangerous driving behavior of the driver to be detected based on the facial target result and the hand target result.
[0010] Preferably, the preprocessing operation includes an image size unification operation, an image normalization operation and a coordinate normalization operation.
[0011] All images are resized and then normalized. Image normalization is to divide the pixel value of the image by 255, so that the pixel value is mapped from the range of 0 to 255 to the range of 0 to 1. Coordinate normalization is to normalize the image width w, height h, center point coordinates (x, y) and two parameters m and n. w, x, m are divided by the image width, and h, y, n are divided by the image height. The normalized image parameters will not skip the optimal solution due to excessive gradient descent in the subsequent training process, thereby improving the accuracy of model training.
[0012] Preferably, obtaining the trained target detection model includes:
[0013] Constructing a training data set and annotating it, obtaining a corresponding label file, and forming an annotated training data set; the training data set includes normal driving pictures, fatigue driving pictures, water cup pictures, and mobile phone pictures;
[0014] Perform data augmentation on the labeled training data set to obtain an augmented training data set;
[0015] Construct a target detection model based on YOLOv8, including a backbone network unit, a neck network unit, and a detection head unit connected in sequence;
[0016] The enhanced training data set is used to train the target detection model based on YOLOv8 to obtain a trained target detection model.
[0017] Preferably, the step of constructing a training data set and annotating it to obtain a corresponding label file to form an annotated training data set includes:
[0018] Each image in the training data set is labeled to obtain the corresponding target category, target box width and height, and center point coordinates, and saved separately as a txt type label file;
[0019] Each image and its corresponding label file form a labeled training data set.
[0020] Preferably, the data enhancement operation includes adding noise data, random cropping, random rotation, image cropping and image normalization processing.
[0021] Adding noise data can effectively improve the robustness of the trained model; random cropping and random rotation increase the amount of training data, which can effectively improve the generalization ability of the trained model. For example, if the number of a certain category is too small, the amount of data can be increased to solve the problem of sample imbalance by generating training data in different directions, positions, scaling, and brightness; image cropping can reduce memory consumption, reduce irrelevant information, and improve experimental accuracy; image normalization can eliminate the order of magnitude difference between data of each dimension, and avoid excessive model prediction errors caused by large order of magnitude differences between input and output data. The enhanced training data set increases the scale and complexity of the training data, which can avoid overfitting and improve the robustness of the model.
[0022] Preferably, the backbone network unit includes a first PConv module, a maximum pooling layer, a first ShuffleNetV2 module, a second ShuffleNetV2 module, a second PConv module and a SPFF module connected in sequence; the output ends of the first ShuffleNetV2 module, the second ShuffleNetV2 module and the SPFF module are all connected to the neck network unit.
[0023] Preferably, the first ShuffleNetV2 module and the second ShuffleNetV2 module have the same structure, and both include a first DWConv layer, a second DWConv layer, a third DWConv layer, a sixth convolutional layer, a seventh convolutional layer, an eighth convolutional layer, a ninth convolutional layer, a tenth convolutional layer, a fifth splicing layer, a sixth splicing layer, a first channel rearrangement layer, a second channel rearrangement layer and a channel segmentation layer;
[0024] The input ends of the first DWConv layer and the seventh convolutional layer are used together as the input end of the ShuffleNetV2 module; the output end of the first DWConv layer is connected to the input end of the sixth convolutional layer, and the output end of the sixth convolutional layer is connected to the input end of the fifth splicing layer; the output end of the seventh convolutional layer is connected to the input end of the second DWConv layer, the output end of the second DWConv layer is connected to the input end of the eighth convolutional layer, and the output end of the eighth convolutional layer is connected to the input end of the fifth splicing layer;
[0025] The output end of the fifth splicing layer is connected to the input end of the first channel rearrangement layer, the output end of the first channel rearrangement layer is connected to the input end of the channel segmentation layer, the output end of the channel segmentation layer is connected to the input end of the ninth convolutional layer, the output end of the ninth convolutional layer is connected to the input end of the third DWConv layer, the output end of the third DWConv layer is connected to the input end of the tenth convolutional layer, and the output end of the tenth convolutional layer is connected to the input end of the sixth splicing layer; the output end of the channel segmentation layer is also connected to the input end of the sixth splicing layer, the output end of the sixth splicing layer is connected to the input end of the second channel rearrangement layer, and the output end of the second channel rearrangement layer serves as the output end of the ShuffleNetV2 module.
[0026] The feature maps have high similarity between different channels. The PConv module only needs to apply regular Conv on part of the input channels for spatial feature extraction, and keep the remaining channels unchanged. At the same time, for continuous or regular memory access, computational redundancy and memory access can be reduced.
[0027] The ShuffleNetV2 module can promote the flow of feature information, including channel rearrangement operations and depth-separable convolutions to reduce the amount of calculation; through channel sparse connections, grouped convolutions are allowed to obtain input data from different groups. At the same time, since the channel shuffle operation process is very small, it can be embedded in end-to-end network training.
[0028] Preferably, the neck network unit includes a first upsampling layer, a second upsampling layer, a first splicing layer, a second splicing layer, a third splicing layer, a fourth splicing layer, a first C2f module, a second C2f module, a first CA attention module, a second CA attention module, a third CA attention module, a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer and a fifth convolutional layer;
[0029] The first upsampling layer, the first splicing layer, the first C2f module, the second upsampling layer, the second splicing layer, the first CA attention module, the first convolutional layer, the third splicing layer, the second CA attention module, the second convolutional layer, the fourth splicing layer, the second C2f module, and the third CA attention module are connected in sequence;
[0030] The output end of the SPFF module is connected to the input end of the first upsampling layer and the fourth splicing layer respectively; the output end of the second ShuffleNetV2 module is connected to the input end of the first splicing layer; the output end of the first ShuffleNetV2 module is connected to the input end of the second splicing layer;
[0031] The output end of the first CA attention module is also connected to the input end of the fifth convolutional layer, and the output end of the second CA attention module is also connected to the input end of the fourth convolutional layer;
[0032] The output ends of the third convolution layer, the fourth convolution layer and the fifth convolution layer are all connected to the detection head unit.
[0033] The CA attention module decomposes channel attention into two one-dimensional feature encoding processes, aggregating features along two spatial directions respectively. While capturing long-range dependencies along one spatial direction, it retains precise position information along another spatial direction. Then, the generated feature maps are encoded into a pair of direction-aware and position-sensitive attention maps, which can be complementary applied to the input feature map to enhance the representation of the object of attention; the CA attention mechanism embeds position information into the channel attention, which is called "cooperative attention". The integration of this attention not only allows the network model to consider channel information, but also direction-related position information, which can improve the detection accuracy in dark light scenes, while making the network model sufficiently flexible and lightweight.
[0034] The YOLOv8-based target detection model is a lightweight network. After training, it can be deployed on an embedded platform while maintaining high accuracy to achieve real-time detection of driving behavior.
[0035] Preferably, the detection head unit includes a first detection head, a second detection head and a third detection head arranged in parallel; the input end of the first detection head is connected to the output end of the fifth convolutional layer, the input end of the second detection head is connected to the output end of the fourth convolutional layer, the input end of the third detection head is connected to the output end of the third convolutional layer, and the first detection head, the second detection head and the third detection head respectively output the predicted category and the bounding box coordinates.
[0036] Preferably, obtaining the facial target result and the hand target result of the driver to be detected includes:
[0037] The trained target detection model outputs the predicted category and bounding box coordinates of each of the preprocessed driving images, and uses a non-maximum suppression algorithm to select the bounding box with the highest confidence for each of the predicted categories as the facial recognition results and hand recognition results.
[0038] Preferably, the identifying the fatigue driving behavior and dangerous driving behavior of the driver to be detected according to the facial target result and the hand target result comprises:
[0039] The facial target result includes the mouth opening and closing state and the eye opening and closing state; the hand target result is whether there is a water cup or a mobile phone in the hand;
[0040] Counting the eye opening and closing states of each frame of the driving image, when the duration of the eye being in the closed state is greater than a first preset time threshold or the eye blinking frequency is less than a preset frequency threshold, it is determined that the driver to be detected is performing fatigue driving behavior;
[0041] Counting the mouth opening and closing state of each frame of the driving image, and when the duration of the mouth being in the open state is greater than a second preset time threshold, determining that the driver to be detected is performing fatigue driving behavior;
[0042] It is counted whether there is a water cup or a mobile phone in the hand of each frame of the driving image. When the duration of the water cup or the mobile phone in the hand is greater than a third preset time threshold, it is determined that the driver to be detected is performing dangerous driving behavior.
[0043] Preferably, before step S1, a vehicle driving state detection is required, including:
[0044] The vehicle's driving state is detected by a gyroscope. When the vehicle is detected to be moving, a driving video of the driver to be detected is obtained, and the driving image is extracted frame by frame.
[0045] Preferably, the method further comprises:
[0046] S5: When fatigue driving behavior and dangerous driving behavior are identified, a corresponding alarm signal is issued.
[0047] The present invention also provides a driving behavior detection system based on YOLOv8, which is used to implement the above detection method, including:
[0048] A data acquisition module is used to acquire the driving video of the driver to be detected and extract the driving image frame by frame;
[0049] A data processing module, used for performing a preprocessing operation on the driving image to obtain a preprocessed driving image;
[0050] A target detection module, used for inputting the preprocessed driving image into a trained target detection model to obtain a facial target result and a hand target result of the driver to be detected;
[0051] The driving behavior recognition module is used to recognize the fatigue driving behavior and dangerous driving behavior of the driver to be detected based on the facial target results and the hand target results.
[0052] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0053] The present invention first extracts driving images frame by frame from the driving video of the driver to be detected, and performs preprocessing operations on the driving images; then the obtained preprocessed driving images are input into the trained target detection model to obtain the facial target results and hand target results of the driver to be detected; finally, the fatigue driving behavior and dangerous driving behavior of the driver to be detected are identified according to the facial target results and hand target results. The trained target detection model in the present invention can detect the driving behavior of the driver in a variety of driving environments, and identify fatigue driving behavior and dangerous driving behavior according to the facial target results and hand target results. The identification basis is diversified, the detection process is efficient, and the detection results are accurate, which can effectively reduce the probability of traffic accidents caused by fatigue driving behavior and dangerous driving behavior. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 This is a flowchart of a driving behavior detection method based on YOLOv8 described in Example 1.
[0055] Figure 2 This is a schematic diagram of the structure of the target detection model based on YOLOv8 described in Example 2.
[0056] Figure 3 This is a schematic diagram of the structure of the ShuffleNetV2 module described in Example 2.
[0057] Figure 4 Schematic diagram of the PConv module described in Example 2 performing spatial feature extraction.
[0058] Figure 5 This is a structural diagram of a driving behavior detection system based on YOLOv8 described in Example 3. DETAILED DESCRIPTION
[0059] The drawings are for illustrative purposes only and should not be construed as limiting the present patent;
[0060] In order to better illustrate the present embodiment, some parts in the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product;
[0061] It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0062] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0063] Example 1
[0064] This embodiment provides a driving behavior detection method based on YOLOv8. Figure 1 As shown, including:
[0065] S1: Obtain the driving video of the driver to be detected and extract the driving image frame by frame;
[0066] S2: performing a preprocessing operation on the driving image to obtain a preprocessed driving image;
[0067] S3: inputting the preprocessed driving image into a trained target detection model to obtain a facial target result and a hand target result of the driver to be detected;
[0068] S4: Identify fatigue driving behavior and dangerous driving behavior of the driver to be detected based on the facial target result and the hand target result.
[0069] In the specific implementation process, this embodiment first extracts driving images frame by frame from the driving video of the driver to be detected, and performs preprocessing operations on the driving images; then, the obtained preprocessed driving images are input into the trained target detection model to obtain the facial target results and hand target results of the driver to be detected; finally, the fatigue driving behavior and dangerous driving behavior of the driver to be detected are identified based on the facial target results and hand target results. The trained target detection model in this embodiment can detect the driver's driving behavior in a variety of driving environments, and identify fatigue driving behavior and dangerous driving behavior based on the facial target results and hand target results. The identification basis is diversified, the detection process is efficient, and the detection results are accurate, which can effectively reduce the probability of traffic accidents caused by fatigue driving behavior and dangerous driving behavior.
[0070] Example 2
[0071] This embodiment provides a driving behavior detection method based on YOLOv8, including:
[0072] S1: Detect the driving state of the vehicle through the gyroscope. When the vehicle is detected to be moving, obtain the driving video of the driver to be detected, and extract the driving image frame by frame;
[0073] S2: performing a preprocessing operation on the driving image to obtain a preprocessed driving image;
[0074] The preprocessing operation includes an image size unification operation, an image normalization operation and a coordinate normalization operation;
[0075] All images are resized and then normalized. Image normalization is to divide the pixel value of the image by 255, so that the pixel value is mapped from the range of 0 to 255 to the range of 0 to 1. Coordinate normalization is to normalize the image width w, height h, center point coordinates (x, y) and two parameters m and n. w, x, m are divided by the image width, and h, y, n are divided by the image height. The normalized image parameters will not skip the optimal solution due to excessive gradient descent in the subsequent training process, thereby improving the accuracy of model training.
[0076] S3: inputting the preprocessed driving image into a trained target detection model to obtain a facial target result and a hand target result of the driver to be detected;
[0077] Obtaining the trained target detection model includes:
[0078] Construct a training data set, annotate each picture in the training data set, obtain the corresponding target category, target box width and height, and center point coordinates, and save them separately as a txt type label file; each picture and its corresponding label file form a labeled training data set; the training data set includes normal driving pictures, fatigue driving pictures, water cup pictures, and mobile phone pictures;
[0079] Perform data augmentation on the labeled training data set to obtain an augmented training data set;
[0080] The data enhancement operation includes adding noise data, random cropping, random rotation, image cropping and image normalization processing;
[0081] Adding noise data can effectively improve the robustness of the trained model; random cropping and random rotation increase the amount of training data, which can effectively improve the generalization ability of the trained model. For example, if the number of a certain category is too small, the amount of data can be increased to solve the problem of sample imbalance by generating training data in different directions, positions, scaling, and brightness; image cropping can reduce memory consumption, reduce irrelevant information, and improve experimental accuracy; image normalization can eliminate the order of magnitude difference between data of each dimension, and avoid excessive model prediction errors due to large order of magnitude differences in input and output data. The enhanced training data set increases the scale and complexity of the training data, which can avoid overfitting and improve the robustness of the model.
[0082] like Figure 2 As shown, a target detection model based on YOLOv8 is constructed, including a backbone network unit, a neck network unit and a detection head unit connected in sequence;
[0083] The backbone network unit includes a first PConv module, a maximum pooling layer, a first ShuffleNetV2 module, a second ShuffleNetV2 module, a second PConv module and a SPFF module which are connected in sequence; the output ends of the first ShuffleNetV2 module, the second ShuffleNetV2 module and the SPFF module are all connected to the neck network unit;
[0084] like Figure 3 As shown, the first ShuffleNetV2 module and the second ShuffleNetV2 module have the same structure, and both include a first DWConv layer, a second DWConv layer, a third DWConv layer, a sixth convolutional layer, a seventh convolutional layer, an eighth convolutional layer, a ninth convolutional layer, a tenth convolutional layer, a fifth splicing layer, a sixth splicing layer, a first channel rearrangement layer, a second channel rearrangement layer, and a channel segmentation layer;
[0085] The input ends of the first DWConv layer and the seventh convolutional layer are used together as the input end of the ShuffleNetV2 module; the output end of the first DWConv layer is connected to the input end of the sixth convolutional layer, and the output end of the sixth convolutional layer is connected to the input end of the fifth splicing layer; the output end of the seventh convolutional layer is connected to the input end of the second DWConv layer, the output end of the second DWConv layer is connected to the input end of the eighth convolutional layer, and the output end of the eighth convolutional layer is connected to the input end of the fifth splicing layer;
[0086] The output end of the fifth splicing layer is connected to the input end of the first channel rearrangement layer, the output end of the first channel rearrangement layer is connected to the input end of the channel segmentation layer, the output end of the channel segmentation layer is connected to the input end of the ninth convolutional layer, the output end of the ninth convolutional layer is connected to the input end of the third DWConv layer, the output end of the third DWConv layer is connected to the input end of the tenth convolutional layer, and the output end of the tenth convolutional layer is connected to the input end of the sixth splicing layer; the output end of the channel segmentation layer is also connected to the input end of the sixth splicing layer, the output end of the sixth splicing layer is connected to the input end of the second channel rearrangement layer, and the output end of the second channel rearrangement layer serves as the output end of the ShuffleNetV2 module.
[0087] The feature maps have high similarity between different channels, such as Figure 4 As shown in Figure 2, the PConv module only needs to apply regular Conv on a portion of the input channels for spatial feature extraction, and keep the remaining channels unchanged. At the same time, for continuous or regular memory access, computational redundancy and memory access can be reduced.
[0088] The ShuffleNetV2 module can promote the flow of feature information, including channel rearrangement operations and depth-separable convolutions to reduce the amount of calculation; through channel sparse connections, grouped convolutions are allowed to obtain input data from different groups. At the same time, because the channel shuffle operation process is very small, it can be embedded in end-to-end network training;
[0089] The neck network unit includes a first upsampling layer, a second upsampling layer, a first splicing layer, a second splicing layer, a third splicing layer, a fourth splicing layer, a first C2f module, a second C2f module, a first CA attention module, a second CA attention module, a third CA attention module, a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer and a fifth convolutional layer;
[0090] The first upsampling layer, the first splicing layer, the first C2f module, the second upsampling layer, the second splicing layer, the first CA attention module, the first convolutional layer, the third splicing layer, the second CA attention module, the second convolutional layer, the fourth splicing layer, the second C2f module, the third CA attention module and the third convolutional layer are connected in sequence;
[0091] The output end of the SPFF module is connected to the input end of the first upsampling layer and the fourth splicing layer respectively; the output end of the second ShuffleNetV2 module is connected to the input end of the first splicing layer; the output end of the first ShuffleNetV2 module is connected to the input end of the second splicing layer;
[0092] The output end of the first CA attention module is also connected to the input end of the fifth convolutional layer, and the output end of the second CA attention module is also connected to the input end of the fourth convolutional layer;
[0093] The output ends of the third convolution layer, the fourth convolution layer and the fifth convolution layer are all connected to the detection head unit.
[0094] The CA attention module decomposes channel attention into two one-dimensional feature encoding processes, aggregating features along two spatial directions respectively. While capturing long-range dependencies along one spatial direction, it retains precise position information along another spatial direction. Then, the generated feature maps are encoded into a pair of direction-aware and position-sensitive attention maps, which can be complementary applied to the input feature map to enhance the representation of the object of attention; the CA attention mechanism embeds position information into the channel attention, which is called "cooperative attention". The integration of this attention not only allows the network model to consider channel information, but also direction-related position information, which can improve the detection accuracy in dark light scenes, while making the network model sufficiently flexible and lightweight.
[0095] The detection head unit includes a first detection head, a second detection head and a third detection head arranged in parallel; an input end of the first detection head is connected to an output end of a fifth convolutional layer, an input end of the second detection head is connected to an output end of a fourth convolutional layer, an input end of the third detection head is connected to an output end of a third convolutional layer, and the first detection head, the second detection head and the third detection head respectively output predicted categories and bounding box coordinates.
[0096] The object detection model based on YOLOv8 is a lightweight network. After training, it can be deployed on embedded platforms while maintaining high accuracy to achieve real-time detection of driving behavior.
[0097] Using the enhanced training data set to train a YOLOv8-based target detection model to obtain a trained target detection model;
[0098] The trained target detection model outputs the predicted category and bounding box coordinates of each of the preprocessed driving images, and uses a non-maximum suppression algorithm to select the bounding box with the highest confidence for each of the predicted categories as the facial recognition results and hand recognition results.
[0099] S4: Identifying fatigue driving behavior and dangerous driving behavior of the driver to be detected according to the facial target result and the hand target result, including:
[0100] The facial target result includes the mouth opening and closing state and the eye opening and closing state; the hand target result is whether there is a water cup or a mobile phone in the hand;
[0101] The eye opening and closing states of each frame of the driving image are counted. When the duration of the eye being in the closed state is greater than the first preset time threshold or the eye blinking frequency is less than the preset frequency threshold, it is determined that the driver to be detected is performing fatigue driving behavior. In this embodiment, the preset frequency threshold is 0.4 times / s; the first preset time threshold is the PERCLOS value, which is set to 6%;
[0102] Counting the mouth opening and closing state of each frame of the driving image, when the duration of the mouth being in the open state is greater than a second preset time threshold, it is determined that the driver to be detected is performing fatigue driving behavior; in this embodiment, the second preset time threshold is 3s;
[0103] Counting whether there is a water cup or a mobile phone in the hand of each frame of the driving image, when the duration of the water cup or the mobile phone in the hand is greater than the third preset time threshold, it is determined that the driver to be detected has performed dangerous driving behavior; in this embodiment, the third preset time threshold is 1s;
[0104] The above thresholds can all be adjusted for sensitivity, with the adjustment range being 50%-150% of the default threshold;
[0105] S5: When fatigue driving behavior and dangerous driving behavior are identified, a corresponding alarm signal is issued.
[0106] In the specific implementation process, Python 3.10 and above are installed to build the development platform; JetBrains PyCharm 2019.1.1x64 is installed as an integrated development environment. After the target detection model is trained using the above method, the driving image is read, and the facial target results and hand target results of the driver are detected to identify the fatigue driving behavior and dangerous driving behavior of the driver to be detected, so as to realize the detection and alarm of fatigue driving and dangerous driving.
[0107] Example 3
[0108] This embodiment provides a driving behavior detection system based on YOLOv8, which is used to implement the detection method described in Embodiment 1 or 2. Figure 5 As shown, including:
[0109] A data acquisition module is used to acquire the driving video of the driver to be detected and extract the driving image frame by frame;
[0110] A data processing module, used for performing a preprocessing operation on the driving image to obtain a preprocessed driving image;
[0111] A target detection module, used for inputting the preprocessed driving image into a trained target detection model to obtain a facial target result and a hand target result of the driver to be detected;
[0112] The driving behavior recognition module is used to recognize the fatigue driving behavior and dangerous driving behavior of the driver to be detected based on the facial target results and the hand target results.
[0113] The same or similar reference numerals correspond to the same or similar components;
[0114] The terms used in the drawings to describe positional relationships are only used for illustrative purposes and should not be construed as limiting this patent;
[0115] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A driving behavior detection method based on YOLOv8, characterized in that: include: S1: Obtain the driving video of the driver to be detected and extract the driving image frame by frame; S2: performing a preprocessing operation on the driving image to obtain a preprocessed driving image; S3: inputting the preprocessed driving image into a trained target detection model to obtain a facial target result and a hand target result of the driver to be detected; S4: Identify fatigue driving behavior and dangerous driving behavior of the driver to be detected based on the facial target result and the hand target result.
2. The driving behavior detection method based on YOLOv8 according to claim 1, characterized in that: The preprocessing operation includes an image size unification operation, an image normalization operation and a coordinate normalization operation.
3. The driving behavior detection method based on YOLOv8 according to claim 1, characterized in that: Obtaining the trained target detection model includes: Constructing a training data set and annotating it, obtaining a corresponding label file, and forming an annotated training data set; the training data set includes normal driving pictures, fatigue driving pictures, water cup pictures, and mobile phone pictures; Perform data augmentation on the labeled training data set to obtain an augmented training data set; Construct a target detection model based on YOLOv8, including a backbone network unit, a neck network unit, and a detection head unit connected in sequence; The enhanced training data set is used to train the target detection model based on YOLOv8 to obtain a trained target detection model.
4. The driving behavior detection method based on YOLOv8 according to claim 3, characterized in that: The training data set is constructed and annotated to obtain the corresponding label file, and the annotated training data set comprises: Label each image in the training data set, obtain the corresponding target category, target box width and height, and center point coordinates, and save them as a txt type label file; Each image and its corresponding label file form a labeled training data set.
5. The driving behavior detection method based on YOLOv8 according to claim 3, characterized in that: The data enhancement operation includes adding noise data, random cropping, random rotation, image cropping and image normalization.
6. The driving behavior detection method based on YOLOv8 according to claim 3, characterized in that: The backbone network unit includes a first PConv module, a maximum pooling layer, a first ShuffleNetV2 module, a second ShuffleNetV2 module, a second PConv module and a SPFF module which are connected in sequence; the output ends of the first ShuffleNetV2 module, the second ShuffleNetV2 module and the SPFF module are all connected to the neck network unit.
7. The driving behavior detection method based on YOLOv8 according to claim 6, characterized in that: The first ShuffleNetV2 module and the second ShuffleNetV2 module have the same structure, and both include a first DWConv layer, a second DWConv layer, a third DWConv layer, a sixth convolutional layer, a seventh convolutional layer, an eighth convolutional layer, a ninth convolutional layer, a tenth convolutional layer, a fifth splicing layer, a sixth splicing layer, a first channel rearrangement layer, a second channel rearrangement layer, and a channel segmentation layer; The input ends of the first DWConv layer and the seventh convolutional layer are used together as the input end of the ShuffleNetV2 module; the output end of the first DWConv layer is connected to the input end of the sixth convolutional layer, and the output end of the sixth convolutional layer is connected to the input end of the fifth splicing layer; the output end of the seventh convolutional layer is connected to the input end of the second DWConv layer, the output end of the second DWConv layer is connected to the input end of the eighth convolutional layer, and the output end of the eighth convolutional layer is connected to the input end of the fifth splicing layer; The output end of the fifth splicing layer is connected to the input end of the first channel rearrangement layer, the output end of the first channel rearrangement layer is connected to the input end of the channel segmentation layer, the output end of the channel segmentation layer is connected to the input end of the ninth convolutional layer, the output end of the ninth convolutional layer is connected to the input end of the third DWConv layer, the output end of the third DWConv layer is connected to the input end of the tenth convolutional layer, and the output end of the tenth convolutional layer is connected to the input end of the sixth splicing layer; the output end of the channel segmentation layer is also connected to the input end of the sixth splicing layer, the output end of the sixth splicing layer is connected to the input end of the second channel rearrangement layer, and the output end of the second channel rearrangement layer serves as the output end of the ShuffleNetV2 module.
8. The driving behavior detection method based on YOLOv8 according to claim 6, characterized in that: The neck network unit includes a first upsampling layer, a second upsampling layer, a first splicing layer, a second splicing layer, a third splicing layer, a fourth splicing layer, a first C2f module, a second C2f module, a first CA attention module, a second CA attention module, a third CA attention module, a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer and a fifth convolutional layer; The first upsampling layer, the first splicing layer, the first C2f module, the second upsampling layer, the second splicing layer, the first CA attention module, the first convolutional layer, the third splicing layer, the second CA attention module, the second convolutional layer, the fourth splicing layer, the second C2f module, and the third CA attention module are connected in sequence; The output end of the SPFF module is connected to the input end of the first upsampling layer and the fourth splicing layer respectively; the output end of the second ShuffleNetV2 module is connected to the input end of the first splicing layer; the output end of the first ShuffleNetV2 module is connected to the input end of the second splicing layer; The output end of the first CA attention module is also connected to the input end of the fifth convolutional layer, and the output end of the second CA attention module is also connected to the input end of the fourth convolutional layer; The output ends of the third convolution layer, the fourth convolution layer and the fifth convolution layer are all connected to the detection head unit.
9. The driving behavior detection method based on YOLOv8 according to claim 3, characterized in that: The step of identifying the fatigue driving behavior and dangerous driving behavior of the driver to be detected according to the facial target result and the hand target result includes: The facial target result includes the mouth opening and closing state and the eye opening and closing state; the hand target result is whether there is a water cup or a mobile phone in the hand; Counting the eye opening and closing state of each frame of the driving image, when the duration of the eye being in the closed state is greater than a first preset time threshold or the eye blinking frequency is less than a preset frequency threshold, it is determined that the driver to be detected is performing fatigue driving behavior; Counting the mouth opening and closing state of each frame of the driving image, and when the duration of the mouth being in the open state is greater than a second preset time threshold, determining that the driver to be detected is performing fatigue driving behavior; It is counted whether there is a water cup or a mobile phone in the hand of each frame of the driving image. When the duration of the water cup or the mobile phone in the hand is greater than a third preset time threshold, it is determined that the driver to be detected is performing dangerous driving behavior.
10. A driving behavior detection system based on YOLOv8, characterized in that: Used to implement the detection method according to any one of claims 1 to 9, comprising: A data acquisition module is used to acquire the driving video of the driver to be detected and extract the driving image frame by frame; A data processing module, used for performing a preprocessing operation on the driving image to obtain a preprocessed driving image; A target detection module, used for inputting the preprocessed driving image into a trained target detection model to obtain a facial target result and a hand target result of the driver to be detected; The driving behavior recognition module is used to recognize the fatigue driving behavior and dangerous driving behavior of the driver to be detected based on the facial target results and the hand target results.
Citation Information
Cited By
Deep learning-based tractor driver face fatigue detection method and system
CN120783323A
Image data acquisition method under dangerous condition
CN121811318A
