Pan-tilt tracking control method and device, monitoring equipment and medium
By introducing an intelligent intermediate decision-making layer into the PTZ tracking control, the target motion trend is identified and motion state switching events are triggered, solving the problem of step loss caused by the mechanical characteristics of the stepper motor. This enables the PTZ to track quickly, smoothly, and accurately, improving the reliability and energy efficiency of the monitoring equipment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 深圳市灵智无界科技有限公司
- Filing Date
- 2025-11-24
- Publication Date
- 2026-05-12
AI Technical Summary
In traditional gimbal tracking solutions, the step loss problem caused by the mechanical characteristics of stepper motors affects tracking reliability and user experience. Existing improvement solutions have failed to effectively solve the nonlinear effects caused by mechanical characteristics.
An intelligent intermediate decision-making layer is introduced. By identifying the positional change data of the target object in the image stream, tracking and control data reflecting the effective motion trend of the target is generated, and specific motion state switching events are triggered. Combined with motor compensation commands, the influence of mechanical characteristics is overcome.
It significantly reduces the frequent start-stop and reversal of the motor caused by slight vibrations of the target or detection noise, reduces power consumption and noise, ensures that the pan-tilt unit switches to a stable tracking state quickly, smoothly and accurately, and improves the reliability and energy efficiency of the monitoring equipment.
Smart Images

