You are on page 1of 5

Monocular Distance Estimation using Pinhole

Camera Approximation to Avoid Vehicle Crash


and Back-over Accidents
Rajesh Kannan Megalingam, Senior Member, IEEE, Vignesh Shriram, Bommu Likhith, Gangireddy
Rajesh, Sriharsha Ghanta
Amrita Vishwa Vidyapeetham University, Kollam, Kerala 690525
rajeshkannan@ieee.org, shriramv99@gmail.com, likhith95@gmail.com, rajeshrdy2511@gmail.com,
ghanta1996@gmail.com

will be discussed in depth in coming sections. Programming is


Abstract- Many accidents happen while driving due to false done using OpenCV libraries in Python wrapper. The
estimation of the tailgating vehicle's distance and even while remainder of the paper will be structured as follows: a)
Motivation and problem statement will discuss the need to
backing up or parking the vehicles in a parking lot. It is very
focus on implementation of the proposed algorithm and will
important for the driver to know how close the tailgating vehicle.
explain the problem briefly. b) The design and implementation
It is equally important to know the vicinity of the other vehicles will delineate the procedure and algorithm used. c) The
and objects while parking or taking vehicle from the parking lots. experiment and result section details the images considered for
The main objective of this paper is to accurately estimate the this method to find the distance and some measurements
distance of a specific object by approximating the camera to be carried out. From the results we can also predict the reasons for
an ideal pinhole camera. In this method we use triangle similarity non-ideal behavior.
to estimate the distance after obtaining the focal length (in pixels)
of the camera. Using image processing techniques we detect the II. MOTIVATION
object for which we want to estimate the distance. We input the An article dated Mar 2014, “Preventing driveway
known width of the object and using the calculated focal length, tragedies: Rear cameras help drivers see behind them”, in the
the algorithm calculates the distance after identifying the object. Insurance Institute for Highway Safety Highway Loss Data
The experimental results are very promising that the estimation Institute says that its research study shows that rear cameras are
of the distance of an object using pin hole approximation would more effective than the sensors used to identify objects while
be extremely useful in vehicles to avoid accidents. backing up / parking. About 292 are killed and 18000 are
injured every year due to accidents caused because of poor
Key words: algorithm, contour, distance, image, monocular, visibility during backing up the vehicles, says CBS News in
pixels (per width). Oct 2013. These are termed as ‘back-over’ accidents. The main
motivation of this paper is to formulate an “easy to implement”
I. INTRODUCTION and affordable technology solution for the ever increasing
All the intelligent parking assist systems (IPAS) now-a- accident rates during parking or even while driving. The same,
days use sophisticated algorithms to estimate the distance. when implemented in the front of the vehicle can avoid
Methods like SONAR involve usage of multiple sensor crashes. The problem that we are addressing is to estimate the
networks and a camera for the driver's comprehensibility. distance using a single camera.
These are difficult to implement, complex to fix them in the The proposed algorithm helps in developing less
vehicles and are less ergonomic. Alternatively, we can have a sophisticated applications of computer vision to avoid fatal
single camera which can detect the objects and its distance accidents and loss of lives which could be a simple
from the vehicle (its camera). The data so obtained can be used technological solution. Using this algorithm we can detect an
to avoid collisions and fatal accidents. Cameras project our object in a particular image and estimate the rectilinear distance
typical 3-D world onto a 2-D image and using image between the camera and object. To achieve this, we input the
processing algorithms we can bridge this gap between 2-D and approximate width of the object and the calculated focal length
3-D world. This approach brings in a lot of scope for distance of camera (in terms of pixels), such that the program outputs
estimation and might change the way we interact with the the distance. The distance that we get here is in the same units
computer. of the width of the object. This could be used for identifying
Stereo vision is a close competitor in terms of accuracy. the distance of the tailgating vehicles while driving and finding
But monocular distance measurement has a better range and is the distance of the objects while backing up or parking in
less difficult to implement. Like all the methods that are used parking lots.
for distance measurement it has its own disadvantages which
III. RELATED WORKS namely “detection of object” and “estimating the distance”.
Many researchers have worked on distaance estimation or The procedure for detecting the ob bject can be explained as
depth estimation of an object from the sourcce, using camera, follows: To find the distance of thee object, primary step is to
over the years with stereo vision which requiires two cameras. detect the contour surrounding the desired
d object. For this we
A variety of techniques, methods and algorrithms have been need to get a perfect vision of the im
mage. To obtain this we had
developed in the due course. This finds appplication in wide converted the image to grayscale an nd removed high frequency
range of areas: intelligent transportation systemms, robotics, face noise by blurring the image and th hen detect the edges of the
identification, location estimation, object trackking etc. Distance gray-scaled blur image. Now it’s easy to find the largest 4 –
estimation using camera orientation compensaation technique is point contour, here we made an asssumption that contour with
presented in [1] for assisting the driver as ppart of intelligent largest area encloses the desired objject to which we are going
transportation systems. A method is proposeed to compute the to find the distance.
homography to compensate for the unnwanted camera
orientation misalignment. A single cameraa based distance
estimation is discussed in [2] which uses two convex mirrors
which imitate the use of two cameras. While the authors claim
that it increases the accuracy of the disparity m
map in computing
the distance, usage of two convex mirrorrs might not be
comfortable for all applications. A frequencyy domain analysis
based algorithm is presented in [3] which uses single camera.
But a lot of testing is required to validate the claim by the
authors that their methods provide accurate distance estimation.
An algorithm that can be used for detectingg multiple vehicle
distances in telematic systems is proposed in [4]. Face distance
estimation using single camera [5], color shhift model based
computational camera [6], inverse perspectivve mapping using
single camera [7] for distance estimationn, camera based
velocity estimation with height compensaation in robotic
application [8] etc. are available for the researrchers to carry on
their work.

