Method and device for detecting and tracking multiple dynamic targets, equipment and medium
Through the YOLO v5s+DeepSORT algorithm, the lawn mower can track and avoid multiple dynamic obstacles in real time, solving the problem of difficulty in avoiding multiple targets and blocking obstacles in the existing technology, and improving safety and efficiency.
Patent Information
- Application Number
- CN202410763297.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-08-23
AI Technical Summary
Existing lawnmower monocular camera obstacle avoidance technology is difficult to effectively avoid when encountering multiple moving objects or obstacles blocked by dense grass, resulting in a high risk of collision.
Using the improved YOLO v5s+DeepSORT multi-target tracking algorithm, video frames are collected through the lawnmower camera, and the trained Yolov5s model and DeepSORT framework are used to predict the motion information and apparent characteristics of multiple dynamic obstacles, and generate predicted path behaviors. Perform path planning to avoid obstacles.
It realizes real-time tracking and avoidance of multiple dynamic obstacles, reduces the risk of collision between the lawn mower and obstacles, and improves safety and efficiency.
Smart Images

Figure CN118537655A
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of target detection and tracking, and in particular to a method, device and medium for detecting and tracking multiple dynamic targets. Background Art
[0002] With the continuous improvement of computer vision technology and the improvement of intelligence level, the application field of multi-target tracking algorithms is also expanding. In addition to being widely used in the field of computer vision technology, multi-target tracking algorithms are also used in various practical scenarios, such as traffic monitoring systems, medical fields, smart homes, and marketing analysis fields.
[0003] At present, the obstacle avoidance technology of the lawn mower monocular camera, whether it is the classification algorithm or the target detection algorithm, can effectively implement obstacle avoidance. When encountering a static obstacle, the visual side gives the control algorithm instructions, and the lawn mower turns right or left. However, in actual testing, it is inevitable to encounter some complex scene problems. For example, when the obstacle is multiple moving objects, the lawn mower may still collide with the obstacle later, or when the obstacle moves to the dense grass and is temporarily blocked by the grass, the lawn mower may violently collide with the blocked obstacle on this route. Summary of the invention
[0004] The present application provides a method, device and medium for detecting and tracking multiple dynamic targets, which can predict the motion information and apparent characteristics of multiple dynamic obstacles, so that multiple dynamic obstacles can be tracked in real time, thereby avoiding multiple dynamic obstacles.
[0005] In a first aspect, the present application provides a method for detecting and tracking multiple dynamic targets, the method comprising:
[0006] Capturing a video frame through a camera of the lawn mower, wherein the video frame includes a plurality of dynamic obstacles;
[0007] Input the data of the video frame into the target detection model to obtain the target detection frames of multiple dynamic obstacles, wherein the target detection frames include the position information and category information of the multiple dynamic obstacles, the target detection model is a trained Yolov5s model, and the training samples of the target detection model are the obstacle sample set taken by the lawn mower;
[0008] The motion information and appearance features of multiple dynamic obstacles are predicted based on the target detection frame and the DeepSORT framework to track the multiple dynamic obstacles and obtain the predicted path behaviors of the multiple dynamic obstacles. The appearance features are extracted by a deep convolutional neural network.
[0009] The path of the lawn mower is planned to avoid multiple dynamic obstacles based on the predicted path behaviors of the multiple dynamic obstacles.
[0010] Optionally, the training process of the object detection model includes:
[0011] Obstacle images taken by the lawn mower are collected and cleaned, classified, and labeled to obtain obstacle samples;
[0012] Input the obstacle sample into the EfficientNet of the backbone network Backbone of the Yolov5s model to obtain the feature map of the obstacle sample;
[0013] The feature map of the obstacle sample is input into the Neck network of the Yolov5s model for fusion to obtain a multi-scale feature map;
[0014] Input the multi-scale feature maps into the detection head network of the Yolov5s model, and construct the loss function based on the prediction box loss, category loss and confidence loss of the multi-scale feature maps;
[0015] Based on the obstacle samples, the Yolov5s model is trained using the loss function to obtain the target detection model.
[0016] Optionally, the motion information and appearance features of multiple dynamic obstacles are predicted based on the target detection box and the DeepSORT framework to track the multiple dynamic obstacles and obtain the predicted path behaviors of the multiple dynamic obstacles, including:
[0017] Use the Kalman filter in the DeepSORT framework to predict the motion information of the target detection box, and use the Mahalanobis space distance to calculate the motion matching based on the motion information of the predicted box and the motion information of the target detection box;
[0018] The deep convolutional neural network in the DeepSORT framework is used to extract the appearance features of multiple dynamic obstacles through the target detection frame, and the appearance matching is calculated using the Mahalanobis space distance according to the appearance features of the prediction frame and the appearance features of the target detection frame;
[0019] Based on the Hungarian algorithm, cascade matching and IOU matching are performed on multiple dynamic obstacles in the previous and next two frames;
[0020] By updating the tracker and Kalman filter, the tracking results are determined and ID information is assigned to multiple dynamic obstacles;
[0021] According to the position of the dynamic obstacle associated with the same ID in each frame, the running trajectory of the same dynamic obstacle ID in the video is obtained to output the predicted path behavior of multiple dynamic obstacles.
[0022] Optionally, according to the motion information of the prediction frame and the motion information of the target detection frame, the motion matching is calculated using the Mahalanobis space distance, including:
[0023] The distance between the target detection frame and the prediction frame is measured using the Mahalanobis space distance, and the Mahalanobis space distance is thresholded; and a Mahalanobis space distance less than a specified threshold is set as association success.
[0024] Optionally, according to the apparent features of the prediction box and the apparent features of the target detection box, the appearance matching is calculated using the Mahalanobis space distance, including:
[0025] The image similarity between the target detection frame and the prediction frame is measured using the Mahalanobis space distance, and the Mahalanobis space distance is thresholded; and the Mahalanobis space distance less than the specified threshold is set as association success.
[0026] Optionally, by updating the tracker and Kalman filter, the tracking results are determined and ID information is assigned to multiple dynamic obstacles, including:
[0027] Update the status and Kalman filter parameters of the original tracker, assign a new tracker to the newly confirmed tracking target, assign new ID information to the newly added unmatched detection target, and delete the tracking target and its tracker whose matching failure exceeds the life cycle threshold.
[0028] In a second aspect, the present application provides a detection and tracking device for multiple dynamic targets, the device comprising:
[0029] A collection module, used for collecting video frames through a camera of the lawn mower, wherein the video frames include a plurality of dynamic obstacles;
[0030] A detection module is used to input the data of the video frame into a target detection model to obtain a target detection frame of multiple dynamic obstacles, wherein the target detection frame includes the position information and category information of the multiple dynamic obstacles, the target detection model is a trained Yolov5s model, and the training sample of the target detection model is a set of obstacle samples taken by a lawn mower;
[0031] A tracking module is used to track multiple dynamic obstacles by predicting the motion information and appearance features of multiple dynamic obstacles based on the target detection frame and the DeepSORT framework, and obtain the predicted path behaviors of multiple dynamic obstacles, wherein the appearance features are extracted by a deep convolutional neural network;
[0032] The path planning module is used to plan the path of the lawn mower according to the predicted path behavior of the multiple dynamic obstacles to avoid the multiple dynamic obstacles.
[0033] Optionally, the device further comprises:
[0034] The training module is used to collect obstacle images taken by the lawn mower, clean them, classify them and label them to obtain obstacle samples; the obstacle samples are input into the EfficientNet of the backbone network Backbone of the Yolov5s model to obtain the feature map of the obstacle samples; the feature map of the obstacle samples is input into the Neck network of the Yolov5s model for fusion to obtain multi-scale feature maps; the multi-scale feature maps are input into the detection head network of the Yolov5s model, and the loss function is constructed based on the prediction box loss, category loss and confidence loss of the multi-scale feature maps; the Yolov5s model is trained using the loss function based on the obstacle samples to obtain the target detection model.
[0035] Optionally, the tracking module includes:
[0036] The prediction submodule is used to predict the motion information of the target detection box using the Kalman filter in the DeepSORT framework
[0037] The motion matching submodule is used to calculate the motion matching using the Mahalanobis space distance according to the motion information of the prediction box and the motion information of the target detection box;
[0038] The appearance matching submodule is used to extract the appearance features of multiple dynamic obstacles through the target detection frame using the deep convolutional neural network in the DeepSORT framework, and calculate the appearance matching using the Mahalanobis space distance based on the appearance features of the prediction frame and the appearance features of the target detection frame;
[0039] Cascade matching and IOU matching submodules, used to perform cascade matching and IOU matching of multiple dynamic obstacles in the previous and next frames based on the Hungarian algorithm;
[0040] An update submodule, used to determine the tracking results and assign ID information to multiple dynamic obstacles by updating the tracker and Kalman filter;
[0041] The output submodule is used to obtain the running trajectory of the same dynamic obstacle ID in the video according to the position of the dynamic obstacle associated with the same ID in each frame, so as to output the predicted path behavior of multiple dynamic obstacles.
[0042] Optionally, the motion matching submodule is specifically used for:
[0043] The distance between the target detection box and the prediction box is measured using the Mahalanobis space distance, and the Mahalanobis space distance is thresholded; the Mahalanobis space distance less than the specified threshold is set as a successful association.
[0044] Optionally, the appearance matching submodule is specifically used for:
[0045] The image similarity between the target detection box and the prediction box is measured using the Mahalanobis space distance, and the Mahalanobis space distance is thresholded; the Mahalanobis space distance less than the specified threshold is set as a successful association.
[0046] Optionally, the update submodule is specifically used to:
[0047] Update the status and Kalman filter parameters of the original tracker, assign a new tracker to the newly confirmed tracking target, assign new ID information to the newly added unmatched detection target, and delete the tracking target and its tracker whose matching failure exceeds the life cycle threshold.
[0048] In a third aspect, the present application provides an electronic device, the electronic device comprising a memory and a processor:
[0049] The memory is used to store computer programs;
[0050] The processor is used to execute the method provided by the first aspect according to the computer program.
[0051] In a fourth aspect, the present application further provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the method provided in the first aspect above.
[0052] It can be seen that this application has the following beneficial effects:
[0053] The present application provides a method for detecting and tracking multiple dynamic targets, which collects video frames through the camera of a lawn mower; inputs the data of the video frames into a target detection model to obtain target detection frames of multiple dynamic obstacles, the target detection frame includes the location information and category information of multiple dynamic obstacles, the target detection model is a trained Yolov5s model, and the training sample of the target detection model is a set of obstacle samples taken by the lawn mower; according to the target detection frame and the DeepSORT framework, the motion information and appearance characteristics of multiple dynamic obstacles are predicted to track multiple dynamic obstacles, and the predicted path behavior of multiple dynamic obstacles is obtained, and the appearance characteristics are extracted by a deep convolutional neural network; finally, according to the predicted path behavior of multiple dynamic obstacles, the lawn mower is path planned to avoid multiple dynamic obstacles. In this process, the target detection of multiple dynamic obstacles is realized by the Yolov5s model, the categories and positions of multiple dynamic obstacles are determined, and the motion information and appearance characteristics of multiple dynamic obstacles are predicted by the Deepsort framework, and the target tracking of multiple dynamic obstacles is realized, so that the coordinates of multiple dynamic obstacles are continuously marked, the motion states of multiple dynamic obstacles are paid attention to, and the obstacle avoidance of multiple dynamic obstacles is realized. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0055] Figure 1 A schematic diagram of a flow chart of a method for detecting and tracking multiple dynamic targets in an embodiment of the present application;
[0056] Figure 2 This is a schematic diagram of the structure of a Yolov5s model in an embodiment of the present application;
[0057] Figure 3 This is a schematic diagram of the structure of an Efficientnet-B0 model in an embodiment of the present application;
[0058] Figure 4 A schematic diagram of a flow chart of an embodiment of a method for detecting and tracking multiple dynamic targets in an embodiment of the present application;
[0059] Figure 5 A schematic diagram of a flow chart of an embodiment of a method for detecting and tracking multiple dynamic targets in an embodiment of the present application;
[0060] Figure 6 This is a schematic diagram of the structure of a device for detecting and tracking multiple dynamic targets in an embodiment of the present application;
[0061] Figure 7 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0063] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0064] When the current monocular camera obstacle avoidance technology for lawn mowers encounters a static obstacle, the vision side gives the control algorithm instructions, and the lawn mower turns right or left. However, in actual testing, it is inevitable to encounter some complex scene problems. On the one hand, when multiple moving objects move toward the lawn mower body, the lawn mower will avoid obstacles due to the detection algorithm; but if it is a moving object, its movement direction is uncontrollable. When the lawn mower turns left or right, the moving object changes its direction of movement in the next second and moves toward the lawn mower, and a collision occurs immediately, causing immeasurable losses. On the other hand, when the lawn mower is moving forward, it cannot detect obstacles blocked by dense grass and will collide violently with the obstacles. For example, the lawn mower collides with a cat hiding in the grass. The cat takes a few steps back and still hides in the grass. The lawn mower still cannot detect the cat and will collide again.
[0065] In an embodiment of the present application, an improved YOLO v5s+DeepSORT multi-target tracking algorithm is used to monitor the position of dynamic obstacles in real time and predict the trajectories of multiple moving targets, so that the lawn mower can plan its movement route in advance to prevent collisions.
[0066] In specific implementation, the method may include, for example: collecting video frames through a camera of a lawn mower, wherein the video frames include multiple dynamic obstacles; inputting data of the video frames into a target detection model to obtain target detection frames of multiple dynamic obstacles, wherein the target detection frames include location information and category information of the multiple dynamic obstacles, wherein the target detection model is a trained Yolov5s model, and the training samples of the target detection model are obstacle sample sets taken by the lawn mower; predicting motion information and appearance features of multiple dynamic obstacles according to the target detection frame and the DeepSORT framework to track the multiple dynamic obstacles and obtain predicted path behaviors of the multiple dynamic obstacles, wherein the appearance features are extracted by a deep convolutional neural network; and finally, planning the path of the lawn mower according to the predicted path behaviors of the multiple dynamic obstacles to avoid the multiple dynamic obstacles.
[0067] It can be seen that the method provided by the implementation of this application can accurately obtain the target detection frames of multiple dynamic obstacles through the target detection model of Yolov5s, and then predict the motion information and apparent characteristics of multiple dynamic obstacles based on the target detection frame and the DeepSORT framework to track multiple dynamic obstacles, so that the lawn mower can avoid multiple dynamic obstacles according to the predicted path behavior of multiple dynamic obstacles.
[0068] To facilitate understanding of the specific implementation of a method for detecting and tracking multiple dynamic targets provided in an embodiment of the present application, an explanation will be given below with reference to the accompanying drawings.
[0069] It should be noted that the subject implementing the method for detecting and tracking multiple dynamic targets may be a method for detecting and tracking multiple dynamic targets provided in the embodiment of the present application, and the method for detecting and tracking multiple dynamic targets may be carried in an electronic device or a functional module of an electronic device. The electronic device in the embodiment of the present application may be any device capable of implementing the method for detecting and tracking multiple dynamic targets in the embodiment of the present application, such as an Internet of Things (IoT) device.
[0070] Figure 1 A flow chart of a method for detecting and tracking multiple dynamic targets provided in an embodiment of the present application is provided. The method can be applied to a method device for detecting and tracking multiple dynamic targets, and the method device for detecting and tracking multiple dynamic targets can be, for example, Figure 6 The detection and tracking method device 600 of multiple dynamic targets shown in FIG. 1 may also be integrated into the detection and tracking method device 600 of multiple dynamic targets. Figure 7 Functional modules in the electronic device 700 are shown.
[0071] like Figure 1 As shown, the method includes the following S101 to S104:
[0072] S101: Capturing video frames through a camera of a lawn mower, wherein the video frames include a plurality of dynamic obstacles.
[0073] In order for the lawn mower to avoid dynamic obstacles, it is first necessary to collect video frames with multiple dynamic obstacles through the lawn mower's camera, input the data of the video frames into the target detection model, obtain the target detection frames of multiple dynamic obstacles, and then predict the motion information and appearance characteristics of multiple dynamic obstacles based on the target detection frames and the DeepSORT framework to track the multiple dynamic obstacles and obtain the predicted path behavior of the multiple dynamic obstacles. Finally, according to the predicted path behavior of the multiple dynamic obstacles, the lawn mower is path-planned to avoid the multiple dynamic obstacles. Therefore, in the embodiment of the present application, S101 collects video frames through the lawn mower's camera, making preliminary preparations for the subsequent acquisition of the target detection frames of multiple dynamic obstacles.
[0074] As an example, S101 may include: the monocular camera of the lawn mower can capture video frames in real time. When an obstacle appears in the video screen, the video frame extraction method can be used to convert the video into video frame data and input it into the target detection model for target detection. It should be noted that the obstacles exemplified in the embodiments of the present application are multiple dynamic obstacles, but the specific type of obstacles is not limited.
[0075] S102: Inputting the data of the video frame into the target detection model to obtain target detection frames of multiple dynamic obstacles, wherein the target detection frames include location information and category information of the multiple dynamic obstacles. The target detection model is a trained Yolov5s model, and the training samples of the target detection model are obstacle sample sets taken by a lawn mower.
[0076] The target detection model in S102 is a pre-trained Yolov5s model. Since the Yolov5s network is the network with the smallest depth and the smallest feature map width in the Yolov5 series, considering the complexity of the task and the requirements for speed, the Yolov5s model is selected as the target detection model in the embodiment of the present application. The following is the specific training process of the target detection model, which may include:
[0077] Firstly, obstacle images taken by the lawn mower are collected for cleaning, classification and category labeling to obtain obstacle samples; the obstacle samples are input into the EfficientNet of the backbone network Backbone of the Yolov5s model to obtain the feature map of the obstacle samples; the feature map of the obstacle samples is input into the Neck network of the Yolov5s model for fusion to obtain multi-scale feature maps; the multi-scale feature maps are input into the detection head network of the Yolov5s model, and the loss function is constructed based on the prediction box loss, category loss and confidence loss of the multi-scale feature maps; the Yolov5s model is trained with the loss function based on the obstacle samples to obtain the target detection model.
[0078] First, the video shot by the lawn mower is converted into an image using the frame extraction method. Since there may be a large number of static frames in the video, in order to reduce the overfitting of the model to static frames, the image data set is cleaned and some static frames and overly blurred images are removed to avoid information redundancy and damage to the model weights. Then, the obstacle images are classified and labeled according to the categories of obstacles in the image to obtain obstacle samples.
[0079] The target detection model in the embodiment of the present application is deployed on a lawn mower, so the target detection model needs to be lightweight, accurate and efficient. The lightweight process can prune some useless neurons, merge BN layers, decompose tensors and perform knowledge distillation during the training phase. Figure 2 As shown in the feature extraction backbone network Backbone of the Yolov5s model provided in the embodiment of the present application, the CSPDarknet53 of the Yolov5s model is replaced by the EfficientNet-B0 network, and the original convolution layer is replaced by the deep separable convolution, the network model efficiency and accuracy are optimized to reduce memory overhead, and the detection accuracy is slightly improved. The specific EfficientNet-B0 network is as follows Figure 3As shown, there are 7 blocks (Block) and modules (Module) corresponding to each block. The Neck network uses the CSP2+PAN structure for upsampling and downsampling to improve the ability of feature fusion. By fusing the feature maps of adjacent layers, it can enhance the positioning information of small objects without bringing too much computational burden. The detection head (Head) of the network uses the original detection head. In the embodiment of the present application, CIOU is used as the loss function, and the anchor frame is screened using the Soft-NMS method to predict image features, obtain bounding boxes and predict categories, so as to improve the detection accuracy of overlapping obstacles. Among them, the Soft-NMS method is used for the box M whose overlap with the highest score frame is greater than the threshold T. Instead of removing it directly, its confidence is reduced. This method can retain more boxes, thereby avoiding the overlap to a certain extent.
[0080] The calculation formula of the above CIOU is as follows:
[0081]
[0082] Where IOU represents the intersection-over-union ratio between the real box and the predicted box; b represents the center point of the real box; b gt represents the center point of the prediction box; ρ(b, b gt ) represents the Euclidean distance between the center points of the real box and the predicted box; c represents the diagonal distance between the minimum circumscribed rectangle of the real box and the predicted box; α is a balance parameter used to adjust the influence of the penalty term.
[0083] S103: Predicting motion information and appearance features of multiple dynamic obstacles according to the target detection frame and the DeepSORT framework to track the multiple dynamic obstacles and obtain predicted path behaviors of the multiple dynamic obstacles, wherein the appearance features are extracted by a deep convolutional neural network.
[0084] As an example, S103 may include: S1031, using the Kalman filter in the DeepSORT framework to predict the motion information of the target detection frame, and using the Mahalanobis space distance to calculate the motion matching according to the motion information of the prediction frame and the motion information of the target detection frame; S1032, using the deep convolutional neural network in the DeepSORT framework to extract the appearance features of the multiple dynamic obstacles through the target detection frame, and using the Mahalanobis space distance to calculate the appearance matching according to the appearance features of the prediction frame and the appearance features of the target detection frame; S1033, based on the Hungarian algorithm, cascade matching and IOU matching are performed on multiple dynamic obstacles in the previous and next two frames; S1034, by updating the tracker and the Kalman filter, the tracking result is determined, and ID information is assigned to multiple dynamic obstacles; S1035, according to the position of the dynamic obstacle associated with the same ID in each frame, the running trajectory of the same dynamic obstacle ID in the video is obtained to output the predicted path behavior of multiple dynamic obstacles.
[0085] The embodiment of the present application adopts the DeepSORT framework to predict the motion state of multiple detected dynamic obstacles, and can assign IDs to the detected dynamic obstacles while tracking the dynamic obstacles in real time.
[0086] The above S1031 specifically includes: first, using an eight-dimensional state space to describe the motion state of the dynamic obstacle, the eight-dimensional state space includes the center point coordinates, aspect ratio, height and speed information of the target detection frame. The position information of the target detection frame is predicted through a Kalman filter based on a uniform velocity model and a linear observation model, wherein the position information of the next frame includes the center point coordinates, aspect ratio and height of the prediction frame. Then, the Mahalanobis space distance is used to measure the distance between the target detection frame and the prediction frame, and the Mahalanobis space distance is thresholded; the Mahalanobis space distance less than the specified threshold is set as an association success to calculate the motion matching of multiple dynamic obstacles.
[0087] In this process, the DeepSORT framework is used to predict the motion states of multiple dynamic obstacles and associate their motion information, thereby calculating the motion matching of multiple dynamic obstacles to achieve motion trajectory tracking of multiple dynamic obstacles.
[0088] The above S1032 specifically includes: using the deep convolutional neural network in the DeepSORT framework to extract the appearance features of the target detection box and the prediction box; using the Mahalanobis space distance to measure the image similarity between the target detection box and the prediction box, and thresholding the Mahalanobis space distance; setting the Mahalanobis space distance less than the specified threshold as an association success to calculate the appearance matching of multiple dynamic obstacles.
[0089] In this process, the DeepSORT algorithm introduces degree learning into the SORT algorithm, reduces identity switching by adding appearance features, thereby improving tracking efficiency and high real-time performance; and in this embodiment, the Mahalanobis space distance measurement method is used to replace the original cosine distance. This method can increase the robustness of the network's tracking due to sudden changes in target appearance or partial occlusion, thereby improving the detection accuracy of occluded or overlapping obstacles.
[0090] After motion matching and appearance matching of multiple dynamic obstacles, the Hungarian algorithm can be used to perform cascade matching and IOU matching on multiple dynamic obstacles in the previous and next frames, so as to calculate the matching degree of multiple dynamic obstacles in the previous and next frames. In the embodiment of the present application, when a target is blocked for a long time, the uncertainty of the Kalman filter prediction will increase. If multiple Kalman filters are matched with the same detection result at the same time, the detection result will be associated with the target with a longer occlusion time. Therefore, cascade matching is introduced to give priority matching rights to targets that appear more frequently.
[0091] The above S1034 specifically includes: updating the status and Kalman filter parameters of the original tracker, assigning a new tracker to the newly confirmed tracking target, assigning new ID information to the newly added unmatched detection target, deleting the tracking target and its tracker whose matching failure exceeds the life cycle threshold, thereby determining and assigning ID information to multiple dynamic obstacles.
[0092] In this process, after updating the state of the tracker and the parameters of the Kalman filter, the ID information is continuously assigned to the detected target, which can realize the target tracking of multiple dynamic obstacles and distinguish between static obstacles and dynamic obstacles.
[0093] S104: performing path planning for the lawn mower according to the predicted path behaviors of the multiple dynamic obstacles to avoid the multiple dynamic obstacles.
[0094] As an example, S104 may include: after obtaining predicted path behaviors of multiple dynamic obstacles, path planning may be performed according to a path planning module in the lawn mower, thereby achieving the purpose of obstacle avoidance.
[0095] It can be seen that the embodiment of the present application realizes target detection of multiple dynamic obstacles through the Yolov5s model, determines the categories and positions of multiple dynamic obstacles, and predicts the motion information and apparent characteristics of multiple dynamic obstacles through the Deepsort framework, thereby realizing target tracking of multiple dynamic obstacles, thereby continuously marking the coordinates of multiple dynamic obstacles, paying attention to the motion states of multiple dynamic obstacles, and realizing obstacle avoidance of multiple dynamic obstacles.
[0096] In order to make the method provided in the embodiment of the present application clearer and easier to understand, Figure 4and Figure 5 A specific example of this method is described.
[0097] like Figure 4 As shown, the implementation may include:
[0098] S401: Obstacle images taken by the lawn mower are collected and cleaned, classified, and labeled to obtain obstacle samples.
[0099] Since the Yolov5s model is used as the target detection model in the embodiment of the present application, the Yolov5s model needs to be optimized and trained before the detection and tracking of multiple dynamic targets is formally performed. Figure 5 As shown in the figure, a dataset of obstacle samples in the lawn mower is first prepared. The specific process is to convert the video shot by the lawn mower into images using the frame extraction method, and clean the image dataset to remove some static frames and overly blurred images to avoid information redundancy and damage to the model weights. Then, the obstacle images are classified and labeled according to the categories of obstacles in the image. For example, 20 ID numbers are labeled according to the categories of obstacles to obtain obstacle samples.
[0100] S402: Optimize the Yolov5s model, replace the backbone network with the EfficientNet network structure, and change the loss function of the original prediction box to CIOU.
[0101] In order to reduce the weight of the Yolov5s model and improve the detection frame rate of the development board under the premise of ensuring the detection accuracy, the embodiment of the present application Figure 5 It is shown that the YOLOv5 model needs to be optimized, specifically by replacing the backbone network with the EfficientNet network structure and changing the loss function of the original prediction box to CIOU to reduce memory overhead and slightly improve detection accuracy.
[0102] S403: Input obstacle samples into the Yolov5s model for training to obtain a target detection model, which outputs a target detection box and a category ID.
[0103] After optimizing the YOLOv5 model, Figure 5 As shown, obstacle samples can be input into the YOLOv5 model for training, and after the training is completed, a target detection model is obtained, wherein the target detection model outputs a target detection box and a category ID. So far, the above S401 to S403 are the process of obtaining the target detection model, that is, the embodiment of the present application can realize target detection through the target detection model and determine the category and position of the obstacle.
[0104] S404: Collecting video frames including multiple dynamic obstacles through a camera of the lawn mower.
[0105] Since the target detection model has been obtained above, we can formally detect and track multiple dynamic targets, such as Figure 5 As shown, it is first necessary to collect video frames including multiple dynamic obstacles through the monocular camera of the lawn mower. During this process, the monocular camera of the lawn mower collects video in real time, extracts frames from the video, and obtains video frame data.
[0106] S405: Inputting the data of the video frame into the target detection model to obtain target detection frames and corresponding category IDs of multiple dynamic obstacles.
[0107] like Figure 5 As shown, in order to realize multiple dynamic target detection, the data of the video frame needs to be input into the target detection model to obtain the target detection frames and corresponding category IDs of multiple dynamic obstacles.
[0108] S406: Use the Kalman filter in the DeepSORT framework to predict the motion information of the target detection frame, and calculate the motion matching using the Mahalanobis space distance according to the motion information of the predicted frame and the motion information of the target detection frame.
[0109] After obtaining the target detection frames of multiple dynamic obstacles, Figure 5 As shown in the figure, multiple targets are tracked for multiple dynamic obstacles. Specifically, the Kalman filter in the DeepSORT framework is used to predict the motion information of the target detection frame, and the Mahalanobis space distance is used to measure the distance between the target detection frame and the prediction frame. The Mahalanobis space distance is thresholded; the Mahalanobis space distance less than the specified threshold is set as a successful association, thereby achieving motion matching.
[0110] S407: extracting the appearance features of multiple dynamic obstacles using the deep convolutional neural network in the DeepSORT framework through the target detection frame, and calculating the appearance matching using the Mahalanobis space distance according to the appearance features of the prediction frame and the appearance features of the target detection frame.
[0111] Since the embodiment of the present application uses the DeepSORT framework for multi-target tracking, in addition to motion matching, such as Figure 5 As shown, appearance matching is also required. Therefore, the deep convolutional neural network in the DeepSORT framework is used to extract the appearance features of multiple dynamic obstacles through the target detection frame, the image similarity between the target detection frame and the prediction frame is measured using the Mahalanobis space distance, and the Mahalanobis space distance is thresholded. The Mahalanobis space distance less than the specified threshold is set as an association success, thereby achieving appearance matching, which can improve the detection accuracy of occluded or overlapping obstacles.
[0112] S408: Perform cascade matching and IOU matching on multiple dynamic obstacles in the previous and next frames based on the Hungarian algorithm.
[0113] like Figure 5 As shown, after performing motion matching and appearance matching on multiple dynamic obstacles, the Hungarian algorithm can be used to perform cascade matching and IOU matching on multiple dynamic obstacles in the previous and next two frames, so as to calculate the matching degree of multiple dynamic obstacles in the previous and next two frames.
[0114] S409: Determine the tracking result by updating the tracker and the Kalman filter, and assign ID information to multiple dynamic obstacles.
[0115] like Figure 5 As shown, the state of the original tracker and the Kalman filter parameters are continuously updated, a new tracker is assigned to the newly confirmed tracking target, new ID information is assigned to the newly added detection target that has not been successfully matched, and the tracking target and its tracker whose matching failure exceeds the life cycle threshold are deleted, so as to determine the tracking result and assign ID information to the detection target, so as to distinguish static obstacles from dynamic obstacles.
[0116] S410: According to the positions of the dynamic obstacles associated with the same ID in each frame, the running tracks of the same dynamic obstacle ID in the video are obtained to output the predicted path behaviors of the multiple dynamic obstacles.
[0117] After assigning ID information, the running trajectory of the same dynamic obstacle ID in the video can be obtained according to the position of the dynamic obstacle associated with the same ID in each frame, so as to output the predicted path behavior of multiple dynamic obstacles and realize target tracking of multiple dynamic obstacles.
[0118] S411: Perform path planning for the lawn mower according to the predicted path behaviors of the multiple dynamic obstacles to avoid the multiple dynamic obstacles.
[0119] Finally, if Figure 5 As shown, after obtaining the predicted path behaviors of multiple dynamic obstacles, path planning can be performed according to the path planning module in the lawn mower to achieve the purpose of obstacle avoidance.
[0120] This embodiment provides a method for detecting and tracking multiple dynamic targets. First, the Yolov5s model is optimized and trained to obtain a target detection model. Then, the video frame data obtained by the lawn mower in real time is input into the target detection model to determine the categories and positions of multiple dynamic obstacles. The motion information and appearance characteristics of the multiple dynamic obstacles are predicted through the Deepsort framework, so as to assign IDs to the multiple dynamic obstacles and improve the detection accuracy of blocked or overlapping obstacles, thereby realizing target tracking of multiple dynamic obstacles. Then, according to the predicted path behavior of the multiple dynamic obstacles, the lawn mower can obtain path planning, thereby realizing obstacle avoidance of multiple dynamic obstacles.
[0121] See also Figure 6 The embodiment of the present application provides a detection and tracking device 600 for multiple dynamic targets, the device comprising:
[0122] A collection module 601 is used to collect video frames through a camera of the lawn mower, wherein the video frames include multiple dynamic obstacles;
[0123] A detection module 602 is used to input the data of the video frame into a target detection model to obtain a target detection frame of multiple dynamic obstacles, wherein the target detection frame includes position information and category information of the multiple dynamic obstacles, wherein the target detection model is a trained Yolov5s model, and the training sample of the target detection model is a set of obstacle samples taken by a lawn mower;
[0124] A tracking module 603 is used to track the multiple dynamic obstacles by predicting the motion information and appearance features of the multiple dynamic obstacles according to the target detection frame and the DeepSORT framework, and obtain the predicted path behaviors of the multiple dynamic obstacles, wherein the appearance features are extracted by a deep convolutional neural network;
[0125] The path planning module 604 is used to plan the path of the lawn mower according to the predicted path behaviors of the multiple dynamic obstacles to avoid the multiple dynamic obstacles.
[0126] Optionally, the device 600 further includes:
[0127] The training module is used to collect obstacle images taken by the lawn mower, clean them, classify them and label them to obtain obstacle samples; the obstacle samples are input into the EfficientNet of the backbone network Backbone of the Yolov5s model to obtain the feature map of the obstacle samples; the feature map of the obstacle samples is input into the Neck network of the Yolov5s model for fusion to obtain multi-scale feature maps; the multi-scale feature maps are input into the detection head network of the Yolov5s model, and the loss function is constructed based on the prediction box loss, category loss and confidence loss of the multi-scale feature maps; the Yolov5s model is trained using the loss function based on the obstacle samples to obtain the target detection model.
[0128] Optionally, the tracking module 603 includes:
[0129] The prediction submodule is used to predict the motion information of the target detection box using the Kalman filter in the DeepSORT framework
[0130] The motion matching submodule is used to calculate the motion matching using the Mahalanobis space distance according to the motion information of the prediction box and the motion information of the target detection box;
[0131] The appearance matching submodule is used to extract the appearance features of multiple dynamic obstacles through the target detection frame using the deep convolutional neural network in the DeepSORT framework, and calculate the appearance matching using the Mahalanobis space distance based on the appearance features of the prediction frame and the appearance features of the target detection frame;
[0132] Cascade matching and IOU matching submodules, used to perform cascade matching and IOU matching of multiple dynamic obstacles in the previous and next frames based on the Hungarian algorithm;
[0133] An update submodule, used to determine the tracking results and assign ID information to multiple dynamic obstacles by updating the tracker and Kalman filter;
[0134] The output submodule is used to obtain the running trajectory of the same dynamic obstacle ID in the video according to the position of the dynamic obstacle associated with the same ID in each frame, so as to output the predicted path behavior of multiple dynamic obstacles.
[0135] Optionally, the motion matching submodule is specifically used for:
[0136] The Mahalanobis space distance is used to measure the distance between the target detection box and the prediction box, and the Mahalanobis space distance is thresholded; the Mahalanobis space distance less than the specified threshold is set as association success.
[0137] Optionally, the appearance matching submodule is specifically used for:
[0138] The image similarity between the target detection box and the prediction box is measured using the Mahalanobis space distance, and the Mahalanobis space distance is thresholded; the Mahalanobis space distance less than the specified threshold is set as a successful association.
[0139] Optionally, the update submodule is specifically used to:
[0140] Update the status and Kalman filter parameters of the original tracker, assign a new tracker to the newly confirmed tracking target, assign new ID information to the newly added unmatched detection target, and delete the tracking target and its tracker whose matching failure exceeds the life cycle threshold.
[0141] It should be noted that the specific implementation method and effect of the multi-dynamic target detection and tracking device 600 can be found in the above Figure 1 or Figure 4 The relevant descriptions in the provided methods will not be repeated here.
[0142] The present application embodiment also provides an electronic device 700, such as Figure 7 As shown, the device 700 includes a memory 701 and a processor 702:
[0143] The memory 701 is used to store computer programs;
[0144] The processor 702 is used to execute the above Figure 1 or Figure 4 The method provided.
[0145] In addition, the present application also provides a computer-readable storage medium, the computer-readable storage medium is used to store a computer program, and the computer program is used to execute Figure 1 or Figure 4 The method provided.
[0146] Through the description of the above implementation methods, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment of the present application or some parts of the embodiments.
[0147] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described above is only schematic, in which the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the goals of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
[0148] The above description is merely an exemplary embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A method for detecting and tracking multiple dynamic targets, characterized in that: The method comprises: Capturing a video frame through a camera of the lawn mower, wherein the video frame includes a plurality of dynamic obstacles; Inputting the data of the video frame into a target detection model to obtain a target detection frame of the multiple dynamic obstacles, wherein the target detection frame includes position information and category information of the multiple dynamic obstacles, the target detection model is a trained Yolov5s model, and the training samples of the target detection model are a set of obstacle samples taken by the lawn mower; Predicting motion information and appearance features of the multiple dynamic obstacles according to the target detection frame and the DeepSORT framework to track the multiple dynamic obstacles and obtain predicted path behaviors of the multiple dynamic obstacles, wherein the appearance features are extracted by a deep convolutional neural network; According to the predicted path behaviors of the multiple dynamic obstacles, the path of the lawn mower is planned to avoid the multiple dynamic obstacles.
2. The method according to claim 1, characterized in that The training process of the target detection model includes: Collecting obstacle images taken by the lawn mower, performing cleaning, classification and category labeling processing, and obtaining obstacle samples; Input the obstacle sample into the EfficientNet of the backbone network Backbone of the Yolov5s model to obtain a feature map of the obstacle sample; Inputting the feature map of the obstacle sample into the Neck network of the Yolov5s model for fusion to obtain a multi-scale feature map; Inputting the multi-scale feature map into the detection head network of the Yolov5s model, and constructing a loss function based on the prediction box loss, category loss and confidence loss of the multi-scale feature map; The target detection model is obtained by training the Yolov5s model based on the obstacle sample using the loss function.
3. The method according to claim 1, characterized in that: The method of predicting the motion information and the appearance features of the multiple dynamic obstacles according to the target detection frame and the DeepSORT framework to track the multiple dynamic obstacles and obtain the predicted path behaviors of the multiple dynamic obstacles includes: Using the Kalman filter in the DeepSORT framework to predict the motion information of the target detection frame, and using the Mahalanobis space distance to calculate motion matching according to the motion information of the prediction frame and the motion information of the target detection frame; Extracting appearance features of the multiple dynamic obstacles using the deep convolutional neural network in the DeepSORT framework through the target detection frame, and calculating appearance matching using the Mahalanobis space distance according to the appearance features of the prediction frame and the appearance features of the target detection frame; Based on the Hungarian algorithm, cascade matching and IOU matching are performed on multiple dynamic obstacles in the previous and next two frames; Determine tracking results by updating the tracker and the Kalman filter, and assign ID information to the multiple dynamic obstacles; According to the positions of the dynamic obstacles associated with the same ID in each frame, the running tracks of the same dynamic obstacle ID in the video are obtained to output the predicted path behaviors of the multiple dynamic obstacles.
4. The method according to claim 3, characterized in that The calculating motion matching by using Mahalanobis space distance according to the motion information of the prediction frame and the motion information of the target detection frame comprises: The distance between the target detection frame and the prediction frame is measured by using the Mahalanobis space distance, and the Mahalanobis space distance is thresholded; and a Mahalanobis space distance less than a specified threshold is set as association success.
5. The method according to claim 3, characterized in that: The calculating the appearance matching by using the Mahalanobis space distance according to the apparent features of the prediction box and the apparent features of the target detection box includes: The image similarity between the target detection frame and the prediction frame is measured using the Mahalanobis space distance, and the Mahalanobis space distance is thresholded; and a Mahalanobis space distance less than a specified threshold is set as association success.
6. The method according to claim 3, characterized in that The updating of the tracker and the Kalman filter to determine the tracking result and assigning ID information to the multiple dynamic obstacles includes: Update the status and Kalman filter parameters of the original tracker, assign a new tracker to the newly confirmed tracking target, assign new ID information to the newly added unmatched detection target, and delete the tracking target and its tracker whose matching failure exceeds the life cycle threshold.
7. A detection and tracking device for multiple dynamic targets, characterized in that: The device comprises: A collection module, used for collecting video frames through a camera of the lawn mower, wherein the video frames include a plurality of dynamic obstacles; A detection module, used for inputting the data of the video frame into a target detection model to obtain a target detection frame of the multiple dynamic obstacles, wherein the target detection frame includes position information and category information of the multiple dynamic obstacles, the target detection model is a trained Yolov5s model, and the training samples of the target detection model are a set of obstacle samples taken by the lawn mower; A tracking module, configured to track the multiple dynamic obstacles and obtain predicted path behaviors of the multiple dynamic obstacles by predicting motion information and appearance features of the multiple dynamic obstacles according to the target detection frame and the DeepSORT framework, wherein the appearance features are extracted by a deep convolutional neural network; A path planning module is used to plan a path for the lawn mower according to the predicted path behaviors of the multiple dynamic obstacles so as to avoid the multiple dynamic obstacles.
8. The device according to claim 7, characterized in that The device also includes: The training module is used to collect obstacle images taken by the lawn mower, clean them, classify them and label them, and obtain obstacle samples; input the obstacle samples into the EfficientNet of the backbone network Backbone of the Yolov5s model to obtain feature maps of the obstacle samples; input the feature maps of the obstacle samples into the Neck network of the Yolov5s model for fusion to obtain multi-scale feature maps; input the multi-scale feature maps into the detection head network of the Yolov5s model, and construct a loss function based on the prediction box loss, category loss and confidence loss of the multi-scale feature maps; and train the Yolov5s model based on the obstacle samples using the loss function to obtain the target detection model.
9. An electronic device, characterized in that: The device includes a memory and a processor, and the processor is used to execute a program stored in the memory to run the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 6.
Citation Information
Cited By
Automatic sidewalk obstacle identification method and system and storage medium
CN118865215A
A method, system and storage medium for identifying obstacles on a moving walkway
CN118865215B
Dynamic target tracking method, system and equipment based on DeepSORT and medium
CN119131087A
Passing method and device of detection area, server, medium and product
CN119920100A
Obstacle avoidance method of unmanned aerial vehicle, storage medium, task machine and unmanned aerial vehicle system
CN120406516A
