Video frame detection and tracking method based on reinforcement learning
Through the video frame detection and tracking method based on reinforcement learning, the DQN model and reward function are used to make control decisions, which solves the problems of difficult threshold selection and high hardware requirements in the existing technology, and improves the real-time and accuracy of video stream analysis.
Patent Information
- Application Number
- CN202410993938.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-10-25
AI Technical Summary
Existing video target detection technology faces stuck problems caused by difficulty in threshold selection and high hardware requirements, making it difficult to achieve fast and accurate video stream analysis on devices with limited resources.
Adopting a video frame detection and tracking method based on reinforcement learning, by building a DQN model and defining a reward function, state information (deviation information and historical information) is used to make control decisions, decide when to perform target detection and when to perform target tracking, and optimize detection. and tracking transitions between.
Through intelligent decision-making optimization, the difficult problem of threshold selection is solved, the real-time performance of detection and tracking is improved, hardware requirements are reduced, and the effective utilization of spatio-temporal redundancy between video frames is achieved.
Smart Images

Figure CN118840692A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video frame detection and tracking, and in particular to a video frame detection and tracking method based on reinforcement learning. Background Art
[0002] With the rapid development of computer technology and artificial intelligence, we are gradually entering the multimedia information age. Information media has undergone tremendous changes, and video is gradually replacing images and text as the mainstream media. Object detection technology is gradually being applied to all aspects of production and life. Application scenarios such as industrial quality inspection, face recognition, video surveillance, and smart cities are inseparable from object detection technology. While video brings rich information and applications, it also brings some challenges, namely how to use the spatiotemporal redundancy between video frames to quickly and accurately analyze video streams on devices with limited resources.
[0003] At present, there are two main types of video target detection technologies. The first type is to directly deploy a target detection model to perform target detection on each frame of the video stream. If a lightweight target detection model is deployed, the target can be detected quickly, but the accuracy is not high; if a heavyweight target detection model is deployed, the detection accuracy is high, but a lot of processing time and computing resources are required, and the hardware equipment requirements are high. The second type is to combine the target detection model with the target tracking model, running a heavy but accurate detector every few frames, and applying a lightweight tracker between frames. The target tracking algorithm has less processing time and a smaller computational level, but the accuracy is not as good as the target detection algorithm, and the tracking effect continues to deteriorate over time. Therefore, this brings a new challenge: when to perform target detection and when to perform target tracking.
[0004] Research on methods that combine target detection models and target tracking models can make full use of the spatiotemporal redundancy between video frames. Redundant information such as background in multiple consecutive frames can be reduced by post-detection tracking to reduce a lot of unnecessary calculations. The current mainstream decision-making method is to achieve the transformation between detection and tracking by setting deviation thresholds and parallel detection and tracking. There are problems such as difficulty in threshold selection, high hardware requirements, and lag, which are specifically manifested as follows:
[0005] (1) Difficulty in selecting thresholds: The method of determining detection or tracking by comparing whether the pixel deviation between two frames is greater than a threshold is sensitive to environmental changes and it is difficult to find the optimal threshold.
[0006] (2) High hardware requirements and lag issues: The real-time performance of video analysis can be enhanced through parallel detection and tracking methods, but this places high demands on hardware devices. In addition, if the gap between frame detection time and frame arrival interval is too large, the cumulative frame waiting time will be too long, causing lag.
[0007] Therefore, technicians in this field are committed to developing a video frame detection and tracking method based on reinforcement learning, which can overcome the problem of difficult threshold selection and make accurate decision adjustments in terms of accuracy and latency. Summary of the invention
[0008] In view of the above-mentioned defects of the prior art, the technical problems to be solved by the present invention are the difficulty in selecting a threshold value and the high hardware requirements and the lag.
[0009] To achieve the above object, the present invention provides a video frame detection and tracking method based on reinforcement learning, the method comprising the following steps:
[0010] Step 1, obtain a video stream; assume that the video stream consists of F video frames, f = 1, ..., F;
[0011] Step 2: Build a reinforcement learning model, define the reward function and optimization objectives;
[0012] Step 3: Obtain state information, input the state information into the reinforcement learning model, and obtain the control decision a of the fth video frame f ;
[0013] Step 4: When a f = 0, it means to detect the current frame and execute the target detection method; when a f =1, it means tracking the current frame and executing the target tracking method.
[0014] Furthermore, the reinforcement learning model adopts a DQN model.
[0015] Furthermore, the reward function is expressed as:
[0016]
[0017] Among them, ω and is the weight;
[0018] The reward function of the fth frame is expressed as:
[0019]
[0020] Among them, a represents the control decision, a f represents the control decision of the f-th video frame; Indicates the accuracy of the current frame detection, Indicates the delay of current frame detection; Indicates the accuracy of the current frame tracking, Indicates the delay of the current frame tracking; Ω f Indicates the waiting delay of the current frame.
[0021] Furthermore, the optimization objective is modeled as:
[0022]
[0023] Furthermore, the state information includes deviation information and historical information; the deviation information is the deviation between the current frame and the previous key frame; the historical information consists of the distance between the current frame and the previous key frame, that is, the number of frames between them and the accumulated number of unprocessed frames.
[0024] Furthermore, the deviation uses the average value of the position offsets of the corner points in the detection frame of the previous key frame and the corresponding corner points in the current frame in the x-axis and y-axis directions respectively.
[0025] Furthermore, the target detection method adopts the Faster RCNN algorithm, the backbone network is resnet101, and is trained on the VOC2007 data set; the trained target detection method is used to preprocess the data, target detection is performed in the data set, and the data dictionary is stored in a file.
[0026] Furthermore, the data dictionary includes detection frame coordinates, labels, accuracy of current frame detection and delay of current frame detection; the detection frame coordinates are used for tracking subsequent non-key frames, and the accuracy of current frame detection and delay of current frame detection are used to calculate rewards.
[0027] Furthermore, the target tracking method adopts an optical flow algorithm based on Lucas-Kanade; the target tracking method includes:
[0028] Input two frames of images, including a first frame of image and a second frame of image;
[0029] Use the corner detection function to extract corner points in the first frame image as feature points;
[0030] Use the optical flow estimation function for tracking, find the position of the corresponding corner point in the second frame image, and return the coordinates of the tracking box to calculate the IOU as the accuracy of the current frame tracking;
[0031] The delay of the current frame tracking is obtained by counting the start time and the end time of the current frame tracking and making the difference;
[0032] The accuracy of the current frame tracking and the delay of the current frame tracking are used to calculate the reward.
[0033] Furthermore, the waiting delay of the current frame is calculated by the current time and the frame arrival time.
[0034] Compared with the prior art, the present invention has at least the following beneficial technical effects:
[0035] Based on the combination of target detection and target tracking, the present invention proposes a method for making control decisions based on reinforcement learning. The intelligent agent can optimize its own decision-making by continuously interacting and learning with the environment in order to achieve the maximum expected reward; by setting appropriate states and reward functions, a trade-off between accuracy and latency is achieved, and the trained model is used to make the best decision for dynamically changing video environment states; the problem of difficult threshold selection is solved and real-time performance is better.
[0036] The concept, specific structure and technical effects of the present invention will be further described below in conjunction with the accompanying drawings to fully understand the purpose, characteristics and effects of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 is a method flow chart of a preferred embodiment of the present invention;
[0038] Figure 2 This is a control decision comparison diagram of a preferred embodiment of the present invention after 300 frames of light load training and testing;
[0039] Figure 3 It is a control decision comparison diagram of a preferred embodiment of the present invention after heavy load training for 300 frames and testing. DETAILED DESCRIPTION
[0040] The following describes several preferred embodiments of the present invention with reference to the drawings in the specification, so that the technical content is clearer and easier to understand. The present invention can be embodied in many different forms of embodiments, and the protection scope of the present invention is not limited to the embodiments mentioned in the text.
[0041] In the drawings, components with the same structure are indicated by the same numerical reference numerals, and components with similar structures or functions are indicated by similar numerical reference numerals. The size and thickness of each component shown in the drawings are arbitrarily shown, and the present invention does not limit the size and thickness of each component. In order to make the illustration clearer, the thickness of the components is appropriately exaggerated in some places in the drawings.
[0042] This embodiment provides a video frame detection and tracking method based on reinforcement learning, the application scenario of which is to analyze a vehicle video stream captured by a traffic camera, including the following steps:
[0043] Step 1: Get a video stream. Assume that the video stream consists of F video frames, f=1,...,F.
[0044] Step 2: Build a reinforcement learning model, define the reward function and optimization objectives;
[0045] The reinforcement learning model used is the DQN (Deep Q-Network) model; in order to achieve a trade-off between accuracy and latency, the reward function of reinforcement learning is defined as where ω and is the weight;
[0046] The goal of reinforcement learning is to maximize the average reward of each frame, where the reward of the fth frame can be expressed as:
[0047]
[0048] Let a represent the control decision, then a f represents the control decision of the f-th video frame; when a f =0, it means to detect the current frame. Indicates the accuracy of the current frame detection, Indicates the delay of the current frame detection; when a f =1, it means tracking the current frame. Indicates the accuracy of the current frame tracking, Indicates the delay of the current frame tracking; Ω f Indicates the waiting delay of the current frame, which is calculated from the current time and the frame arrival time;
[0049] Then the optimization objective can be modeled as:
[0050]
[0051] Step 3: Figure 1 As shown in the figure, the state information state is obtained. The state consists of deviation information and historical information. The deviation information is the deviation between the current frame, i.e., the i-th frame, and the previous key frame. The deviation uses the average value of the position offset of the corner point in the detection box of the previous key frame and the corresponding corner point in the current frame in the x-axis and y-axis directions respectively; the historical information consists of the distance between the current frame and the previous key frame, i.e., the number of frames separated, and the accumulated number of unprocessed frames; the state is input into the trained DQN model to get the action, i.e., a f The value of .
[0052] Step 4: When a f = 0, the detection frame coordinates and labels can be obtained; and Use Faster RCNN as the target detection method;
[0053] The backbone network is resnet101, which is trained on the VOC2007 dataset. The trained target detection method is used to preprocess the data, and target detection is performed on the dataset. The data dictionary consisting of the detection frame coordinates, labels, the accuracy of the current frame detection, and the delay of the current frame detection is stored in the file;
[0054] The detection frame coordinates are used for tracking subsequent non-key frames. The accuracy of the current frame detection and the delay of the current frame detection are and Used to calculate rewards
[0055] when a f = 1, the tracking frame coordinates and labels can be obtained; and Use Lucas-Kanade based optical flow algorithm as target tracking method;
[0056] This method takes two frames of images as input. First, the corner detection function is used to extract corners in the first frame as feature points (corner points are pixels with unique local structures in the image, usually located at the junction of the image edges or where the texture changes significantly. These points show good stability in image transformation and are therefore very suitable for tracking). Then, the optical flow estimation function is used for tracking, and the position of the corresponding corner points is found in the second frame. The coordinates of the tracking box are returned to calculate the IOU as the accuracy of the current frame tracking. The delay of the current frame tracking is obtained by counting the start time and the end time of the current frame tracking and subtracting them. Finally, the accuracy of the current frame tracking is The delay between the current frame tracking and Used to calculate rewards
[0057] Through the above steps, appropriate decisions can be made for frames in the video stream to obtain corresponding rewards and achieve a trade-off between accuracy and latency.
[0058] like Figure 2 As shown in the figure, it is a decision comparison chart of training 300 frames and testing under light load mode, that is, when the frame waiting time is 0. It can be seen that the model effect is better than all detection or tracking, fixed detection interval, fixed deviation threshold and random selection decision.
[0059] like Figure 3 As shown in the figure, the serial model represents the decision comparison diagram of training 300 frames and testing under heavy load mode, that is, when the frame waiting delay is not 0. Although the overall accuracy is reduced by 50%, the total waiting time is reduced by 76%, which increases the real-time performance.
[0060] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A video frame detection and tracking method based on reinforcement learning, It is characterized in that The method comprises the following steps: Step 1, obtain a video stream; assume that the video stream consists of F video frames, f = 1, ..., F; Step 2: Build a reinforcement learning model, define the reward function and optimization objectives; Step 3: Obtain state information, input the state information into the reinforcement learning model, and obtain the control decision a of the fth video frame f ; Step 4: When a f = 0, it means to detect the current frame and execute the target detection method; when a f =1, it means tracking the current frame and executing the target tracking method.
2. The video frame detection and tracking method based on reinforcement learning as claimed in claim 1, It is characterized in that The reinforcement learning model adopts the DQN model.
3. The video frame detection and tracking method based on reinforcement learning as claimed in claim 1, It is characterized in that The reward function is expressed as: Among them, ω and is the weight; The reward function of the fth frame is expressed as: Among them, a represents the control decision, a f represents the control decision of the f-th video frame; Indicates the accuracy of the current frame detection, Indicates the delay of current frame detection; Indicates the accuracy of the current frame tracking, represents the delay of current frame tracking; Ωf represents the waiting delay of current frame.
4. The video frame detection and tracking method based on reinforcement learning as claimed in claim 3, It is characterized in that The optimization objective model is: s.t.a f ∈{0,1}。 5. The video frame detection and tracking method based on reinforcement learning as claimed in claim 1, It is characterized in that The state information includes deviation information and historical information; the deviation information is the deviation between the current frame and the previous key frame; the historical information consists of the distance between the current frame and the previous key frame, that is, the number of frames between them and the accumulated number of unprocessed frames.
6. The video frame detection and tracking method based on reinforcement learning as claimed in claim 5, It is characterized in that The deviation uses the average value of the position offsets of the corner points in the detection frame of the previous key frame and the corresponding corner points in the current frame in the x-axis and y-axis directions respectively.
7. The video frame detection and tracking method based on reinforcement learning as claimed in claim 3, It is characterized in that The target detection method adopts the Faster RCNN algorithm, the backbone network is resnet101, and training is performed on the VOC2007 data set; the trained target detection method is used to preprocess the data, target detection is performed in the data set, and the data dictionary is stored in a file.
8. The video frame detection and tracking method based on reinforcement learning as claimed in claim 7, It is characterized in that The data dictionary includes detection frame coordinates, labels, accuracy of current frame detection and delay of current frame detection; the detection frame coordinates are used for tracking subsequent non-key frames, and the accuracy of current frame detection and delay of current frame detection are used to calculate rewards.
9. The video frame detection and tracking method based on reinforcement learning as claimed in claim 3, It is characterized in that The target tracking method adopts an optical flow algorithm based on Lucas-Kanade; The target tracking method comprises: Input two frames of images, including a first frame of image and a second frame of image; Use the corner detection function to extract corner points in the first frame image as feature points; Use the optical flow estimation function for tracking, find the position of the corresponding corner point in the second frame image, and return the coordinates of the tracking box to calculate the IOU as the accuracy of the current frame tracking; The delay of the current frame tracking is obtained by counting the start time and the end time of the current frame tracking and making the difference; The accuracy of the current frame tracking and the delay of the current frame tracking are used to calculate the reward.
10. The video frame detection and tracking method based on reinforcement learning as claimed in claim 3, It is characterized in that The waiting delay of the current frame is calculated by the current time and the frame arrival time.
Citation Information
Patent Citations
Target tracking optimization method based on tracking learning detection
CN107967692A
Target detecting and tracking method and device and computer equipment
CN110400332A
Dynamic task scheduling method for video detection and tracking
CN115002409A