IV. DESIGN AND IMPLEMENTATTION


The Figure 1 represents the main conntrol flow of the
camera-object system. The pinhole cameera provides the
necessary input (image) to the system. The said input
undergoes a series of processes to ultimately detect the desired
object and also estimate the distance of thee object from the
camera. The algorithm is designed in such a way that as soon Figure 2: Flow Chart for im
mage detection
as the program is executed, and images are feed as input, using
inbuilt functions, image is first converted to grreyscale, after the The main algorithm can be drawn d as the flowchart as
evaluation of focal length. This grey-scaled image is blurred shown in figure 2. It basically deescribes the steps that the
using Gaussian blur to remove unwaanted frequency system takes and gives the reequired output. Our key
components. Now we find out all possible eedges, that is, all assumption is that the largest possible contour is the object.
frequency transitions and keep the largest possible 4-point The consequences of this assumptio on are discussed in a later
contour or edge as the object we wish to dettect. Then we use stage. Any other technique to detectt the contours of our object
method of similar triangles to determine thee distance of that of interest can be used. The main requirement
r here is to find
particular contour from the camera. the object's width in the image in term
ms of pixels.
Figure 2 explains the flowcharrt or the steps taken by the
system while executing the algorithm
m. Now we have planar co-
Image
ordinates of the contour. We use thhe similarity of triangles to
Focal Length Edgee
Estimation
Conversion to
Detectio
on approximately estimate the distancee of object from camera as
Gray Scale
explained.
Pin Hole Distance
Camera Estimation

Gaussian Contou ur
Sample Image Filtering Eliminattion

MPU

Figure 1. Architectural Diagram of the Propoose System

Figure 1 explains the basic control flow


w in the proposed
system. Essentially the entire process consiists of two steps
Table 1: Focal Length for variious object Widths

Distance Focal Focal Focal Row Wise


(in Feet) Length(in Length(in Length(in Avg.
pixels) pixels) pixels)
Width= Width= Width=
1inch 2inch 3inch

2 1124.98 1039.63 1047.38 1069.63

3 1196.15 1116.52 1114.63 1142.43

4 1091.33 1112.84 1130.06 1111.41

5 1182.99 1081.42 1085.91 1116.77

6 1159.17 1098.22 1109.53 1122.30

Column 1150.92 1089.72 1097.52 1112.58


Wise (Final
Avg. Focal Ln.)

The data in Figure 1 can be more m clearly analyzed by


representing it in a plot as shown in Figure 4.

Figure 3: Triangle Similarity Methodd

Figure 3 illustrates the experimental seetup and explains


