Video image motion smoothing processing method, device, terminal equipment and storage medium
By adaptively adjusting the filtering strategy and trajectory smoothing processing, the problem of unstable video images caused by sensor abnormalities is solved, robust video generation in complex scenes is achieved, and video quality and user experience are improved.
Patent Information
- Application Number
- CN202311752617.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-19
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-12-19
AI Technical Summary
When the sensor observation data is abnormal, the existing video image anti-shake algorithm has poor anti-shake effect, which can easily cause the video image to be shaken, blurred or unstable, affecting the video quality.
By acquiring camera attitude data, using quaternions to represent and initialize the nominal state vector, combined with error state Kalman filtering and smooth variable structure filtering, the filtering strategy is adaptively adjusted to perform abnormality judgment and trajectory smoothing to generate stable video frames.
When the camera is impacted by external forces or in complex motion scenarios, it detects and adapts to sensor anomalies, provides robust and stable video images, and improves the shooting experience and video quality in extreme scenarios.
Smart Images

Figure CN117714873B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of video image processing, and specifically to a method, an apparatus, a terminal device and a storage medium for motion smoothing processing of video images. Background Art
[0002] In the existing video image stabilization algorithms, whether based on Kalman filtering, sliding window filtering or other filtering schemes, there is a common problem, that is, the abnormal observation data of the sensor itself may lead to poor stabilization effect.
[0003] For example, the Kalman filter-based solution is very sensitive to external interference. Excessive vibration and external acceleration during camera acceleration, as well as magnetic interference caused by motor rotation or rotation of nearby rigid bodies, will seriously affect the attitude estimation of the Kalman filter. When the inertial measurement unit (IMU) fails, the obtained system and measurement model are inevitably susceptible to unknown constant deviations or time-varying random deviations. Such failure of the IMU will cause the estimation performance of the Kalman filter algorithm to deteriorate seriously and may even cause the algorithm to diverge.
[0004] When the sensor itself observes abnormal data, the anti-shake algorithm will be affected regardless of the filtering scheme used. These abnormal data may be caused by sensor failure, noise interference, environmental changes or other external factors.
[0005] Abnormal data may cause the anti-shake algorithm to mistakenly regard these abnormal data as real posture changes, resulting in poor anti-shake effect, which may cause jitter, blur or instability in the video image, reducing the quality of the camera video image and the viewing experience. Summary of the invention
[0006] The embodiments of the present invention provide a method, apparatus, terminal device and storage medium for motion smoothing processing of video images. The technical problem to be solved is that, in view of the defects of the prior art, there is a common problem in the existing video image anti-shake algorithms, whether based on Kalman filtering, sliding window filtering or other filtering schemes, that is, abnormal observation data of the sensor itself may lead to poor anti-shake effect.
[0007] In order to solve the above technical problems, a technical solution adopted by the present invention is to provide a motion smoothing processing method for a video image, the method comprising the following steps:
[0008] Obtaining the posture data of the current camera corresponding to the current video frame of the video stream, representing the current camera posture by quaternion, and initializing the nominal state vector of the current camera;
[0009] The prior error covariance matrix P of the current camera is calculated based on the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ;
[0010] Estimate an expected posture model according to the historical posture data of the current camera, and perform abnormality judgment on the posture data of the current camera according to the expected posture model:
[0011] When the judgment result of the posture data of the current camera is an abnormal state, a smooth variable structure filter is used to calculate the smooth variable structure gain K K+1 ;
[0012] When the judgment result of the posture data of the current camera is normal, the Kalman filter is used to calculate the Kalman gain K' K+1 ;
[0013] According to the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera;
[0014] Estimate the rotation matrix according to the posture of the current camera within a set time length, perform trajectory smoothing, and obtain a smoothed posture matrix of the current camera;
[0015] The video image is rotated according to the smoothed pose matrix of the current camera to generate a stable video frame.
[0016] In a specific embodiment, the smoothly variable structure gain K K+1 satisfy:
[0017] Among them, H + K+1 is the Jacobian matrix of the observation information at time k+1, is a priori function, is the posterior function, γ is the convergence rate of the smooth variable structure filter, is a diagonal matrix constructed from the width of the smoothed boundary layer ψ.
[0018] In a specific embodiment, the Kalman gain K' K+1 satisfy:
[0019] K' K+1 =P - K+1 H K+1 T (H K+1 P - K+1 H K+1T +R K+1 ) -1 , where P - K+1 is the prior error covariance matrix, H K+1 is the Jacobian matrix of the observation information at time k+1, R K+1 is the measurement error covariance matrix.
[0020] In a specific implementation, the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera, including:
[0021] According to the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Compute the posterior error state According to the a posteriori error state Update the posterior nominal state X and renormalize the quaternion Calculate the posterior error covariance matrix P + K+1 , update the posterior error covariance matrix P + K+1 , calculate the posterior innovation function And update the attitude estimation rotation matrix of the current camera.
[0022] In a specific implementation, the step of estimating a rotation matrix according to the posture of the current camera within a set time length and performing trajectory smoothing includes:
[0023] According to the estimated rotation matrix of the current camera posture within the set time length, an updated rotation matrix B is calculated i , and obtain the first-order smoothness E f , And further calculate the second-order smoothness E s , Where R i Estimated rotation matrix for the current camera pose.
[0024] In a specific implementation, the abnormality determination of the posture data of the current camera includes:
[0025] Based on the fault detection method of the chi-square matrix, the difference between the posture data of the current camera and the expected posture model is judged, and when the difference is greater than or equal to a first preset threshold, the judgment result of the fault detection method of the chi-square matrix is output as an abnormal state, otherwise, the judgment result of the fault detection method of the chi-square matrix is output as a normal state;
[0026] Then, based on the fault detection method of sequential probability ratio test, the difference between the probability distribution of the posture data of the current camera and the normal distribution of the expected posture model is judged, and when the difference is greater than or equal to a second preset threshold, the judgment result of the fault detection method of sequential probability ratio test is output as an abnormal state, otherwise, the judgment result of the fault detection method of sequential probability ratio test is output as a normal state;
[0027] Finally, a fault detection method based on angle deviation is used to calculate the angle deviation between the angle data and the expected posture model according to the angle data in the posture data of the current camera. When the angle deviation is greater than or equal to a third preset threshold, the judgment result of the fault detection method of the angle deviation is output as an abnormal state; otherwise, the judgment result of the fault detection method of the angle deviation is output as a normal state.
[0028] When the judgment results output by any two or more of the fault detection methods of the chi-square matrix fault detection method, the sequential probability ratio test fault detection method and the angle deviation fault detection method are abnormal states, the posture data of the current camera is judged to be in an abnormal state; otherwise, the posture data of the current camera is judged to be in a normal state.
[0029] In a specific implementation, rotating the video image according to the smoothed pose matrix of the current camera to generate a stable video frame includes:
[0030] Map the points on the longitude and latitude image to the points on the spherical image;
[0031] All points on the unit sphere are traversed, and all points on the unit sphere are rotated using the pose matrix of the current camera to generate a stable video frame.
[0032] In a specific embodiment, a video image motion smoothing processing device is also included, and the video image motion smoothing processing device includes:
[0033] An initialization module, the initialization module is used to obtain the posture data of the current camera corresponding to the current video frame of the video stream, represent the current camera posture by quaternion, and initialize the nominal state vector of the current camera;
[0034] The first calculation module is used to calculate the prior error covariance matrix P of the current camera according to the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ;
[0035] A judgment module, the judgment module is used to estimate an expected posture model according to the historical posture data of the current camera, and perform abnormal judgment on the posture data of the current camera according to the expected posture model;
[0036] The second calculation module is used to calculate the smooth variable structure gain K by using smooth variable structure filtering when the judgment result of the posture data of the current camera is an abnormal state. K+1 ;
[0037] The third calculation module is used to calculate the Kalman gain K' by using Kalman filtering when the judgment result of the posture data of the current camera is normal. K+1 ;
[0038] An updating module is used to update the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera;
[0039] A trajectory smoothing module, the trajectory smoothing module is used to estimate the rotation matrix according to the posture of the current camera within a set time length, perform trajectory smoothing, and obtain a smoothed posture matrix of the current camera;
[0040] A generation module is used to rotate the video image according to the smoothed pose matrix of the current camera to generate a stable video frame.
[0041] In a specific implementation, a terminal device is also included, including:
[0042] one or more processors;
[0043] Memory;
[0044] And, one or more computer programs, the processor and the memory are connected via a bus, wherein the one or more computer programs are stored in the memory and are configured to be executed by the one or more processors, characterized in that when the processor executes the computer program, the steps of the motion smoothing processing method for video images described in any of the above-mentioned specific embodiments are implemented.
[0045] In a specific embodiment, it also includes a computer-readable storage medium, which stores a computer program. The computer program is suitable for loading by a processor to execute the steps of the motion smoothing processing method for video images described in any of the above specific embodiments.
[0046] The beneficial effect of the present invention is that, different from the prior art, the present invention provides a method for smoothing motion of a video image, the method comprising the following steps:
[0047] Obtaining the posture data of the current camera corresponding to the current video frame of the video stream, representing the current camera posture by quaternion, and initializing the nominal state vector of the current camera;
[0048] The prior error covariance matrix P of the current camera is calculated based on the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ;
[0049] Estimate an expected posture model according to the historical posture data of the current camera, and perform abnormality judgment on the posture data of the current camera according to the expected posture model:
[0050] When the judgment result of the posture data of the current camera is an abnormal state, a smooth variable structure filter is used to calculate the smooth variable structure gain K K+1 ;
[0051] When the judgment result of the posture data of the current camera is normal, the Kalman filter is used to calculate the Kalman gain K' K+1 ;
[0052] According to the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera;
[0053] Estimate the rotation matrix according to the posture of the current camera within a set time length, perform trajectory smoothing, and obtain a smoothed posture matrix of the current camera;
[0054] The video image is rotated according to the smoothed pose matrix of the current camera to generate a stable video frame.
[0055] It can be seen from the above technical solutions that the embodiments of the present invention have the following advantages:
[0056] By comparing the current camera's posture data with the expected estimated posture model, it is determined whether the current camera's posture data is in an abnormal state based on the comparison results, so as to determine whether the sensor is abnormal. According to the abnormal state, the filtering fusion strategy is adaptively adjusted, and finally, the steady-state video is drawn and generated in conjunction with the smoothing strategy of the camera motion trajectory.
[0057] This application can detect and adapt to abnormal sensor observation data when the camera is subjected to large external force impacts and in complex motion scenes with severe fluctuations, and adaptively provide robust and stable steady-state video, thereby improving the user's shooting experience in various extreme scenes and providing better anti-shake effect and video image quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0059] Figure 1 It is a schematic diagram of the implementation flow of a method for processing motion smoothing of a video image provided by an embodiment of the present invention;
[0060] Figure 2 It is a schematic diagram of a judgment flow of a method for processing motion smoothing of a video image provided by an embodiment of the present invention;
[0061] Figure 3 It is a schematic diagram of the module composition of a motion smoothing processing device for video images provided by an embodiment of the present invention;
[0062] Figure 4 It is a functional structure diagram of a terminal device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0063] The present application is further described in detail below in conjunction with the accompanying drawings and implementation methods. It is particularly noted that the following implementation methods are only used to illustrate the present application, but do not limit the scope of the present application. Similarly, the following implementation methods are only some implementation methods of the present application rather than all implementation methods. All other implementation methods obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0064] The terms "including" and "having" and any variations thereof in this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or modules is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other steps or modules inherent to these processes, methods, products or devices.
[0065] The terms "first", "second", and "third" in this application are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, a feature defined as "first", "second", and "third" may explicitly or implicitly include at least one of the features.
[0066] The above terms are only for the convenience of description and should not be construed as limitations on the present technical solution.
[0067] Reference to "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0068] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments:
[0069] Embodiment 1:
[0070] Figure 1 to Figure 2 The implementation process of a video image motion smoothing processing method provided by the first embodiment of the present invention is shown. For the convenience of description, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0071] In step S101, the posture data of the current camera corresponding to the current video frame of the video stream is obtained, the current camera posture is represented by a quaternion, and the nominal state vector of the current camera is initialized.
[0072] In the embodiment of the present invention, it is applicable to a terminal device, and the terminal device may include at least one of a mobile phone, a computer device, a camera, a video camera, and a panoramic camera. Through the terminal device, a video stream is obtained, and the posture data of the current camera corresponding to the current video frame of the video stream is obtained. The posture data of the current camera is represented by a quaternion, and the camera posture in any direction can be represented by a unit quaternion as follows:
[0073]
[0074] Where θ is the rotation angle, is the axis of rotation.
[0075] Initialize the nominal state vector of the current camera:
[0076] In step S102, the prior error covariance matrix P of the current camera is calculated based on the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ;
[0077] The error state Kalman filter uses the error value as the filter state quantity. The error state Kalman filter is used in the pre-integration of the inertial measurement module IMU (Inertial Measurement Uni) to calculate the confidence and obtain the error covariance matrix.
[0078] The prior error covariance matrix P of the current camera is calculated based on the system model and the posture data of the current camera through the error state Kalman filter. - K+1 .
[0079] After initializing the nominal state vector of the current camera, the nominal state is propagated and propagating error status And calculate the prior error covariance matrix P - K+1 =F N,K P + K F T N,K +F i Q i F T i .
[0080] In step S103, an expected posture model is estimated according to the historical posture data of the current camera, and abnormality judgment is performed on the posture data of the current camera according to the expected posture model;
[0081] In some specific implementations, based on abnormal data from the inertial measurement module IMU, it is necessary to determine whether there is an abnormal state such as a system failure, and adaptively select different filtering fusion strategies according to the abnormal state.
[0082] When there is no system modeling uncertainty, the estimation performance of the error state Kalman filter will exceed that of the smooth variable structure filter. Therefore, in the scheme of the present application, the output of the error state Kalman filter is used when there is no system failure, and the output of the smooth variable structure filter is used when there is a system failure, so as to obtain a better estimation result. In order to implement the above scheme, the present application provides an accurate fault detection method.
[0083] An expected posture model is estimated according to the historical posture data of the current camera, and fault detection of the posture data is performed based on different fault detection methods.
[0084] Based on the fault detection method of the chi-square matrix, the difference between the posture data of the current camera and the expected posture model is judged. When the difference is greater than or equal to a first preset threshold, the judgment result of the fault detection method of the chi-square matrix is output as an abnormal state. Otherwise, the judgment result of the fault detection method of the chi-square matrix is output as a normal state.
[0085] One specific implementation method is to calculate the chi-square matrix fault parameter based on the chi-square matrix fault detection method according to the current camera posture data. The chi-square matrix fault parameters satisfy:
[0086] Among them, K is the new information sequence, P -1 ZZ,K is the innovation covariance matrix;
[0087] When the chi-square matrix fault parameter When the chi-square matrix fault parameter is less than the first preset threshold value λ, the posture data of the current camera is judged to be in a normal state, that is, the judgment result of the fault detection method outputting the chi-square matrix is in a normal state; when the chi-square matrix fault parameter When the value is greater than or equal to the first preset threshold value λ, the posture data of the current camera is judged to be in an abnormal state, that is, the judgment result of the fault detection method of outputting the chi-square matrix is in an abnormal state. The first preset threshold value λ is determined according to the expected confidence level of the chi-square distribution. Specifically, the first preset threshold value λ is set to a confidence level of 95%.
[0088] Subsequently, based on the sequential probability ratio test fault detection method, the difference between the probability distribution of the posture data of the current camera and the normal distribution of the expected posture model is judged; when the difference is greater than or equal to a second preset threshold, the judgment result of the sequential probability ratio test fault detection method is output as an abnormal state; otherwise, the judgment result of the sequential probability ratio test fault detection method is output as a normal state.
[0089] Compared with the fault detection method of the chi-square matrix, the fault detection method of the sequential probability ratio test is a statistical hypothesis test of a sequence data set, which can identify slowly increasing or constant system faults.
[0090] Finally, based on the fault detection method of angle deviation, the angle deviation between the angle data and the expected posture model is calculated according to the angle data in the posture data of the current camera. When the angle deviation is greater than or equal to the third preset threshold, the judgment result of the fault detection method of the angle deviation is output as an abnormal state; otherwise, the judgment result of the fault detection method of the angle deviation is output as a normal state.
[0091] When the judgment results output by any two or more of the fault detection methods of the chi-square matrix fault detection method, the sequential probability ratio test fault detection method and the angle deviation fault detection method are abnormal states, the posture data of the current camera is judged to be in an abnormal state; otherwise, the posture data of the current camera is judged to be in a normal state.
[0092] In step S1031, when the judgment result of the posture data of the current camera is an abnormal state, a smooth variable structure filter is used to calculate a smooth variable structure gain K K+1 ;
[0093] The smoothly varying structure gain K K+1 satisfy:
[0094]
[0095] Among them, H + K+1 is the Jacobian matrix of the observation information at time k+1, is a priori function, is the posterior function, γ is the convergence rate of the smooth variable structure filter, is a diagonal matrix constructed from the width of the smoothed boundary layer ψ.
[0096] In the above formula, ο and superscript + represent the Schur theorem and pseudo-inverse of a matrix, respectively. is a diagonal matrix constructed from the width of the smoothed boundary layer ψ and is defined as follows:
[0097]
[0098] Among them, H K+1 Defined as:
[0099]
[0100] is a saturation function, which can be expressed as:
[0101]
[0102] In one embodiment, the posterior error covariance matrix P + K+1 It can be calculated as follows:
[0103] P + K+1 =(I-KK K+1 H K+1 ) - K+1 (IK K+1H K+1 ) T +K K+1 R K+1 K T K+1
[0104] In calculating the smooth variable structure gain K K+1 , the updated measurement estimate is used in subsequent iterations and the posterior innovation function The calculation is as follows:
[0105]
[0106] In step S1031, when the judgment result of the posture data of the current camera is normal, the Kalman filter is used to calculate the Kalman gain K' K+1 ;
[0107] In the embodiment of the present invention, the Kalman gain K' K+1 satisfy:
[0108] K' K+1 =P - K+1 H K+1 T (H K+1 P - K+1 H K+1 T +R K+1 ) -1 , where P - K+1 is the prior error covariance matrix, H K+1 is the Jacobian matrix of the observation information at time k+1, R K+1 is the measurement error covariance matrix.
[0109] In step S104, according to the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera;
[0110] In the embodiment of the present invention, the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera, including:
[0111] Compute the posterior error state The a posteriori error state satisfy:
[0112]
[0113] Using the a posteriori error state Update the posterior nominal state X:
[0114]
[0115] Renormalizing quaternions
[0116]
[0117] Calculate the posterior error covariance matrix P + K+1 :
[0118] P + K+1 =(I-KK K+1 H K+1 ) - K+1 (IK K+1 H K+1 ) T ;
[0119] Compute the posterior innovation function
[0120]
[0121] Then, the attitude estimation rotation matrix of the current camera is updated.
[0122] In step S105, a rotation matrix is estimated according to the posture of the current camera within a set time length, and trajectory smoothing is performed to obtain a smoothed posture matrix of the current camera;
[0123] The step of estimating a rotation matrix according to the posture of the current camera within a set time length and performing trajectory smoothing includes:
[0124] According to the estimated rotation matrix of the current camera posture within the set time length, an updated rotation matrix B is calculated i , and obtain the first-order smoothness E f , And further calculate the second-order smoothness E s , Where R i Estimated rotation matrix for the current camera pose.
[0125] The first-order smoothness E f and the second-order smoothness E s In this example, the camera translation data is ignored, and the focus is on updating the rotation matrix B. iEstimation of the current camera's pose is performed using the rotation matrix R i Smoothing the trajectory can obtain a smooth camera trajectory, and then obtain the smoothed pose matrix of the current camera. This method simplifies the analysis process and does not introduce distortion between faces. By minimizing the energy value, we can estimate the updated rotation of each frame, thereby achieving video stability.
[0126] In an embodiment of the present invention, by further performing trajectory smoothing on the posture estimation rotation matrix of the current camera within the set time length, the problem of divergence between the filtering result and the actual operating state caused by the abnormal posture data caused by the violent rotation movement of the sensor or camera can be effectively further reduced.
[0127] In one specific implementation manner, the set time length is one third or one half of the length of the video stream.
[0128] In step S106, the video image is rotated according to the smoothed pose matrix of the current camera to generate a stable video frame;
[0129] In an embodiment of the present invention, rotating the video image according to the smoothed pose matrix of the current camera to generate a stable video frame includes:
[0130] All points on the unit sphere are traversed, and all points on the unit sphere are rotated using the smoothed pose matrix of the current camera to generate a stable video frame.
[0131] The following formula can be used to rotate all points on the unit sphere using the smoothed pose matrix of the current camera: where X, Y, and Z represent the spherical coordinates before the unit circle is rotated, x, y, and z represent the spherical coordinates after the rotation, and M K Represents the current rotation matrix, t represents the displacement vector, t=[0,0,0] T .
[0132] Embodiment 2:
[0133] Figure 3 A schematic diagram of the module composition of a video image motion smoothing processing device provided by the second embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown.
[0134] A video image motion smoothing processing device according to an embodiment of the present invention includes:
[0135] An initialization module, the initialization module is used to obtain the posture data of the current camera corresponding to the current video frame of the video stream, represent the current camera posture by quaternion, and initialize the nominal state vector of the current camera;
[0136] The first calculation module is used to calculate the prior error covariance matrix P of the current camera according to the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ;
[0137] A judgment module, the judgment module is used to estimate an expected posture model according to the historical posture data of the current camera, and perform abnormal judgment on the posture data of the current camera according to the expected posture model;
[0138] The second calculation module is used to calculate the smooth variable structure gain K by using smooth variable structure filtering when the judgment result of the posture data of the current camera is an abnormal state. K+1 ;
[0139] The third calculation module is used to calculate the Kalman gain K' by using Kalman filtering when the judgment result of the posture data of the current camera is normal. K+1 ;
[0140] An updating module is used to update the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera;
[0141] A trajectory smoothing module, the trajectory smoothing module is used to estimate the rotation matrix according to the posture of the current camera within a set time length, perform trajectory smoothing, and obtain a smoothed posture matrix of the current camera;
[0142] A generation module is used to rotate the video image according to the smoothed pose matrix of the current camera to generate a stable video frame.
[0143] It should be noted that for technical details not fully described in this embodiment, reference may be made to the motion smoothing processing method for video images provided in the above-mentioned embodiment 1.
[0144] Embodiment three:
[0145] In an embodiment of the present invention, a terminal device is provided, such as Figure 4 As shown, the terminal device 30 includes one or more processors 31 and a memory 32. The memory 32 stores a computer program 33. When the computer program 33 is executed by the processor 31, steps S101 to S10 of a planar image generation method in the above-mentioned embodiment 1 are implemented.
[0146] The processor 31 is the control center of the terminal device 30. It uses various interfaces and lines to connect the various parts of the entire terminal device 30, executes various functions of the terminal device 30 and processes data by running or loading computer programs 33 and / or modules stored in the memory 32, and calling data stored in the memory 32, thereby monitoring the terminal device 30 as a whole.
[0147] In the embodiment of the present invention, the processor 31 in the terminal device 30 loads instructions corresponding to the processes of one or more application programs into the memory 32 according to the following steps, and the processor 31 runs the application programs stored in the memory 32, thereby realizing various functions:
[0148] Obtaining the posture data of the current camera corresponding to the current video frame of the video stream, representing the current camera posture by quaternion, and initializing the nominal state vector of the current camera;
[0149] The prior error covariance matrix P of the current camera is calculated based on the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ;
[0150] Estimate an expected posture model according to the historical posture data of the current camera, and perform abnormality judgment on the posture data of the current camera according to the expected posture model:
[0151] When the judgment result of the posture data of the current camera is an abnormal state, a smooth variable structure filter is used to calculate the smooth variable structure gain K K+1 ;
[0152] When the judgment result of the posture data of the current camera is normal, the Kalman filter is used to calculate the Kalman gain K' K+1 ;
[0153] According to the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera;
[0154] Estimate the rotation matrix according to the posture of the current camera within a set time length, perform trajectory smoothing, and obtain a smoothed posture matrix of the current camera;
[0155] The video image is rotated according to the smoothed pose matrix of the current camera to generate a stable video frame.
[0156] The specific implementation of each of the above operations can be found in the above embodiment 1, which will not be described in detail here.
[0157] Embodiment 4:
[0158] In an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program is suitable for being loaded by a processor to execute the steps of any method provided in the first embodiment of the present application. For example, the computer program may execute the following steps:
[0159] Obtaining the posture data of the current camera corresponding to the current video frame of the video stream, representing the current camera posture by quaternion, and initializing the nominal state vector of the current camera;
[0160] The prior error covariance matrix P of the current camera is calculated based on the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ;
[0161] Estimate an expected posture model according to the historical posture data of the current camera, and perform abnormality judgment on the posture data of the current camera according to the expected posture model:
[0162] When the judgment result of the posture data of the current camera is an abnormal state, a smooth variable structure filter is used to calculate the smooth variable structure gain K K+1 ;
[0163] When the judgment result of the posture data of the current camera is normal, the Kalman filter is used to calculate the Kalman gain K' K+1 ;
[0164] According to the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera;
[0165] Estimate the rotation matrix according to the posture of the current camera within a set time length, perform trajectory smoothing, and obtain a smoothed posture matrix of the current camera;
[0166] The video image is rotated according to the smoothed pose matrix of the current camera to generate a stable video frame.
[0167] The specific implementation of each of the above operations can be found in the above embodiment 1, which will not be described in detail here.
[0168] Different from the prior art, the present invention provides a method for smoothing motion of a video image, the method comprising the following steps:
[0169] Obtaining the posture data of the current camera corresponding to the current video frame of the video stream, representing the current camera posture by quaternion, and initializing the nominal state vector of the current camera;
[0170] The prior error covariance matrix P of the current camera is calculated based on the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ;
[0171] Estimate an expected posture model according to the historical posture data of the current camera, and perform abnormality judgment on the posture data of the current camera according to the expected posture model:
[0172] When the judgment result of the posture data of the current camera is an abnormal state, a smooth variable structure filter is used to calculate the smooth variable structure gain K K+1 ;
[0173] When the judgment result of the posture data of the current camera is normal, the Kalman filter is used to calculate the Kalman gain K' K+1 ;
[0174] According to the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera;
[0175] Estimate the rotation matrix according to the posture of the current camera within a set time length, perform trajectory smoothing, and obtain a smoothed posture matrix of the current camera;
[0176] The video image is rotated according to the smoothed pose matrix of the current camera to generate a stable video frame.
[0177] It can be seen from the above technical solutions that the embodiments of the present invention have the following advantages:
[0178] By comparing the current camera's posture data with the expected estimated posture model, it is determined whether the current camera's posture data is in an abnormal state based on the comparison results, so as to determine whether the sensor is abnormal. According to the abnormal state, the filtering fusion strategy is adaptively adjusted, and finally, the steady-state video is drawn and generated in conjunction with the smoothing strategy of the camera motion trajectory.
[0179] This application can detect and adapt to abnormal sensor observation data when the camera is subjected to large external force impacts and in complex motion scenes with severe fluctuations, and adaptively provide robust and stable steady-state video, thereby improving the user's shooting experience in various extreme scenes and providing better anti-shake effect and video image quality.
[0180] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0181] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of software functional modules.
[0182] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a terminal device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0183] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for smoothing motion of a video image, characterized in that: The method comprises the following steps: Obtaining the posture data of the current camera corresponding to the current video frame of the video stream, representing the current camera posture by quaternion, and initializing the nominal state vector of the current camera; The prior error covariance matrix P of the current camera is calculated based on the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ; Estimate an expected posture model according to the historical posture data of the current camera, and perform abnormality judgment on the posture data of the current camera according to the expected posture model: When the judgment result of the posture data of the current camera is an abnormal state, a smooth variable structure filter is used to calculate the smooth variable structure gain K K+1 ; When the judgment result of the posture data of the current camera is normal, the Kalman filter is used to calculate the Kalman gain K' K+1 ; According to the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera; Estimate the rotation matrix according to the posture of the current camera within a set time length, perform trajectory smoothing, and obtain a smoothed posture matrix of the current camera; The video image is rotated according to the smoothed pose matrix of the current camera to generate a stable video frame.
2. The method for smoothing video image motion according to claim 1, characterized in that: The smoothly varying structure gain K K+1 satisfy: Among them, H + K+1 is the Jacobian matrix of the observation information at time k+1, l - z,k+1 is the prior function, l + z,k is the posterior function, γ is the convergence rate of the smooth variable structure filter, is a diagonal matrix constructed from the width of the smoothed boundary layer ψ.
3. The method for smoothing video image motion according to claim 2, characterized in that: The Kalman gain K' K+1 satisfy: K' K+1 =P - K+1 H K+1 T (H K+1 P - K+1 H K+1 T +R K+1 ) -1 , where P - K+1 is the prior error covariance matrix, H K+1 is the Jacobian matrix of the observation information at time k+1, R K+1 is the measurement error covariance matrix.
4. The method for smoothing video image motion according to claim 3, characterized in that: The smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Update the attitude estimation rotation matrix of the current camera, including: According to the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Compute the posterior error state According to the a posteriori error state Update the posterior nominal state X and renormalize the quaternion Calculate the posterior error covariance matrix P + K+1 , update the posterior error covariance matrix P + K+1 , calculate the posterior innovation function l + z,k+1 , and update the posture estimation rotation matrix of the current camera.
5. The method for processing motion smoothing of a video image according to claim 1, characterized in that: The step of estimating a rotation matrix according to the posture of the current camera within a set time length and performing trajectory smoothing includes: According to the estimated rotation matrix of the current camera posture within the set time length, an updated rotation matrix B is calculated i , and obtain the first-order smoothness E f , And further calculate the second-order smoothness E s , Where R i Estimated rotation matrix for the current camera pose.
6. The method for smoothing video image motion according to claim 1, characterized in that: The abnormality determination of the posture data of the current camera includes: Based on the fault detection method of the chi-square matrix, the difference between the posture data of the current camera and the expected posture model is judged, and when the difference is greater than or equal to a first preset threshold, the judgment result of the fault detection method of the chi-square matrix is output as an abnormal state, otherwise, the judgment result of the fault detection method of the chi-square matrix is output as a normal state; Then, based on the fault detection method of sequential probability ratio test, the difference between the probability distribution of the posture data of the current camera and the normal distribution of the expected posture model is judged, and when the difference is greater than or equal to a second preset threshold, the judgment result of the fault detection method of sequential probability ratio test is output as an abnormal state, otherwise, the judgment result of the fault detection method of sequential probability ratio test is output as a normal state; Finally, a fault detection method based on angle deviation is used to calculate the angle deviation between the angle data and the expected posture model according to the angle data in the posture data of the current camera. When the angle deviation is greater than or equal to a third preset threshold, the judgment result of the fault detection method of the angle deviation is output as an abnormal state; otherwise, the judgment result of the fault detection method of the angle deviation is output as a normal state. When the judgment results output by any two or more of the fault detection methods of the chi-square matrix fault detection method, the sequential probability ratio test fault detection method and the angle deviation fault detection method are abnormal states, the posture data of the current camera is judged to be in an abnormal state; otherwise, the posture data of the current camera is judged to be in a normal state.
7. The method for processing motion smoothing of a video image according to claim 1, characterized in that: The step of rotating the video image according to the smoothed position matrix of the current camera to generate a stable video frame includes: Map the points on the longitude and latitude image to the points on the spherical image; All points on the unit sphere are traversed, and all points on the unit sphere are rotated using the pose matrix of the current camera to generate a stable video frame.
8. A video image motion smoothing processing device, characterized in that: The video image motion smoothing processing device comprises: An initialization module, the initialization module is used to obtain the posture data of the current camera corresponding to the current video frame of the video stream, represent the current camera posture by quaternion, and initialize the nominal state vector of the current camera; The first calculation module is used to calculate the prior error covariance matrix P of the current camera according to the system model and the posture data of the current camera through the error state Kalman filter. - K+1 ; A judgment module, the judgment module is used to estimate an expected posture model according to the historical posture data of the current camera, and perform abnormal judgment on the posture data of the current camera according to the expected posture model; The second calculation module is used to calculate the smooth variable structure gain K by using smooth variable structure filtering when the judgment result of the posture data of the current camera is an abnormal state. K+1 ; The third calculation module is used to calculate the Kalman gain K' by using Kalman filtering when the judgment result of the posture data of the current camera is normal. K+1 ; An updating module is used to update the smooth variable structure gain K K+1 Or the Kalman gain K' K+1 Updating the attitude estimation rotation matrix of the current camera; A trajectory smoothing module, the trajectory smoothing module is used to estimate the rotation matrix according to the posture of the current camera within a set time length, perform trajectory smoothing, and obtain a smoothed posture matrix of the current camera; A generation module is used to rotate the video image according to the smoothed pose matrix of the current camera to generate a stable video frame.
9. A terminal device, characterized in that: include: one or more processors; Memory; And, one or more computer programs, the processor and the memory are connected via a bus, wherein the one or more computer programs are stored in the memory and are configured to be executed by the one or more processors, characterized in that when the processor executes the computer program, the steps of the motion smoothing processing method for video images as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor to execute the steps of the motion smoothing processing method for video images according to any one of claims 1 to 7.
