The present invention relates to a method for compensating for off-axis tilting of a lens.
Referring now to
In order to compensate for lens tilt, it must be properly modelled and the modelling parameters estimated.
Both Matlab Camera Calibration Toolbox and OpenCV refer to the distortion caused by lens tilt as “tangential distortion” and suggest that it can be corrected by the following set of equations:
xdist=x+(2p1xy+p2(r2+2x2))
ydist=Y+(p1(r2+2y2)+2p2xy)
where xdist, ydist are the x,y coordinates of a pixel within an image distorted by a tilted lens; x, y are the normalised pixel coordinates;
r is the distance to the optical axis where r=√{square root over (x2+y2)}; and
p1,p2 are the modelling parameters.
However, according to Beauchemin et al., “Modelling and Removing Radial and Tangential Distortions in Spherical Lenses”, Multi-Image Analysis, 10th International Workshop on Theoretical Foundations of Computer Vision Dagstuhl Castle, Germany, Mar. 12-17, 2000, pp. 1-21 the above equations are based on thin prism distortion caused by the misalignment of the lens optical elements and are applicable only to spherical lenses. Thus, these equations may not be applicable in the case of lenses containing a large number of aspherical elements such as lens assemblies common in modern smartphones.
There is provided an image acquisition system arranged to compensate for off-axis tilting of a lens according to each of claim 1 or 4.
In an image acquisition system with a lens tilt of 0.25 degrees, the errors between the present method and the conventional method are 1.5 pixels on average with 3 pixels maximum for a 2 Mpixel Full-HD image sensor. This error gets worse for higher resolutions and so the improvement provided by the invention improves for higher resolution image sensors.
Similarly, the error grows quite significantly with the amount of tilt, thus lower quality lens modules can also benefit more from the invention than higher quality devices.
Embodiments of the invention will now be described, by way of example, with reference to the accompanying drawings, in which:
Referring now to
Compensation for lens tilt can be implemented at any stage in the image processing pipeline and in the example of
In any case, the system controller 34 provides the compensation module 26 with a set of parameters {right arrow over (n)} which can then be used by the module 26 to map pixel information from an image distorted by lens tilt to a distortion corrected image and these parameters along with how they can be used are described in more detail below.
In the description below, the effect caused by lens tilt does not need to take into account lens projection, as the model is only concerned with the path of light exiting the lens 20.
It can be observed, that for any field angle, the lens is producing a cone of light that intersects the sensor surface. We need to find the shape of the intersection as a function of the tilt. It is convenient to describe such a transformation in terms of mapping the “perfect” point coordinates produced by the lens 20 when it is perfectly aligned with the sensor 22, to the new coordinates which are distorted by the sensor tilt. In this way, the lens projection characteristics can be separated from the effect caused by the lens tilt. The problem can be approached from two directions, each producing equivalent end results:
1. Modelling the Lens Tilt by Raytracing
For convenience, we can assume that a projection plane is on the same side of the plane as object. It is a common convention used in computer graphics as the ISP 24 typically flips the raw image produced by lens 20, so there is no point in reversing this process in order to model the fact that the lens produces a flipped image.
We adopt the convention that the z-axis of the coordinate system is the optical axis and the ideal projection (not tilted) is done on the plane z=1 with the projection centre in the origin of the coordinate system.
Referring now to
and the unit normal vector of S1 will be
An ideally projected point will form a vector
where ux and uy are normalised coordinates on the horizontal plane S0.
The first stage of this approach is to find a point {right arrow over (P)} which is the intersection of the ray described by the vector {right arrow over (u)} with the plane S1. In order to do that we need to find a scale factor s that will stretch the vector {right arrow over (u)} to make it meet with S1. The scale factor s is defined as:
Since the vector {right arrow over (w)} is aligned with the coordinate system it can be simplified to:
The 3D position of the point {right arrow over (P)} is defined as
These calculations are relatively simple to implement and are very friendly for GPU or DSP implementations where dot products can be efficiently calculated by using SIMD (Single Instruction/Multiple Data) instructions.
Since we are interested in the position of point {right arrow over (P)} in the local coordinates of S1, the coordinates of point {right arrow over (P)} must be rotated in order to align them with the xy plane of the coordinate system. This can be done by finding a rotation matrix {circumflex over (R)} that rotates the vector {right arrow over (n)} to the vector {right arrow over (w)}.
The rotation axis is defined by the cross product between the vectors {right arrow over (n)} and {right arrow over (w)}:
and the cosine of the rotation angle is defined as the dot product between these vectors:
cos θ={right arrow over (w)}·{right arrow over (n)}=−nz
The vector {right arrow over (v)} can be used to construct a skew-symmetric matrix {circumflex over (V)}:
The rotation matrix {circumflex over (R)} can be calculated by rearranging the Rodriguez formula to the following form, and plugging in for the values of cos θ and {circumflex over (V)}:
To perform the rotation around the projection plane origin, the points have to be first shifted to the coordinate centre, rotated then shifted back to the original location. So the final point coordinates in the local coordinate system of the tilted plane are defined as follows:
{right arrow over (P)}′={circumflex over (R)}({right arrow over (P)}+{right arrow over (w)})−{right arrow over (w)}
Since we are not interested in the z coordinate of the point {right arrow over (P)}′ (as it should equal 1 for all points), the calculations can be simplified to:
with the scale factors given by
The form of the above equations makes them readily computed using SIMD instructions. For example, the compensation module 26 can simply step through each ux, uy pixel location of a lens tilt compensated output image and determine the corresponding coordinates Px′, Py′ in the input distorted image—note that these coordinates need not necessarily correspond with a pixel location in the input image. As described in U.S. Pat. No. 9,280,810 and U.S. patent application Ser. No. 15/879,310, some interpolation between input image pixel values for pixel locations surrounding the input image coordinates may then be required to produce the pixel value for the output image pixel location.
Moreover, slight reorganisation of the equations will allow for further parallelization. The calculation of s and the expression in parentheses can be performed in parallel followed by the multiplication of the results.
2. Modelling the Lens Tilt by Conical Section
Referring to
The circle 10 shows the intersection between the horizontal plane S0 and the cone of light 11 produced by the lens that intersects the sensor surface; the ellipse 12 is the intersection of the tilted plane S1 and the cone; and the ellipse 14 is the ellipse after rotation back to the horizontal plane S0. A non-linear mapping {right arrow over (p)}{right arrow over (q)},
In this case, the coordinate system is inverted with respect to the previous ray tracing approach, as the optical centre is located at (0,0,1), so the focal point vector {right arrow over (f)}=−{right arrow over (w)}, and the horizontal plane is located at z=0.
Referring to
{right arrow over (n)}·{right arrow over (z)}=xnx+yny+znz+n1=0
and the vectors are:
where {right arrow over (z)} is an element of the 3-dimensional projective plane {right arrow over (z)}∈3. The 4th element of the normal vector is a translational component and describes the displacement of the tilted plane from the origin: (x,y,z)=(0,0,0). Here we need only consider planes which contain the origin. Therefore we may exclude the translational component and treat the unit normal {right arrow over (n)} as a 3-vector. There are 2 planes that are of interest to this study; respectively defined by the normal vectors
With {right arrow over (n)}0={right arrow over (f)}, which is the focal point {right arrow over (f)} of the lens, and the centre of projection.
The cone of light rays 11 emanating from the focal point is illustrated in
The 2-dimensional coordinates of the intersection points with the horizontal plane are described by the vector:
The light rays extend from the centre of projection toward the horizontal plane.
The light rays {right arrow over (l)} extend from the focal point {right arrow over (f)} and intersect the horizontal plane at {right arrow over (p)}. The intersection points are transformed to the tilted plane {right arrow over (q)}0 under the non-linear mapping
{right arrow over (p)}{right arrow over (q)}0
Where {right arrow over (q)}0 are the 3-dimensional transformed coordinates defined by
{right arrow over (q)}0={right arrow over (f)}+λ{right arrow over (l)}
Where is the non-linear scaling of the light rays between the horizontal and tilted plane. The explicit form of the scaling parameter is found from the dot product of {right arrow over (q)}0 with the normal to the tilted imaging sensor plane {right arrow over (n)}.
The light rays intersect the tilted plane at {right arrow over (q)}0.
The intersection of the light rays with the tilted plane is illustrated by the ellipse 12 in
The cosine of the angle of rotation is given by the dot product between the unit normal to the tilted plane and the focal point vector:
cos θ={right arrow over (f)}·{right arrow over (n)}=nz
We seek the non-linear mapping:
{right arrow over (p)}{right arrow over (q)}
Where {right arrow over (p)} and {right arrow over (q)} are 2-dimensional vectors, both with a zero component along the optical axis pz=qz=0.
The 2-dimensional transformed coordinates are found by rotating {right arrow over (q)}0 back to the horizontal plane, via:
{right arrow over (q)}={circumflex over (Q)}{right arrow over (q)}0
{circumflex over (Q)} is an axis-angle quaternion, described by the Rodrigues rotation equation.
where is the identity matrix, and {circumflex over (K)} is a skew symmetric matrix given by the axis of rotation:
Making the substitutions
cos θ=nz and (kx,ky,kz)=(ny,−nx,θ)
the Rodrigues axis-angle quaternion simplifies to:
Applying the rotation
{right arrow over (q)}={circumflex over (Q)}{right arrow over (q)}0
we obtain the 2-dimensional transformed coordinates
The non-linear mapping from pxqx, and from pyqy, is
with the scale factor λ given by:
Now that the parameters {right arrow over (n)} defining the above described model and their application to compensate an acquired image for lens tilt have been described, it will be appreciated that any image acquisition system 200 (camera) having a lens tilt calibration module 26 driven by these parameters {right arrow over (n)} can be readily calibrated as described at the following link: http://ags.cs.uni-kl.de/fileadmin/inf ags/3dcv-ws11-12/3DCV WS11-12 lec03.pdf, Stricker by pointing the camera at a 3-surface reference object to acquire a single 2-D image and then applying a global optimisation algorithm to determine parameters both for camera location (X,Y,Z) and rotation (Rx,Ry,Rz) relative to the reference object as well as camera model parameters including taking into account lens distortion as well as lens tilt parameters {right arrow over (n)} by minimizing an error function mapping the points of the reference object to locations in the acquired 2-D image.
While the approach of Stricker is based on a reference object including a checkerboard type pattern, other reference objects can comprise surfaces including boards comprising unique ChArUco characters rather than a repeating pattern of the same unit.
Note that there may also be a loss in focus associated with lens tilt but this is not considered in detail here. Nonetheless, the above compensation technique can be combined with any other technique compensating for any loss of focus.
In variants of the above embodiments, rather than supplying the three coordinates for the vector {right arrow over (n)} directly, these can instead be derived from a pair of scalars, NX and NY generated by a calibration process as described above. First, a length of the input vector is calculated as follows: d=sqrt(NX2+NY2+1) (essentially a third scalar NZ=1). Then the components of the vector {right arrow over (n)} are calculated as follows:
nx=NX/d
ny=NY/d
nz=1/d.
Using such an approach, the interface for the compensation module 26 can be made interchangeable with that of compensation modules using the prior art approach, yet still provide an improved result.
Note that the above derivation from two parameters is just an example and other methods might be used, for example, the vector {right arrow over (n)} could be derived from two rotation angles of a sensor plane.
Number | Name | Date | Kind |
---|---|---|---|
8482628 | Khan | Jul 2013 | B1 |
9280810 | Stec et al. | Mar 2016 | B2 |
20040032952 | Pinto | Feb 2004 | A1 |
20040125227 | Tsuruoka | Jul 2004 | A1 |
20050261849 | Kochi | Nov 2005 | A1 |
20110032374 | Imanishi | Feb 2011 | A1 |
20130100249 | Norita | Apr 2013 | A1 |
20130242129 | Harmeling | Sep 2013 | A1 |
20140009568 | Stec | Jan 2014 | A1 |
20140063229 | Olsson | Mar 2014 | A1 |
20140111672 | Seki | Apr 2014 | A1 |
Entry |
---|
Beauchemin et al., “Modelling and Removing Radial and Tangential Distortions in Spherical Lenses”, Multi-Image Analysis, 10th International Workshop on Theoretical Foundations of Computer Vision Dagstuhl Castle, Germany, Mar. 12-17, 2000, pp. 1-21. |
Strickler, Prof. Didier, “Camera model and calibration” https://ags.cs.uni-kl.de/fileadmin/inf_ags/3dcv-ws11-12/3DCV_WS11-12_lec03.pdf. |
Stec, et al. “Method and system for correcting a distorted input image,” U.S. Appl. No. 15/879,310, filed Jan. 24, 2018. |
“Mars Autonomy Project Stereo Ranging”, Field Robotics Center, Carnegie Mellon Robotics Institute, https://www.frc.ri.cmu.edu/projects/mars/stereo.html. |