Figure CN122018566A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent control, and in particular to a PTZ tracking control method and device, monitoring equipment and medium. Background Technology
[0002] In the field of intelligent control of surveillance equipment driven by PTZ (pan-tilt-zoom) cameras, especially in scenarios involving automatic tracking of moving targets such as humans, the following technical solution is typically adopted: By analyzing continuous image frames captured by the camera, the position of the target object in the frame is identified, and then control commands are generated to drive the PTZ stepper motor to rotate, ensuring that the target remains in the center of the image. Within this technical framework, stepper motors are widely used due to their advantages such as precise positioning, simple control, and ability to maintain position even after power failure.
[0003] However, traditional gimbal tracking solutions based on stepper motors have inherent technical flaws that directly affect tracking reliability and user experience. These flaws stem from the control characteristics of the stepper motor itself and the physical limitations of the gimbal's mechanical structure. Specifically, the gimbal transmission system suffers from static friction and gear backlash. During tracking, when the gimbal needs to be started or its rotation direction changed, the stepper motor must first output sufficient torque to overcome the system's static friction before it can actually move the gimbal. During reversal, the motor needs to idle to clear the backlash between the gears before effectively re-engaging the transmission. Traditional control strategies often directly generate motor motion commands based on the position of the tracked target, failing to fully consider the nonlinear effects of these mechanical characteristics. This leads to insufficient starting torque at startup, causing step loss during startup, resulting in gimbal startup delays or inaccurate positioning. When changing direction, backlash can cause step loss during reversal, making the actual rotation angle of the gimbal smaller than the commanded angle, causing the tracked target to deviate.
[0004] Existing technologies for addressing step loss typically employ either a single, fixed acceleration curve or simply increasing the motor's torque margin. However, the former cannot adaptively compensate for commutation backlash, while the latter introduces side effects such as increased power consumption and noise, making them suboptimal solutions. The root cause lies in the fact that these improvements remain at the level of localized optimization within the motor control commands themselves, leading to a disconnect between the underlying control logic and the upper-level image recognition logic. They fail to address the systemic issue at the source of the entire tracking control chain—how to intelligently determine the motor's operating state based on target motion information. Therefore, it is necessary to explore relevant improvement schemes to effectively eradicate the motor step loss phenomenon. Summary of the Invention
[0005] The primary objective of this application is to solve at least one of the above-mentioned problems by providing a PTZ tracking and control method, device, monitoring equipment, and medium.
[0006] To achieve the various objectives of this application, the following technical solution is adopted: A gimbal tracking control method provided for one of the purposes of this application includes the following steps: Based on the image stream captured by the camera fixed on the pan-tilt unit, identify the position change data of the target object in each frame of the image stream; Based on the position change data, tracking and control data is generated to reflect the effective movement trend of the target object; Based on the tracking control data, a motion state switching event required for tracking the target object is triggered, and this event is associated with a specific motion state mode. In response to the motion state switching event, the stepper motor is controlled to perform motion compensation according to the motion state mode corresponding to the event, so that the gimbal switches to an effective tracking state.
[0007] A gimbal tracking control device, proposed to meet one of the objectives of this application, comprises: The position recognition module is configured to identify position change data of the target object in each frame of the image stream based on the image stream captured by the camera fixed on the pan-tilt-zoom (PTZ) platform. The tracking and analysis module is configured to generate tracking and control data that reflects the effective movement trend of the target object based on the position change data; The event recognition module is configured to trigger a motion state switching event required for tracking the target object based on the tracking control data, and the event is associated with a specific motion state mode. The mode driving module is configured to respond to the motion state switching event, control the stepper motor to perform motion compensation according to the motion state mode corresponding to the event, and then drive the gimbal to enter the effective tracking state.
[0008] On another front, a monitoring device provided for one of the purposes of this application includes a camera, a pan-tilt unit, a stepper motor, and a controller. The controller includes a processor and a memory. The camera is fixed to the pan-tilt unit. The stepper motor is used to drive the pan-tilt unit to rotate so that the camera can track a target object and acquire an image stream. The processor calls and runs a computer program in the memory to execute the steps of the pan-tilt tracking control method.
[0009] In another aspect, a computer-readable storage medium is provided to suit another purpose of this application, which stores in the form of computer-readable instructions a computer program implemented according to the described gimbal tracking control method, which, when called by a computer, executes the steps included in the corresponding method.
[0010] Compared to traditional technologies, this application effectively overcomes the step loss problem caused by mechanical characteristics in traditional solutions by introducing an intelligent intermediate decision-making layer. This application generates tracking control data reflecting the effective movement trend of the target and triggers motion state switching events accordingly. It can intelligently distinguish between genuine tracking needs and invalid mechanical responses, thus fundamentally avoiding ineffective drive of the gimbal system. This significantly reduces the frequent start-stop and reversing of the stepper motor caused by minor target jitter or detection noise, fundamentally reducing the probability of step loss during start-up and reversing. Furthermore, this application associates motor compensation commands with high-level motion state switching events, ensuring that each compensation operation is executed only when necessary. This on-demand intelligent control strategy ensures sufficient power to overcome static friction and gear backlash during critical moments such as start-up and turning, while avoiding the additional power consumption and operating noise caused by continuously applying excessive torque. Ultimately, this allows the gimbal to quickly, smoothly, and accurately switch to a stable tracking state, significantly improving the reliability, energy efficiency, and service life of the monitoring equipment. Attached Figure Description
[0011] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a schematic diagram of the electrical structure of the monitoring equipment in this application; Figure 2 This is a flowchart illustrating a typical embodiment of the gimbal tracking control method of this application; Figure 3 This is a schematic block diagram of the gimbal tracking and control device of this application; Figure 4 This is a schematic diagram of the structure of a computer device used in this application. Detailed Implementation
[0012] Please see Figure 1 , Figure 1 This is a schematic diagram of the electrical structure of a monitoring device suitable for applying the technical solution of this application. As shown in the figure, the monitoring device mainly includes a camera 1, a pan-tilt unit 2, a stepper motor 3, and a controller 4. The controller 4 serves as the control core of the entire device, and its internal components typically include a processor and memory. The camera 1 is fixedly mounted on the pan-tilt unit 2 via a rotating transmission mechanism 5. This transmission mechanism 5 is connected to the output shaft of the stepper motor 3, enabling the stepper motor 3 to drive the camera 1 to rotate horizontally or vertically relative to the pan-tilt unit 2 by driving the transmission mechanism 5.
[0013] In this application, the stepper motor 3 plays a crucial actuator role. It operates by receiving pulse signals from the controller 4 or a chip controlled by it. Each pulse signal corresponds to a fixed angle rotation of the motor, i.e., one step. By controlling the number and frequency of the pulses, the rotation angle and speed of the stepper motor 3 can be precisely controlled, which in turn precisely controls the pointing of the camera 1 via the transmission mechanism 5. The camera 1 is responsible for continuously acquiring image streams of the monitored scene and transmitting the image data to the controller 4 for processing in real time.
[0014] The software program running inside the controller 4 can be a computer program implemented according to the PTZ tracking control method of this application, forming an intelligent hub. This program continuously analyzes the image stream transmitted back by the camera 1, identifies the target object to be tracked, which can be any moving target including human figures, and calculates the target's positional changes in the image. Based on this visual information, the controller 4 generates corresponding control commands to drive the stepper motor 3, thereby enabling the lens of the camera 1 to continuously and stably aim at the moving target, achieving automatic tracking.
[0015] In practical applications, the physical system consisting of stepper motor 3 and transmission mechanism 5 has inherent mechanical characteristics, mainly static friction and gear backlash. Static friction exists at the moment of motor start-up and requires additional torque to overcome; backlash is manifested when the motor changes its rotation direction, it needs to idle for a certain angle to eliminate the backlash between gears before it can actually drive the load. If these nonlinear factors are not effectively compensated, it will directly cause a deviation between the rotation of gimbal 2 and the command of controller 4, that is, step loss will occur, which manifests as tracking delay, target deviation from the center of the screen, and other problems.
[0016] Therefore, the core of this application lies in the fact that the control method executed by controller 4 does not simply convert the target position deviation into motor motion commands, but introduces a more intelligent decision-making and compensation mechanism. This method fully considers the aforementioned mechanical characteristics and, by introducing an intermediate layer between high-level decision-making and low-level driving, achieves precise and reliable control of stepper motor 3, thereby ensuring the accuracy and stability of gimbal tracking in complex real-world application scenarios. The specific implementation steps of this method will be described in detail below.
[0017] Please see Figure 2 In some embodiments, the gimbal tracking control method of this application can be implemented as an application running in the controller, and the method includes: Step S3100: Based on the image stream captured by the camera fixed on the pan-tilt unit, identify the position change data of the target object in each frame of the image stream; The monitoring equipment continuously acquires image streams of the external environment during its operation. In this application, target detection can be performed on image frames in the image stream at preset frame intervals or frame by frame. Target detection can be performed using various target detection algorithms known in the art, such as deep learning-based target detection models, which can identify target objects of preset target categories and locate their bounding boxes in the image frames as detection results. Based on this detection result, the position of the target object in the image coordinate system can be extracted, for example, represented by the coordinates of the center point or a corner point of the bounding box. By observing the differences in the position of the target object between consecutive frames, preliminary positional change data reflecting the target's movement can be obtained.
[0018] To improve the quality of position change data, the detected position sequences can be further processed. A basic implementation is to directly use the position coordinates of the target object detected in each frame to construct a position sequence arranged in chronological order; this sequence itself represents the position change data of the target object. This method is simple to implement, but may contain coordinate jitter caused by image noise or minor deformations of the target.
[0019] Another preferred implementation involves using a pre-defined state estimation algorithm to smooth and optimize the original detected position coordinates, thereby suppressing observation noise and obtaining data that more closely approximates the target's true motion trajectory. Specifically, a state vector containing position and velocity components can be constructed for the target and processed using algorithms such as Kalman filtering. This process first initializes the target's state vector based on its detection position in the initial frame. For each subsequent frame, the algorithm first predicts the target's possible position in the current frame based on the state vector from the previous frame, then fuses the predicted position with the actual detection position in the current frame to update and obtain the optimal state vector estimate for the current frame. The smoothed position information output through this process effectively filters out high-frequency jitter, such as jitter caused by motors, thus obtaining higher-quality position change data.
[0020] Regardless of the specific implementation method used above, the ultimate goal is to obtain a data sequence that can reliably reflect the positional changes of the target in each frame of the image stream. This positional change data lays the necessary data foundation for subsequent analysis of the target's motion trend.
[0021] Step S3200: Generate tracking and control data that reflects the effective movement trend of the target object based on the position change data; After obtaining the position change data of the target object, it is necessary to generate tracking and control data that reflects the effective movement trend of the target object. This tracking and control data is not a simple sequence of position coordinates, but a high-level information that has been further analyzed and processed to characterize the target's movement intention. Its core purpose is to distinguish whether the target object has moved substantially or not, providing a reliable basis for subsequent movement decisions.
[0022] The process of generating tracking and control data essentially involves intelligently assessing the target's motion state based on position change data. A basic implementation includes quantifying and judging motion trends. Specifically, the instantaneous motion trend characteristics of the target object can be calculated based on multiple consecutive frames of position change data within a sliding time window. These characteristics typically include motion direction and motion amplitude. Motion direction indicates the target's tendency to move relative to the image center or the current orientation of the gimbal, such as left, right, up, or down. Motion amplitude quantifies the magnitude of the target's displacement per unit time, such as a velocity value in pixels per second.
[0023] In a preferred embodiment, to ensure that the identified motion trend is valid and worthy of gimbal response, the calculated instantaneous motion trend features need to be validated, specifically including persistence and salience assessment. Persistence assessment confirms whether the corresponding motion trend is stable over time, rather than a brief, random fluctuation. For example, a threshold can be set requiring the target's motion direction to remain consistent across multiple consecutive image frames, thereby filtering out frequent changes in direction caused by minor target wobbling or image detection noise. Salience assessment confirms whether the amplitude of the corresponding motion trend exceeds a preset amplitude threshold, ensuring that the displacement is large enough to warrant gimbal tracking and avoiding reactions to negligible movements.
[0024] When instantaneous motion trend characteristics pass both persistence and significance tests, a valid motion trend can be determined to exist within the current time window. This determination (i.e., the existence of a valid motion trend) and its corresponding motion trend characteristics (such as direction and amplitude) are then encapsulated to form the tracking and control data corresponding to that time window. This data encapsulation provides the system with clear decision signals, indicating not only whether the gimbal needs to act but also key information on how it should act, such as the direction it should turn and the approximate rotation speed required. In this way, raw, potentially noisy position change data is transformed into high-quality intelligent signals that can be directly used to trigger higher-level control events.
[0025] Step S3300: Trigger a motion state switching event required for tracking the target object based on the tracking control data. This event is associated with a specific motion state mode. After successfully generating tracking and control data reflecting the effective motion trend of the target object, the process enters the stage of triggering a motion state switching event based on this data. This transforms the intelligent judgment of the target's motion trend obtained in the preceding steps into a clear, high-level control command that can drive subsequent actuator actions. The motion state switching event here acts as an abstract interface or signal, indicating that the current tracking state of the gimbal needs to change, and associating this change with a specific, predefined motion state mode.
[0026] The logic for triggering motion state switching events is based on the parsing of tracking control data. Since the tracking control data encapsulates the existence of valid motion trends and specific motion trend characteristics, pattern matching can be performed accordingly. Specifically, by traversing or examining the tracking control data corresponding to the current and recent time windows, the motion trend characteristics contained within are analyzed and compared with the current operating state of the gimbal mechanical system to determine which mode to switch to. The duration of the time window and its sliding step can both be preset.
[0027] A basic triggering logic involves conditional judgment. For example, if the tracking control data corresponding to the current time window indicates a valid motion trend, and the direction of this valid motion trend is inconsistent with the current tracking direction of the gimbal, then a motion state switching event associated with the motion steering mode is triggered. This event means that it has been determined that the target is attempting to escape the current tracking field of view of the gimbal, and the gimbal needs to change its rotation direction to relock onto the target.
[0028] Another triggering scenario involves decisions regarding gimbal activation. If the tracking control data corresponding to the current time window indicates a valid motion trend, but the gimbal is currently stationary or rotating but not in a low-speed state for effective tracking (e.g., scanning or in standby), a motion state switching event associated with the motion activation mode is triggered. This indicates that a target object worth tracking has been identified, and the gimbal needs to transition from a non-tracking state to an active tracking state.
[0029] In another scenario, it's necessary to handle the decision of maintaining the current state. If the tracking control data corresponding to the current time window indicates no valid motion trend, but the gimbal is already in motion tracking mode, this suggests the target object may be relatively stationary or moving very slowly. In this case, a motion state switching event associated with the motion persistence mode is triggered. This event instructs the gimbal to maintain its current tracking action, such as keeping the gimbal rotating at a constant speed or making fine adjustments at a very low speed, rather than stopping or drastically changing its motion state.
[0030] The triggering mechanism for motion state transition events can be designed to be more complex and intelligent, such as by introducing a state machine model or a rule-based inference engine. However, regardless of the specific implementation, the fundamental purpose is to transform validated and effective motion trend information into an unambiguous command that guides the next specific control action. This event acts as a bridge connecting the intelligent decision-making layer and the underlying precision control layer, ensuring that the gimbal's motion response is targeted, accurate, and reliable.
[0031] Step S3400: Respond to the motion state switching event, control the stepper motor to perform motion compensation according to the motion state mode corresponding to the event, so that the gimbal switches to the effective tracking state.
[0032] After successfully triggering a motion state switching event associated with a specific motion state mode, the motion compensation execution phase begins. Accordingly, in response to different event types, a pre-configured, targeted stepper motor control strategy is invoked to drive the gimbal to switch to an effective tracking state. Each motion state mode corresponds to a specially designed sequence of motor control commands, the purpose of which is to compensate for specific mechanical defects in the gimbal drive system, ensuring the speed, smoothness, and accuracy of the motion.
[0033] When the response motion state mode is motion-on mode, the corresponding control strategy executes anti-step-loss control for the start-up phase. This control strategy is responsible for providing a start control command sequence to the stepper motor. This command sequence first instructs the motor driver to apply a drive current significantly higher than its normal steady-state operating current to the stepper motor at the moment of start-up. This current value is set to the static friction current. The purpose of applying this high current is to generate a sufficiently large starting torque to overcome the inherent static friction of the gimbal drive system, ensuring that the gimbal can be reliably driven from a stationary state, thereby avoiding step-loss due to insufficient torque at the moment of start-up. After successfully starting and running for a very short preset time or number of steps, the control strategy switches to the acceleration phase, reducing the drive current to the normal operating value, and controlling the motor to smoothly increase the speed from the lower starting speed to the target tracking speed according to a smooth acceleration curve, such as an S-curve or a sine curve, ultimately enabling the gimbal to enter an effective tracking state.
[0034] When the response motion mode is motion steering mode, the corresponding control strategy executes backlash compensation control for the reversing phase. At this time, the control strategy outputs a steering control command. After completing the basic steering command, this command includes an additional compensation step, instructing the stepper motor to run an additional preset number of return backlash steps. This number of steps is pre-determined or calculated based on the physical return backlash value of the gimbal drive gear pair. The compensation is executed as follows: after the motor receives the reverse rotation command and completes the theoretical reversing steps, the controller continues to drive the motor to idle for the compensation steps. The purpose is to allow the gears on the motor side to overcome the physical gap between themselves and the gears on the load side, and to re-engage the gear teeth. This ensures that the actual rotation angle of the gimbal body is strictly consistent with the angle required by the control command, eliminating the reversing step loss problem caused by gear backlash, and enabling the gimbal to accurately maintain target tracking after turning.
[0035] When the response motion mode is continuous motion mode, it indicates that the gimbal is in a stable tracking phase and no special compensation action is required. At this time, the corresponding control strategy outputs a constant speed control command. This command controls the stepper motor driver to drive the motor at a constant pulse frequency, thereby maintaining a constant speed for both the motor and the gimbal, smoothly following the target's movement. In this mode, the motor typically operates with lower current, helping to reduce system power consumption and operating noise.
[0036] The above method maps high-level motion state switching events to precise, compensated motion control commands at the lower level. This mode-based differentiated compensation control mechanism ensures that the gimbal can respond quickly, smoothly, and accurately to target motion while overcoming the nonlinear effects of the mechanical system, achieving highly reliable automatic tracking. The ultimate goal of the entire control process is to switch the gimbal to and maintain an effective tracking state.
[0037] As can be seen from the above embodiments, this application effectively overcomes the step loss problem caused by mechanical characteristics in traditional solutions by reconstructing the entire gimbal tracking control link, significantly improves the reliability of the tracking system, and achieves multiple technical advantages and positive effects, including but not limited to: First, this application does not directly drive the motor based on the positional changes of the tracked target object, but introduces an intelligent intermediate decision-making layer. Specifically, it first extracts the target's positional change data from the image stream, then generates tracking control data that reflects the target's true motion intention, and triggers specific motion state switching events based on this data. This allows for a macroscopic distinction between effective tracking motion and ineffective mechanical response requirements.
[0038] Secondly, this application avoids ineffective driving of the gimbal's mechanical system in principle. By deciding whether to trigger a state switch based on tracking control data reflecting effective motion trends, it ensures that a powerful motor compensation command to overcome static friction or gear backlash is only issued when it is confirmed that the target object has indeed made an intentional and worthwhile movement. For situations where the target object sways left and right but does not actually move, even if image jitter techniques such as Kalman filtering cannot eliminate it, it can be eliminated by recognizing the motion trend. This fundamentally prevents frequent motor starts, stops, and reversals caused by minute or macroscopic jitter in the target object image or detection noise, greatly reducing the triggering scenarios of starting step loss and reversing step loss.
[0039] Furthermore, this application offers greater precision and reliability in motor control. Since the issuance of motor compensation commands is linked to a high-level motion state switching event, this means that each compensation is executed only when absolutely necessary. The corresponding mode is triggered and its preset, targeted compensation strategy is executed only when starting or turning is required. This ensures sufficient power to overcome mechanical resistance at critical moments while avoiding the power consumption and noise problems caused by continuously applying excessive torque in traditional solutions. This achieves intelligent, on-demand power control, ultimately enabling the gimbal to quickly, smoothly, and accurately switch to a stable and effective tracking state, effectively extending the lifespan of the motor and gimbal, and ensuring that the camera acquires more stable and clear video images.
[0040] Based on any embodiment of the method in this application, identifying the position change data of the target object in each frame of the image stream includes: Step S3110: Based on target detection of the initial image frame in the image stream, determine the initial position state vector of the target object; Target detection in the initial image frames of an image stream is the process of locating and identifying specific target objects within a single image frame of the video stream using image processing algorithms. Examples of implementing target detection include, but are not limited to: one embodiment, deep learning-based target detection models, such as single-stage or two-stage detectors like Faster R-CNN, YOLO, or SSD, which can directly output the bounding box coordinates of the target object in the image and its class confidence score; another embodiment, traditional computer vision methods, such as feature template matching, background subtraction, or optical flow, to identify moving targets. The specific algorithm selected can be determined by comprehensively considering real-time requirements, computational resources, and the characteristics of the target to be detected.
[0041] After successfully detecting the target in the initial image frame, the initial position information of the target object in the frame image coordinate system can be obtained. This position information is usually represented in the form of a bounding box, for example, using the pixel coordinates of the top left and bottom right corners of the bounding box, or using the coordinates of the center point of the bounding box combined with its width and height. This position information is a direct observation of the target on the image plane and constitutes the basic data for initializing the state vector.
[0042] The initial position state vector is a mathematical representation describing the motion state of a target. Its dimension and content depend on the state-space model used. A typical state vector contains at least the target's position information. In more sophisticated models, this vector usually includes more state components, such as position and velocity components, to better describe the target's dynamic characteristics. Specifically, the state vector can be constructed in various ways. A basic implementation is to construct a two-dimensional state vector containing only the target's horizontal and vertical coordinates in the image. Another, more efficient implementation is to construct a four-dimensional state vector, which includes not only the target's horizontal and vertical coordinates but also its velocity components in these two directions. For more complex motion models, the state vector can be further extended to include information such as acceleration.
[0043] After determining the dimension of the state vector, it needs to be initialized using the detected initial position information. For the position component, the coordinate values obtained from target detection are used directly. For the velocity component, since historical motion information is lacking at the initial moment, there are several feasible strategies for initialization. A common strategy is to set the initial value of the velocity component to zero, assuming the target is initially stationary, and assigning it a large initial error covariance to represent the uncertainty of this initial assumption. Subsequent filtering processes will quickly correct this estimate based on new observations. Another strategy, if the system allows for a short delay, is to use the initial frame and the next one or several frames to estimate an initial velocity value by calculating the difference in position between frames, and then use this value to initialize the velocity component. This method can obtain a relatively more accurate initial estimate.
[0044] Step S3120: For subsequent image frames in the image stream, based on the position state vector updated in the previous frame, predict the predicted position of the target object in the current frame using a motion model, and determine the image search area corresponding to the predicted position. After completing target detection and initializing the position state vector for the initial image frame, a prediction and update loop is entered for each subsequent image frame in the image stream. This process predicts the possible position of the target object at the current moment based on its past motion state, and uses this prediction to guide the target search and localization in the current frame, thereby updating the target's state efficiently and accurately.
[0045] Specifically, for the current image frame to be processed, the predicted position of the target object in the current frame is first predicted based on the position state vector updated in the previous frame, using a pre-defined motion model. This motion model is a mathematical description of the target's motion, and its form can be chosen according to the complexity and accuracy requirements of the application scenario. Common motion models include, but are not limited to, uniform velocity models, uniform acceleration models, and more complex statistical motion models. For example, in a typical implementation, a uniform velocity motion model is used. This model assumes that the target moves at a uniform linear velocity between adjacent frames, thus extrapolating the predicted position of the current frame based on the position and velocity information contained in the state vector of the previous frame. The output of the prediction step is a priori estimate of the target's current position, reflecting the best prediction of the target's current position based on historical information.
[0046] After obtaining the predicted location, a finite image search region is determined based on this location. This transforms the global problem into a local one, significantly reducing computational cost and improving search efficiency and robustness. The method for determining the search region can be flexibly chosen. A basic implementation uses the predicted location as the center, defining a fixed-size rectangular region as the search region. The size of this rectangular region should be sufficient to cover the maximum possible displacement of the target between frames. Another more adaptive implementation dynamically adjusts the range of the search region based on the magnitude of the velocity component in the state vector; the greater the velocity, the larger the search region becomes to cover greater uncertainty.
[0047] Step S3130: Within the search area, determine the actual position of the target object in the current frame by matching its visual features, and use the actual position and the predicted position to update the position state vector of the previous frame as the position state vector of the current frame. After determining the search region, the actual location of the target object in the current frame, i.e., the observation location, is determined by matching the visual features of the target object within that region. During visual feature matching, the image content within the search region of the current frame is compared with the feature representation of the target object to find the location most likely to contain the target object. The visual features used for matching can be diverse, including but not limited to features based on color statistics (such as color histograms), gradient-based features (such as HOG features), deep learning-based features (such as feature maps extracted by convolutional neural networks), or template images of the target. Matching algorithms can employ correlation filtering, mean shift, or optical flow methods, etc. The observation location found through matching is a direct measurement of the target in the current frame.
[0048] After obtaining the observed position, the position-state vector of the previous frame is updated using the actual position and the predicted position, thus obtaining the position-state vector of the current frame. This allows for data fusion of the predicted and new observation information to obtain the optimal estimate of the target object's current state. The update algorithm can employ optimal estimation methods such as Kalman filtering and particle filtering. For example, within the Kalman filtering framework, the update step calculates the Kalman gain based on the difference between the predicted and observed values, combined with a pre-defined system noise and observation noise model. This gain is then used to weight and correct the predicted state vector, ultimately outputting a more accurate and smoothed estimate of the current frame's state vector.
[0049] Step S3140: Use the position state vector updated after multiple consecutive frames as the position change data.
[0050] By repeatedly performing the aforementioned process of prediction, search region determination, observation matching, and state vector update on multiple frames of images, a series of optimized position state vectors arranged in chronological order are obtained. This series of state vectors constitutes high-quality position change data, which not only contains the target's motion trajectory information in the image, but also significantly suppresses noise and jitter that may be caused by single-frame detection due to its filtering and smoothing process, providing a stable and reliable input for subsequent generation of tracking and control data.
[0051] The above embodiments elevate traditional isolated single-frame target detection to intelligent state estimation based on temporal context information, fundamentally improving the quality and reliability of position change data. Specifically, the introduction of motion model prediction and limiting the search area not only significantly reduces computational complexity and meets real-time requirements, but also effectively integrates historical motion patterns with current observation data through optimal estimation algorithms such as Kalman filtering. This significantly suppresses interference from image noise, target jitter, and brief occlusions, outputting a smooth, continuous position state vector sequence that reflects the true motion trend. This deep processing and optimization of the original position data lays a solid data foundation for subsequent accurate identification of effective motion trends and intelligent triggering of state switching events. This enables the entire gimbal tracking system to distinguish between unintentional minor jitters and intentional continuous movement, ultimately achieving on-demand compensation and avoiding invalid actions at the control level. Therefore, this embodiment is not a simple algorithm superposition, but rather a systematic solution to the control mis-triggering problem caused by poor data quality in traditional solutions through multi-level information fusion and optimization, highlighting the substantial innovation of this application in improving tracking intelligence, reliability, and energy efficiency.
[0052] Based on any embodiment of the method in this application, tracking and control data reflecting the effective movement trend of the target object is generated according to the position change data, including: Step S3210: Based on the position change data of multiple consecutive frames within a sliding time window, determine the instantaneous motion trend characteristics of the target object, wherein the instantaneous motion trend characteristics include the motion direction and motion amplitude of the target object; After obtaining optimized position change data, such as a sequence of position state vectors updated over multiple consecutive frames, the process moves to the stage of generating tracking and control data. This stage extracts high-level information reflecting the true movement intentions of the target object from this temporal motion data of position change, providing a basis for subsequent intelligent decision-making. Specifically, it first needs to determine the instantaneous movement trend characteristics of the target object based on the position change data of multiple consecutive frames within a sliding time window.
[0053] The purpose of a sliding time window is to extract a subset of data from a continuous stream of positional changes over a recent period for analysis. The length of the window, i.e., the number of image frames it contains, can be set according to the requirements for response speed and stability of trend assessment. For example, a shorter window responds faster to the onset of motion but is more sensitive to noise; while a longer window provides more stable trend assessment but introduces some latency. The window can slide at fixed time intervals or frame-by-frame, the latter providing a more intensive trend evaluation.
[0054] Within a defined sliding time window, position change data from multiple consecutive frames are analyzed to calculate instantaneous motion trend features. These features aim to quantify the target's motion state within the recent window. Instantaneous motion trend features include at least the target's motion direction and amplitude. Motion direction describes the target's tendency to move in the image coordinate system; it can be quantified as an angle value (such as the angle relative to the image center line) or simplified to a discrete category (such as left, right, up, down). Motion amplitude quantifies the magnitude of the target's displacement per unit time, typically expressed as velocity. The specific methods for calculating these features can vary. One implementation directly uses the velocity components (such as Vx, Vy) in the position state vector to represent the motion amplitude and direction. Another implementation estimates the average velocity and direction based on the position coordinates of multiple frames within the window, using linear fitting or difference calculation. For example, the displacement vector can be calculated based on the target's position coordinates in the first and last frames within the window; the direction of this vector is the average motion direction, and its magnitude divided by the time window length is the average motion velocity, which serves as a measure of motion amplitude.
[0055] Step S3220: Perform a persistence judgment and a significance judgment on the instantaneous motion trend feature, wherein the persistence judgment is used to confirm whether the corresponding motion trend is stably maintained within the time window, and the significance judgment is used to confirm whether the motion amplitude of the corresponding motion trend exceeds a preset amplitude threshold. After identifying the instantaneous motion trend characteristics, these characteristics can be validated to distinguish between real, meaningful motion and transient jitter or noise. This can be achieved through two parallel judgment logics: persistence judgment and significance judgment. These two judgments together form a filter, ensuring that only motion trends with a certain intensity and stability are considered valid.
[0056] Persistence assessment evaluates the stability of motion trends over time. Its purpose is to confirm whether the calculated motion direction remains stable within a sliding time window, rather than exhibiting transient, random, or oscillating changes. The specific methods for implementing persistence assessment can vary. A basic implementation checks the consistency of the motion direction across multiple consecutive frames within the time window. For example, a threshold for the number of consecutive frames a direction can be set, requiring that the target's motion direction does not fundamentally change (e.g., from left to right) for more than a certain number of consecutive image frames within the window; only then is the persistence assessment considered successful. Another more refined implementation calculates the variance or standard deviation of the motion direction within the time window. If this statistic is below a preset stability threshold, it indicates minimal directional fluctuation and a stable trend. Persistence assessment effectively filters out frequent changes in direction caused by minor swaying of the target itself (such as the adjustment of a person's center of gravity when standing) or image processing noise, ensuring that the identified trend represents the target's intentional and continuous movement.
[0057] The saliency assessment focuses on evaluating the intensity of a motion trend in the spatial dimension, confirming whether the amplitude of the corresponding motion trend exceeds a preset amplitude threshold. This amplitude threshold is a key parameter, and its setting must consider the actual application scenario, such as the distance between the target and the camera, the pixel resolution of the image, and the necessity for the gimbal to respond to minute movements. Motion amplitude is usually represented by a velocity value. When performing the saliency assessment, the calculated motion amplitude (e.g., velocity modulus in pixels per second) is compared with the preset amplitude threshold. If the motion amplitude is greater than or equal to the threshold, the saliency assessment passes; otherwise, it fails. The saliency assessment ensures that only motions with sufficiently large displacements that warrant the gimbal system to activate or change its tracking state are responded to, avoiding reactions to trivial, non-tracking-value micro-movements, thereby reducing unnecessary mechanical wear and energy consumption.
[0058] Step S3230: When the instantaneous motion trend feature passes both the persistence judgment and the significance judgment, it is determined that a valid motion trend exists within the time window; A valid motion trend is determined to exist within the current sliding time window only if a set of instantaneous motion trend features simultaneously meets the conditions for both persistence and salience as described above. By combining these two criteria, a valid motion must possess both temporal stability and spatial salience; neither can be lacking. For example, a trend with a large amplitude but a sudden reversal of direction (potentially indicating a collision or false detection), or a trend with a very stable direction but extremely slow movement (potentially lacking tracking urgency), will not be considered a valid motion trend. This dual-verification mechanism significantly improves the accuracy of motion intent recognition.
[0059] Step S3240: Encapsulate the effective motion trend and its features to serve as the tracking control data corresponding to the time window.
[0060] After determining that a valid motion trend exists, the judgment result (i.e., the Boolean value "valid motion trend exists") is associated with and encapsulated with the verified motion trend characteristics on which it is based (e.g., specific motion direction angle and motion speed values). This encapsulated data set constitutes the tracking control data corresponding to that specific time window. At this point, the tracking control data not only contains the decision signal of whether to trigger a control action, but also carries the key parameters of how to execute that action (e.g., in which direction the gimbal should rotate and approximately what angular velocity is required), providing complete information input for subsequently triggering precise motion state switching events.
[0061] The above embodiments, by introducing instantaneous motion trend feature extraction based on a sliding time window and combining a dual verification mechanism of persistence and saliency judgment, elevate the traditional approach of relying directly on single-point or simple differential position data processing into a high-level decision-making process that deeply and intelligently evaluates the target's motion intention. This creatively distinguishes between the target's physical displacement and effective motion trend. By quantitatively analyzing the stability of motion in the time dimension and the saliency in the spatial dimension, it can accurately filter out invalid jitter signals caused by image noise and minor shaking of the target itself, ensuring that only trends with persistence and sufficient amplitude that represent the target's true movement intention will trigger subsequent gimbal control actions. This not only avoids frequent motor starts, stops, and turns due to misjudgment at the source, significantly improving the anti-interference capability and tracking reliability of the gimbal mechanical system, but also allows the power compensation of the gimbal mechanical system, such as high-torque start-up and gap compensation, to be precisely allocated on demand, executing only when there is a confirmed effective tracking need. This fundamentally solves the problems of step loss, high power consumption, and mechanical wear caused by the disconnect between low-level control and high-level decision-making in traditional solutions, representing a technological leap from passive response to proactive intelligent decision-making.
[0062] Based on any embodiment of the method in this application, a motion state switching event required for tracking the target object is triggered based on the tracking control data. This event is associated with a specific motion state mode and includes: Step S3310: Traverse the motion trend features corresponding to the effective motion trends provided by multiple time windows in the tracking and control data; After successfully generating tracking and control data containing effective motion trend judgments and specific motion trend characteristics, the motion state switching event triggering phase can begin. The core function of this phase is to act as an intelligent decision-maker, analyzing the information carried by the tracking and control data and logically matching it with the current operating state of the gimbal mechanical system. This determines which predefined motion state mode the gimbal needs to enter and triggers the corresponding event, ensuring that the gimbal's motion response is highly contextualized, accurate, and only occurs when there is a clear need.
[0063] Therefore, the first step is to traverse or access data points corresponding to multiple time windows in the tracking and control data. These data points provide continuous or discrete time-series information about the target's movement trend. The purpose of traversal is to obtain the latest and possibly recent historical trend judgments and characteristic data to make more comprehensive and robust decisions, avoiding false triggers caused by data fluctuations at a single clock scale. For example, the data of the current time window and the one or two windows preceding it can be examined to confirm whether the persistence of the movement trend holds true on a longer time scale.
[0064] Step S3320: If the tracking control data corresponding to the current time window indicates the existence of a valid motion trend, and the motion direction of the valid motion trend is inconsistent with the current tracking direction of the gimbal, then a motion state switching event associated with the motion turning mode is triggered. During the traversal, the effective motion trend characteristics indicated by the current tracking control data are compared with the current tracking state of the gimbal. If the tracking control data corresponding to the current time window clearly indicates the existence of an effective motion trend, and analysis of its motion trend characteristics reveals that the direction of this effective motion trend is inconsistent with the current tracking direction of the gimbal, a motion state switching event associated with the motion steering mode is triggered. This event indicates that the system determines that the target object is attempting to move out of the gimbal's current field of view or tracking path, and the gimbal's rotation direction must be changed immediately to recapture and follow the target. Inconsistency in motion direction can be determined by comparing whether the angle between the target's motion direction vector and the gimbal's current rotation direction vector exceeds a certain threshold.
[0065] Step S3330: If the tracking control data corresponding to the current time window indicates that there is an effective motion trend, and the gimbal is currently stationary or in a low-speed state that has not entered effective tracking, then trigger the motion state switching event associated with the motion activation mode. If the tracking control data corresponding to the current time window indicates a valid motion trend, but the gimbal system is currently stationary, or rotating but in a low-speed state where it has not entered effective tracking (e.g., performing a preset path scan, just starting up, or in standby slow operation), then a motion state switching event associated with the motion activation mode is triggered. This indicates that a target worthy of tracking has appeared and begun to move effectively, requiring the gimbal to formally transition from an inactive tracking state to an active tracking state. The determination of a low-speed state where effective tracking has not yet commenced can be based on whether the current rotation speed of the gimbal is below a set threshold.
[0066] Step S3340: If the tracking control data corresponding to the current time window indicates that there is no effective motion trend, and the gimbal is currently in motion tracking state, then trigger the motion state switching event associated with the motion continuous mode.
[0067] If the tracking control data corresponding to the current time window indicates that there is no valid motion trend (i.e., the target's motion is verified to be invalid or negligible), but the gimbal is already in motion tracking mode, a motion state switching event associated with the motion persistence mode can be triggered. This typically means that the target object is relatively stationary, moving slowly, or maintaining a stable following state within the gimbal's current field of view. This event instructs the system to maintain the current tracking control strategy, such as controlling the gimbal to rotate at a constant speed or making very minor adjustments, to maintain lock on the target, rather than completely stopping or drastically changing the motion state.
[0068] The aforementioned triggering logic collectively constitutes a complete decision-making mechanism. The motion state switching event, as a clear signal, seamlessly connects upper-level intelligent perception (effective motion trend recognition) with lower-level precise control (patterned motion compensation). In this way, it ensures that every change in the gimbal's motion state—whether initiation, turning, or maintenance—is a rational decision based on a reliable assessment of the target behavior. This fundamentally avoids ineffective mechanical actions caused by noise, jitter, or misjudgment, achieving efficient, reliable, and energy-saving automatic gimbal tracking.
[0069] Based on any embodiment of the method in this application, in response to the motion state switching event, the stepper motor is controlled to perform motion compensation according to the motion state mode corresponding to the event, so that the gimbal switches to an effective tracking state, including any one or more of the following: Step S3410: When the motion state mode is motion on mode, output start control command, and provide static friction current higher than its normal working current to the stepper motor to start it, and then smoothly accelerate to the target speed to complete motion compensation, so as to drive the gimbal into effective tracking state. After successfully triggering a motion state transition event and determining its associated specific motion state mode, the control flow enters the motion compensation execution phase. This phase translates high-level mode decisions into specific, low-level control commands that drive the stepper motors. It also introduces targeted compensation strategies to overcome the inherent limitations of the gimbal's mechanical system, thereby achieving a smooth and precise transition from the current state to the effective tracking state. Each motion state mode corresponds to a pre-designed set of control logic and compensation measures.
[0070] When it is determined that the motion activation mode needs to be entered, it is necessary to ensure that the gimbal can reliably start from a stationary state and smoothly accelerate to the target speed required for tracking. To this end, a corresponding control strategy can be applied, outputting a dedicated start-up control command sequence. This command sequence first controls the stepper motor driver, applying a drive current significantly higher than its normal steady-state operating current to the stepper motor at the moment of startup. This current value is set as the static friction current, which can be pre-calibrated. The purpose of applying this high current is to generate a sufficiently large instantaneous torque to overcome the static friction in the gimbal's transmission mechanism, ensuring that the motor rotor can start decisively and drive the load, thereby fundamentally avoiding the phenomenon of missed steps due to insufficient starting torque.
[0071] After a successful start and a brief period of maintenance, such as tens of milliseconds or a few steps, the control strategy switches. The drive current is reduced to normal operating levels, while the controller guides the motor to accelerate from a lower starting speed to a preset target tracking speed according to a pre-defined smooth acceleration curve (such as an S-curve or a linear increasing curve). This two-stage start-up control strategy ensures both reliable start-up and smooth acceleration, avoiding mechanical shocks and potential loss of synchronization caused by sudden speed changes.
[0072] Step S3420: When the motion state mode is motion steering mode, output steering control command, and provide the stepper motor with the number of return gap steps for motion compensation through the command. Drive the stepper motor to perform steering compensation according to the number of return gap steps and drive the gimbal to maintain effective tracking state. When it is determined that a motion steering mode needs to be entered, the impact of gear drive backlash on steering accuracy must be eliminated. To this end, the corresponding control strategy outputs a steering control command that, in addition to the basic direction change command, integrates a crucial compensation mechanism. Specifically, after the stepper motor executes the theoretical direction reversal command, the controller additionally drives the motor to run a pre-measured or calculated number of backlash steps. The purpose of these compensation steps is to allow the drive gear on the motor shaft to first idle and transition away from the physical gap with the driven gear during reverse rotation, and then re-achieve a state of tight gear meshing before actually driving the gimbal to rotate in the reverse direction. In this way, the actual rotation angle of the gimbal remains consistent with the command angle issued by the controller, effectively eliminating the root cause of lost steps during direction reversal and ensuring that the gimbal can quickly and accurately follow the target when its direction of movement changes, thereby maintaining effective tracking.
[0073] Step S3430: When the motion state mode is continuous motion mode, output a uniform speed control command, and drive the stepper motor to rotate continuously at the target speed to maintain effective tracking state.
[0074] When the system determines that continuous motion mode is needed, it indicates that the current tracking phase is stable and requires no special compensation. At this time, the corresponding control strategy outputs a constant speed control command. This command controls the stepper motor driver to drive the motor with pulse signals at a constant frequency, thereby maintaining a constant rotational speed for both the motor and the gimbal. In this mode, the motor typically operates at its rated current or a current optimized for the load, contributing to lower power consumption and noise levels and ensuring smooth and continuous tracking of the moving target by the gimbal.
[0075] In the above embodiments, differentiated control strategies for different modes are implemented through a smart interface—the motion state switching event—achieving tight coupling between high-level decision-making and low-level execution. This design ensures that operations requiring significant power or precise compensation, such as starting and turning, are only triggered when proven necessary, while the stepper motor operates at a low-power, constant speed most of the time. This significantly improves the reliability and accuracy of the tracking system, optimizes the energy efficiency and mechanical lifespan of the gimbal's mechanical system, and ultimately achieves the goal of enabling the gimbal to quickly, smoothly, and accurately switch to and stably maintain an effective tracking state.
[0076] Based on any embodiment of the method in this application, before identifying the position change data of the target object in each frame of the image stream captured by a camera fixed on a pan-tilt unit, the method includes: Step S1100: In response to the current calibration start command, apply a drive current that slowly increases from zero to the stepper motor; To ensure the accurate implementation of the anti-step loss control strategy in motion-activated mode, a calibration procedure can be performed to determine key static friction current parameters before formal tracking control begins. This parameter serves as the baseline value for the minimum drive current required to overcome the static friction of the gimbal drive system, and its accuracy directly affects the reliability of the start-up control. The calibration process can be performed during system power-on initialization, maintenance cycles, or when triggered by user commands.
[0077] The current calibration start command can originate from various situations, including but not limited to the self-test program when the device is first powered on, manual calibration commands issued by the user through the software interface or physical buttons, or automatic triggering when the system reaches the preset maintenance cycle. Once the command is received, the device responds and enters a dedicated calibration state.
[0078] In response to the current calibration start command, the stepper motor driver is controlled to apply a slowly increasing drive current to the stepper motor, starting from zero. There are several ways to implement this current increase. One basic implementation uses a linear increase with small steps, where the drive current increases by a fixed, tiny increment at fixed intervals. Another implementation uses a ramp function with a controllable slope to generate a continuously rising current signal. This is achieved by gradually increasing the motor torque from zero until it just overcomes the static resistance.
[0079] Step S1200: Detect whether the gimbal has started to actually rotate using a preset motion sensor; As the current slowly increases, a pre-set motion sensor continuously monitors whether the pan-tilt unit (PTZ) has started to rotate. The key here is distinguishing between the minute vibrations or hysteresis of the motor rotor and the continuous movement of the entire PTG mechanism. The choice of motion sensor can be varied; for example, an optical encoder or magnetic encoder mounted on the PTG's rotation axis can be used, or image processing technology can be employed to analyze images captured by the camera itself to determine if there is a continuous and minute shift in the PTG background. The detection logic continuously monitors changes in the signal output from the motion sensor; once a signal indicating that the PTG has begun to generate continuous, non-transient rotation is detected, the start-up point is determined.
[0080] Step S1300: Obtain the current value corresponding to the instant when the gimbal starts to rotate continuously, and use it as the static friction current.
[0081] At the instant the gimbal begins to rotate, record the value of the drive current output by the stepper motor driver. This current value is the minimum current required to overcome the static friction of the entire transmission chain, including the motor itself, the reducer, and the gear set; it is the reference value for the static friction current. After obtaining this value, it can be stored in non-volatile memory for later use in motion activation mode control. After calibration, exit the calibration state and choose to stop the motor or enter standby mode.
[0082] The above embodiments, by introducing a fully automated static friction current calibration process, elevate the traditional method of relying on manual experience for estimation or fixed parameters to an intelligent system with self-sensing and self-learning capabilities. This calibration mechanism creatively distinguishes the individual mechanical characteristic differences of different devices caused by manufacturing tolerances, wear, and temperature variations. Through systematic execution, it automatically and accurately measures the true static friction threshold of the current physical system, enabling the high-torque start-up strategy in subsequent anti-step-loss control to be precisely customized based on objective measured data rather than subjective preset values. This not only fundamentally solves the problem of start-up step loss or excessive torque caused by inaccurate parameters, improving the adaptability and reliability of control, but also realizes the self-optimization capability of the PTZ system to maintain optimal performance under different lifecycles and operating conditions. It represents a technological leap from static parameter control to dynamic system identification, highlighting the substantial innovation of this application in improving the intelligence level and long-term robustness of monitoring equipment.
[0083] Based on any embodiment of the method in this application, before identifying the position change data of the target object in each frame of the image stream captured by a camera fixed on a pan-tilt unit, the method includes: Step S2100: In response to the step calibration start command, control the stepper motor to drive the gimbal to rotate a preset distance along the first direction and then stop; To ensure the accurate implementation of the anti-loss-step control strategy during steering in motion mode, a calibration process can be used to automatically determine the key return backlash step count parameter before formal tracking control. This parameter quantifies the physical number of steps of the return backlash of the gear pair in the gimbal drive system, and its accuracy directly affects the effectiveness of steering compensation. This calibration process is similar to static friction current calibration and can be triggered by system power-on initialization, maintenance commands, or user commands.
[0084] The calibration process begins with the system responding to a step calibration start command. This command can originate from initial calibration during first use, periodic system maintenance procedures, or user-initiated calibration commands. Upon receiving the command, the system enters the retrace clearance calibration state.
[0085] In response to the step calibration start command, firstly, the stepper motor drives the gimbal to rotate a preset distance in a selected first direction and then stops. This preset distance ensures that the gear pairs in the transmission mechanism are fully engaged in that direction, eliminating backlash on either side and keeping the entire transmission system in a unidirectional taut state. The preset distance can be determined in various ways; for example, it can be a fixed, sufficiently large number of steps to ensure that even initial backlash can be completely eliminated; or it can be controlled by rotating the gimbal until it hits a mechanical limit switch, thus ensuring that the limit position is reached.
[0086] Step S2200: Control the stepper motor to run gradually in a second direction opposite to the first direction, and monitor whether the gimbal has started to actually rotate through a preset motion sensor; After completing rotation in the first direction and stopping, the stepper motor is immediately controlled to move gradually in a second direction completely opposite to the first direction. The purpose of gradual movement is to capture the critical point from idle to actual rotation with high precision. Implementation methods may include continuous operation at extremely low speeds, or intermittent drive in units of single step pulses, with a short pause after each one or several pulses for status detection.
[0087] As the motor gradually moves in the second direction, a preset motion sensor can monitor in real time whether the gimbal body has begun to actually rotate. The monitoring principle is to detect the physical displacement of the gimbal body relative to its base or reference point. The type of motion sensor is the same as described above, and it can continuously determine whether the sensor signal indicates that the gimbal has begun to undergo a substantial angular displacement change.
[0088] Step S2300: Record the cumulative number of motor steps from when the stepper motor starts moving in the second direction until the gimbal starts to actually rotate, and use this as the return interval step number.
[0089] The number of steps taken by the stepper motor begins to accumulate from the moment the command to move in the second direction is issued. Once the motion sensor detects that the gimbal has started to actually rotate, the step counting stops immediately, and the accumulated motor steps are recorded. This step count is the number of idle steps from when the motor receives the reverse command to when the gimbal actually begins to respond, which is also the baseline value for the return backlash steps. This value directly reflects the total mechanical backlash, such as gear meshing clearance, in the transmission chain.
[0090] After obtaining the return stroke backlash steps, store them as a fixed setting for later use in motion steering mode control. After calibration is complete, you can exit the calibration state and choose to stop the motor or enter standby mode.
[0091] The above embodiments, by introducing a fully automated return backlash step calibration process, elevate the traditional method relying on manual measurement or fixed compensation values to an intelligent system with self-diagnosis and parameter self-tuning capabilities. This calibration mechanism creatively distinguishes between dynamic backlash differences caused by mechanical wear, assembly tolerances, or temperature variations in different devices. Through a closed-loop measurement process, it automatically and objectively quantifies the true return backlash of the transmission chain, enabling subsequent commutation compensation strategies to accurately compensate based on measured physical steps rather than theoretical estimates. This not only fundamentally solves the problem of lost steps or overcompensation during commutation caused by inaccurate backlash measurement, ensuring absolute accuracy of angle positioning, but also realizes the adaptive compensation capability of the gimbal mechanical system for mechanical performance degradation throughout its entire lifecycle. This represents a technological leap from static open-loop control to dynamic closed-loop parameter optimization, highlighting the substantial innovation of this application in improving the long-term stability and accuracy retention of monitoring equipment and reducing reliance on manual adjustments.
[0092] Please see Figure 3 This invention provides a gimbal tracking control device to meet one of the purposes of this application. It is a functional embodiment of the gimbal tracking control method of this application. The device includes a position recognition module 3100, a tracking analysis module 3200, an event recognition module 3300, and a mode driving module 3400. The position recognition module 3100 is configured to identify position change data of a target object in each frame of an image stream captured by a camera fixed on the gimbal. The tracking analysis module 3200 is configured to generate tracking control data reflecting the effective motion trend of the target object based on the position change data. The event recognition module 3300 is configured to trigger a motion state switching event required for tracking the target object based on the tracking control data, and this event is associated with a specific motion state mode. The mode driving module 3400 is configured to respond to the motion state switching event, control a stepper motor to perform motion compensation according to the motion state mode corresponding to the event, and then drive the gimbal into an effective tracking state.
[0093] Based on any embodiment of the device in this application, the position recognition module 3100 includes: a position initialization module, configured to determine the initial position state vector of the target object based on target detection of the initial image frame in the image stream; a region determination module, configured to predict the predicted position of the target object in the current frame based on the position state vector updated in the previous frame and determine the image search region corresponding to the predicted position; a position update module, configured to determine the actual position of the target object in the current frame by matching its visual features within the search region, and update the position state vector of the previous frame as the position state vector of the current frame using the actual position and the predicted position; and a change representation module, configured to use the position state vector updated after multiple consecutive frames as the position change data.
[0094] Based on any embodiment of the device in this application, the tracking analysis module 3200 includes: a feature determination module, configured to determine the instantaneous motion trend features of the target object based on the position change data of multiple consecutive frames within a sliding time window, wherein the instantaneous motion trend features include the motion direction and motion amplitude of the target object; an analysis and judgment module, configured to perform persistence judgment and significance judgment on the instantaneous motion trend features, wherein the persistence judgment is used to confirm whether the corresponding motion trend is stably maintained within the time window, and the significance judgment is used to confirm whether the motion amplitude of the corresponding motion trend exceeds a preset amplitude threshold; a trend recognition module, configured to determine that a valid motion trend exists within the time window when the instantaneous motion trend features pass both the persistence judgment and the significance judgment; and a tracking representation module, configured to encapsulate the valid motion trend and its motion trend features as the tracking control data corresponding to the time window.
[0095] Based on any embodiment of the device in this application, the event recognition module 3300 includes: a feature traversal module, configured to traverse the motion trend features corresponding to the effective motion trends provided by multiple time windows in the tracking control data; a turning trigger module, configured to trigger a motion state switching event associated with the motion turning mode if the tracking control data corresponding to the current time window indicates the existence of an effective motion trend and the motion direction of the effective motion trend is inconsistent with the current tracking direction of the gimbal; an activation trigger module, configured to trigger a motion state switching event associated with the motion activation mode if the tracking control data corresponding to the current time window indicates the existence of an effective motion trend and the gimbal is currently stationary or in a low-speed state that has not entered effective tracking; and a continuous trigger module, configured to trigger a motion state switching event associated with the motion continuous mode if the tracking control data corresponding to the current time window indicates the absence of an effective motion trend and the gimbal is currently in a motion tracking state.
[0096] Based on any embodiment of the device in this application, the mode driving module 3400 includes any one or more of the following: an activation control module, configured to output a start control command when the motion state mode is motion activation mode, thereby providing a static friction current higher than its normal operating current to the stepper motor to achieve startup, and then smoothly accelerating to the target speed to complete motion compensation, so as to drive the gimbal into an effective tracking state; a steering control module, configured to output a steering control command when the motion state mode is motion steering mode, thereby providing a return gap step number to the stepper motor for motion compensation, driving the stepper motor to perform steering compensation according to the return gap step number, and driving the gimbal to maintain an effective tracking state; and a continuous control module, configured to output a uniform speed control command when the motion state mode is motion continuous mode, thereby driving the stepper motor to continuously rotate at the target speed to maintain an effective tracking state.
[0097] Based on any embodiment of the device in this application, prior to the position recognition module 3100, this device further includes: a current command module, configured to apply a driving current that slowly increases from zero to the stepper motor in response to a current calibration start command; a rotation detection module, configured to detect whether the gimbal has started to actually rotate through a preset motion sensor; and a current calibration module, configured to obtain the current value corresponding to the instant when the gimbal starts to generate continuous rotation, as the static friction corresponding current.
[0098] Based on any embodiment of the device in this application, prior to the position recognition module 3100, this device further includes: a step count command module, configured to respond to a step count calibration start command, control the stepper motor to drive the gimbal to rotate a preset distance along a first direction and then stop; a reverse operation module, configured to control the stepper motor to run gradually along a second direction opposite to the first direction, and monitor whether the gimbal has started to actually rotate through a preset motion sensor; and a step count calibration module, configured to record the cumulative number of motor steps from when the stepper motor starts running in the second direction to when the gimbal starts to actually rotate, as the return interval steps.
[0099] To address the aforementioned technical problems, embodiments of this application also provide a computer device. For example... Figure 4 The diagram shows the internal structure of a computer device. This computer device includes a processor, a computer-readable storage medium, a memory, a network interface, and various communication components connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store control information sequences. When the computer-readable instructions are executed by the processor, they enable the processor to implement a gimbal tracking control method. The processor of this computer device provides computing and control capabilities, supporting the operation of the entire computer device. The memory of this computer device may store computer-readable instructions. When these computer-readable instructions are executed by the processor, they enable the processor to execute the gimbal tracking control method of this application. The network interface of this computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0100] In this embodiment, the processor is used to execute... Figure 3 The system contains the specific functions of each module and its sub-modules, and the memory stores the program code and various data required to execute these modules or sub-modules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules / sub-modules in the PTZ tracking control device of this application, and the server can call the server's program code and data to execute the functions of all sub-modules.
[0101] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the gimbal tracking control method of any embodiment of this application.
[0102] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0103] Those skilled in the art will understand that the steps, measures, and solutions in the various operations, methods, and processes discussed in this application can be alternated, modified, combined, or deleted. Furthermore, other steps, measures, and solutions in the various operations, methods, and processes discussed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted. Furthermore, steps, measures, and solutions in the prior art that are similar to those in the open-source operations, methods, and processes of this application can also be alternated, modified, rearranged, decomposed, combined, or deleted.
[0104] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A gimbal tracking control method, characterized in that, include: Based on the image stream captured by the camera fixed on the pan-tilt unit, identify the position change data of the target object in each frame of the image stream; Based on the position change data, tracking and control data is generated to reflect the effective movement trend of the target object; Based on the tracking control data, a motion state switching event required for tracking the target object is triggered, and this event is associated with a specific motion state mode. In response to the motion state switching event, the stepper motor is controlled to perform motion compensation according to the motion state mode corresponding to the event, so that the gimbal switches to an effective tracking state.
2. The gimbal tracking control method according to claim 1, characterized in that, Identifying the positional change data of the target object in each frame of the image stream includes: Based on target detection of the initial image frame in the image stream, the initial position state vector of the target object is determined; For subsequent image frames in the image stream, based on the position state vector updated in the previous frame, the motion model is used to predict the predicted position of the target object in the current frame, and the image search area corresponding to the predicted position is determined. Within the search area, the actual position of the target object in the current frame is determined by matching its visual features. The actual position and the predicted position are then used to update the position state vector of the previous frame as the position state vector of the current frame. The position state vector updated over multiple consecutive frames is used as the position change data.
3. The gimbal tracking control method according to claim 1, characterized in that, Based on the position change data, tracking and control data is generated to reflect the effective movement trend of the target object, including: Based on the position change data of multiple consecutive frames within a sliding time window, the instantaneous motion trend characteristics of the target object are determined, and the instantaneous motion trend characteristics include the motion direction and motion amplitude of the target object; The instantaneous motion trend features are subjected to a persistence judgment and a significance judgment. The persistence judgment is used to confirm whether the corresponding motion trend is stably maintained within the time window, and the significance judgment is used to confirm whether the motion amplitude of the corresponding motion trend exceeds a preset amplitude threshold. When the instantaneous motion trend feature passes both the persistence judgment and the significance judgment, it is determined that a valid motion trend exists within the time window; The effective motion trend and its features are encapsulated to serve as the tracking and control data corresponding to the time window.
4. The gimbal tracking control method according to claim 1, characterized in that, Based on the tracking control data, a motion state switching event required for tracking the target object is triggered. This event is associated with a specific motion state mode, including: Iterate through the motion trend features corresponding to the effective motion trends provided by multiple time windows in the tracking and control data; If the tracking control data corresponding to the current time window indicates the existence of a valid motion trend, and the direction of motion of the valid motion trend is inconsistent with the current tracking direction of the gimbal, then a motion state switching event associated with the motion steering mode is triggered. If the tracking control data corresponding to the current time window indicates that there is a valid motion trend, and the gimbal is currently stationary or in a low-speed state that has not entered effective tracking, then a motion state switching event associated with the motion activation mode is triggered. If the tracking control data corresponding to the current time window indicates that there is no effective motion trend, and the gimbal is currently in motion tracking state, then a motion state switching event associated with the motion continuous mode is triggered.
5. The gimbal tracking control method according to any one of claims 1 to 4, characterized in that, In response to the motion state switching event, the stepper motor is controlled to perform motion compensation according to the corresponding motion state mode of the event, so that the gimbal switches to an effective tracking state, including any one or more of the following: When the motion state mode is motion-on mode, a start control command is output. This command provides a static friction current higher than the normal operating current to the stepper motor to start it up. Then, it smoothly accelerates to the target speed to complete motion compensation, thereby driving the gimbal into an effective tracking state. When the motion state mode is motion steering mode, a steering control command is output. This command provides the stepper motor with the number of return gap steps for motion compensation. The stepper motor is driven to perform steering compensation according to the number of return gap steps, and then the gimbal is driven to maintain an effective tracking state. When the motion state mode is continuous motion mode, a constant speed control command is output, which drives the stepper motor to rotate continuously at the target speed to maintain effective tracking.
6. The gimbal tracking control method according to claim 5, characterized in that, Before identifying the positional change data of the target object in each frame of the image stream captured by a camera fixed on a pan-tilt-zoom (PTZ) platform, the process includes: In response to the current calibration start command, a drive current that slowly increases from zero is applied to the stepper motor; The system uses a preset motion sensor to detect whether the gimbal has started to actually rotate. The current value corresponding to the instant when the gimbal begins to rotate continuously is obtained, and is used as the static friction current.
7. The gimbal tracking control method according to claim 5, characterized in that, Before identifying the positional change data of the target object in each frame of the image stream captured by a camera fixed on a pan-tilt-zoom (PTZ) platform, the process includes: In response to the step calibration start command, the stepper motor is controlled to drive the gimbal to rotate a preset distance along the first direction and then stop. The stepper motor is controlled to run gradually in a second direction opposite to the first direction, and the gimbal is monitored by a preset motion sensor to see if it has started to actually rotate. The number of motor steps accumulated from the start of the stepper motor moving in the second direction to the start of actual rotation of the gimbal is recorded as the return interval steps.
8. A gimbal tracking and control device, characterized in that, include: The position recognition module is configured to identify position change data of the target object in each frame of the image stream based on the image stream captured by the camera fixed on the pan-tilt-zoom (PTZ) platform. The tracking and analysis module is configured to generate tracking and control data that reflects the effective movement trend of the target object based on the position change data; The event recognition module is configured to trigger a motion state switching event required for tracking the target object based on the tracking control data, and the event is associated with a specific motion state mode. The mode driving module is configured to respond to the motion state switching event, control the stepper motor to perform motion compensation according to the motion state mode corresponding to the event, and then drive the gimbal to enter the effective tracking state.
9. A monitoring device, comprising a camera, a pan-tilt unit, a stepper motor, and a controller, wherein the controller includes a processor and a memory, the camera is fixed to the pan-tilt unit, and the stepper motor is used to drive the pan-tilt unit to rotate so that the camera tracks a target object and acquires an image stream, characterized in that, The processor invokes and runs a computer program in the memory to perform the steps of the gimbal tracking control method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, performs the steps included in the corresponding method.