The present invention relates to a method for stabilizing a camera frame of a video sequence.
Electronic Image Stabilization (EIS) is a family of image enhancement techniques that utilize electronic processing to minimize image blurring and dampen the effects of camera shake. With advancements in camera imaging technology and the recent rise in popularity of action cameras for recording live sporting events, video blogging, and various on-the-fly events, there is a demand for high quality stabilized video from such cameras.
Popular methods to stabilize video require the use of additional hardware, such as a gyro-gimbal stabilizer or movable lens elements as used in optical image stabilization (OIS).
WO2017/140438 (Ref: FN-495-PCT) discloses stabilizing a sequence of images captured by an image capture device. The method comprises, using lens based sensors indicating image capture device movement during image acquisition to perform OIS during acquisition of each image of the sequence of images to provide a sequence of OIS corrected images. Movement of the device for each frame during which each OIS corrected image is captured is determined using inertial measurement sensors. At least an estimate of OIS control performed during acquisition of an image is obtained. The estimate is removed from the intra-frame movement determined for the frame during which the OIS corrected image was captured to provide a residual measurement of movement for the frame. EIS of each OIS corrected image based on the residual measurement is performed to provide a stabilized sequence of images.
Alternatively, post-processing techniques can stabilize video by feature matching between frames to track camera motion, smooth it, and then produce stabilized video. For the casual videographer, these additional hardware requirements and/or post-processing steps can be both time consuming and expensive.
It is an object of the present invention to provide stabilization in real-time of a video feed acquired with a camera susceptible to shake.
According to the present invention, there is provided a method for stabilizing a camera frame of a video sequence according to claim 1.
Further aspects provide an image capture device and a computer program product comprising computer readable code which when executed on an image capture device is configured to perform the method according to the invention.
Embodiments ensure that the orientation of a crop frame relative to an image frame acquired by the camera, the camera frame, is controlled so that “black” borders do not intrude into the displayed crop frame.
Embodiments track camera motion using an on-board inertial measurement unit (IMU)—this low-cost unit is typically integrated within commercially available cameras. IMUs can comprise any combination of gyroscope, accelerometer or magnetometer and in embodiments of the present invention, the IMU is used principally to track the rotational motion of the camera and to provide an absolute orientation of the camera for camera frames in a recorded sequence.
A cropping of the recorded frames can follow a smoothed version of the camera's path. Once the cropped frame remains within the camera frame boundary, and moves smoothly and continuously, the displayed video is optimally stabilized. Embodiments detect when smoothed frame-to-frame movement could cause the cropped frame to leave the camera frame boundary and then adjust the path in a minimally disruptive manner.
Once stabilized according to the present method, no post-processing of the stabilized video frames is necessary. Nonetheless post-processing could be applied to any stored version of the video sequence stabilized according to the present method, for example, to remove or mitigate discontinuities evident in the stabilized video due to the adjustment of the cropped frame which would otherwise have breached the camera frame boundary.
Embodiments can operate in two phases: in a first phase, a frame wise correction quaternion which counter rotates the various lines of a crop frame by a minimum amount is determined according a relative orientation of the crop frame and camera frame so that the crop frame is back within the limits of the camera frame, with no black borders. In a potential second phase, in order to take into account fast camera motion on a rolling shutter exposure which can result in a squeezing of the camera frame relative to the cropped frame, correction quaternions are determined for each line of the rolling shutter camera frame, which effectively stretches the camera frame relative to the crop frame by the minimum amount so that the crop frame is back within the limits of the camera frame.
An embodiment of the invention will now be described, by way of example, with reference to the accompanying drawings, in which:
Referring to
Such cameras 10 can include downstream dedicated image processing units which can analyse acquired images and process such images either to extract information from the images or to correct the images. Such processing can include face detection and tracking, object recognition or distortion correction such as disclosed in PCT Application WO2014/005783 (Ref: FN-384-PCT). Other processing can determine frame-to-frame motion, for example, as disclosed in WO2014/146983 (Ref: FN-389-PCT) and PCT Application WO2017/140438 (Ref: FN-495-PCT).
In the present specification, such processing units, which can be dedicated hardware modules or a generic central processing unit (CPU), are indicated as processing unit (PU) 16 which is capable of running either low-level firmware/software or in the case of the CPU, application software, capable of obtaining image information from memory 14 and further processing the images.
As mentioned, it is known for cameras 10 to include inertial measurement units (IMU) 18 which can indicate a trajectory of camera movement during image acquisition and between acquisition of images, enable processing unit(s) 16 to use that information to correct an acquired image to take into account blur caused by involuntary or unwanted camera motion during image capture or to stabilize video sequences.
As mentioned above, the IMU 18 sensors can comprise: gyroscopic sensors providing measures of rotational velocity around each of the three spatial axes (X,Y,Z); and accelerometers which provide measures of translational acceleration during image sequence capture and the direction of the gravitational force. The IMU can further include a magnetometer indicating the absolute angular orientation of the camera relative to the earth's magnetic field.
In embodiments of the present invention, the processing unit 16 uses information from the IMU gyroscope to provide a sequence of stabilised crop frames from respective acquired camera frames.
The camera's rotational motion is the integral of the rotational frequency, measured by the gyroscope. In the present embodiment, this information is used to obtain the orientation of the camera at each instance in time a frame is captured, in quaternion form. For rolling shutter cameras, a camera frame is divided into a number of lines Li, each line corresponding to one or more rows acquired from the image sensor.
The orientation of the camera is determined for each line and can be stored in association with the camera frame and represented subsequently in quaternion form as {right arrow over (Q)}L
Referring to
Embodiments use a cropping of the acquired camera frames, with the crop frame following a smoothed path relative to camera frame to take into account shaky camera motion. In one embodiment, the shape of the cropped frame relative to the camera frame does not change during the recorded sequence. The absolute orientation of the cropped frame is labelled {right arrow over (Q)}C in quaternion terms. The first frame of the recording determines the camera's orientation, and the cropped frame's orientation. These are initialized as the identity, {right arrow over (Q)}F={right arrow over (Q)}C=(1,0,0,0), and all subsequent camera orientations are described relative to this point.
The smoothed path of the cropped frame is interpolated from the known path of the camera frame. There are a number of equivalent methods to obtain the smoothed motion, for example, spherical linear interpolation as illustrated in equations 1a and 1b below, or linear interpolation as illustrated in equation 1c:
Spherical linear interpolation:
{right arrow over (Q)}′C={right arrow over (Q)}C⊗({right arrow over (Q)}C−1⊗{right arrow over (Q)}F)1−λ (Equation 1a)
The parameter λ is some value between 0 and 1, which determines the degree of smoothing. {right arrow over (Q)}F is the camera quaternion for the current frame derived from the IMU 18, {right arrow over (Q)}C is the crop quaternion from the previous frame and {right arrow over (Q)}′C is the candidate crop quaternion of the current frame. The symbol ⊗ indicates quaternion multiplication. Equivalently,
where, cos(Ω)={right arrow over (Q)}F·{right arrow over (Q)}C.
Linear interpolation:
{right arrow over (Q)}′C={right arrow over (Q)}C+λ({right arrow over (Q)}F−{right arrow over (Q)}C) (Equation 1c)
These methods are detailed in Ken Shoemake, “Animating rotation with quaternion curves” ACM SIGGRAPH Computer Graphics 19(3), pages 245-254 July (1985). For small values of λ the stabilized path is very smooth, which comes at the expense of a large lag between the camera's path and the cropped frame's path.
The boundary of the crop frame defines the limits of the relative motion of the camera and crop frames. In the event that the boundary of the crop frame were to move beyond the limits of the camera frame, so-called “black” borders would intrude on the stabilized video, as illustrated in
Referring now to
In step 100, a camera frame is acquired from an IPP 12. This can be stored temporarily in a cache within a processing unit 16 or it may be stored in main memory 14. A measure of camera movement during the acquisition of the camera frame may either be acquired by the processing unit 16 directly from an IMU 18 or this information may be acquired from meta-information associated with the stored camera frame in memory. This path is smoothed, step 102 and used then as illustrated in equations 1(a) . . . (c) above to determine the relative coordinates (in quaternion form {right arrow over (Q)}′C) for a candidate crop frame orientation for the present camera frame, step 104, for example, as explained in relation to equations (1) above. As will be explained in more detail, a distance between a camera frame boundary and a boundary of the crop frame at a candidate orientation is calculated at grid points around a boundary of the camera (or the crop) frame to determine if a boundary violation would occur, step 106. In the event of a potential boundary violation, a correction quaternion {right arrow over (Q)}cor of a first type is calculated, step 108, to counter rotate the orientation {right arrow over (Q)}′C of the candidate crop frame by a minimum amount so that it is located back within the limits of the camera frame, so that no black borders appear in the stabilized video sequence, again this will be explained in more detail below.
As mentioned, embodiments can be implemented in rolling shutter cameras, where rapid camera motion can squeeze and distort the boundary of the camera frame to the extent that it is smaller than the cropped frame and so it is possible that even after rotating the crop frame according to the calculated distance back inside the camera frame, the camera frame boundary may still be violated by the rotated candidate crop frame orientation.
In order to determine if such camera motion could cause a black boundary, in the present embodiment, the distance measure of step 106 is reapplied in step 110 before determining in step 111 if the rotated candidate crop frame orientation based on the correction quaternion {right arrow over (Q)}cor would cause a boundary violation.
If so, then in step 112, the processing unit tests if a camera frame has been squeezed as illustrated in
Squeezing caused by rapid camera motion can be corrected by stretching a camera frame line-by-line, by the minimum amount, so that the borders of crop frame are back within the camera frame limits.
Thus, in this event, a correction quaternion of a second type is applied to the rotated candidate crop frame, step 114 to stretch the camera frame information. This involves calculation of a line-by-line correction {right arrow over (Q)}cor
If the frame is not squeezed, then the boundary frame violation detected at step 111 may be as a result of the approximation of camera movement and/or the granularity of the camera grid at whose nodes the distance measure of step 106 is performed. Thus, in this case, using the distance measure calculated in step 110, a further correction quaternion of the first type used in step 108 is applied to the rotated candidate crop frame orientation to refine its orientation and minimize any boundary frame violation, step 116.
This process can be repeated by returning to perform the distance measurement of step 110 again or alternatively, the process could complete by proceeding to calculating the required correction quaternion for the next frame.
Note that once the correction quaternion, either frame wise from steps 104, 108 or 116; and/or line-by-line from step 114 is calculated and the final orientation of the lines of the crop frame relative to the camera frame has been determined, this crop frame orientation is then used to determine a mapping from pixel locations in a crop frame to be displayed into coordinates within the camera frame. Then, pixel locations within the camera frame surrounding those coordinates can be interpolated to provide a value for the pixel location within the crop frame, as explained in for example, PCT Application WO2019/063850 (Ref: FN-622-PCT). The interpolated crop frame information can be stored in memory 14 and/or displayed directly with the likelihood of having any black boundary pixels minimized to extreme unavoidable circumstances.
In relation to steps 106, 110, in embodiments of the present invention, the distance between the camera frame and a crop frame rotated according to camera movement is calculated using the unit sphere as follows:
The gyro data is integrated to obtain the quaternion {right arrow over (Q)}F describing the absolute camera orientation at the mid-point of the rolling shutter, which is stored locally in quaternion form. The absolute orientation of each line of the rolling shutter, {right arrow over (Q)}L
The relative orientation of the camera frame relative to the crop frame is labelled {right arrow over (Q)}f and is given by:
{right arrow over (Q)}f={right arrow over (Q)}F−1⊗{right arrow over (Q)}′C (Equation 2a)
The relative orientation of each line of the rolling shutter is described with respect to the crop frame and labelled {right arrow over (Q)}1
{right arrow over (Q)}l
between each pair of neighbouring nodes {right arrow over (a)} and {right arrow over (b)} on the boundary. Note that for a zoom lens, these normalized cross products would be pre-calculated and stored for all zoom values of the lens (changing focal lengths and field of view). These values can be stored locally in memory 14 or within the processing unit 16 and used to calculate the distance measure for each frame. The corresponding node on the camera frame boundary {right arrow over (p)} lies in the interval between {right arrow over (a)} and {right arrow over (b)}.
When the minimum distance is less than zero, Dmin<0, the limits are exceeded and the relative orientation between the frames must be corrected.
Note that in variations of the above described embodiment, other methods than the described triple product for determining a point on one of the camera frame or crop frame boundaries where the crop frame maximally exceeds the camera frame can be employed. Nonetheless, it will be appreciated that the above method provides an efficient way of determining not only a boundary violation, but its magnitude.
The method to find a correction quaternion {right arrow over (Q)}cor required to bring the candidate crop frame at orientation {right arrow over (Q)}′C back within the boundary of the camera frame in steps 108 and 116 is as follows.
A X
2
+B X+C=0
The correction cosine is given by
We need only consider the positive root, as quoted above, and the abbreviations A, B, and C are explicitly given by:
A=β22+4β32B=2β1β2−4β32C=β12
with
β1=({right arrow over (a)}×{right arrow over (b)})·{right arrow over (s)}
β2=({right arrow over (a)}×{right arrow over (b)})·({right arrow over (p)}−{right arrow over (s)})
β3=({right arrow over (a)}×{right arrow over (b)})·({right arrow over (n)}×{right arrow over (p)})
So as illustrated in
Referring now to
A threshold distance is used for the crop frame arc lengths. In the event of frame squeezing, the method to find the correction cosine is adapted as follows:
is obtained as described for steps 108, 116 above, using the triangle vectors, {right arrow over (a)}, {right arrow over (b)} and {right arrow over (p)}, of the maximum boundary violation. The correction cosine for each line of the rolling shutter is given by the formulae
Using these correction quaternions from step 114, the camera frame can be stretched by the minimum amount necessary to avoid the crop frame exceeding the boundary of the camera frame, as illustrated in
The above described method is a stable and fast method to obtain the correction quaternion(s), that adjust the relative orientation of the camera and crop frames so that no black borders intrude in the stabilized video. This method can be suitable for all types of rolling shutter cameras. The method can correct the relative orientation of the camera and crop frames in all conditions of camera motion and is applicable to all lens models.
This application is a continuation of U.S. patent application Ser. No. 16/575,748 filed Sep. 19, 2019, which is incorporated by reference herein in its entirety.
Number | Name | Date | Kind |
---|---|---|---|
9888179 | Liang | Feb 2018 | B1 |
20040100560 | Stavely et al. | May 2004 | A1 |
20050122403 | Yoneda | Jun 2005 | A1 |
20060120615 | Wang | Jun 2006 | A1 |
20100271485 | Kim et al. | Oct 2010 | A1 |
20110149094 | Chen et al. | Jun 2011 | A1 |
20110254972 | Yaguchi | Oct 2011 | A1 |
20130208134 | Hamalainen | Aug 2013 | A1 |
20130235221 | Zhou | Sep 2013 | A1 |
20140267901 | Nowakowski et al. | Sep 2014 | A1 |
20170332018 | Bell et al. | Nov 2017 | A1 |
20180041707 | Beysserie et al. | Feb 2018 | A1 |
20180220073 | Keal | Aug 2018 | A1 |
20190028645 | Satoh | Jan 2019 | A1 |
20200137308 | Kulik et al. | Apr 2020 | A1 |
20200137309 | Kulik et al. | Apr 2020 | A1 |
20220038629 | Ozone | Feb 2022 | A1 |
Number | Date | Country |
---|---|---|
2014005783 | Jan 2014 | WO |
2014146983 | Sep 2014 | WO |
2017140438 | Aug 2017 | WO |
2019063850 | Apr 2019 | WO |
Entry |
---|
Ken Shoemake, “Animating rotation with quaternion curves” ACM SIGGRAPH Computer Graphics 19(3), pp. 245-254 (JJul. 1985). |
European Paten Office: “Extended Search Report” for EP Patent Application No. 20187353.6 filed Jul. 23, 2020 titled “Method for Stabilizing a Camera Frame of a Video Sequence.” EP Search Report dated Jan. 13, 2021; 9 pages. |
Number | Date | Country | |
---|---|---|---|
20210302755 A1 | Sep 2021 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 16575748 | Sep 2019 | US |
Child | 17233546 | US |