Professional Documents
Culture Documents
For MEI6900 – Experimental Methods in Fluid Mechanics and Combustion with Prof. Yiannis
Andreopoulos
Yoribaldis Olivo
Department of Mechanical Engineering, City College of City University of New York, New
York, NY 10031, USA
yolivo01@citymail.cuny.edu
1
MEI6900
1. Introduction
The primary objective of this study is to determine the calibration parameters from an image
taken of a phone camera. The process of manipulating and analyzing images to improve their
quality or obtain information for further study is known as image processing [1]. Today, image
processing is widely used in different fields for a variety of applications from pattern recognition
to development of machine learning tools [2,3]. For this project we are interested in defining
camera properties that affect the imaging processing procedure and are necessary to calibrate our
image. The image calibration process consists of determining the intrinsic and extrinsic parameters
necessary to find misrepresentations in our images. The intrinsic parameters are the camera’s
internal geometric and optical properties whereas the extrinsic parameters are defined by the
orientation of the camera with respect to a specified world coordinate system [4]. These properties
are necessary to process are images correctly by removing any unwanted characteristics due to the
image discrepancies from real world representation.
Our phone camera introduces significant distortion in the images taken from it. These
distortions are mainly radial and tangential [5]. Due to these distortions, lines on the image may
appear to be curved when in reality they are not. However, these distortions are constant and can
be adjusted for. Knowing the camera calibration parameters, allows us to apply a routine that lets
us eliminate distortion effects from an image. With these calibration parameters, we can determine
the correlation matrix, the relationship between the camera’s units and the real world units along
with rotational and translational matrices. Utilizing a MATLAB image processing algorithm
derived from pinhole camera theory which explains the relationship between a three-dimensional
point and the projection of its image [6]. In this case we will apply the model for a split view discs
for which we will determine the calibration matrix, intrinsic matrix, extrinsic matrix, and camera
calibration parameters from the image taken from our cellphone camera.
2. Methodology
The use of pinhole camera theory allowed people to design and manufacture more affordable
cameras. These cheap cameras come with one big disadvantage: a large distortion on the images
obtained from the camera. However, as mentioned before, these distortions are constant for the
camera model and can be eliminated by processing the image and calibrating it. The idea of the
pinhole camera is that we take a three-dimensional images and project it in a two-dimensional
space ideally without any distortion as observed in Fig. 1. This two-dimensional image is mapped
by the camera matrix into the image plane. The camera matrix is obtained from an algorithm that
uses the intrinsic and extrinsic parameters.
2
MEI6900
The purpose of this calibration is to find the relationship between the camera units in pixels
and the real world units usually in millimeters or inches. By using lensmaker triangles similarity
equation we can obtain the relationship between the focal length and the image location which
provides us with the perspective projection formulas
−𝑓 ̅𝑥 −𝑓 ̅𝑦 −𝑓 ̅𝑧
𝑥′ = ; 𝑦′ = ; 𝑧′ =
𝑧−𝑓 𝑧−𝑓 𝑧−𝑓
For this study we used an image taken iPhone X designed and manufactured by Apple
Incorporated. This cellphone has a 12 Megapixels wide-angle and telephotos camera. With the
iPhone X camera, we took a photo of a calibration plate with pluses symbols and know spatial
three dimensional coordinates observed in Fig. 2a. The plate has 11 columns with an uneven
number of rows with a total of 97 plus signs. The first step is to determine a calibration pattern
which in our case is the calibration plate observed in Fig. 1a. Then this image was imported into
the MATLAB software algorithm provided named Cal1_Left1_1_NewPlate.m. This program
exports the locations of each of the plus signs in the plate. After importing the image and
determining its size, we manually select the center location for each of the plus signs on our plates
3
MEI6900
that have different X, Y, and Z coordinates. The program then defines the coordinate system and
the arrangement of the plus signs on the plate. Each of the plus signs on the plate are from their
neighboring signs equally in the X and Y directions where ∆𝑥 and ∆𝑦 equal 25.4 mm. Fig. 2b
below illustrates the calibration plate after being processed by the program with the center location
of the plus signs selected.
Figure 2. Calibration plates with known three dimensional coordinates (a) Before processing (b)
After processing
After determining the three-dimensional location of each plus sign for the first program we
imported the data into the second MATLAB program provided OneViewOnly1.m. The algorithm
determines the calibration coefficients, camera matrix, intrinsic matrix and extrinsic matrix using
pinhole camera theory for one sensor location. These parameters are necessary to calibrate the
image and account for its distortions. After determining the world coordinate system, we start of
by transforming it to the camera coordinate system using the following relationship taking into
account the lens distortion:
This R matrix takes into the account the translational and rotational components needed for
the transformation. The 𝑥𝑐𝐴 , 𝑦𝑐𝐴 , and 𝑧𝑐𝐴 represents the camera coordinates while 𝑋𝑤 , 𝑌𝑤 , and 𝑍𝑤
are the real world coordinates. Then the system still has to be converted into the image
4
MEI6900
coordinate system by relating the camera coordinate transformation matrix with the intrinsic
matrix given by
𝑓𝑆𝑥 0 −𝑐𝑥 𝑆𝑥 0
𝐾 = [ 0 𝑓𝑆𝑦 −𝑐𝑦 𝑆𝑦 0 ]
0 0 1 0
Where 𝑓 is the focal length in pixels, 𝑆 is the skew coefficient (the pixel size in the
respective direction) and 𝑐 is the principal point in pixels. Then the world coordinate
transformation matrix becomes
𝑋𝑤
𝑥𝑠𝐴 𝑓𝑆𝑥 0 −𝑐𝑥 𝑆𝑥 0 𝑅𝐴11 𝑅𝐴12 𝑅𝐴13 𝑅𝐴14
𝑌
𝛼 {𝑦𝑠𝐴 } = [ 0 𝑓𝑆𝑦 −𝑐𝑦 𝑆𝑦 0 ] [𝑅𝐴21 𝑅𝐴22 𝑅𝐴23 𝑅𝐴24 ] { 𝑤 }
𝑍𝑤
1
0 0 1 0 𝑅𝐴21 𝑅𝐴22 𝑅𝐴23 𝑅𝐴24 1
Finally, by simplifying the above matrix we obtain the matrix for the calibration coefficients
below. The matrix below represents the calibration coefficients needed to transform the real world
coordinates into the image coordinates system derived from the intrinsic and extrinsic The results
obtained from the second program provided are illustrated in the results section.
𝑋𝑤
𝛼𝑥𝑠𝐴 𝐿𝐴11 𝐿𝐴12 𝐿𝐴13 𝐿𝐴14
𝑌
{𝛼𝑦𝑠𝐴 } = [𝐿𝐴21 𝐿𝐴22 𝐿𝐴23 𝐿𝐴24 ] { 𝑤 }
𝛼 𝐿𝐴31 𝐿𝐴32 𝐿𝐴33 𝐿𝐴34 𝑍𝑤
1
4. Results
In this section we discuss all the parameters obtained from the study and explain what is the
relationship or effect of each based on the pinhole camera theory. From the calibration coefficients
matrix, the image coordinates are recovered and compared to the original points obtained from the
first MATLAB program using the OneViewOnly1.m. code provided. Fig. 3 below illustrates the
overlay of the points of the calibration plate.
The difference between the original image points and the image coordinates recovered from
the calibration matrix is on average 2.6%. The largest error as expected occur when further away
from the center of the images where the distortion effects are greater. Other parameters calculated
5
MEI6900
in this study used to calibrate the calibration plate images are tabulated below with a brief
description of their particular contribution to the overall process.
Table 1, Table 2, and Table 3 below illustrate the real world coordinates of the calibration
object in mm where the origin of our system is the optical center of the camera for 𝑋𝑤 , 𝑌𝑤 , and 𝑍𝑤 ,
respectively. The world coordinate system is three-dimensional and independent of the camera
position with respect to the object in study.
6
MEI6900
After converting the world coordinates to camera coordinate we finally have to transform them
into image coordinates. Table 4 and Table 5 illustrate the 2D projection of the image in pixel units
for its X and Y coordinates, respectively. This result is obtained after rotating and translating the
world coordinate units since usually the center of the image does not correspond with the center
of the camera coordinates.
7
MEI6900
Table 5 illustrates the Camera Matrix (K) which is also referred as the intrinsic matrix. This
matrix contains the intrinsic parameters which includes the focal length, image principal points,
and the camera skew.
8
MEI6900
The extrinsic matrix components are shown below in Table 6 and 7. This matrix represents
the parameters needed to transform the three-dimensional world coordinates into the camera
coordinates by translation (Table 7) and rotation (Table 6).
Finally, one we have established the camera internal geometric parameters and three-
dimensional orientation in the real world coordinate system we can determine the calibration
necessary to transform our object into the image coordinate system. The camera calibration matrix
for the pinhole model P is shown below in Table 8. This matrix represents the relationship between
the values necessary to calibrate the object in the real world to the coordinate system of the image.
9
MEI6900
The calibration matrix L is the same as the camera calibration matrix discussed before.
5. Conclusion
Image calibration is an essential technique needed to effectively retrieve the correct data
needed for studies in many different field. In order calibrate the image many different internal and
external camera and image parameters have to be taken into account to properly process our
images. The average error from the study was 2.6% error. Since the distortion is constant there
might be some additional parameters that might not be taken into account and in order to determine
that we would need a more in depth understanding of the physical parameters and mathematical
modeling involved.
It would also interesting to follow the same procedure for different calibration patterns with
the same phone camera to observe if there would be any difference in the results observed in this
study. Another study using the same calibration plates for different camera phone and study any
correlation in the results depending a camera specifications and features.
10
MEI6900
6. References
[1] Šonka, Milan, et al. Image Processing, Analysis, and Machine Vision. Cengage Learning, 2015.
[2] Guo, Yandong, et al. “MS-Celeb-1M: A Dataset and Benchmark for Large-Scale Face
Recognition.” Computer Vision – ECCV 2016 Lecture Notes in Computer Science, 2016, pp. 87–
102., doi:10.1007/978-3-319-46487-9_6.
[3] Zhi-Ming, Dong, et al. “Oil-Spills Detection in Net-Sar Radar Images Using Support Vector
Machine.” The Open Automation and Control Systems Journal, vol. 7, no. 1, 2015, pp. 1958–
1962., doi:10.2174/1874444301507011958.
[4] Tsai, R. “A Versatile Camera Calibration Technique for High-Accuracy 3D Machine Vision
Metrology Using off-the-Shelf TV Cameras and Lenses.” IEEE Journal on Robotics and
Automation, vol. 3, no. 4, 1987, pp. 323–344., doi:10.1109/jra.1987.1087109.
[5] Hartley, Richard, and Andrew Zisserman. Multiple View Geometry in Computer Vision.
Cambridge University Press, 2017.
[6] Zhang, Z. “A Flexible New Technique for Camera Calibration.” IEEE Transactions on Pattern
Analysis and Machine Intelligence. Vol. 22, No. 11, 2000, pp. 1330–1334.
[7] “Tutorial Camera Calibration.” Tutorial Camera Calibration - BoofCV,
boofcv.org/index.php?title=Tutorial_Camera_Calibration.
[8] Bouguet, J. Y. “Camera Calibration Toolbox for Matlab.” Computational Vision at the California
Institute of Technology.
11