the method for distance calculation using trriangle similarity.
From the above formula we can find the distaance of the object.
But focal length is unknown. There are manyy methods to find
the focal length of a camera. The most used method involves
calibrating the camera using a images of a chessboard (or a
similar object) captured by camera at from vvarious angles of
inclination at x, y, z planes. Elucidation oof this method is
beyond the scope of this paper. This methodd is too technical
and cumbersome.
A simpler work around is to check for the specifications
sheet of the camera or the EXIF data of an iimage taken from Figure 4: Graph showing variations in focal length for various widths
the camera. However, these methods are nott applicable to all
the cameras. Figure 4 shows the plot for focal lengths obtained at
various widths. From the above plott, it can be inferred that the
Therefore we use the same triangle sim milarity method to calculation of focal length gets morre accurate as the width or
find the focal length. To do this, we need to knnow distance of the object increases. Forr a 1 inch wide object, the
The distance of the camera from an object.. focal length varies highly with the final focal length till a
distance of 4 feet. Also, the variations in focal length achieved
The width (here inches) of this object. using 2 inch and 3 inch wide objeects can be ignored, as the
Here we took 3 pictures at different diistances from the maximum variation is less than 100 0 pixels. Since the practical
camera in order to use them for calibratioon process. Focal applications involve objects of width greater than 5 inches
length can be calculated using the formula : located at least 5 feet away from the camera, this algorithm can
be used without flaws and inaccuraciies.
DTH
Focal-Length = (Wp * DISTANCE) /WID
Now we have calibrated our sy ystem and a focal length (in
Where, Wp is the width of the object inn pixels, Distance pixels) is obtained which can be useed to find the distance from
and width is known to us. the formula derived using similar triangles. The width of object
(in this case a simple black insulaation tape) is constant and
Also note that the DISTANCE and WID DTH must be in
taken to be as 1 inch. The distance is varied from 2 feet to 6
same units and not scaled by a factor. This m
method is repeated
feet in steps of 1 foot. The pictures which are shown as output
by varying the DISTANCE of an object annd the results are
are given as follows:
averaged for accuracy.
measured the obtained distance and d the error percentage and
also we have plotted a graph for the values:
v
Table 2: Results for an objecct of width 1 inch

Actual Calculated or
Erro Accuracy%
Distance Distance (Inch
hes)
(Inches) (Inches)
2 2.07 0.7 96.5
3 2.82 0.18 94
4 4.12 0.12
2 97
5 4.81 0.19 96.2
6 5.76 0.24
4 96
7 6.68 0.32
2 95.42
8 7.60 0.4 95

Figure 5 shows resultant distances for an object oof width 1 inch Table 3: Results for an objectt of width 2 inches

Actual Calculated Error


E Accuracy
Distance Distance (IInches) %
(Inches) (Inches)
2 2.12 0.12
0 94
3 2.79 0.21
0 93
4 3.74 0.26
0 93.5
5 4.82 0.18
0 96.4
6 5.84 0.16
0 97.33
7 6.76 0.24
0 96.57
8 7.72 0.28
0 96.5

Table 4: Results for an objectt of width 3 inches

Actual Calculated Errror Accuracy%


Distance Distance (In
nches)
Figure 6 shows resultant distances for an object off width 2 inches (Inches) (Inches)
2 2 0 100
3 2.92 0.0
08 97.33
4 3.71 0.2
29 92.75
5 4.89 0.1
11 97.8
6 5.91 0.0
09 98.5
7 6.82 0.1
18 97.42
8 7.79 0.2
21 97.35

Figure 7 shows the resultant distances for an object oof width 3 inches

We have tabulated the values for a range of distances


