Estimation of Object Dimension Using Image Processing: Project Team
Estimation of Object Dimension Using Image Processing: Project Team
Estimation of Object Dimension Using Image Processing: Project Team
Processing
Project Team
May– 2020
i
FACULTY OF ENGINEERING AND TECHNOLOGY
Certificate
This is to certify that the Project titled “Estimation of Object Dimension
using Image Processing” is a bonafide work carried out in the
Department of Computer Scienceand Engineeringby Mr. Segu Sai
Bharadwaj bearing Reg. No. 16ETCS002116 in partial fulfilment of
requirements for the award of B. Tech. Degree in Computer Science and
Engineeringof Ramaiah University of Applied Sciences.
May – 2020
Mr. Prakash P
Assistant Professor
ii
M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Declaration
The project work is submitted in partial fulfilment of academic requirements for the
award ofB. Tech. Degree in the Department ofComputer Science and Engineeringof the
Faculty of Engineering and Technologyof Ramaiah University of Applied Sciences. The
project report submitted herewith is a result of our own work and in conformance to the
guidelines on plagiarism as laid out in the University Student Handbook. All sections of
the text and results which have been obtained from other sources are fully referenced.
We understand that cheating and plagiarism constitute a breach of University
regulations, hence this project report has been passed through plagiarism check and the
report has been submitted to the supervisor.
iii
M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Acknowledgements
The successful completion of this project could not have been possible without the
guidance of Mr. Prakash P, our mentor, whose guidance was priceless.
We extend our sincere gratitude to everyone who guided us, cleared our doubts and
supported us throughout the project either directly and indirectly.
We humbly thank Dr.P.V.R. Murthyand Dr. M. Arulanantham for their constant,
unwavering support.
We thank our family and friends who have supported us in carrying out this project
and gave us a moral support.
Engineers and Scientists constantly build physical scientific models & need to ascertain
its dimensions. It is cumbersome to carry around measuring instruments. This problem
was the motivating factor for this project. Applying the knowledge of Image Processing
can solve this problem if one can obtain the pictures of the objects customarily using
cellphone camera.So, we intend to build a system that takes the images of objects as
input and gives their dimensions as output.
This project when implemented with a higher accuracy has a huge scope in the science
and academia. Engineers and Scientists can use it to measure their physical models,
colleges &universities can use it to grade students on the basis of their models etc.
Python programming language is used to implement the project and “OpenCV” is the
library is used to pre-process the image. Threshold and Canny methods are used to
identify the edges of the object. Then, Reference Object Method&“imutils” library is
used tofind the dimensions of the object.
Certificate ……………………………………………………………………………………………………………….…(ii)
Declaration………………………………………………………………………….……..................................(iii)
Acknowledgements……………………………………………………………..…………………………………….(iv)
Summary …………………………………………………..……………………………………………………………..…(v)
Table of Contents………………………………………….……………………………………………………..…. (vi)
List of Tables……………………………………………….………………………………………………………..…..(x)
List of Figures……………………………………………………………………………………..………………….…(xi)
Nomenclature………………………………………………………………………………………………………….(xii)
Abbreviations and Acronyms……………………………………………………………………………..……(xiii)
Chapter-1: Introduction………………………………………………………..…………..………………………01
Preamble to the Chapter
1.1 Heading 2………………………………………………………………………………………..……...02
1.2 Heading 2…………………………………………………………………………………..…………...03
Chapter-2: Background Theory
Preamble to the Chapter
2.1 Background Theory to be Written in Various Sub-Sections
(Read books and survey papers on your domain and summarize with citations)
Chapter-3:Aim and Objectives
Preamble to the Chapter
3.1 Title of the Project
3.2 Aim of the Project
3.3 Objectives of the Project
3.4 Methods and Methodology
Chapter-4: Problem Solving
Preamble to the Chapter
A Acceleration (m/s2)
F Force (N)
T Temperature (K)
t Temperature (oC)
N Speed (RPM)
DOF Degrees of Freedom
W Track Width (m)
1. Introduction
Science is not a 21st century thing but can be dated back to 3500 to 3000 BCE
(Lindberg&David 2007). Scientists and Engineers have adopted various methods to
research from a very long time and building physical models is one of them. Measuring
the dimensions of these models is a crucial task and has to be done with utter care.
Colleges, Universities and other educational institutions also make students build
models and often need to grade them based on their models by measuring them.
Accurate measurements are necessary only in certain fields or domains. For example, a
carpenter who is building thigs using wood needs a precision of say 0.5 mm. If the
accuracy is reduced significantly, the furniture built would be terrible. But 0.5 mm
precision is totally insignificant for more sophisticated domains like building a car engine
or other parts. Now the precision needed boils down to 0.01 mm or less.
So, a lot of experimental physicists are focused on measuring things more accurately,
discovering new things and confirm theoretical ideas. This important task of measuring
has led to the development of sophisticated measuring devices. Tons of Nobel prizes
were awarded to essentially better measurements, e.g., Rudolf Mössbauer, Albert
Abraham Michelson, Polykarp Kusch etc.
1.1 Motivation
Often, teachers and professors have to measure models of hundreds of students and
grade them accordingly which is both tiring and prone to errors. There is a huge need of
using technology to automate this task. The reason is that to grade students in a
university, the precision required resembles precision for woodworking mentioned
earlier and the accuracy obtained by automating the task also resembles the precision
1
M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
needed for the task. This gives a major reason to go ahead with the idea of developing
such tool.
If such a tool is developed it will not only help the academia industry but other common
and day to day tasks that people carry out. The developed tool would aid
1.2.1 Pretext
The standard measuring devices and tools may be sophisticated but there are errors
while measuring due to various reasons varying from instrumental errors to human
errors. Also, carrying these instruments around is cumbersome. Even if the device is
somehow disassembled and carried, some of these devices are complex in structure and
takes good amount of effort and expertise to set up.
This amount of effort can be put up but only for situation where high precision and
accurate measurements are needed. There are domains where not so accurate
measurements are not needed like woodworking as mentioned earlier. There are many
other such domains where not so precise measurements are not required yet there is a
need to buy these fancy measuring devices and carry them around.
The project has a very good scope in the field of academia which was the major initial
motivation.Schools, Colleges and Universities can opt to use this tool. A customised web
or mobile application can be designed using the current project as an interface if
needed. The teachers and professors can use that tool to analyse the models of the
students and get its dimensions with just a digital image(picture) of the models.
The developed tool is not only restricted to schools and colleges. Any domain where
objects have to be measured can use the tool. The only criteria for using it would be the
The usage and scope of the project increases with the increasing accuracy that the
developed tool provides. There is a huge need for such tool in the world and with high
accuracy the tool can even be used in science for experimenting and measuring scientific
models.
The goal here is to find the dimension of the object using its image. To do this there has
to be asystem that manipulates takes the image as input, uses mathematical operations
and does computations to give the dimensions of the object in the image as output. In
order to do to this, there has to be a technique using which we can extract information
from images and use the data for further computations. This can be done using Image
Processing. Specifically, Digital Image Processing deals with such problems.
The field of digital image processing has become widespread and is used extensively as
possible. Applying this knowledge to solve the problem at hand can solve it one and for
all. Open Source programming languages like Python have lots of image processing and
manipulation libraries like “openCV”, “imutils”, “simpleCV”, “scikit-image”, “pillow” etc.
There are various research papers which gives mathematical insights that are in line with
the objectives of the current project and using all these resources the project is built.
Each of the chapters along with its short summary is given in table 1.1.
Digital Image Processing has become widespread in the recent times due to the advent
of the sophisticated smartphone cameras. Large number of people use Image Processing
in their daily life either directly or indirectly when they take selfie and apply filters to it,
crop a picture or increase its brightness, contrast or photoshop themselves with their
favourite celebrities!
2.1.1 Depth and Geometry from a Single 2D Image Using Triangulation(Saliah& Malik,
2012)
In ths paper, the authors present a novel method for computing depth of field
and geometry from a single 2D image. The presented technique, unlike the ones
that existed at the time of publishing the paper, measures the absolute depth of
field and distances in the scene from single image only using the concept of
triangulation. The algorithm devised by the authors requires minimum inputs
such as camera height, camera pitch angle and camera field of view for
computing the depth of field and 3D coordinates of any given point in the image.
In addition, the presented method can be used to compute the actual size of an
As shown in figure 2.1, the paper takes into account how the cameras are set up
and uses basic principles of physics pertaining to triangulation to compute the
size of the objects.
As shown in figure 2.2, the devised algorithm can be used to measure targets
such as a human being itself and gives results with good precision. The proposed
methodology, according to the authors,can be implemented in high impact
The same process is done with another object, say a cube or another
doorway.Then a similar step is carried out but in backwards.The object is
photographed, the distance to the object measured, and then the scene is
Then, the scale of the cube is adjusted until it matches the photo, and the
resulting scale is the measurement.
That window that the author measured is 77 inches tall and the camera method
measured ~79 inches. That is 2.5% inaccuracy. The blog gives some more
implementation ideas which is beyond the scope of this report and thus not
mentioned here.
2.1.3 A fast and accurate approach for computing the dimensions of boxes from
single perspective images(Fernandes et al., 2006)
This paper describes an accurate method for computing the dimensions of boxes
directly from perspective projection images acquired by cameras. The approach
is based on projective geometry and computes the box dimensions using data
Figure 2.4Illustration of proposed method using lasers and contour segmentation (Source:
http://www.scielo.br/pdf/jbcos/v12n2/03.pdf)
In order to identify the box silhouette, the authors have developed a statistical
model for homogeneous-background-colour removal that works with a moving
camera, and an efficient voting scheme for the Hough transform that allows the
identification of almost collinear groups of pixels.
2.1.5 Single-image shadow detection and removal using paired regions(Guo et al.,
2011)
In the current paper, the authors address the problem of shadow detection and
removal from single images of natural scenes. The methods used in the paper are
different from traditional methods that explore pixel or edge information. This
paper employs a region-based approach. In addition to considering individual
regions separately, the authors predict relative illumination conditions between
segmented regions from their appearances and perform pairwise classification
based on such information.
Conducting literature survey about the previous research and projects that focused on
similar theories gives immense insight on the project that is being carried out and gives
an opportunity to introspect the requirements. Such surveys many times makes the
researcher realise that similar projects that can satisfy the requirements already exist
and can be used freely to solve the problem.
Title
Objectives
requirements
The FRs and NFRs are identified for the system and feasibility of the
requirements are analysed. On careful analysis, it can be concluded that the
requirements identified for the system is feasible and implementable.
1.3 : Design
There are various dependencies in the FRs identified for the system. In order to
build the system as per the requirements, a proper flow of the tasks needs to be
designed.
A flowchart is designed representing the flow of the system shown in Figure 4.1.
The flow here represents a high level design which is just a simple design
representing the system overview. It starts with providing an image to the
system, which is pre-processed before proceeding with finding edges and the
dimensions of those edges. The dimensions are then finally output to the user.
Choice of libraries/tools:
OpenCV is one of the most widely used libraries for computer vision applications.
OpenCV-Python is not only fast, since the background consists of code written in
C/C++, but it is also easy to code and deploy (due to the Python wrapper in the
foreground). This makes it a great choice to perform computationally intensive
computer vision programs.
Alongside OpenCV, other libraries like Numpy, imutils and distance are used for
other calculations in the system.
1.5.2 Blurring:
The object whose dimension is to be found need not always have a
clear surface. Especially in cases where the blocks provided in
mechanical workshops, which are so often prone to rust and often
comes with irregularities. Various methods are available to blur an
image like simple blur, Gaussian blur, Median blur, et cetera.
1.5.3 Thresholding:
The image input to this is a grayscale image with each pixel value
between 0-255. It basically sets each pixel to 0 if the pixel value is below
a threshold and 1 if it is above the threshold, thereby producing a
binary image. The problem with common thresholding methods like
adaptive threshold, binary thresholding is that threshold value varies
with images. However, Otsu’s threshold technique provides a way to
dynamically determine the threshold value for each image which is used
here.
1.7 Testing:
5. Results
Figure 5.1 showing real dimensions of our reference object (a standard Indian
one-rupee coin) which is 24.97 mm
Figure 5.2 showing real dimensions of a product which was developed in an industry we
visited (i) its length was 99.71 mm (ii) its breath was 24.55 mm and (iii) diameter of hole
is 7.99 mm
Now, an image of this product next to our reference object (standard Indian one-
rupee coin)was taken with a phone (Xiaomi Mi A2) camera holding it in our bare hands.
Figure 5.3 the input image given to our developed python program
Figure 5.4 showing the stages of preprocessing done on the input image (i) image after
converting it to grayscale (ii) image after blurring the grayscale image (iii) thresholding
the blurred image (iv) identified edges of threshold image
Figure 5.4 in this location of the image to be uploaded and width (in this case diameter
of one-rupee coin) of reference object is given as prerequisite
Figure 5.5 showing that our reference object is identified from the image given
Figure 5.6 output image showing the length and breadth of the object in mm,length is
shown as 103.13 mm and breadthis shown as 24.62 mm (considering the closest values)
Figure 5.7 output image showing diameter of hole drilled into our object in mm,
diameter is shown as 8.38 mm
Table 5.1 comparing the real dimensions and dimensions obtained from output image
Figure 5.8 the image taken exactly perpendicular to the object (piece of
paper)shows its original shape as a rectangle
Figure 5.9 the image taken with some angle to the same object (piece of paper)
shows that the rectangle shape is now somewhat looking like trapezoid
Our main objective in this project was to find approximate dimensions of objects
just by using simple image clicked from our smartphone and using some image
processing methods available which, we have done with accuracy level of nearly,greater
than or equal to 94 percent as depicted in table 5.1
In this part of the report final conclusions are drawn for our project work and also
discuss some methods to improve our accuracy in measuring the dimensions of object.
After going through some of the research papers and some articles based on
image processing,many possible ways to calculate the dimensions of object from an
image were found. Two of them were very easy and efficient to implement, one was to
know the focal distance between the object and the camera while taking the image and
focal length of the lens of camera being used to take the image beforehand, using this
data the dimensions of the object can be calculated by some simple knowledge on
trigonometry.In another method, (the one which is chosen for this project work)while
taking the image of an object to calculate its dimensions a reference object should also
be present in that image whose dimensions are known beforehand and now by knowing
this one can calculate the number of pixels occupied within that specified dimensions of
reference object leading to PPM ratio using which the dimensions of the object are
calculated and given as output.
OpenCV, imutils and scipy are the most necessary libraries in the project.
OpenCV library was used in the project for pre-processing of the input image, imutils
library was used to find the contours from the pre-processed image and finally scipy
library was used to find the Euclidean distanceof each edge identified from the image.
Now, after dividing this distance with already calculated PPM ratio gives the dimensions
of the object.
Appendix
Appendix-A
Any material, which is important but affects the flow of your writing can be brought
under Appendix.