A gimbal camera-oriented moving object intelligent tracking method and device
By constructing a reinforcement learning model and using frame sampling technology to optimize the moving object tracking method of PTZ cameras, the problem of time-consuming and power-consuming processes in existing technologies has been solved, achieving efficient and low-energy moving object tracking, and improving the intelligence and applicability of monitoring.
Patent Information
- Application Number
- CN202310168870.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-27
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2043-02-27
AI Technical Summary
Existing methods for tracking moving objects using PTZ cameras are time-consuming and power-intensive, making it difficult to maintain tracking of moving objects for extended periods, especially in scenarios with frequent movement such as pedestrians.
By constructing a reinforcement learning model that includes multi-layer neural networks and customized reward and punishment mechanisms, and combining motion trajectory analysis, the generation and execution of gimbal rotation commands are optimized. Frame sampling is used to match the object's movement speed, reducing redundant commands.
It achieves efficient and low-energy-consumption tracking of moving objects, improves the effectiveness and intelligence of monitoring, and is suitable for outdoor solar-powered scenarios, reducing power consumption.
Smart Images

Figure CN116385482B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent monitoring technology, and in particular to an intelligent tracking method and device for moving objects using a PTZ camera. Background Technology
[0002] Pan-tilt cameras have been widely used in recent years for monitoring scenarios such as home care for the elderly / children and shop anti-theft alarms. They support automatic tracking of moving objects and can provide wider area coverage than fixed cameras, thus holding promise for future applications in large-scale outdoor monitoring scenarios such as rural areas, fish farms, orchards, and factories. Currently, mainstream commercial pan-tilt cameras use a grid-based tracking method. Two stepper motors drive a gear shaft to rotate the pan-tilt unit grid by grid. Visual detection algorithms (usually background subtraction or frame differencing) continuously search for moving objects, then determine the grid point in the direction the camera is facing, making it closest to the center of the object (the horizontal tracking process of the pan-tilt unit is as follows). Figure 1 (As shown). Specifically, when the object's direction is between two adjacent grid points and closer to the grid point it just rotated through, the gimbal will rotate back so that the grid point facing the camera is the grid point it just rotated through. However, the process of frequently accelerating, decelerating, rotating (or even rotating back) between two-dimensional grid points to search for the optimal grid point is time-consuming and power-intensive, making it difficult to keep the tracked object within the camera's field of view for a long time. Alternatively, a gimbal camera driven by a servo motor can be assembled, employing a target-based tracking method. That is, after visually detecting the object as the target, the gimbal rotates according to the target's movement direction, ensuring that the camera's front is always facing the target's center (the horizontal tracking process of the gimbal is as follows). Figure 2 (As shown). Although this method can overcome time-consuming rotations, it is sensitive to subtle movements of objects, leading to excessive stacking of rotation instructions for asynchronous execution, which is equally time-consuming and power-intensive.
[0003] One intuitive way to overcome the above problems is to set a tolerance boundary around the center of the camera's field of view and avoid gimbal rotation when the target object's center only moves within the boundary. However, since the boundary size is constrained by many object properties (object size, movement speed, and direction, etc.), it is difficult to set a suitable value in practice. Too small a value cannot reduce the frequency of rotation command generation, while too large a value affects the timeliness of the camera's object tracking. Another improvement method is to use proportional-integral-derivative (PID) control, iteratively calculating the difference between the object and the camera's field of view center as the error value, and obtaining the gimbal rotation angle based on proportional, integral, and derivative corrections. However, the PID coefficients are determined by the motor and object properties, requiring complex online debugging to meet the effective criteria. In summary, existing tracking methods for gimbal cameras determine gimbal rotation only based on the instantaneous position of the detected object, which easily leads to tracking failure due to the inability to track in a timely manner, makes it difficult to maintain tracking for long periods, and generates considerable power consumption. This is especially unsuitable for tracking frequently moving objects such as pedestrians and in energy-constrained scenarios. Summary of the Invention
[0004] The purpose of this invention is to provide a method and apparatus for tracking moving objects with high efficiency and low power consumption using a gimbal camera. By closely monitoring the state changes of the target object, unnecessary gimbal rotation is avoided, enabling real-time object tracking for extended periods while minimizing rotation overhead, thus solving the practical problems existing in the prior art.
[0005] To achieve the above objectives, this invention provides an intelligent tracking method for moving objects using a PTZ camera, which mainly includes the following steps:
[0006] Step 1: By performing correlation filtering on the position and size features of moving objects, the same objects appearing in consecutive frames are associated, and two key points of the target object in each frame are abstracted to construct the motion trajectory in the panoramic space of the PTZ camera's field of view.
[0007] Step 2: Based on the object state change information indicated in the motion trajectory obtained in real time in Step 1, construct a reinforcement learning model containing multi-layer neural networks and a customized reward and punishment mechanism. Make online decisions to adjust the gimbal rotation amplitude based on the spatiotemporal information of the object's motion trajectory, and integrate the learning experience of tracking the same type of object in Step 1 to accelerate model convergence.
[0008] Step 3: Based on the reinforcement learning model in Step 2, the decision generation and execution of its output rotation command are processed in a pipeline manner, redundant commands in the buffer queue are merged or eliminated, and low-frequency moving objects are tracked by frame sampling. The sampling interval is adaptively adjusted according to the object motion information to match the gimbal rotation and the object movement speed.
[0009] Furthermore, step 1 is completed through three modules: moving object detection, cross-frame target association, and motion trajectory construction. Specifically,
[0010] Step 1.1: The moving object detection module integrates optical flow into the detection algorithm used by mainstream PTZ cameras to solve the problem of incomplete object pixels affecting positioning accuracy.
[0011] Step 1.2: In the cross-frame target association module, correlation filtering is used to perform element-wise operations in the frequency domain to match target objects in different frames in order to eliminate background noise and interference from other objects on tracking.
[0012] Step 1.3: In the motion trajectory construction module, the object's motion trajectory is constructed in the same space using the object information such as position, size, and accurate contour continuously obtained from the above two modules.
[0013] Step 2 is completed through two modules: online model inference and fusion of learning experiences. Specifically,
[0014] Step 2.1: In the online inference module of the model, the information obtained in step 1 is used to infer the next state of the object based on the reinforcement learning model and perform appropriate gimbal rotation accordingly, so as to minimize the rotation cost of the gimbal while keeping the object tracked.
[0015] Step 2.2, the learning experience fusion module integrates the learning experience of tracking the same type of objects in step 1 into the model, so that the model can converge as soon as possible and make reasonable inferences, avoiding the cold start problem when initially tracking objects;
[0016] Step 3 is completed through two modules: rotation command processing and video frame sampling. Specifically,
[0017] Step 3.1: The rotation command processing module adopts a pipeline approach to process the decision generation and execution of rotation commands in order to reduce the impact of the speed difference between the mechanical rotation speed and the command generation speed on the timeliness of object tracking, thereby reducing the risk of tracking failure.
[0018] Step 3.2: The video frame sampling module extracts sample frames at a dynamic low frequency for processing to exclude frames that do not pose a risk of object tracking loss and reduce the number of generated instructions to adapt to low-speed mechanical rotation.
[0019] Furthermore, the moving object detection module in step 1.1 completes the following steps:
[0020] Step 1.1.1: Divide each frame image into a series of square regions, where the side length a of the region is the greatest common divisor of the frame width w and height h, i.e. a = gcd(w,h);
[0021] Step 1.1.2, for any frame F t Take the first two frames F t-1 and F t-2 Calculate the pixel difference between two adjacent frames and take their intersection D. t =|F t –F t-1 |∩|F t-1 –F t-2 |As a differential frame;
[0022] Step 1.1.3: After thresholding the differential frames to eliminate background noise, extract the set of pixels with the largest connected region.
[0023] Step 1.1.4: For each pixel (x, y) of the extracted region, calculate the two-dimensional optical flow vector based on the Lucas-Kanade algorithm, denoted as... Obtain the complete outline of the object and its motion pattern between adjacent frames.
[0024] Furthermore, the cross-frame target association module completes this through the following steps:
[0025] Step 1.2.1, construct a position filter f p A set of sample images is obtained by sampling the frame image at twice the size of the object, and features are extracted from all pixels of each sample image;
[0026] Step 1.2.2, construct a size filter f s A small sample set of object sizes is created by scaling up and down the objects.
[0027] Step 1.2.3, for the two filters f x (x=p,s), calculate the value of each image or sample h. k correlation in and This refers to the two-dimensional Fast Fourier Transform and its inverse operation. ⊙ and * represent element-wise multiplication and complex conjugation, respectively. A suitable filter f can be found using the least squares optimization method. p and f s and the corresponding h k Achieve maximum relevance;
[0028] Step 1.2.4: Using the obtained filter position and size, locate the two-dimensional coordinates of the center of the target object and the side length of the object's circumscribed square in the frame, and call step 1.1.4 to obtain the object's outline based on the circumscribed square;
[0029] The above process is iteratively executed until no object is associated in three consecutive frames. Then, steps 1.1.2 to 1.1.4 are executed to re-detect moving objects. When there are multiple objects in the camera's field of view, the same method is used to continuously track the identified target object.
[0030] Furthermore, the motion trajectory construction module completes this through the following steps:
[0031] Step 1.3.1, based on the object contour and its internal pixel set P = {(p x i ,p y i )}(i=1,…,n), calculate the coordinates of the centroid of the object (c x ,c y ) is c v =[(∑ i p v i ) / n](v=x,y), where the operator [] indicates rounding to the nearest integer, where, in order to reduce the influence of small motions, the object's centroid is used instead of the center of the circumscribed square to represent the object's position;
[0032] Step 1.3.2: Extract the x and y coordinates of the contour point with the largest horizontal and vertical distance from the image center to construct a virtual boundary point (b). x ,b y ), where b v =max i {|p v i |}(v=x,y), where the operator || represents the absolute value of the coordinates, paying special attention to the positional changes of the object contour points closest to the frame image boundary to keep the object within the camera's field of view;
[0033] Step 1.3.3, the centroid (c) of the above object x ,c y ) and virtual boundary points (b x ,b y These two key points, with their coordinates relative to the image center in different frames, are uniformly converted into their absolute coordinates (θ) within the 360° panoramic space generated by the camera's field of view and the gimbal rotation. cp ,θ ct )(θ bp ,θ bt The conversion method is as follows: Where (θ) gp ,θ gt θ represents the horizontal and vertical angles of the current camera's facing direction in the panoramic space, where θ gu ∈[-1 / 2Θ gu ,1 / 2Θ gu (u=p,t), maximum rotation angle Θ gp and Θ gt Set by the manufacturer, w and h are the width and height of the frame image, and the viewpoint. It can be calculated by arctan(d / 2f), where d and f are the reticulum size and focal length provided by the manufacturer, respectively;
[0034] Step 1.3.4, based on the current frame F m The object's motion trajectory vector is constructed from the coordinates of its key points in the previous frame in panoramic space, denoted as .
[0035] Furthermore, the online inference module of the model completes this through the following steps:
[0036] Step 2.1.1: Construct a reinforcement learning model. The input consists of a Long Short-Term Memory (LSTM) structure with k units, used to mine implicit spatiotemporal features hidden in the motion trajectory. This is followed by two similar neural networks: one outputs a rotation action based on the extracted features (called the Actor), and the other judges the action's value (called the Critic). Each neural network contains two fully connected layers and one output layer. The flattened sequence of the LSTM units is input into the fully connected layers of both neural networks, using the tanh activation function to enhance learning ability. The output layer of the Actor network uses softmax as the activation function to generate a probability distribution for selecting each action, thus outputting the action with the highest probability. The reinforcement learning model is denoted as S based on the state sequence of the current frame. m Let a be the rotational motion performed. m The control strategy based on iterative learning and updating is π(S) m ,a m The output layer of the Critic network is a linear neuron that estimates the expected total reward or penalty starting from the current state, π(S). m ,a m The corresponding value of ) is denoted as V. π (S m To meet the requirements of online inference, algorithms such as Proximity Optimization (PPO) should be used during model training to promote rapid model convergence and smoothly update policy parameters to generate reasonable decisions as quickly and stably as possible.
[0037] Step 2.1.2: Combine the k nearest quadruplets of the object's trajectory obtained in Step 1.3.4 with the current camera facing direction (θ). gp ,θ gt As a state-input reinforcement learning model, in order to match the LSTM structure that the model receives input, frame F... m The actual input state sequence is adjusted to The first four elements are sequences extracted column-wise from the k most recent four-tuples and differiated with the corresponding camera facing direction at that moment, denoted as follows:
[0038] Step 2.1.3: Infer the corresponding gimbal rotation motion a online. m =(a p m ,a t m ), where a p m and a t m All originate from a discrete action space A = {ω*j} (j∈[-n) a ,n a]∩Z) is selected, where ω represents a rotation angle unit, n a This is the rotation amplitude (maximum number of angular units), and the two dimensions are represented by (n... ap ,n at This means that ω*n needs to be satisfied. au <1 / 2Θ u (u = p, t);
[0039] Step 2.1.4: Redirect the camera and update the object trajectory to generate a new state S. m+1 And calculate with action a m Related reward / penalty value r m To enable the model to continuously learn, while the object remains within the camera's field of view, the focus is primarily on its distance to the boundary of the field of view and its direction of movement, setting a position reward / penalty value r. p m and directional reward / penalty value r d m Both are based on state S m+1 The camera is facing in the direction (θ) gp m+1 ,θ gt m+1 ) and object motion sequence The calculation formulas are r p m =1–2|θ bp m+1 | / Θ p –2|θ bt m+1 | / Θ t and r d m =-(θ) cp m+1 θ cp Δ +θ ct m+1 θ ct Δ ) / [(|θ cp m+1 |+|θ ct m+1 |)*(|θ cp Δ |+|θ ct Δ |)], where θ cu Δ =θ cu m+1 –θ cu m(u = p, t); Once the object leaves the camera's field of view, the gimbal will immediately rotate to the direction corresponding to the most recently acquired object's centroid to resume tracking. For this situation, a penalty value r for tracking the object needs to be set. l m A sufficiently large negative value, such as -10, to reflect action a. m The adverse effects; and the cost penalty value for gimbal rotation should be related to the amplitude, calculated using the formula r. c m =1–a p m / (ω*n ap )–a t m / (ω*n at Overall reward and punishment value r m It should include all four reward and punishment components mentioned above, and can be implemented through r m =μr l m +(1–μ)(βr p m +δr d m +ηr c m The calculation is obtained, where μ∈{0,1} represents action a. m Whether to remove the object from the camera's field of view, where 1 represents the case of removal, and β, δ, and η are hyperparameters that are set. The optimal values are verified to be 1, 1, and 2 according to grid search.
[0040] Furthermore, the learning experience integration module is completed through the following steps:
[0041] Step 2.2.1: Collect a certain number of previously used object tracking model records. Each model adopts the LSTM and neural network structure described in Step 2.1.1. Assume there are n models in total, and each model contains m neural network units.
[0042] Step 2.2.2, using matrix Ξ ij =(ξ ij ) n*m Let ξ represent the neural network parameters of all models, where the element ξ is... ij This represents the parameter of the j-th unit in model i;
[0043] Step 2.2.3: Take the weighted average of the parameters of the corresponding units in different models to obtain an aggregate model, where the parameter elements are obtained through... Where ρ iThe weights represent the experience weights of model i. Usually, all previous models have the same weights. However, if a model has tracked the same object, it can be determined by the ReID method, and a higher weight is set for the corresponding model to learn from more experience.
[0044] Furthermore, the rotation command processing module in step 3.1 completes the process through the following steps:
[0045] Step 3.1.1: After each action output by the model based on step 2.1.4, generate rotation command I. r =(a p ,a t ,θ gp ,θ gt ) is added to the instruction queue, where (a p ,a t ) is the inferred rotation motion of the gimbal, while (θ) gp ,θ gt () indicates the direction the camera is facing when performing the action;
[0046] Step 3.1.2: Set up an asynchronous controller to retrieve one rotation command from the command queue each time, and execute the mechanical rotation by calling the command to control the motor; for the direction including the camera's facing direction (θ) gp i ,θ gt i ) and the current actual direction the camera is facing (θ) gp c ,θ gt c Inconsistent instructions are eliminated to avoid executing outdated instructions that could cause rotational errors.
[0047] Step 3.1.3: Instructions containing small-amplitude rotation movements are cached in the queue and the rotation is not executed immediately. Only the relative coordinates of the camera's facing direction and the object are virtually updated. For a series of consecutive small-amplitude rotation instructions... Satisfying θ gp k+1 =θ gp k +a p k (u = p, t) can combine these instructions into a new instruction I. r b =(θ gp m –θ gp 1 ,θ gt m –θ gt 1 ,θ gp 1 ,θgt 1 Then only the newly constructed instructions are executed.
[0048] Furthermore, the video frame sampling module in step 3.2 is completed through the following steps:
[0049] Step 3.2.1: Buffer the video frames continuously into a queue at the frame rate set by the camera, usually 15 or 30 frames per second;
[0050] Step 3.2.2, using dynamically changing sample frame intervals T. s Frame sampling is performed, and the number of sample frame intervals T is recursively calculated by combining the rotation execution speed with the position and motion direction of the currently tracked object. s k =T s k-1 *(1+σmin{r p k-1 ,r d k-1})*v r k-1 / v r k , where v r r represents the number of rotations performed per second. p and r d These are the object position and orientation reward / penalty values described in step 2.1.3, with the factor σ∈(0,1) used to limit the influence of object motion. This allows for a reduction in frame processing frequency when the rotation execution speed decreases and the object is less likely to leave the camera's field of view, i.e., an increase in the sampling interval, and vice versa.
[0051] Step 3.2.3: Input only the object motion information extracted from the sample frames into the model constructed in step 2.1.1.
[0052] Meanwhile, this invention also provides a mobile object intelligent tracking device for gimbal cameras. The device includes an object tracking component, an intelligent decision-making component, and a rotation control component. The object tracking component performs correlation filtering on the position and size features of moving objects, associates the same objects appearing in consecutive frames, abstracts two key points of the target object in each frame, and constructs a motion trajectory in the panoramic space of the gimbal camera's field of view. The intelligent decision-making component constructs a reinforcement learning model containing multi-layer neural networks and a customized reward and punishment mechanism based on the object state change information indicated in the motion trajectory obtained in real time by the object tracking component. It makes online decisions to adjust the gimbal rotation amplitude based on the spatiotemporal information of the object's motion trajectory and integrates the learning experience of the object tracking component in tracking the same type of objects to accelerate model convergence. The rotation control component, based on the reinforcement learning model of the intelligent decision-making component, uses a pipeline approach to process the decision generation and execution of its output rotation commands, merges or eliminates redundant commands in the buffer queue, and uses frame sampling to track low-frequency moving objects. It adaptively adjusts the sampling interval according to the object's motion information to match the gimbal rotation with the object's movement speed.
[0053] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0054] This invention utilizes an intelligent motion tracking algorithm combined with gimbal functionality to achieve a highly efficient and low-power intelligent tracking method for moving objects, significantly improving the effectiveness and intelligence of monitoring. Compared to existing methods, it offers substantial improvements in both continuous tracking time and rotational power consumption, making it highly suitable for various outdoor solar-powered monitoring scenarios. Furthermore, this method is simple to implement and has low hardware requirements, making it easy to integrate with commercial gimbal camera chips. It is foreseeable that manufacturing gimbal cameras equipped with this invention will provide favorable support for industrial and agricultural development, bringing significant social and economic benefits. Attached Figure Description
[0055] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0056] Figure 1 This describes the tracking process of a gimbal in the horizontal direction using a grid-based tracking method in existing technologies.
[0057] Figure 2 This describes the tracking process of the gimbal in the horizontal direction based on target tracking methods in existing technologies;
[0058] Figure 3 This is a basic architecture diagram of an embodiment of the present invention, including the interaction process between three components;
[0059] Figure 4This is the panoramic space of the camera's field of view for the object tracking component in an embodiment of the present invention;
[0060] Figure 5 This is a reinforcement learning model for the intelligent decision-making component in an embodiment of the present invention.
[0061] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0062] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. Terms such as "step 1," "step 2," "step 3," etc., used in this specification are to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in sequences other than those described herein.
[0063] The invention will be further described below with reference to the accompanying drawings.
[0064] This invention provides a method for intelligent tracking of moving objects using a PTZ camera, which mainly includes the following steps:
[0065] Step 1: By performing correlation filtering on the position and size features of moving objects, the same objects appearing in consecutive frames are associated, and two key points of the target object in each frame are abstracted to construct the motion trajectory in the panoramic space of the PTZ camera's field of view.
[0066] Step 2: Based on the object state change information indicated in the motion trajectory obtained in real time in Step 1, construct a reinforcement learning model containing multi-layer neural networks and a customized reward and punishment mechanism. Make online decisions to adjust the gimbal rotation amplitude based on the spatiotemporal information of the object's motion trajectory, and integrate the learning experience of tracking the same type of object in Step 1 to accelerate model convergence.
[0067] Step 3: Based on the reinforcement learning model in Step 2, the decision generation and execution of its output rotation command are processed in a pipeline manner, redundant commands in the buffer queue are merged or eliminated, and low-frequency moving objects are tracked by frame sampling. The sampling interval is adaptively adjusted according to the object motion information to match the gimbal rotation and the object movement speed.
[0068] Step 1 is completed through three modules: moving object detection, cross-frame target association, and motion trajectory construction. Specifically,
[0069] Step 1.1: The moving object detection module integrates optical flow into the detection algorithm used by mainstream PTZ cameras to solve the problem of incomplete object pixels affecting positioning accuracy.
[0070] Step 1.2: In the cross-frame target association module, correlation filtering is used to perform element-wise operations in the frequency domain to match target objects in different frames in order to eliminate background noise and interference from other objects on tracking.
[0071] Step 1.3: In the motion trajectory construction module, the object's motion trajectory is constructed in the same space using the object information such as position, size, and accurate contour continuously obtained from the above two modules.
[0072] Step 2 is completed through two modules: online model inference and fusion of learning experiences. Specifically,
[0073] Step 2.1: In the online inference module of the model, the information obtained in step 1 is used to infer the next state of the object based on the reinforcement learning model and perform appropriate gimbal rotation accordingly, so as to minimize the rotation cost of the gimbal while keeping the object tracked.
[0074] Step 2.2, the learning experience fusion module integrates the learning experience of tracking the same type of objects in step 1 into the model, so that the model can converge as soon as possible and make reasonable inferences, avoiding the cold start problem when initially tracking objects;
[0075] Step 3 is completed through two modules: rotation command processing and video frame sampling. Specifically,
[0076] Step 3.1: The rotation command processing module adopts a pipeline approach to process the decision generation and execution of rotation commands in order to reduce the impact of the speed difference between the mechanical rotation speed and the command generation speed on the timeliness of object tracking, thereby reducing the risk of tracking failure.
[0077] Step 3.2: The video frame sampling module extracts sample frames at a dynamic low frequency for processing to exclude frames that do not pose a risk of object tracking loss and reduce the number of generated instructions to adapt to low-speed mechanical rotation.
[0078] The moving object detection module in step 1.1 completes the following steps:
[0079] Step 1.1.1: Divide each frame image into a series of square regions, where the side length a of the region is the greatest common divisor of the frame width w and height h, i.e. a = gcd(w,h);
[0080] Step 1.1.2, for any frame F t Take the first two frames F t-1 and F t-2 Calculate the pixel difference between two adjacent frames and take their intersection D. t =|F t –F t-1 |∩|F t-1 –F t-2 |As a differential frame;
[0081] Step 1.1.3: After thresholding the differential frames to eliminate background noise, extract the set of pixels with the largest connected region.
[0082] Step 1.1.4: For each pixel (x, y) of the extracted region, calculate the two-dimensional optical flow vector based on the Lucas-Kanade algorithm, denoted as... Obtain the complete outline of the object and its motion pattern between adjacent frames.
[0083] The cross-frame target association module completes this through the following steps:
[0084] Step 1.2.1, construct a position filter f p A set of sample images is obtained by sampling the frame image at twice the size of the object, and features are extracted from all pixels of each sample image;
[0085] Step 1.2.2, construct a size filter f s A small sample set of object sizes is created by scaling up and down the objects.
[0086] Step 1.2.3, for the two filters f x (x=p,s), calculate the value of each image or sample h. k correlation in and This refers to the two-dimensional Fast Fourier Transform and its inverse operation. ⊙ and * represent element-wise multiplication and complex conjugation, respectively. A suitable filter f can be found using the least squares optimization method. p and f s and the corresponding h k Achieve maximum relevance;
[0087] Step 1.2.4: Using the obtained filter position and size, locate the two-dimensional coordinates of the center of the target object and the side length of the object's circumscribed square in the frame, and call step 1.1.4 to obtain the object's outline based on the circumscribed square;
[0088] The above process is iteratively executed until no object is associated in three consecutive frames. Then, steps 1.1.2 to 1.1.4 are executed to re-detect moving objects. When there are multiple objects in the camera's field of view, the same method is used to continuously track the identified target object.
[0089] like Figure 4 As shown, the motion trajectory construction module completes the process through the following steps:
[0090] Step 1.3.1, based on the object contour and its internal pixel set P = {(p xi ,p y i )}(i=1,…,n), calculate the coordinates of the centroid of the object (c x ,c y ) is c v =[(∑ i p v i ) / n](v=x,y), where the operator [] indicates rounding to the nearest integer, where, in order to reduce the influence of small motions, the object's centroid is used instead of the center of the circumscribed square to represent the object's position;
[0091] Step 1.3.2: Extract the x and y coordinates of the contour point with the largest horizontal and vertical distance from the image center to construct a virtual boundary point (b). x ,b y ), where b v =max i {|p v i |}(v=x,y), where the operator || represents the absolute value of the coordinates, paying special attention to the positional changes of the object contour points closest to the frame image boundary to keep the object within the camera's field of view;
[0092] Step 1.3.3, the centroid (c) of the above object x ,c y ) and virtual boundary points (b x ,b y These two key points, with their coordinates relative to the image center in different frames, are uniformly converted into their absolute coordinates (θ) within the 360° panoramic space generated by the camera's field of view and the gimbal rotation. cp ,θ ct )(θ bp ,θ bt The conversion method is as follows: Where (θ) gp ,θ gt θ represents the horizontal and vertical angles of the current camera's facing direction in the panoramic space, where θ gu ∈[-1 / 2Θ gu ,1 / 2Θ gu (u=p,t), maximum rotation angle Θ gp and Θ gt Set by the manufacturer, w and h are the width and height of the frame image, and the viewpoint. It can be calculated by arctan(d / 2f), where d and f are the reticulum size and focal length provided by the manufacturer, respectively;
[0093] Step 1.3.4, based on the current frame F mThe object's motion trajectory vector is constructed from the coordinates of its key points in the previous frame in panoramic space, denoted as .
[0094] like Figure 5 As shown, the online inference module of the model completes the following steps:
[0095] Step 2.1.1: Construct a reinforcement learning model. The input consists of a Long Short-Term Memory (LSTM) structure with k units, used to mine implicit spatiotemporal features hidden in the motion trajectory. This is followed by two similar neural networks: one outputs a rotation action based on the extracted features (called the Actor), and the other judges the action's value (called the Critic). Each neural network contains two fully connected layers and one output layer. The flattened sequence of the LSTM units is input into the fully connected layers of both neural networks, using the tanh activation function to enhance learning ability. The output layer of the Actor network uses softmax as the activation function to generate a probability distribution for selecting each action, thus outputting the action with the highest probability. The reinforcement learning model is denoted as S based on the state sequence of the current frame. m Let a be the rotational motion performed. m The control strategy based on iterative learning and updating is π(S) m ,a m The output layer of the Critic network is a linear neuron that estimates the expected total reward or penalty starting from the current state, π(S). m ,a m The corresponding value of ) is denoted as V. π (S m To meet the requirements of online inference, algorithms such as proximal policy optimization (PPO) should be used during model training to promote rapid model convergence and smoothly update policy parameters to generate reasonable decisions as quickly as possible.
[0096] Step 2.1.2: Combine the k nearest quadruplets of the object's trajectory obtained in Step 1.3.4 with the current camera facing direction (θ). gp ,θ gt As a state-input reinforcement learning model, in order to match the LSTM structure that the model receives input, frame F... m The actual input state sequence is adjusted to The first four elements are sequences extracted column-wise from the k most recent four-tuples and differiated with the corresponding camera facing direction at that moment, denoted as follows:
[0097] Step 2.1.3: Infer the corresponding gimbal rotation motion a online. m =(a pm ,a t m ), where a p m and a t m All originate from a discrete action space A = {ω*j} (j∈[-n) a ,n a ]∩Z) is selected, where ω represents a rotation angle unit, n a This is the rotation amplitude (maximum number of angular units), and the two dimensions are represented by (n... ap ,n at This means that ω*n needs to be satisfied. au <1 / 2Θ u (u = p, t);
[0098] Step 2.1.4: Redirect the camera and update the object trajectory to generate a new state S. m+1 And calculate with action a m Related reward / penalty value r m To enable the model to continuously learn, while the object remains within the camera's field of view, the focus is primarily on its distance to the boundary of the field of view and its direction of movement, setting a position reward / penalty value r. p m and directional reward / penalty value r d m Both are based on state S m+1 The camera is facing in the direction (θ) gp m+1 ,θ gt m+1 ) and object motion sequence The calculation formulas are r p m =1–2|θ bp m+1 | / Θ p –2|θ bt m+1 | / Θ t and r d m =-(θ) cp m+1 θ cp Δ +θ ct m+1 θ ct Δ ) / [(|θ cp m+1 |+|θ ct m+1 |)*(|θ cp Δ |+|θ ct Δ|)], where θ cu Δ =θ cu m+1 –θ cu m (u = p, t); Once the object leaves the camera's field of view, the gimbal will immediately rotate to the direction corresponding to the most recently acquired object's centroid to resume tracking. For this situation, a penalty value r for tracking the object needs to be set. l m A sufficiently large negative value, such as -10, to reflect action a. m The adverse effects; and the cost penalty value for gimbal rotation should be related to the amplitude, calculated using the formula r. c m =1–a p m / (ω*n ap )–a t m / (ω*n at Overall reward and punishment value r m It should include all four reward and punishment components mentioned above, and can be implemented through r m =μr l m +(1–μ)(βr p m +δr d m +ηr c m The calculation is obtained, where μ∈{0,1} represents action a. m Whether to remove the object from the camera's field of view, where 1 represents the case of removal, and β, δ, and η are hyperparameters that are set. The optimal values are verified to be 1, 1, and 2 according to grid search.
[0099] The learning experience integration module is completed through the following steps:
[0100] Step 2.2.1: Collect a certain number of previously used object tracking model records. Each model adopts the LSTM and neural network structure described in Step 2.1.1. Assume there are n models in total, and each model contains m neural network units.
[0101] Step 2.2.2, using matrix Ξ ij =(ξ ij ) n*m Let ξ represent the neural network parameters of all models, where the element ξ is... ij This represents the parameter of the j-th unit in model i;
[0102] Step 2.2.3: Take the weighted average of the parameters of the corresponding units in different models to obtain an aggregate model, where the parameter elements are obtained through... Where ρ i The weights represent the experience weights of model i. Usually, all previous models have the same weights. However, if a model has tracked the same object, it can be determined by the ReID (Re-identification) method. In this case, a higher weight is set for the corresponding model to learn from more experience.
[0103] like Figure 3 As shown, the rotation command processing module in step 3.1 completes the process through the following steps:
[0104] Step 3.1.1: After each action output by the model based on step 2.1.4, generate rotation command I. r =(a p ,a t ,θ gp ,θ gt ) is added to the instruction queue, where (a p ,a t ) is the inferred rotation motion of the gimbal, while (θ) gp ,θ gt () indicates the direction the camera is facing when performing the action;
[0105] Step 3.1.2: Set up an asynchronous controller to retrieve one rotation command from the command queue each time, and execute the mechanical rotation by calling the command to control the motor; for the direction including the camera's facing direction (θ) gp i ,θ gt i ) and the current actual direction the camera is facing (θ) gp c ,θ gt c Inconsistent instructions are eliminated to avoid executing outdated instructions that could cause rotational errors.
[0106] Step 3.1.3: Instructions containing small-amplitude rotation movements are cached in the queue and the rotation is not executed immediately. Only the relative coordinates of the camera's facing direction and the object are virtually updated. For a series of consecutive small-amplitude rotation instructions... Satisfying θ gp k+1 =θ gp k +a p k (u = p, t) can combine these instructions into a new instruction I. r b =(θ gp m –θ gp 1 ,θ gt m–θ gt 1 ,θ gp 1 ,θ gt 1 Then only the newly constructed instructions are executed.
[0107] The video frame sampling module in step 3.2 completes the process through the following steps:
[0108] Step 3.2.1: Buffer the video frames continuously into a queue at the frame rate set by the camera, usually 15 or 30 frames per second;
[0109] Step 3.2.2, using dynamically changing sample frame intervals T. s Frame sampling is performed, and the number of sample frame intervals T is recursively calculated by combining the rotation execution speed with the position and motion direction of the currently tracked object. s k =T s k-1 *(1+σmin{r p k-1 ,r d k-1})*v r k-1 / v r k , where v r r represents the number of rotations performed per second. p and r d These are the object position and orientation reward / penalty values described in step 2.1.3, with the factor σ∈(0,1) used to limit the influence of object motion. This allows for a reduction in frame processing frequency when the rotation execution speed decreases and the object is less likely to leave the camera's field of view, i.e., an increase in the sampling interval, and vice versa.
[0110] Step 3.2.3: Input only the object motion information extracted from the sample frames into the model constructed in step 2.1.1.
[0111] Meanwhile, this invention also provides a smart tracking device for moving objects using a gimbal camera, such as... Figure 3As shown, the device includes an object tracking component, an intelligent decision-making component, and a rotation control component. The object tracking component performs correlation filtering on the position and size features of moving objects, associates the same objects appearing in consecutive frames, abstracts two key points of the target object in each frame, and constructs a motion trajectory in the panoramic space of the gimbal camera's field of view. The intelligent decision-making component constructs a reinforcement learning model containing multi-layer neural networks and a customized reward and punishment mechanism based on the object state change information indicated in the motion trajectory acquired in real time by the object tracking component. It makes online decisions to adjust the gimbal rotation amplitude based on the spatiotemporal information of the object's motion trajectory and integrates the learning experience of the object tracking component in tracking the same type of object to accelerate model convergence. The rotation control component, based on the reinforcement learning model of the intelligent decision-making component, uses a pipeline approach to process the decision generation and execution of its output rotation commands, merges or eliminates redundant commands in the buffer queue, and uses frame sampling to track low-frequency moving objects. It adaptively adjusts the sampling interval according to the object's motion information to match the gimbal rotation with the object's moving speed.
[0112] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
Claims
1. A method for intelligent tracking of moving objects using a PTZ camera, characterized in that, The method includes the following steps: Step 1: By performing correlation filtering on the position and size features of moving objects, the same objects appearing in consecutive frames are associated, and two key points of the target object in each frame are abstracted to construct the motion trajectory in the panoramic space of the PTZ camera's field of view. Step 2: Based on the object state change information indicated in the motion trajectory obtained in real time in Step 1, construct a reinforcement learning model containing multi-layer neural networks and a customized reward and punishment mechanism. Make online decisions to adjust the gimbal rotation amplitude based on the spatiotemporal information of the object's motion trajectory, and integrate the learning experience of tracking the same type of object in Step 1 to accelerate model convergence. Step 3: Based on the reinforcement learning model in Step 2, the decision generation and execution of its output rotation command are processed in a pipeline manner, redundant commands in the buffer queue are merged or eliminated, and low-frequency moving objects are tracked by frame sampling. The sampling interval is adaptively adjusted according to the object motion information to match the gimbal rotation and the object movement speed. Step 1 is accomplished through three modules: moving object detection, cross-frame target association, and motion trajectory construction. Specifically, Step 1.1: The moving object detection module integrates optical flow into the detection algorithm used by mainstream PTZ cameras to solve the problem of incomplete object pixels affecting positioning accuracy. Step 1.2: In the cross-frame target association module, correlation filtering is used to perform element-wise operations in the frequency domain to match target objects in different frames in order to eliminate background noise and interference from other objects on tracking. Step 1.3: In the motion trajectory construction module, the position, size, and accurate outline object information continuously obtained from the above two modules are used to construct the object's motion trajectory in the same space; Step 2 is completed through two modules: online model inference and fusion of learning experience. Specifically, Step 2.1: In the online inference module of the model, the information obtained in step 1 is used to infer the next state of the object based on the reinforcement learning model and perform appropriate gimbal rotation accordingly, so as to minimize the rotation cost of the gimbal while keeping the object tracked. Step 2.2, the learning experience fusion module integrates the learning experience of tracking the same type of objects in step 1 into the model, so that the model can converge as soon as possible and make reasonable inferences, avoiding the cold start problem when initially tracking objects; Step 3 is completed through two modules: rotation command processing and video frame sampling. Specifically, Step 3.1: The rotation command processing module adopts a pipeline approach to process the decision generation and execution of rotation commands in order to reduce the impact of the speed difference between the mechanical rotation speed and the command generation speed on the timeliness of object tracking, thereby reducing the risk of tracking failure. Step 3.2: The video frame sampling module extracts sample frames at a dynamic low frequency for processing to exclude frames that do not pose a risk of object tracking loss and reduce the number of generated instructions to adapt to low-speed mechanical rotation. The online inference module of the model is completed through the following steps: Step 2.1.1: Construct a reinforcement learning model. The input consists of a Long Short-Term Memory (LSTM) structure with k units, used to mine implicit spatiotemporal features hidden in the motion trajectory. This is followed by two similar neural networks: one outputs a rotation action based on the extracted features (called the Actor), and the other judges the action's value (called the Critic). Each neural network contains two fully connected layers and one output layer. The flattened sequence of the LSTM units is input into the fully connected layers of both neural networks, using the tanh activation function to enhance learning ability. The output layer of the Actor network uses softmax as the activation function to generate a probability distribution for selecting each action, thus outputting the action with the highest probability. The reinforcement learning model is denoted as S based on the state sequence of the current frame. m Let a be the rotational motion performed. m The control strategy based on iterative learning and updating is π(S) m ,a m The output layer of the Critic network is a linear neuron that estimates the expected total reward or penalty starting from the current state, π(S). m ,a m The corresponding value of ) is denoted as V. π (S m To meet the requirements of online inference, the nearest neighbor strategy should be used to optimize the PPO during model training to promote the model to converge to the algorithm quickly and smoothly update the policy parameters to generate reasonable decisions as soon as possible. Step 2.1.2: Combine the k nearest quadruplets of the object's trajectory obtained in Step 1.3 with the current camera facing direction (θ). gp ,θ gt As a state-input reinforcement learning model, in order to match the LSTM structure that the model receives input, frame F... m The actual input state sequence is adjusted to The first four elements are sequences extracted column-wise from the k most recent four-tuples and differiated with the corresponding camera facing direction at that moment, denoted as follows: Step 2.1.3: Infer the corresponding gimbal rotation motion a online. m =(a p m ,a t m ), where a p m and a t m All originate from a discrete action space A = {ω*j} (j∈[-n) a ,n a ]∩Z) is selected, where ω represents a rotation angle unit, n a This is the number of angle units with the maximum rotation amplitude, and the two dimensions are represented by (n) ap ,n at This means that ω*n needs to be satisfied. au <1 / 2Θ u (u = p, t); Step 2.1.4: Redirect the camera and update the object trajectory to generate a new state S. m+1 And calculate with action a m Related reward / penalty value r m To enable the model to continuously learn, while the object remains within the camera's field of view, the focus is primarily on its distance to the boundary of the field of view and its direction of movement, setting a position reward / penalty value r. p m and directional reward / penalty value r d m Both are based on state S m+1 The camera is facing in the direction (θ) gp m+1 ,θ gt m+1 ) and object motion sequence The calculation formulas are r p m =1–2|θ bp m+1 | / Θ p –2|θ bt m+1 | / Θ t and r d m =-(θ) cp m+1 θ cp Δ +θ ct m+1 θ ct Δ ) / [(|θ cp m+1 |+|θ ct m+1 |)*(|θ cp Δ |+|θ ct Δ |)], where θ cu Δ =θ cu m+1 –θ cu m (u = p, t); Once the object leaves the camera's field of view, the gimbal will immediately rotate to the direction corresponding to the most recently acquired object's centroid to resume tracking. For this situation, a penalty value r for tracking the object needs to be set. l m To obtain a sufficiently large negative value, we take -10 to reflect action a. m The adverse effects; and the cost penalty value for gimbal rotation should be related to the amplitude, calculated using the formula r. c m =1–a p m / (ω*n ap )–a t m / (ω*n at Overall reward and punishment value r m It should include all four reward and punishment components mentioned above, through r m =μr l m +(1–μ)(βr p m +δr d m +ηr c m The calculation is obtained, where μ∈{0,1} represents action a. m Whether to remove the object from the camera's field of view, where 1 represents the case of removal, and β, δ, and η are hyperparameters that are set. The optimal values are verified to be 1, 1, and 2 according to the grid search.
2. The intelligent tracking method for moving objects using a PTZ camera according to claim 1, characterized in that, The moving object detection module in step 1.1 completes the following steps: Step 1.1.1: Divide each frame image into a series of square regions, where the side length a of the region is the greatest common divisor of the frame width w and height h, i.e. a = gcd(w,h); Step 1.1.2, for any frame F t Take the first two frames F t-1 and F t-2 Calculate the pixel difference between two adjacent frames and take their intersection D. t =|F t –F t-1 |∩|F t-1 –F t-2 |As a differential frame; Step 1.1.3: After thresholding the differential frames to eliminate background noise, extract the set of pixels with the largest connected region. Step 1.1.4: For each pixel (x, y) of the extracted region, calculate the two-dimensional optical flow vector based on the Lucas-Kanade algorithm, denoted as... Obtain the complete outline of the object and its motion pattern between adjacent frames.
3. The intelligent tracking method for moving objects using a PTZ camera according to claim 2, characterized in that, The cross-frame target association module is completed through the following steps: Step 1.2.1, construct a position filter f p A set of sample images is obtained by sampling the frame image at twice the size of the object, and features are extracted from all pixels of each sample image; Step 1.2.2, construct a size filter f s A small sample set of object sizes is created by scaling up and down the objects. Step 1.2.3, for the two filters f x (x=p,s), calculate the value of each image or sample h. k correlation in and This involves the two-dimensional Fast Fourier Transform and its inverse operation. ⊙ and * represent element-wise multiplication and complex conjugation, respectively. A suitable filter f is found using the least squares optimization method. p and f s and the corresponding h k Achieve maximum relevance; Step 1.2.4: Using the obtained filter position and size, locate the two-dimensional coordinates of the center of the target object and the side length of the object's circumscribed square in the frame, and call step 1.1.4 to obtain the object's outline based on the circumscribed square; The above process is iteratively executed until no object is associated in three consecutive frames. Then, steps 1.1.2 to 1.1.4 are executed to re-detect moving objects. When there are multiple objects in the camera's field of view, the same method is used to continuously track the identified target object.
4. The intelligent tracking method for moving objects using a PTZ camera according to claim 2, characterized in that, The motion trajectory construction module is completed through the following steps: Step 1.3.1, based on the object contour and its internal pixel set P = {(p x i ,p y i )}(i=1,…,n), calculate the coordinates of the centroid of the object (c x ,c y ) is c v =[(∑ i p v i ) / n](v=x,y), where the operator [] indicates rounding to the nearest integer, where, in order to reduce the influence of small motions, the object's centroid is used instead of the center of the circumscribed square to represent the object's position; Step 1.3.2: Extract the x and y coordinates of the contour point with the largest horizontal and vertical distance from the image center to construct a virtual boundary point (b). x ,b y ), where b v =max i {|p v i |}(v=x,y), where the operator || represents the absolute value of the coordinates, paying special attention to the positional changes of the object contour points closest to the frame image boundary to keep the object within the camera's field of view; Step 1.3.3, the centroid (c) of the above object x ,c y ) and virtual boundary points (b x ,b y These two key points, with their coordinates relative to the image center in different frames, are uniformly converted into their absolute coordinates (θ) within the 360° panoramic space generated by the camera's field of view and the gimbal rotation. cp ,θ ct )(θ bp ,θ bt The conversion method is as follows: Where (θ) gp ,θ gt θ represents the horizontal and vertical angles of the current camera's facing direction in the panoramic space, where θ gu ∈[-1 / 2Θ gu ,1 / 2Θ gu (u=p,t), maximum rotation angle Θ gp and Θ gt Set by the manufacturer, w and h are the width and height of the frame image, and the viewpoint. Calculated by arctan(d / 2f), where d and f are the reticulum size and focal length provided by the manufacturer, respectively; Step 1.3.4, based on the current frame F m The object's motion trajectory vector is constructed from the coordinates of its key points in the previous frame in panoramic space, denoted as .
5. The intelligent tracking method for moving objects using a PTZ camera according to claim 1, characterized in that, The learning experience integration module is completed through the following steps: Step 2.2.1: Collect a certain number of previously used object tracking model records. Each model adopts the LSTM and neural network structure described in Step 2.1.
1. Assume there are n models in total, and each model contains m neural network units. Step 2.2.2, using matrix Ξ ij =(ξ ij ) n * m Let ξ represent the neural network parameters of all models, where the element ξ is... ij This represents the parameter of the j-th unit in model i; Step 2.2.3: Take the weighted average of the parameters of the corresponding units in different models to obtain an aggregate model, where the parameter elements are obtained through... Where ρ i The weight represents the experience weight of model i. All previous models have the same weight, but when a model has tracked the same object, the ReID method determines that the corresponding model has a high weight to learn from more experience.
6. The intelligent tracking method for moving objects using a PTZ camera according to claim 1, characterized in that, The rotation command processing module in step 3.1 completes the process through the following steps: Step 3.1.1: After each action output by the model based on step 2.1.4, generate rotation command I. r =(a p ,a t ,θ gp ,θ gt ) is added to the instruction queue, where (a p ,a t ) is the inferred rotation motion of the gimbal, while (θ) gp ,θ gt () indicates the direction the camera is facing when performing the action; Step 3.1.2: Set up an asynchronous controller to retrieve one rotation command from the command queue each time, and execute the mechanical rotation by calling the command to control the motor; for the direction including the camera's facing direction (θ) gp i ,θ gt i ) and the current actual direction the camera is facing (θ) gp c ,θ gt c Inconsistent instructions are eliminated to avoid executing outdated instructions that could cause rotational errors. Step 3.1.3: Instructions containing small-amplitude rotation movements are cached in the queue and the rotation is not executed immediately. Only the relative coordinates of the camera's facing direction and the object are virtually updated. For a series of consecutive small-amplitude rotation instructions... Satisfying θ gp k+1 =θ gp k +a p k (u = p, t), combine these instructions into a new instruction I. r b =(θ gp m –θ gp 1 ,θ gt m –θ gt 1 ,θ gp 1 ,θ gt 1 Then only the newly constructed instructions are executed.
7. The intelligent tracking method for moving objects using a PTZ camera according to claim 1, characterized in that, The video frame sampling module in step 3.2 is completed through the following steps: Step 3.2.1: Cache the video frames continuously into a queue at the frame rate set by the camera, which is 15 or 30 frames per second; Step 3.2.2, using dynamically changing sample frame intervals T. s Frame sampling is performed, and the number of sample frame intervals T is recursively calculated by combining the rotation execution speed with the position and motion direction of the currently tracked object. s k =T s k-1 *(1+σmin{r p k-1 ,r d k-1 })*v r k -1 / v r k , where v r r represents the number of rotations performed per second. p and r d These are the object position and orientation reward / penalty values described in step 2.1.3, respectively. The factor σ∈(0,1) is used to limit the influence of object motion. This reduces the frame processing frequency when the rotation execution speed decreases and the object is not easy to leave the camera's field of view, i.e., increases the sampling interval, and vice versa. Step 3.2.3: Input only the object motion information extracted from the sample frames into the model constructed in step 2.1.
1.
8. A moving object intelligent tracking device according to any one of claims 1-7 for a moving object intelligent tracking method for a PTZ camera, characterized in that, The device includes an object tracking component, an intelligent decision-making component, and a rotation control component. The object tracking component performs correlation filtering on the position and size features of moving objects, associates identical objects appearing in consecutive frames, abstracts two key points of the target object in each frame, and constructs a motion trajectory in the panoramic space of the gimbal camera's field of view. The intelligent decision-making component constructs a reinforcement learning model containing multi-layer neural networks and a customized reward and punishment mechanism based on the object state change information indicated in the motion trajectory acquired in real time by the object tracking component. It makes online decisions to adjust the gimbal rotation amplitude based on the spatiotemporal information of the object's motion trajectory and integrates the learning experience of the object tracking component in tracking similar objects to accelerate model convergence. The rotation control component, based on the reinforcement learning model of the intelligent decision-making component, uses a pipelined approach to process the decision generation and execution of its output rotation commands, merges or eliminates redundant commands in the buffer queue, and uses frame sampling to track low-frequency moving objects. It adaptively adjusts the sampling interval based on the object's motion information to match the gimbal rotation with the object's movement speed.