keeping width to be constant for a particular ccase. The graph is
tabulated for Width in inches versus accuraccy is plotted. We
Figure 8: Plot showing variations in acccuracy for various widths
can implicitly infer that for a larger width Avverage accuracy is
much higher for a larger width for reasoons that will be Figure 8 shows the plot for vario
ous accuracies measured for
explained shortly. It is to be noted that surrrounding lighting different widths. Possible reasons for
f deviation and non-ideal
too, surprisingly plays an important role. T The pictures were behavior is discussed here. The primmary assumption is that the
taken with ambient lighting as it is importaant for the object camera used is approximated to a pinhole.
p This assumption is
detection. Without sufficient lighting we m might not get the not necessarily true as pinhole cam mera is assumed to have a
contour we want. For a more realistic casee we assume that point sized aperture and might have distortions. The object may
sufficient lighting is available or at least make sure it is not be at the near center of the fieeld of vision (FOV) of the
available. We can tabulate the values obttained. We have camera. In such a case we cannot usse the similarity of triangles
approach. This is one of the manageable draw backs with a International Conference on Innovations in Bio-inspired Computing and
scope of rectification possible through rigorous refining of the Applications (IBICA),Pages: 9 - 12, DOI: 10.1109/IBICA.2011.7
[5] Kumar, M.S.S.; Vimala, K.S.; Avinash, N., "Face distance estimation
algorithm. The main assumption of the algorithm is that after from a monocular camera", 2013 20th IEEE International Conference on
detecting all edges, the largest possible contour is assumed to Image Processing (ICIP) Pages: 3532 - 3536, DOI:
be as the object we wish to detect. This approach is faulty as it 10.1109/ICIP.2013.6738729
might be less reliable for objects at larger distances as evident [6] Sangjin Kim; Eunsung Lee; Hayes, M.H.; Joonki Paik, "Multifocusing
by the table. This method is a rudimentary approach with a and Depth Estimation Using a Color Shift Model-Based Computational
Camera", IEEE Transactions on Image Processing Year: 2012, Volume:
very promising scope for development and can be an important 21, Issue: 9 Pages: 4152 - 4166, DOI: 10.1109/TIP.2012.2202671
area of research. However the conditions in with we might [7] Bharade, A.; Gaopande, S.; Keskar, A.G., "Statistical approach for
achieve accurate results are very much realistic. The object too, distance estimation using Inverse Perspective Mapping on embedded
must be reasonable large otherwise, a contour with a larger area platform", 2014 Annual India Conference (INDICON) IEEE Pages: 1 -
might be detected to give impertinent results. This condition 5, DOI: 10.1109/INDICON.2014.7030430
can be changed by programming .Also, as mentioned before, [8] Xiaojing Song; Althoefer, K.; Seneviratne, L., "A robust downward-
looking camera based velocity estimation with height compensation for
the choice of method used to detect the contour of the object of mobile robots", 2010 11th International Conference on Control
interest varies for different applications in which this algorithm Automation Robotics & Vision (ICARCV), Pages: 378 - 383, DOI:
is used. 10.1109/ICARCV.2010.5707269

V. FUTURE WORKS
When cost of the materials comes into play monocular
camera serves the best alternative to stereo vision. To attain our
objectives we are focusing on expanding our limitations of
selecting the contour. We have various ideas for selecting the
contour such as utilization of color of desired object and other
methods like key point detection, local invariant descriptions
and key point matching. These methods extend the limits of
finding distances in different scenarios.

VI. CONCLUSION
In this paper we have presented a method for finding a
distance of the object by using a single camera. This method is
aimed at reducing road accidents and parking area accidents
where in the driver could be warned if the vehicle is close to an
object. The results obtained when an object of width 1, 2 and 3
inches placed at a distance ranging from 2 inches to 8 inches
are satisfactory, as shown in tables 2, 3, and 4. A further
development and testing is required and as such has to be
implemented in vehicles and evaluated for real time data.

ACKNOWLEDGEMENT
We wish to thank Almighty God who gave us the
opportunity to successfully complete this venture. The authors
wish to thank Amrita Vishwa Vidyapeetham and the
Humanitarian Technology (HuT) Lab for aiding us in this
endeavor.

REFERENCES
[1] Hoi-Kok Cheung; Wan-Chi Siu,; Lee, S.; Poon, L.; Chiu-Shing Ng,
"Accurate distance estimation using camera orientation compensation
technique for vehicle driver assistance system", 2012 IEEE International
Conference on Consumer Electronics (ICCE), Pages: 227 - 228, DOI:
10.1109/ICCE.2012.6161840
[2] Murmu, N.; Nandi, D., "Low cost distance estimation system using low
resolution single camera and high radius convex mirrors", 2014
International Conference on Advances in Computing Communications
and Informatics (ICACCI), Pages: 998 - 1003, DOI:
10.1109/ICACCI.2014.6968509
[3] In-Sub Yoo; Seung-Woo Seo, "Object distance estimation based on
frequency domain analysis using a stereo camera", 2015 IEEE
International Conference on Consumer Electronics (ICCE), Pages: 343 -
344, DOI: 10.1109/ICCE.2015.7066437
[4] Shi-Huang Chen; Ruie-Shen Chen, " Vision-Based Distance Estimation
for Multiple Vehicles Using Single Optical Camera", 2011 Second

You might also like