The present invention relates generally to the field of videos, and more specifically to an anti-shake method and apparatus for a panoramic video, and a portable terminal.
The panoramic video provided by the existing technology, when worn with VR glasses, will make people feel sick and dizzy, and VR motion sickness is a problem that has not been solved very well. In addition to the failure to make a breakthrough in hardware, the software failure is also the reason. Especially for VR panoramic video, if a handheld panoramic camera is used, the shaking of the picture will further accelerate the generation of VR motion sickness.
The object of the present invention is to provide an anti-shake method and apparatus for a panoramic video, computer-readable storage medium and a portable terminal, aiming to solve the problem that the shaking of the picture will further accelerate the generation of VR motion sickness.
According to a first aspect, the present invention provides an anti-shake method for a panoramic video, comprising:
acquiring, in real time, a current state timestamp, an accelerometer data and an angular velocity of a gyroscope in a portable terminal;
estimating a rotation from the portable terminal to a world coordinate system using Extended Kalman Filtering combined with both the accelerometer data and the angular velocity;
synchronizing the timestamp of the gyroscope with a timestamp of a panoramic video frame;
performing quaternion interpolation in a state of the gyroscope to obtain a rotation matrix corresponding to the panoramic video frame; and
rotating a panoramic image according to the current rotation matrix to generate a stable video frame.
According to a second aspect, the present invention provides an anti-shake apparatus for a panoramic video, comprising:
acquiring unit, for acquiring, in real time, a current state timestamp, an accelerometer data and an angular velocity of a gyroscope in a portable terminal;
an estimation unit, for estimating a rotation from the portable terminal to a world coordinate system using Extended Kalman Filtering combined with both the accelerometer data and the angular velocity;
a synchronizing unit, for synchronizing the timestamp of the gyroscope with a timestamp of a panoramic video frame;
an interpolation unit, for performing quaternion interpolation in a state of the gyroscope to obtain a rotation matrix corresponding to the panoramic video frame; and
a rotation unit, for rotating a panoramic image according to the current rotation matrix to generate a stable video frame.
According to a third aspect, the present invention provides a computer-readable medium that stores a computer program, the computer program is to be executed by a processor to perform steps of the anti-shake method for a panoramic video described above.
According to a fourth aspect, the present invention provides a portable terminal, comprising:
one or more processors;
a memory; and
one or more computer programs, wherein the one or more computer programs are stored in the memory and are configured to be executed by the one or more processors to perform steps of the anti-shake method for a panoramic video described above.
By means of performing quaternion interpolation in a state of the gyroscope to obtain a rotation matrix corresponding to the panoramic video frame in the present invention, a more accurate rotation matrix can be obtained, and a panoramic image is then rotated according to the current rotation matrix to generate a stable video frame. Therefore, a shaky video frame can finally be stabilized, VR motion sickness can be alleviated, and strong robustness for a loud-noise scene and most motion scenes is provided.
The foregoing objects, technical solution and advantages of the invention will be much clearer from the following detail description taken with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
In order to explain the technical solution of the present invention, the following will be described by specific embodiments.
Referring to
S101, acquiring, in real time, a current state timestamp, an accelerometer data and an angular velocity of a gyroscope in a portable terminal.
In the first embodiment of the present invention,
acquiring, in real time, an accelerometer data of the gyroscope in the portable terminal, may specifically be: reading 3-axis accelerometer data using a gravity sensor;
acquiring, in real time, an angular velocity of the gyroscope in the portable terminal, may specifically be: reading 3-axes angular velocities using an angular velocity sensor.
In the first embodiment of the present invention, after S101, may further comprise a step of:
reducing noise from the accelerometer data using a low-pass filtering, which can further comprise steps of:
reducing noise from the accelerometer data using a low-pass filtering through the formula d′i=α·di+(1−α)·Ri·d′i−1, where d′i represents the accelerometer data after low-pass filtering at time i, di represents the accelerometer data at time i, and Ri is a relative rotation of the i frame video of the gyroscope; Ri=exp[−ωi·Δt]×, where ωi represents an angular velocity at time i, d′i−1 represents the accelerometer data after low-pass filtering at time i−1, and α represents a smoothing factor,
where fc represents a cut-off frequency for a low-pass filtering, Rc represents a time constant, and Δt represents a sampling time interval of the gyroscope.
S102, estimating a rotation from the portable terminal to a world coordinate system using EKF (Extended Kalman Filtering) combined with both the accelerometer data and the angular velocity.
Extended Kalman Filtering is to linearize a nonlinear system and then perform Kalman filtering. Kalman filter is a highly efficient recursive filter that can estimate a state of a dynamic system from a series of measurements that do not completely contain noise.
Referring to
S1021, an initial-state rotation
where, d0 is a measured initial accelerometer data, g is the gravity vector of the world coordinate system; and an initial process covariance matrix
S1022, calculating a State Transition Matrix Φ(ωk) at time K using the angular velocity ωk;
Φ(ωk)=exp(−[ωk·Δt]×), where, ωk is an angular velocity at time K, Δt represents the sampling time interval of the gyroscope;
S1023, calculating a State Noise Covariance Matrix Qk, updating an a priori estimate for a state rotation qk− and an a priori estimate for a process covariance matrix pk−;
where Qk is a State Noise Covariance Matrix;
qk−=Φ(ωk)*qk−1+, where, qk−1+ is an a posteriori estimation for a state rotation at time K−1;
Pk−=qk−·Pk−1+·qk−+Qk, where, Pk−1+ is an a posteriori estimation for a process covariance matrix at time K−1;
S1024, updating an Observation Noise Covariance Matrix Rk from the accelerometer data dk, calculating an Observation Transformation Jacobian Matrix Hk, and calculating an Observation Error ek between the current observation and estimated observation;
where, δk=δvark+δmeank, δvark=α∥dk|−|dk−1∥+(1−α)δvark−1,
α is a smoothing factor for an acceleration change, and β is an impact factor for an acceleration module;
where, h is an observation function, h(q,v)=q·g+vk, g is the gravity vector of the world coordinate system, q is a state, that is, a rotation from the world coordinate system to the gyroscope coordinate system; vk is a measurement noise;
ek=dk×h(qk−,0);
S1025, updating the optimal Kalman Gain Matrix Kk at time k:
Kk=Pk−·HkT(Hk·Pk−·HkT+Rk)−1; and
S1026, updating the a posteriori estimation for the rotation qk+ from the portable terminal to the world coordinate system, and the a posteriori estimation for the process covariance matrix pk+ according to the optimal Kalman Gain Matrix Kk and the Observation Error ek,
S103, synchronizing the timestamp of the gyroscope with a timestamp of a panoramic video frame.
In accordance with the first embodiment of the present invention, S103 can be:
synchronizing the timestamp of the gyroscope with a timestamp of a panoramic video frame, so that tk≥tj>tk−1, where tj is the timestamp of a panoramic video frame, tk is the timestamp of the K frame of the gyroscope, and tk−1 is the timestamp of the K−1 frame of the gyroscope.
S104, performing quaternion interpolation in the state of the gyroscope to obtain a rotation matrix corresponding to the panoramic video frame.
In the first embodiment of the present invention, S104 may specifically comprise steps of:
calculating a relative rotation of adjacent timestamps of the gyroscope, rk=qk+qk−1+, where, rk is the relative rotation at time K, qk+ and qk−1+ are respectively a posteriori estimation for the state at time K and K−1, that is, the rotation from the world coordinate system to the gyroscope coordinate system;
performing quaternion interpolation to obtain a relative rotation from the panoramic video frame to the K frame, Rj=γ·I+(1−γ)·rk, where, Rj is the relative rotation of the K frame,
and
calculating a rotation matrix of the j-frame video in the panoramic video frame: Qj=Rj−1qk+.
S105, rotating a panoramic image according to the current rotation matrix to generate a stable video frame.
In the first embodiment of the present invention, S105 may specifically comprise steps of:
mapping grid points on the 2D image with latitude and longitude to a spherical coordinate; and
traversing all points on the unit sphere, using the current rotation matrix to rotate all points on the unit sphere, and generate a stable video frame;
where, using the current rotation matrix to rotate all points on the unit sphere, which can use the following formula:
where [x, y, z]T represents the spherical coordinate before a unit circle rotates, [xnew, ynew, znew]T represents the spherical coordinates after rotation, Qj represents the current rotation matrix, and t represents a displacement vector, t=[0,0,0]T.
Referring to
an acquiring unit 11, for acquiring, in real time, a current state timestamp, an accelerometer data and an angular velocity of a gyroscope in a portable terminal;
an estimation unit 12, for estimating a rotation from the portable terminal to a world coordinate system using Extended Kalman Filtering combined with both the accelerometer data and the angular velocity;
a synchronizing unit 13, for synchronizing the timestamp of the gyroscope with a timestamp of a panoramic video frame;
an interpolation unit 14, for performing quaternion interpolation in a state of the gyroscope to obtain a rotation matrix corresponding to the panoramic video frame; and
a rotation unit 15, for rotating a panoramic image according to the current rotation matrix to generate a stable video frame.
An anti-shake apparatus for a panoramic video provided in the second embodiment of the present invention and an anti-shake method for a panoramic video provided in the first embodiment belong to the same idea. For the detail implementation process, please refer to the full text of the specification, which will not be repeated here.
The third embodiment of the present invention provides a computer-readable medium that stores a computer program, the computer program is to be executed by a processor to perform steps of the anti-shake method for a panoramic video provided in the first embodiment of the present invention.
In accordance with the embodiment of the present invention, by means of performing quaternion interpolation in a state of the gyroscope to obtain a rotation matrix corresponding to the panoramic video frame, a more accurate rotation matrix can be obtained. A panoramic image is then rotated according to the current rotation matrix to generate a stable video frame. Therefore, a shaky video frame can finally be stabilized, VR motion sickness can be alleviated, and strong robustness for a loud-noise scene and most motion scenes is provided.
A person of ordinary skill in the art may understand that all or part of the steps in the method of the above embodiments can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable storage medium, and the storage Media can be, such as ROM/RAM, magnetic disk, optical disk, etc.
The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modification, equivalents replacements and improvements made within the spirit and principle of the present invention should be included within the scope of the present invention.
Number | Date | Country | Kind |
---|---|---|---|
201711015180.0 | Oct 2017 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2018/110467 | 10/16/2018 | WO | 00 |