Estimation of Object Dimension Using Image Processing: Project Team

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 61

Estimation of Object Dimension using Image

Processing

Project Team

Sl. No. Reg. No. Student Name


1. 16ETCS002116 S. Sai Bharadwaj

Supervisor: Mr. Prakash P

May– 2020

B. Tech. in Computer Science and Engineering


FACULTY OF ENGINEERING AND TECHNOLOGY
M. S. RAMAIAH UNIVERSITY OF APPLIED SCIENCES
Bengaluru -560 054

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

Dr. P.V.R. Murthy Dr. M. Arulanantham


Professor and Head – Dept. of CSE Professor and Dean-FET

ii
M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Declaration

Estimation of Object Dimension using Image Processing

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.

Sl. No. Reg. No. Student Name Signature


1. 16ETCS002116 S. Sai Bharadwaj

Date: 08 May 2020

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.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Summary

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.

 Highlights of the project based on analysis and conclusions drawn


<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Table of Contents

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
(Title this Chapter as applicable to your work)
1. Design, Simulation and Implementation/Data Collection, Modelling and
Simulation
2. Testing
3. Analysis
Chapter-5: Results
Preamble to the Chapter
Chapter-6: Project Costing
Chapter-7: Conclusions and Suggestions for Future Work
Preamble to the Chapter
References
Appendices<Font: Calibri, 12>

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
List of Tables

A typical List of Tables content page looks like this


<Font: Calibri, 12>

Table 1.1 Title of the table……………………………………………………10


Table 2.1 Title of the table……………………………………………………14


Table 5.1 …………………………………

How to represent a table:


Table number, Table title, Units of the parameters are important
Table 2.1 Enthalpy of formation of some common elements and compounds

Sl. No. Species Reaction State

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
List of Figures
________________________________________________________________________

Figure 1.1 Title of the figure……………………………………………………..11


Figure 1.2 Title of the figure………………………………..
Figure 1.* …………………………………………………………..
Figure 2.1 ………………………………………………………….
Figure 3.1 …………………………………………………………
Figure 4.1 ……………………………………….

How to represent a figure

Figure 2.7 Levels of functionality required for control systems

<Font: Calibri, 12>

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Nomenclature

A Acceleration (m/s2)
F Force (N)
T Temperature (K)
t Temperature (oC)
N Speed (RPM)
DOF Degrees of Freedom
W Track Width (m)

<Font: Calibri, 12>

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Abbreviation and Acronyms
________________________________________________________________________

DIP Digital Image Processing


FR Functional Requirements
NFR Non-Functional Requirements
PPM Pixel Per Metric
mm Milli meter
(To be filled in alphabetical order)

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

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 Introduction to the problem

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.

1.2.2 Scope of the project

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
amount of accuracy that the domain expects from the tool. If the accuracy of the tool is
nearly same as the precision required for measuring objects in the particular domain,
then it can be readily used in those domains. Some common examples are warehouses
where the dimension of the package or object have to be measured, construction
industry where the height of the structure has to be measured etc.

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.

1.2.3 Development of solution

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.

1.3 Organization of the report

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
The report is organized into different chapters where each chapter explaining one part
of the project. When the reader finishes the whole report, they will have a clear and
intuitive understanding of what the project is, what are the previous research works
around it, how it is designed, the implementation, how the system is test and analysed
and suggestions for the future work.

Each of the chapters along with its short summary is given in table 1.1.

Table 1.1Summary of all the chapters in the report


