The present invention relates to the field of video, and especially a method and a system for panoramic video stabilization, and a portable terminal.
Panoramic video of the existing technology makes the user fell sick and dizzy when he wears the VR glasses. VR motion sickness is a problem not yet well solved, not only the hardware having no breakthroughs, but the software part also being a problem. Especially for a VR panoramic video, when it is taken with a hand-held panoramic camera, the imaging shaking will accelerate VR motion sickness to happen.
An object of the present invention is to provide a method and a system for panoramic video stabilization, and a portable terminal, which aims to solve the problem that imaging shaking accelerates VR motion sickness happing.
At a first aspect, the present invention provides a method for panoramic video stabilization, and the method comprises steps of:
acquiring a timestamp, an accelerometer value and an angular velocity value of the current state of a portable terminal in real time;
estimating a rotation vector of the current state using an Extended Kalman Filtering combined with the accelerometer value and the angular velocity value;
calculating a current rotation matrix via the Rodrigues' rotation formula on the basis of the rotation vector of the current state; and
rotating a panoramic image on the basis of the current rotation matrix, and producing a stabilized video frame.
At a second aspect, the present invention provides a system for panoramic video stabilization, and the system comprises:
an acquiring module, for acquiring a timestamp, an accelerometer value and an angular velocity value of the current state of a portable terminal in real time;
an estimating module, for estimating a rotation vector of the current state using an Extended Kalman Filtering combined with the accelerometer value and the angular velocity value;
a calculating module, for calculating a current rotation matrix via the Rodrigues' rotation formula on the basis of the rotation vector of the current state; and
a video frame generation module, for rotating a panoramic image on the basis of the current rotation matrix, and producing a stabilized video frame.
At a third aspect, the present invention provides a portable terminal, comprising a memory and a processor; the processor and the memory are connected by bus; the memory is used for storing a set of program codes therein, the processor executes the program codes and performs steps of:
acquiring a timestamp, an accelerometer value and an angular velocity value of the current state of a portable terminal in real time;
estimating a rotation vector of the current state using an Extended Kalman Filtering combined with the accelerometer value and the angular velocity value;
calculating a current rotation matrix via the Rodrigues' rotation formula on the basis of the rotation vector of the current state; and
rotating a panoramic image on the basis of the current rotation matrix, and producing a stabilized video frame.
Because the angle estimated by accelerometer values is easily interfered (such as by walking, hiking and running, etc.); and the cumulative error of angular velocity will become larger and larger over time. In the present invention, estimating a rotation vector of the current state using an Extended Kalman Filtering combined with the accelerometer value and the angular velocity value, calculating a current rotation matrix via the Rodrigues' rotation formula on the basis of the rotation vector of the current state, and then rotating a panoramic image; thereby a shaking video frames can be finally stabilized, and thus VR motion sickness can be alleviated.
Aspects, features, and advantages of the present invention will become clearer and better understood by reference to the following detailed description of the embodiments of the invention when considered in connection with the accompanying drawings. The following description of certain embodiments of the invention are not intended to limit the invention to these embodiments, but rather, are only explains the present invention.
The features of the present are now described in connection with the following detailed embodiments.
Referring to
S101, acquiring a timestamp, an accelerometer value and an angular velocity value of the current state of a portable terminal in real time.
Where, in the first embodiment of the present invention,
the step of “acquiring an accelerometer value of a portable terminal in real time”, specifically can be: reading a triaxial accelerometer value using a gravity sensor.
Where the step of “acquiring an angular velocity value of the portable terminal in real time”, specifically can be: reading a triaxial angular velocity value using an angular speed sensor.
In the first embodiment of the present invention, after S101, the method can further comprise a step of:
performing a noise reduction process to the accelerometer value and the angular velocity value using low-pass filtering; and which specifically can comprise:
performing the noise reduction process using low-pass filtering respectively to the accelerometer value and the angular velocity value with a formula of di′=α·di+(1−α)·di-1′, where di represents the accelerometer value or the angular velocity value at time i, di represents the accelerometer value or the angular velocity value after the noise reduction process using low-pass filtering at time i, and di-1′ represents the accelerometer value or the angular velocity value after the noise reduction process using low-pass filtering at time i−1; α is a smoothing factor,
where ƒc is a cut-off frequency of low-pass filtering, Rc is a time constant, and Δt is a sampling time interval.
S102, estimating a rotation vector of the current state using an Extended Kalman Filtering combined with the accelerometer value and the angular velocity value.
The Extended Kalman Filtering is a kind of high efficient recursive filter, which linearizes a nonlinear system and then performs Kalman Filtering. It can be used to estimate the state of a dynamic system from a series of measurements which do not fully contain noise.
Referring to
S1021, calculating a state transition matrix Fk at time k using the angular velocity value; and calculating the current predicted residual ŷk using the accelerometer value combined with the gravity vector g in a reference coordinate system and a rotation matrix of the previous state;
in the first embodiment of the present invention, S1021 specifically comprises steps of:
initializing an initial state transition matrix, an initial predicted covariance matrix, and an initial observation matrix, where the initial state transition matrix
the initial predicted covariance matrix
and the initial observation matrix
calculating a state transition matrix
at time k, calculating the observation information matrix
where xk-1 represents a state estimate of the portable terminal at the time of k−1, xk represents a state estimate of the portable terminal at the time of k, ∂ represents a partial differential, ƒ represents a function of the state equation, x represents a state of the portable terminal, that is, rotation angles of three-Axis direction, h represents a function of the observation equation; {circumflex over (x)}k-1|k-2=ƒ(xk-2,uk-1,wk-1), {circumflex over (x)}k|k-1=ƒ(xk-1,uk,wk) where xk-2 represents the state of the portable terminal at the time of k−2, uk-1 represents the angular velocity value at the time of k−1, wk-1 represents a process noise at the time of k−1, {circumflex over (x)}k-1|k-2 represents using the state estimate at time k−2 to predict the state estimate of the portable terminal at time k−1, xk-1 represents a state of the portable terminal at the time of k−1, uk represents the angular velocity value at the time of k, wk represents a process noise at the time of k, {circumflex over (x)}k|k-1 represents using the state estimate at time k−1 to predict the state estimate of the portable terminal at time k; xk-2=[Xk-2,Yk-2,Zk-2]T, where Xk-2,Yk-2,Zk-2 represent the respective rotation angles of the x Axis, y Axis, and z Axis in the reference coordinate system at the time of k−2, xk-1=[Xk-1,Yk-1,Zk-1]T, here Xk-1,Yk-1,Zk-1 represent the respective rotation angles of x Axis, y Axis, and z Axis in the reference coordinate system at the time of k−1, T denotes a transpose;
projecting the gravity acceleration vertical downwards in the reference coordinate system into the rigid-body coordinate system, and calculating the observation residual ŷk with the formula ŷk=zk−Hk{circumflex over (x)}k|k-1, where zk represents the accelerometer value at time k after the noise reduction processing using low-pass filtering; Hk is an observation information matrix and represents a Jacobian matrix calculated with the observation formula zk=h(xk,g,vk) using the current state estimate, where g is the gravity vector vertical downwards in the reference coordinate system, g=[0,0,−9.81]T, vk is a measurement error.
S1022, estimating the error covariance matrix Pk|k-1 of the current state using the estimated error covariance matrix Pk-1|k-1 of the previous state, the state transition matrix Fk of the current state and the process noise Q;
in the first embodiment of the present invention, S1022 specifically is: predicting the estimated error covariance matrix Pk|k-1 of the state with the formula Pk|k-1=Fk·Pk-1|k-1·FkT+Qk, where Pk-1|k-1 represents the estimated covariance matrix at time k−1, Qk represents the process-noise covariance matrix,
dt represents time interval of sampling the gyroscopes data, Fk represents the state transition matrix at time k, and FkT represents a transpose of Fk.
S1023, calculating an optimal Kalman Gain Matrix Kk of the current state using the estimated error covariance matrix Pk|k-1 of the current state, the observation matrix Hk and the noise variance matrix R;
in the first embodiment of the present invention, S 1023 specifically can comprise:
calculating the optimal Kalman Gain Matrix Kk at time K using the estimated covariance matrix Pk|k-1 of predicting the state, Kk=Pk|k-1·HkT(Hk·Pk|k-1·HkT+R)−1, where R represents the noise variance matrix,
where σ2 represents noise variance; and generally σ=0.75, Hk is an observation information Jacobian matrix at time k, and HkT represents a transpose of Hk.
S1024, updating a rotation vector {circumflex over (x)}k|k of the current state estimate according to both the optimal Kalman Gain Matrix Kk of the current state and the current predicted residual ŷk.
In the first embodiment of the present invention, S1024 specifically can comprise steps of:
updating a state estimate to obtain the rotation vector {circumflex over (x)}k|k of the current state by combing the accelerometer value and the angular velocity value at time k, {circumflex over (x)}k|k={circumflex over (x)}k|k-1+Kkŷk, and then updating the estimated covariance matrix Pk|k, Pk|k=(I−Kk·Hk)Pk|k-1, where I represents a unit matrix, and Pk|k represents the error covariance matrix Pk|k-1 to be estimated next time.
S103, calculating a current rotation matrix via the Rodrigues' rotation formula on the basis of the rotation vector of the current state.
Rodrigues' rotation formula is used to calculate the new vector after the vector rotates a given angle around a rotational axis in three-dimensional space. This formula uses the original vector, the rotational Axis and their cross product as a frame to represent the vector after rotation.
S104, rotating a panoramic image on the basis of the current rotation matrix, and producing a stabilized video frame.
in the first embodiment of the present invention, S104 can specifically comprise steps of:
mapping points on a longitude-latitude image to points on a spherical image;
generating a stabilized video frame by rotating all points on the unit sphere using the current rotation matrix;
where a step of “rotating all points on the unit sphere using the current rotation matrix” can specifically use the formula
where x, y, z represent spherical coordinates before an unit circle rotation, xnew,ynew,znew represent spherical coordinates after rotation, Mk represents the current rotation matrix, and t represents a displacement vector, t=[0,0,0]T.
Referring to
an acquiring module 11, for acquiring a timestamp, an accelerometer value and an angular velocity value of the current state of a portable terminal in real time;
an estimating module 12, for estimating a rotation vector of the current state using an Extended Kalman Filtering combined with the accelerometer value and the angular velocity value;
a calculating module 13, for calculating a current rotation matrix via the Rodrigues' rotation formula on the basis of the rotation vector of the current state; and
a video frame generation module 14, for rotating a panoramic image on the basis of the current rotation matrix, and producing a stabilized video frame.
In the second embodiment of the present invention, the system further comprises:
a noise reduction module, for performing a noise reduction process to the accelerometer value and the angular velocity value using low-pass filtering.
The estimating module can specifically comprise:
a predicted-residual calculation module, for calculating a state transition matrix Fk at time k using the angular velocity value, and calculating the current predicted residual ŷk using the accelerometer value combined with the gravity vector g in a reference coordinate system and a rotation matrix of the previous state;
an error covariance-matrix estimating module, for estimating the error covariance matrix Pk|k-1 of the current state using the estimated error covariance matrix Pk-1|k-1 of the previous state, the state transition matrix Fk of the current state and the process noise Q;
an optimal Kalman Gain Matrix Kk calculating module, for calculating the optimal Kalman Gain Matrix Kk of the current state using the estimated error covariance matrix Pk|k-1 of the current state, the observation matrix Hk and the noise variance matrix R; and
an updating module, for updating the rotation vector {circumflex over (x)}k|k of the current state estimate according to both optimal Kalman Gain Matrix Kk of the current state and the current predicted residual ŷk.
The video frame generation module can specifically comprise:
a mapping module, for mapping points on a longitude-latitude image to points on a spherical image; and
a rotating module, for generating a stabilized video frame by rotating all points on the unit sphere using the current rotation matrix.
Referring to
acquiring a timestamp, an accelerometer value and an angular velocity value of the current state of a portable terminal in real time;
estimating a rotation vector of the current state using an Extended Kalman Filtering combined with the accelerometer value and the angular velocity value;
calculating a current rotation matrix via the Rodrigues' rotation formula on the basis of the rotation vector of the current state; and
rotating a panoramic image on the basis of the current rotation matrix, and producing a stabilized video frame.
Because the angle estimated by accelerometer values is easily interfered (such as by walking, hiking and running); and the cumulative error of angular velocity will become larger and larger over time. In the present invention, estimating a rotation vector of the current state using an Extended Kalman Filtering combined with the accelerometer value and the angular velocity value, calculating a current rotation matrix via the Rodrigues' rotation formula on the basis of the rotation vector of the current state, and then rotating a panoramic image; thereby a shaking video frames can be finally stabilized, and thus VR motion sickness can be alleviated.
Those skilled in the art can understand that all or part of the steps of the method described in the above-mentioned embodiments can be performed by program to instruct the related hardware, the program can be stored in a computer readable storage medium, and the storage medium includes such as a ROM/RAM, disk, an optical disc, and the like.
The above mentioned is preferable embodiments of the invention and is not intended to limit the scope of the inventions. Any modification, substitution and improvements, etc., may be made without departing from the spirit of the inventions, shall be included in the protection scope of the invention.
Number | Date | Country | Kind |
---|---|---|---|
201710225056.0 | Apr 2017 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2018/075265 | 2/5/2018 | WO | 00 |