This disclosure relates to video or image processing, and more specifically, to automatically compensating for camera motion in a sequence of images.
Professional videographers often use gyroscope-based cameras or camera mounts to reduce or eliminate unwanted camera motion when capturing video or burst images. However, gyroscope-based cameras or camera mounts can be bulky and expensive and thus may be unsuitable for consumer-grade action cameras where low cost and small form factor are highly desirable. Electronic image stabilization (EIS) may be used to digitally compensate for camera motion in post-processing. However, conventional EIS may introduce undesirable artifacts into the video or burst images, particularly when non-rectilinear lens distortion is introduced by the camera.
The present disclosure satisfies the foregoing needs by providing, inter alia, methods and apparatus for aligning a target image to a reference image in the presence of lens distortion.
In a first aspect of the present disclosure, a method for aligning a target image to a reference image in the presence of lens distortion is disclosed. In one embodiment, the method includes: receiving the target image and the reference image, each of the target image and the reference image being captured by a lens having lens distortion parameters; detecting a first plurality of visual features appearing in the target image at first image feature coordinates in a two-dimensional image space, and a corresponding second plurality of visual features appearing in the reference image at second image feature coordinates in the two-dimensional image space; transforming, based on the lens distortion parameters, the first and second image feature coordinates from the two-dimensional image space to a three-dimensional spherical space to generate respective first spherical feature coordinates and second spherical feature coordinates; applying, by a processor, a rotation to the target image in the three-dimensional spherical space to generate a rotated target image, the applying of the rotation comprising (i) aligning at least a subset of the first spherical feature coordinates to a corresponding subset of the second spherical feature coordinates, and (ii) determining the subset of the first spherical feature coordinates and the subset of the second spherical feature coordinates as background features in the target image and the reference image, respectively; and inverse transforming, based on the lens distortion parameters, the rotated target image to the two-dimensional image space. The determining of the subset of the first spherical feature coordinates and the subset of the second spherical feature coordinates as background features includes: determining feature tracks representing a distance along a spherical arc and a direction from each of the first spherical feature coordinates to a corresponding one of the second spherical feature coordinates; clustering the feature tracks by length to determine a plurality of feature track clusters; and determining from the plurality of feature track clusters, a background cluster of feature tracks corresponding to the background features.
In one variant, the determining of the background cluster includes: determining a predefined number of largest clusters from the plurality of feature track clusters; determining weighted averages of track lengths in each of the largest clusters; and selecting a cluster having a shortest weighted average of the weighted averages.
In another variant, the applying of the rotation further includes: determining first three-dimensional Cartesian coordinates corresponding to the subset of the first spherical feature coordinates and second three-dimensional Cartesian coordinates corresponding to the subset of the second spherical feature coordinates; determining a first coordinate centroid of the first three-dimensional Cartesian coordinates and a second coordinate centroid of the second three-dimensional Cartesian coordinates; determining first translated coordinates as a difference between the first three-dimensional Cartesian coordinates and the first coordinate centroid, and second translated coordinates as a difference between the second three-dimensional Cartesian coordinates and the second coordinate centroid; determining products between each of the first translated coordinates and respective corresponding second translated coordinates; determining an accumulation matrix as a combination of the vector products; and applying a singular value decomposition to the accumulation matrix to determine a rotation matrix, the rotation matrix indicating the rotation to apply to the target image in the three-dimensional spherical space.
In yet another variant, the lens distortion parameters correspond to a fisheye lens that introduces curvature into straight lines in a scene near edges of a captured image.
In yet another variant, the applying of the rotation further comprises optimally aligning the subset of the first spherical feature coordinates to the corresponding subset of the second spherical feature coordinates based on an optimization metric.
In yet another variant, the method further includes storing the lens distortion parameters within the target image and the reference image.
In yet another variant, the method further includes determining from the plurality of feature track clusters a foreground object that is distinct from the background features.
In a second aspect of the present disclosure, a non-transitory computer-readable apparatus is disclosed. In one embodiment, the computer-readable apparatus includes a storage medium storing a computer program configured to align a target image to a reference image in the presence of lens distortion, the computer program including instructions configured to, when executed by a processor apparatus, cause the processor apparatus to perform steps including: receiving the target image and the reference image, each of the target image and the reference image being captured by a lens having lens distortion parameters; detecting a first plurality of visual features appearing in the target image at first image feature coordinates in a two-dimensional image space, and a corresponding second plurality of visual features appearing in the reference image at second image feature coordinates in the two-dimensional image space; transforming, based on the lens distortion parameters, the first and second image feature coordinates from the two-dimensional image space to a three-dimensional spherical space to generate respective first spherical feature coordinates and second spherical feature coordinates; applying a rotation to the target image in the three-dimensional spherical space to generate a rotated target image, the application of the rotation comprises aligning at least a subset of the first spherical feature coordinates to a corresponding subset of the second spherical feature coordinates, and determining the subset of the first spherical feature coordinates and the subset of the second spherical feature coordinates as background features in the target image and the reference image, respectively; and inverse transforming, based on the lens distortion parameters, the rotated target image to the two-dimensional image space. The determination of the subset of the first spherical feature coordinates and the subset of the second spherical feature coordinates as background features includes: determining feature tracks representing a distance along a spherical arc and a direction from each of the first spherical feature coordinates to a corresponding one of the second spherical feature coordinates; clustering the feature tracks by length to determine a plurality of feature track clusters; and determining from the plurality of feature track clusters, a background cluster of feature tracks corresponding to the background features.
In one variant, the determination of the background cluster includes: determining a predefined number of largest clusters from the plurality of feature track clusters; determining weighted averages of track lengths in each of the largest clusters; and selecting a cluster having a shortest weighted average of the weighted averages.
In another variant, the application of the rotation further includes: determining first three-dimensional Cartesian coordinates corresponding to the subset of the first spherical feature coordinates and second three-dimensional Cartesian coordinates corresponding to the subset of the second spherical feature coordinates; determining a first coordinate centroid of the first three-dimensional Cartesian coordinates and a second coordinate centroid of the second three-dimensional Cartesian coordinates; determining first translated coordinates as a difference between the first three-dimensional Cartesian coordinates and the first coordinate centroid, and second translated coordinates as a difference between the second three-dimensional Cartesian coordinates and the second coordinate centroid; determining products between each of the first translated coordinates and respective corresponding second translated coordinates; determining an accumulation matrix as a combination of the vector products; applying a singular value decomposition to the accumulation matrix to determine a rotation matrix, the rotation matrix indicating the rotation to apply to the target image in the three-dimensional spherical space.
In yet another variant, the lens distortion parameters correspond to a fisheye lens that introduces curvature into straight lines in a scene near edges of a captured image.
In yet another variant, the application of the rotation includes optimally aligning the subset of the first spherical feature coordinates to the corresponding subset of the second spherical feature coordinates based on an optimization metric.
In yet another variant, the determination of the background cluster includes determining which of the plurality of feature track clusters comprises a cluster having the largest size.
In yet another variant, the instructions are configured to, when executed by the processor apparatus, further apply a translation to the target image in the three-dimensional spherical space to generate the rotated target image.
In a third aspect of the present disclosure, a video server is disclosed. In one embodiment, the video server includes one or more processors; and a non-transitory computer-readable apparatus having a storage medium configured to store a computer program having instructions for aligning a target image to a reference image in the presence of lens distortion, the instructions, when executed by one or more processor apparatus, being configured to cause the one or more processor apparatus to perform steps including: receiving the target image and the reference image, each of the target image and the reference image captured by a lens having lens distortion parameters; detecting a first plurality of visual features appearing in the target image at first image feature coordinates in a two-dimensional image space, and a corresponding second plurality of visual features appearing in the reference image at second image feature coordinates in the two-dimensional image space; transforming, based on the lens distortion parameters, the first and second image feature coordinates from the two-dimensional image space to a three-dimensional spherical space to generate respective first spherical feature coordinates and second spherical feature coordinates; applying a rotation to the target image in the three-dimensional spherical space to generate a rotated target image, the application of the rotation being configured to align at least a subset of the first spherical feature coordinates to a corresponding subset of the second spherical feature coordinates; and inverse transforming, based on the lens distortion parameters, the rotated target image to the two-dimensional image space. The application of the rotation includes determination of the subset of the first spherical feature coordinates and the subset of the second spherical feature coordinates as background features in the target image and the reference image, respectively. The determination of the subset of the first spherical feature coordinates and the subset of the second spherical feature coordinates as background features includes: determination of feature tracks representing a distance along a spherical arc and direction from each of the first spherical feature coordinates to a corresponding one of the second spherical feature coordinates; clustering of the feature tracks by length to determine a plurality of feature track clusters; determination of from the plurality of feature track clusters, a background cluster of feature tracks corresponding to the background features.
In one variant, the determination of the background cluster includes: determination of a predefined number of largest clusters from the plurality of feature track clusters; determination of weighted averages of track lengths in each of the largest clusters; and selection of a cluster having a shortest weighted average of the weighted averages.
In another variant, the application of the rotation further includes: determining first three-dimensional Cartesian coordinates corresponding to the subset of the first spherical feature coordinates and second three-dimensional Cartesian coordinates corresponding to the subset of the second spherical feature coordinates; determining a first coordinate centroid of the first three-dimensional Cartesian coordinates and a second coordinate centroid of the second three-dimensional Cartesian coordinates; determining first translated coordinates as a difference between the first three-dimensional Cartesian coordinates and the first coordinate centroid and second translated coordinates as a difference between the second three-dimensional Cartesian coordinates and the second coordinate centroid; determining products between each of the first translated coordinates and respective corresponding second translated coordinates; determining an accumulation matrix as a combination of the vector products; and applying a singular value decomposition to the accumulation matrix to determine a rotation matrix, the rotation matrix being configured to indicate the rotation to apply to the target image in the three-dimensional spherical space.
In yet another variant, the application of the rotation further includes an alignment of the subset of the first spherical feature coordinates to the corresponding subset of the second spherical feature coordinates based on an optimization metric.
In yet another variant, the video server is configured to be in data communication with one or more of a camera device and a client device via a network.
In yet another variant, the instructions are further configured to, when executed by the one or more processors, cause the one or more processors to extract the lens distortion parameters from one or more of the target image and the reference image.
Other features and advantages of the present disclosure will be immediately recognized by persons of ordinary skill in the art with reference to the attached drawings and detailed description of exemplary embodiments as given below.
The disclosed embodiments have other advantages and features which will be more readily apparent from the following detailed description of the invention and the appended claims, when taken in conjunction with the accompanying drawings, in which:
The figures and the following description relate to preferred embodiments by way of illustration only. It should be noted that from the following discussion, alternative embodiments of the structures and methods disclosed herein will be readily recognized as viable alternatives that may be employed without departing from the principles of what is claimed.
Reference will now be made in detail to several embodiments, examples of which are illustrated in the accompanying figures. It is noted that wherever practicable similar or like reference numbers may be used in the figures and may indicate similar or like functionality. The figures depict embodiments of the disclosed system (or method) for purposes of illustration only. One skilled in the art will readily recognize from the following description that alternative embodiments of the structures and methods illustrated herein may be employed without departing from the principles described herein.
In an embodiment, images captured from a fisheye lens or other lens with known distortion parameters may be transformed into a spherical image space using the known lens distortion parameters. Features in a target image may be detected and matched to features in a reference image. In the spherical image space, images may be re-pointed or rotated in three dimensions to align all or a subset of the features of the target image to the corresponding features of the reference image. For example, in a sequence of images, background features of the target image in the spherical image space may be aligned to background features of the reference image in the spherical image space to compensate for camera motion while preserving foreground motion. After alignment, the inverse transformation may then be applied to bring the images back into the original (e.g., fisheye or other known distortion) image space. The described technique for aligning image features may be useful for a number of applications such as electronic image stabilization applications, foreground/background segmentation and generating composite images or video.
Embodiments may also include a video server and a non-transitory computer-readable storage medium to enable a processor to perform the above-described method.
The camera 130 can include a camera body, one or more a camera lenses, various indicators on the camera body (such as LEDs, displays, and the like), various input mechanisms (such as buttons, switches, and touch-screen mechanisms), and electronics (e.g., imaging electronics, power electronics, metadata sensors, etc.) internal to the camera body for capturing images via the one or more lenses and/or performing other functions. In one embodiment, the camera 130 may capture images using a wide-angle lens that introduces some lens distortion into the image, such as, for example, a fisheye effect. In this example, the projection of the captured images onto a rectangular display may result in the appearance of increased distortion (e.g., curvature) in the edge and corner regions of the images relative to the center region. For example, straight lines in the scene that are centered in the image may appear relatively straight, but straight lines in the scene may appear increasingly curved near the edge and corner regions of the image as the distance from the center increases. Furthermore, in a fisheye lens, objects of equal size in the scene may appear larger in the center region and may appear increasingly smaller as they approach the edges. In one embodiment, the camera 130 may capture spherical or substantially spherical content via two or more wide-angle lenses (e.g., two hyper-hemispherical lenses pointed in opposite directions). In other embodiments, the camera 130 may capture images or video having another non-rectilinear field of view in which some curvature is introduced into the images as an artifact of the lens parameters.
The video server 140 may receive and store videos and/or images captured by the camera 130. Furthermore, in one embodiment, the video server 140 may provide the user with an interface, such as a web page or native application installed on the client device 135, to interact with and/or edit the stored videos. The videos stored by the video server 140 may include traditional videos having, for example, 30 frames per second or 60 frames per second, or videos formed from a sequence of burst-captured images or time-lapsed images.
In a burst mode, for example, the camera 130 may capture a given number of frames (burst of photos) over a given time window, typically in rapid succession. In some implementations, the number of photos per burst may be configured by the user, e.g., between 1 and 1000. In some implementations, the time window duration may be user selected (e.g., between 0.1 s and 10 s) or dynamically configured by the camera given user preferences (e.g., inter-shot duration), detected user activity (e.g., sky diving, surfing, biking), available storage, image resolution, bracketing configuration (e.g., 3 exposures per shot), and/or other settings. By way of an illustration, a skateboarder, attempting to record a jump, may configure the camera to collect a burst of 30 frames within 1 s time window.
When operating in a time lapse mode, the camera 130 may be configured to capture one or more images at a given interval. The capture may commence based on an indication by the user (e.g., press of the record button, voice command, camera shake, clap, and/or other indication). In some implementations, the time lapse image acquisition may be initiated automatically by the camera based on a given condition (e.g., timer expiration, parameter breaching a threshold (e.g., ambient light reaching a given level during pre-dawn/dawn), arrival of a wireless communication (e.g., text message, ping), and/or other condition). The time lapse photo acquisition interval may be configured, for example, between 0.1 s and 120 s. In some implementations of time lapse photo acquisition, the camera 130 may be configured to take a single image (photo) at the specified interval or a plurality of images (e.g., 2-100). Multiple images may be utilized, e.g., when bracketing for exposure and/or focus distance. Duration of the time lapse may be configured by the user.
A user can interact with interfaces provided by the video server 140 via the client device 235 in order to edit or view the videos and images. The client device 135 may be any computing device capable of receiving user inputs and viewing video content. Furthermore, the client device 135 may be capable of transmitting and/or receiving data via the network 120. In one embodiment, the client device 135 may be a conventional computer system, such as a desktop or a laptop computer. Alternatively, the client device 135 may be a device having computer functionality, such as a personal digital assistant (PDA), a mobile telephone, a smartphone or another suitable device. The user can use the client device 135 to view and interact with or edit videos stored on the video server 140. For example, the user can view web pages including video summaries for a set of videos captured by the camera 130 via a web browser on the client device 135. Alternatively, the editing and viewing interfaces described herein may execute locally on the client device 135 without necessarily requiring the video server 140.
One or more input devices associated with the client device 135 receive input from the user. For example, the client device 135 can include a touch-sensitive display, a keyboard, a trackpad, a mouse, a voice recognition system, and the like. In some embodiments, the client device 135 can access video directly from the camera 130, and can transfer the accessed video to the video server 140 or view the video locally on the client device 135. While
The network 120 enables communication between the video server 140, the client device 135, and the camera 130. The network 120 may include any combination of local area and/or wide area networks, using both wired and/or wireless communication systems. In one embodiment, the network 120 uses standard communications technologies and/or protocols.
Various components of the environment 100 of
In the process of
The two-dimensional image space feature coordinates (x, y) in ft and ft-k may be transformed 206 into three-dimensional spherical coordinates vt and vt-k, respectively, where the ith spherical coordinate corresponding to the ith feature is νi=[ρi, θi, ϕi] and ρ is on the unit sphere, θ is the azimuthal angle, and ϕ is the elevation angle measured from the +Z-axis. An example illustration of this coordinate system is shown in
The transformation from the two-dimensional image space to the three-dimensional spherical space may be performed using the lens distortion model that maps the two-dimensional image coordinates to the three-dimensional spherical coordinates. In one embodiment, the lens distortion model may comprise a predefined mapping stored by the video server 140. In another embodiment, the lens distortion model or a reference to it may be stored as metadata in the captured images or video, and extracted by the video server 140 when processing the image or video. In another embodiment, the lens distortion model may be calculated based on visual characteristics of the images.
A transformation 208 may be applied to the spherical transformation of the target image It in order to align the features of the target image vt to the features of the reference image vt-k. For example, the transformation may comprise a rotation and a translation that optimizes alignment criteria (e.g., a sum of absolute differences optimization, a mean of absolute differences optimization, a sum of ratios optimization, or other optimization metric in L1 norm, a least squares optimization, a mean squared error optimization, a maximum likelihood estimate optimization, or other optimization metric in L2 norm). A more detailed example of a process for aligning the features of the target image vt to the features of the reference image vt-k is described with respect to
Although the process of
The lengths of the spherical tracks may be clustered 304. In general, features corresponding to stationary background objects in the images should have feature tracks may be expected to have similar feature track lengths related to the amount of camera motion. Furthermore, features corresponding to moving foreground objects may be expected to have similar feature track lengths related to both the amount of camera motion and the motion of the object. Features tracks that have lengths not sufficiently similar to other feature tracks may correspond to features that are incorrectly tracked and do not correspond to the same object. Thus, in one embodiment, feature tracks may be clustered to include a cluster of feature tracks corresponding to the background, one or more clusters of features tracks each corresponding to a different foreground object, and a set of outlier feature tracks corresponding to incorrectly tracked features. In one embodiment, the feature tracks corresponding to the background are identified 306. In an embodiment, one or more metrics may be used to determine which cluster (or clusters) corresponds to the background. For example, one embodiment, the largest cluster may be determined to correspond to the background. In another embodiment, the cluster corresponding the feature tracks with shortest lengths may be determined to correspond to the background. In yet another embodiment, a predefined number (e.g., 3) of largest clusters may be chosen and a weighted average of the track lengths may be computed. Then, the cluster with the shorted weighted average track length may be determined to correspond to the background. The feature space for clustering can vary widely from simple differences between all features to more complex clustering in higher dimensions. This can vary depending on the application as one type of clustering may be better for different applications.
A desired rotation may then be determined to rotate the target image such that the features are aligned to the features of the reference image. For example, in one embodiment, a rotation is determined that optimally aligns the features in the three-dimensional spherical space according to an optimization criteria (e.g., a sum of absolute differences optimization, a mean of absolute differences optimization, a sum of ratios optimization, or other optimization metric in L1 norm, a least squares optimization, a mean squared error optimization, a maximum likelihood estimate optimization, or other optimization metric in L2 norm). In one embodiment, the alignment may be determined by solving for a rotation matrix R and a translation t in the equation:
B=RA+t
where A represents the Cartesian coordinate transform ct=[xt, yt, zt]T of the spherical coordinates v′t of the background features and B represents the Cartesian coordinate transform ct-k=[xt-k, yt-k, zt-k]T of the spherical coordinates v′t-k of the background features.
To solve for the optimal rotation, the centroids μA and μB may first be determined 308 for both feature datasets A and B corresponding to the target image and reference image respectively. Both datasets may then be centered 310 so that the centroids are at the origins. This removes the translational component, leaving only the rotational component. The rotation matrix R may then be determined 312 for rotating the feature dataset A of the target image to align to the feature dataset B of the reference image. For example, in one embodiment, accumulation matrix may then be created for all M points and the singular value decomposition (SVD) may be used to solve the rotation matrix R. These steps are summarized in the below equations:
The rotation matrix R may be decomposed to find the rotation angles (α, β, γ) about the X, Y, and Z axes, respectively. These rotation angles may then be applied 314 to repoint the target image It in spherical space.
The algorithm described above can compensate for camera motion that is purely rotational. Furthermore, the algorithm may be robust enough to handle at least small amounts of camera translation in the three-dimensional space. For large camera translations, a full three-dimensional visual odometry system may be used to detect and compute accurate camera rotations and translations.
Using the process described above, a target image may be aligned to a reference image as shown in
Using the foreground/background segmentation technique discussed above, composite images or video may be generated. Here, a foreground object in a given frame is separated from the background and then overlaid onto subsequent frames of video. This creates an effect of tracking a path of a moving foreground object. An example sequence of composite image frames 502, 504, 506 is illustrated in
Another application of the above described algorithm may be video stabilization. In an example video stabilization process, camera paths between a reference frame and each of a sequence of target frames is first estimated, which may be determined by the respective estimated rotation matrices. Then, a smoothed camera path is generated. The smoothing may apply a filter to the estimated sequence of rotation matrices so as to retain large camera motion likely to correspond to intentional panning or re-orienting, while removing small camera motion likely to correspond to unintentional shaking of the camera. For example, in an embodiment, an averaging filter or a Kalman filter may be applied.
Throughout this specification, some embodiments have used the expression “coupled” along with its derivatives. The term “coupled” as used herein is not necessarily limited to two or more elements being in direct physical or electrical contact. Rather, the term “coupled” may also encompass two or more elements are not in direct contact with each other, but yet still co-operate or interact with each other, or are structured to provide a thermal conduction path between the elements.
Likewise, as used herein, the terms “comprises,” “comprising,” “includes,” “including,” “has,” “having” or any other variation thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, article, or apparatus that comprises a list of elements is not necessarily limited to only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
In addition, use of the “a” or “an” are employed to describe elements and components of the embodiments herein. This is done merely for convenience and to give a general sense of the invention. This description should be read to include one or at least one and the singular also includes the plural unless it is obvious that it is meant otherwise.
Finally, as used herein any reference to “one embodiment” or “an embodiment” means that a particular element, feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. The appearances of the phrase “in one embodiment” in various places in the specification are not necessarily all referring to the same embodiment.
Upon reading this disclosure, those of skill in the art will appreciate still additional alternative structural and functional designs for the described embodiments as disclosed from the principles herein. Thus, while particular embodiments and applications have been illustrated and described, it is to be understood that the disclosed embodiments are not limited to the precise construction and components disclosed herein. Various modifications, changes and variations, which will be apparent to those skilled in the art, may be made in the arrangement, operation and details of the method and apparatus disclosed herein without departing from the scope defined in the appended claims.
This application is a continuation of, and claims the benefit of priority to, co-owned and co-pending U.S. patent application Ser. No. 15/249,347 filed Aug. 26, 2016 of the same title, which in turn claims the benefit of priority to U.S. Provisional Application Ser. No. 62/352,530 filed on Jun. 20, 2016 of the same title, each of the foregoing being incorporated herein by reference in their entireties.
Number | Date | Country | |
---|---|---|---|
62352530 | Jun 2016 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 15249347 | Aug 2016 | US |
Child | 15967364 | US |