Sl. No Chapter Title Summary
1. Introduction The first chapter introduces the problem at hand to the
readers. Motivation for the project, pretext, scope of the
project and short explanation about development of the
solution is given. At the end, this chapter contains the
organization of the report which had a short summary of
every chapter in the report.
2. Digital Image DIP is the main concept using to implement the solution
Processing that is proposed to the problem at hand. This chapter
contains various programming languages and tools that
can be used to implement DIP, various libraries in the
chosen programming language (Python), scholarly
documents which aids the project along with citation.
3. Aim and The title, aim and objectives of the current project is
Objectives explained here. The Methods and Methodologies that
are adopted to satisfy the objectives are also explained in
this chapter.
4. Problem solving This is the core part of the report. In this chapter, the
design of solution is drafted, the explanation to the
actual implementation is explained along with testing the
end product. This chapter contains the code that is

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
developed to solve the problem.
5. Results In this chapter, the results obtained after implementing
the project and testing is explained along with suitable
explanations. Inference is drawn as to where the system
can be used with the amount of accuracy obtained in the
result.
6. Project costing The total amount of investment that is done on the
project during the course of development is given here.
7. Conclusions and Final thoughts on the project from the team and
Suggestions for suggestions for future work on the same project on how
future work to improve the results is mentioned here.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

2.Digital Image Processing

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!

In computer science, Digital Image Processing is the use of computer algorithms to


perform image processing on digital images (Chakravorty 2018). An image is a two-
dimensional signal defined by the mathematical function f (x, y) where x and y are the
two co-ordinates horizontally and vertically. The image which is a mathematical function
is manipulated using mathematical operations so as to change its structure or derive
some useful information from it.

2.1 Background Theory/Previous works

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
object in the scene (width and height) as well as the distance between different
objects in the image.

Figure 2.1Typical camera setup for surveillance cameras (Source:https://urlzs.com/6Z1g )

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.

Figure 2.2 Capturing the image of the target (Source: https://urlzs.com/p4gP)

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
applications such as distance measurement from mobile phones, robot
navigation and aerial surveillances.

2.1.2 How to measure the size of an object using a camera(Johnson 2010)


This article is published in a blog written by Forrest Johnson. The author wanted
to do a fun project of measuring some object but was reluctant to climb up and
measure it.Thus, the author undertook this project.
The author took a picture of something that is measurable and then made a
version of that situation in Unity. The camera is placed at a set distance away
from the doorway and then the image is taken. Then the dimension of the
doorway and distance to the camera is measured which is illustrated in Figure
2.1.

Figure 2.1 Capturing the image of the target (Source: https://urlzs.com/p4gP)

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
reconstructed inside unity with the photo as a background and a cube
representing the object of interest.

Figure 2.2Reconstructing the scene inside unity (Source: https://urlzs.com/Pq5p)

Then, the scale of the cube is adjusted until it matches the photo, and the
resulting scale is the measurement.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 2.3Measuring the dimension of the house (Source:https://urlzs.com/gUuL)

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
extracted from the box silhouette and from the projection of two parallel laser
beams on one of the imaged faces of the box.

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.

The paper demonstrates the effectiveness of the proposed approach by


automatically computing the dimensions of real boxes using a scanner prototype
that implements the algorithms and methods described in the paper.

2.1.4 Edge detection using Image Processing (Meysenburg 2016)


In the current article, he author has explained how to use OpenCV functions to apply
edge detection to an image. In edge detection, the boundaries or edges of objects in
an image are found by determining where the brightness of the image changes
dramatically. Edge detection can be used to extract the structure of objects in an
image. If interested, one can also get information about the number, size, shape, or
relative location of objects in an image. Edge detection all enables focusing on the
parts of the image most helpful, while ignoring parts of the image that will not help
in the process.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
For example, once the edges of the objects in the image is found (or once we have
converted the image to binary using thresholding), that information can be used to
find the image contours. This procedure is explained in the article by the author.
With the contours, one can do things like counting the number of objects in the
image, measure the size of the objects, classify the shapes of the objects, and so on.

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.

Figure 2.5 Illumination relation graph (Source:


http://dhoiem.web.engr.illinois.edu/publications/cvpr11_shadow.pdf )

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Classification results are used to build a graph of segments, and graph-cut is used
to solve the labelling of shadow and non-shadow regions. Detection results are
later refined by image matting, and the shadow free image is recovered by
relighting each pixel based on our lighting model. We evaluate our method on
the shadow detection dataset given by Jiejie et al., 2010.

2.2 Inference drawn from previous works

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.

 Need to discuss related work at start to set scene


 Principles and Assumptions
 Understanding of key definitions and its implications
 Standard Formulae, units and relation between important parameters
 Merits, Demerits and Applicability
 Relative comparison with peripheral topics
 Need to discuss related work at end to demonstrate your originality

<Font: Calibri, 12>

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
3. Aim and Objectives

Preamble to the Chapter

 Title

 Development of a system to estimate the object dimension using Image


Processing
 Aim
 To develop a system to estimate the dimensions of a given object using
Image Processing techniques

 Objectives

 To conduct literature survey on image processing, depth and geometry


prediction using triangulation
 To analyze the literature survey and derive the requirements for building
system to find the dimensions of an object in an image
 To design a mathematical model for depth analysis and to measure
dimensions of an object
 To implement the designed mathematical model using appropriately
chosen programming languages and tools
 To test and validate the system built for different cases considered and
incorporate necessary changes
 To document the report by unifying all the results and outcomes

 Methods and Methodology/Approach to attain each objective

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Table 3.1 Methods and Methodologies adopted to satisfy the objectives of the
project

Objective Statement of the Method/ Methodology Resources Utilised


No. Objective

1 To conduct literature To conduct literature


survey on image survey on
- Parallax method to
processing, depth and
compute the
geometry prediction dimensions of object
using triangulation when the viewpoint
changes
- Reference object
method, scale of
areference object
tocompute the
dimensions of the
object
- Image pre-processing
and processing,Object
Segmentation in
animage

2 To analyze the - Compare different


literature survey and methods found in the
literaturesurvey to find
derive the
the dimensions of the
requirements for object in animage
building system to - Based on the analysis,
find the functional and
find the dimensions of
non-
an object in an image functionalrequirement
s
- Check feasibility for
the identified

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

requirements

3 To design a - A high-level block


mathematical model diagram is designed to
identifyprimary
for depth analysis and
functionalities of
to measure thesystem
dimensions of an - A mathematical model
to compute the
object
dimensions from a
theoretical aspect is
built
- A low-level block
diagram is then
designed to represent
the functions that
inputs an image,
processes the image,
separates the object
from background and
outputs the
dimensions of the
object

4 To implement the - Identify the


designed appropriate
programming
mathematical model
language and
using appropriately tools(mostly free
chosen programming and/or open source)
to use based on
languages and tools
thedesign and
requirements
- Develop system that
accepts an image as

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

input, processes it,


identifies various
objects in it, compute
and returns the
dimensions of the
object

5 To test and validate - The system built will


the system built for be tested for different
cases and find
different cases
exceptions
considered and andanomalies
incorporate necessary - Unit test, integration
and functional tests
changes
will be made to ensure
the product works well
in different
layers/levels
- Comparison is made
between the actual
dimensions of
anobject and the
dimensions given by
the system
- The errors and the
functionality test case
failures (if any) are
identified and changes
are incorporated

6 To document the - A report will be made


report by unifying all illustrating the need
for the project,
the results and
introduction of the
outcomes project and the related

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

works in this domain


so far
- The various designs
made,
implementation,testin
g and results are
reported
- Demonstrate the
working of the product
built with sample
image as input to the
system
- The performance is
compared with other
existing models and
efficiency, error rate is
reported

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
4. Problem Solving

Preamble to the Chapter


This section of the report discusses the design and implementation of the project.
Initially, the system overview, modelling of the system and assumptions are discussed.
Later in this section; choice of programming languages, tools, testing and analysis of the
implementation is discussed.

4.1 System Overview:


The input for the system being built is a raw image with a clear background with
a standard object towards the left of the image. Pre-processing of the image is
then done which helps in identifying the objects in the image and computing the
dimensions. A standard reference model towards the left of the image is
significant here. Since the dimensions of the standard model is known, the size of
the standard model is computed and other objects are scaled with the same ratio
as the reference model. Finally, the dimensions of the other objects are made
available to the user.

1.2 Functional and Non-Functional Requirements:


The Functional requirements (FRs) and the Non Functional Requirements (NFRs)
are identified before the design phase of the system is identified.

Functional Requirements for the system are:

FR1: System should read the image given as input


FR2: System should identify the objects from the imageread
FR3: System should identify all the edges for objects present in image
FR4: System should identify corners for each edge of each object in image

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
FR5: System should calculate dimensions of each edge of these objects,
Euclidean distance in the image
FR6: System should calculate the approximate dimensions based on dimensions
of reference object
FR7: System should produce an image as output showing the identified edges
and dimensions of input image

Non-Functional Requirements for the system are:


NFR1: System shall produce the output image accurately and quickly
NFR2: System shall take input image of any size
NFR3: System shall be available in any platform to be executed
NFR4: System shall allow only one image as input with any number of objects in
it

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.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 4.1 High Level Block Diagram


While the high level design represents an abstract overview of the system, it is
less helpful to begin the implementation with this flowchart. The high level
design shows pre-processing of the image. However, it does not tell anything
about what needs to be done. Therefore, a low level block diagram is designed
which will aid in the implementation phase. The low level design is shown in
Figure 4.2.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 4.2 Low Level Block Diagram

1.4 Choice of programming language and tools:


A proper programming language and libraries/tools has to be chosen considering
various parameters like project-cost, efficiency, simplicity, performance, et
cetera.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Choice of programming Language:

Three programming languages; Python, C++/C#, Matlab, come very close


considering different parameters for image processing.
Python is free-to-use with well-defined libraries like OpenCV, SimpleCV, scikit-
image, et cetera. Matlab needs a license which would increase the project cost.
Both the languages are comparable in terms of performance as both are based
on dynamic programming which involves fast coding and slow processing. The
cost factor puts Python on the top.
Python code, generally, is slower than C++. But for the modules needed in this
project, OpenCV, it is quite different.Python’s OpenCV is just a wrapper around
the original C/C++ OpenCV code. So when a function is called in OpenCV python,
the underlying C/C++ code runs. So, the performance is the same. However,
Python brings in simplicity and portability.
Hence, Python is chosen as the programming language to build the system.

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.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
1.5 Image processing techniques:
The image processing techniques used in the system are listed below:

1.5.1.1 Conversion to Grayscale:


It is done since it is very efficient to apply thresholding on a grayscale
image. Otherwise, the RGB values of a pixel has to be compared with a
threshold tuple of RGB values. This is not an efficient way. Hence, it is
converted to grayscale. Also, contouring works best with black and
white images which is a result of thresholding. Conversion to grayscale
is accomplished using the method from cv2 (OpenCV) library.

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.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

1.5.4 Canny edge detection:


The objects are identified, but for further processing only the outline of
the objects is needed. Canny edge detector method in OpenCV provides
this functionality.

1.5.5 Dilation and Erosion:


Dilationand eroding of the image is done which helps in closing in on
minute gaps and approximatingDilation adds pixels to the boundaries of
objects in an image, while erosion removes pixels on object boundaries.

1.5.6 Getting the contours:


After all the pre-processing is done, the contours are detected from this
image. This is done using the function cv2.findContours provided by the
OpenCV library. These contours are then sorted from left to right. In this
process, smaller contours representing the noises are ignored.

1.5.7 Check for convexity:


A few contours may have a few edges not properly recognized, say the
edge of a square is cut and pushed inwards. The convexHull function in
OpenCV fixes this and provides a proper square.

1.5.8 Approximating the polygon:


The contours determined thus far has far too many vertices, which
might just differ by a pixel or two. All these unwanted vertices must be
removed and this done using the approxPolyDp method provided by
OpenCV. This approximates a polygon using the Ramer-Douglas-

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Peucker algorithm. It then returns a list of vertices that represents an
object in the image, using which dimensions are then computed.
1.6 Implementation:

Figure 4.3 – Implementation of preprocess.py

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 4.4 – Implementation of preprocess.py - 2


The preprocess.py module here does all the pre-processing of the image. It
inputs the path of the image, reads the image, converts to grayscale, blurs it and
binarizes the image which helps in object segmentation. Edges are identified in
this image using Canny edge detection method, which is followed by dilation and
erosion of the image to yield better results.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 4.5 – Implementation of findDimensions.py

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 4.6 – Implementation of findDimensions.py – 2

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 4.7 – Implementation of findDimensions.py – 3


The findDimensions.py module takes in the binarized image from preprocess.py
and finds the contours in it. For each contour identified, it is approximated to a
polygon and its vertices are noted down. Euclidean distance between
consecutive vertices are determined and scaled to the pixels per metric (PPM)
ratio. PPM ratio is the ratio of actual dimensions of the reference object to its

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
dimension computed by the system in the image. The dimensions are then
displayed on the image.

Figure 4.8 – Implementation of dim.py


The dim.py module integrates the pre-processing and finding the dimension
functionality into one and the whole code is made available as a package named
“Final”.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 4.9 – Implementation of User.py


The User.py module is the python code which the end-user has to run on the
terminal. The user has the run the python file with the image path and width of
the reference object as arguments. These arguments are parsed and sent to
dim.py

1.7 Testing:

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Tes Descriptio Input Expecte Actual output Resul
t n d t
Cas Output
e
1. Conversio Colour A Pass
n to Image grayscal
grayscale e image

2. Blur the Grayscal Blurred Pass


image e image
image

3. Binarize Blurred Complet Pass


the image image e black
and
white
image

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Test Description Input Expected Actual output Result
Cas Output
e
4. Canny Threshol Image with Pass
edge d image edges of
detection objects

5. Dilation Edge Enhanced Pass


and detected edges
Erosion image

6. Get the Image Objects Pass


contours with with
edges contours
detected around it

Test Description Input Expected Actual output Result


Cas Output

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
e
7. Show Image Object Pass
dimensions with with its
of objects edges dimensions
detected

Table 4.1 Unit test cases


1.8 Analysis:
The different image processing techniques discussed in Section 4.5 are significant
in the process of estimating the dimensions of the object in the image. The
results produced are image dependent. The better the image, better results are
given. It is as good as the image. The main criteria is that the image should be
taken from a 90° from the plane containing the objects. Also, the background
should not have any edges and must be distinguishable from the object easily. All
these would lead to better results and improve the efficiency. The whole code is
made available as a package, so the user has to just run one file and pass
arguments to get results.

5. Results

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
In this part of the report results are shown i.e., output of our developed python program
is shown when an image given as an input.

Many industries develop products everyday which have dimensions and


dimensions of these products are to be measured by hand in most of the industries, for
each product developed. They use very high precision Vernier calliper or ball micrometre
to measure dimensions of these products.
After visiting an industry where such products are developed,for a reference
their high precision measuring instrument was used to measure one of their product’s
dimensions. The actual real-world dimensions of the product are shown in below images
(All dimensions shown in images are in mm)

Figure 5.1 showing real dimensions of our reference object (a standard Indian
one-rupee coin) which is 24.97 mm

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

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.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 5.3 the input image given to our developed python program

This image undergoes pre-processing where it will be converted to grayscale,


grayscale image is then blurred now this imageundergoes thresholding where
background is separated from the objects and then edges are detected after
thresholding is done.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
After the above preprocessing is done to the image,program identifies the
leftmost object in the image as a reference whose real dimensions are already known
and given as input to the program.

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
Based on given dimensions of reference object pixels per metric ratio is
calculatedfrom this ratio approximate dimensions of object in input image are calculated
and shown in an output image

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)

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Figure 5.7 output image showing diameter of hole drilled into our object in mm,
diameter is shown as 8.38 mm

Real Output dimensions Difference Accuracy


Dimensions (from image processing)
99.71 mm 103.87 mm and 103.13 mm 4.16 mm and 3.42 96.3 %
mm
24.55 mm 24.62 mm and 25.20 mm 0.07 mm and 0.65 98.5 %
mm
7.99 mm 8.38 mm 0.39 mm 95.3 %

Table 5.1 comparing the real dimensions and dimensions obtained from output image

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
While taking the image to find the dimensions one should make sure the camera
lens is facing exactly perpendicular if not the result i.e., the dimensions obtained will not
be so accurate. This will be explained briefly by showing some sample images.

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
From the above images shown one can conclude that shape of the objects
appears different from different angles similarly in images they look like both have
different dimensions though being the same object in both the images

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

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
<Heading-1: Calibri, 16>
6. Project Costing

Preamble to the Chapter

<Font: Calibri, 12>

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
7. Conclusions and Suggestions for Future Work

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.

Suggestions for future work:


 Presently theprogram works better when the image is taken in black background

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
 While taking the image shadows and reflections interfere,which result in
difficulty to identify objects from the background correctly
The program can be improved by developing a workaround in the above mentioned
problems which is our future work in terms to improve our project

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
References

 Chakravorty,Pragnan. "What Is a Signal? [Lecture Notes]," IEEE Signal Processing


Magazine, vol. 35, no. 5, pp. 175-177, Sept. 2018.
https://doi.org/10.1109/MSP.2018.2832195
 Fernandes, Leandro A. F., Oliveira, Manuel M., Silva, Roberto da, & Crespo,
Gustavo J. (2006). “A fast and accurate approach for computing the dimensions
of boxes from single perspective images”. Journal of the Brazilian Computer
Society, 12(2), 19-30. https://dx.doi.org/10.1007/BF03192392
 Guo, R, Dai, Q &Hoiem, DW 2011, Single-image shadow detection and removal
using paired regions. in 2011 IEEE Conference on Computer Vision and Pattern
Recognition, CVPR 2011., 5995725, Proceedings of the IEEE Computer Society
Conference on Computer Vision and Pattern Recognition, IEEE Computer Society,
pp. 2033-2040. https://doi.org/10.1109/CVPR.2011.5995725
 Jiejie. Zhu, Kegan. G. G. Samuel, Syed. Masood, and Marshall. F. Tappen.(2010).
“Learning to recognize shadows in monochromatic naturalimages”.[Online].
Available at: http://www.cs.ucf.edu/~mtappen/pubs/cvpr10_shadow.pdf
[Accessed: 27 Feb. 2019].
 Johnson, Forrest. (2010). “How to measure the size of an object using camera”
[Online].Journal.Available
at:https://web.archive.org/web/20131123073926/http://forestjohnson.blogspot
.com/2010/01/how-to-measure-size-of-object-using.html [ Accessed: 24 Feb.
2019].
 Lindberg, David C. (2007). "Science before the Greeks". The beginnings of
Western science: the European Scientific tradition in philosophical, religious, and
institutional context (Second ed.). Chicago, Illinois: University of Chicago Press.
pp. 1–27. ISBN 978-0-226-48205-7.

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)
 Meysenburg, Mark. (2016). Image Processing: Edge Detection. [online]
mmeysenburg.github.io. Available at: https://mmeysenburg.github.io/image-
processing/08-edge-detection/ [Accessed 26 Mar. 2019].

<Estimation of Object Dimension using Image Processing>


M.S.Ramaiah University of Applied Sciences – Faculty of Engineering and Technology (FET)

Appendix
Appendix-A

Any material, which is important but affects the flow of your writing can be brought
under Appendix.

<Estimation of Object Dimension using Image Processing>

You might also like