0% found this document useful (0 votes)
24 views21 pages

Minor Report Final-1

The report details a minor project on object detection using color thresholding and contour detection, supervised by Dr. R. Dayana. It discusses the significance of object detection in computer vision, outlines the proposed system, and highlights the limitations of the basic method compared to advanced deep learning approaches like YOLO and Faster R-CNN. The project aims to provide a foundational understanding of object detection while emphasizing the need for more robust techniques in practical applications.

Uploaded by

MEMES INFINITY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views21 pages

Minor Report Final-1

The report details a minor project on object detection using color thresholding and contour detection, supervised by Dr. R. Dayana. It discusses the significance of object detection in computer vision, outlines the proposed system, and highlights the limitations of the basic method compared to advanced deep learning approaches like YOLO and Faster R-CNN. The project aims to provide a foundational understanding of object detection while emphasizing the need for more robust techniques in practical applications.

Uploaded by

MEMES INFINITY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Object Detection Using Color Thresholding and Contour

Detection

MINOR PROJECT REPORT

Submitted by
Satish Kumar S (RA2011004010070)
Kiran Akash S J (RA2011004010114)
Arunaachalam M (RA2011004010126)

Semester – VII
Academic Year: 2023-24

Under the supervision of

Dr. R. Dayana
Associate Professor,
Department of Electronics and Communication Engineering

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING
College of Engineering and Technology,
SRM Institute of Science and Technology
SRM Nagar, Kattankulathur – 603203, Chengalpattu District, Tamil Nadu.

NOV 2023

i
SRM Institute of Science and Technology
(Under Section 3 of UGC Act, 1956)

BONAFIDE CERTIFICATE

Certified that this project report titled “Object Detection Using Color
Thresholding and Contour Detection ” is the bonafide work of SATISH
KUMAR [Reg.No:RA2011004010070], KIRAN AKASH [Reg.No:
RA2011004010114], ARUNAACHALAM [Reg.No: RA2011004010126], who
carried out the project work under my supervision. Certified further, that to the
best of my knowledge the work reported herein does not form any other project
report or dissertation on the basis of which a degree or award was conferred on an
earlier occasion on this or any other candidate.

SIGNATURE SIGNATURE

Dr. R. Dayana Dr. S. Malarvizhi


Associate Professor Professor
Guide Dept. of Electronics and
Dept. of Electronics and Communication Engineering
Communication Engineering

ii
ABSTRACT

Object detection and tracking are fundamental tasks in computer vision that play
a vital role in enabling machines to perceive and interact with their environments.
Object detection involves recognizing and localizing objects within images or
video frames, often by drawing bounding boxes around them. This task goes
beyond simple classification, providing crucial information about object
locations. Various methods have been developed for object detection, including
traditional techniques utilizing handcrafted features, as well as deep learning
approaches using convolutional neural networks (CNNs). These methods find
applications in fields such as self-driving cars, surveillance, and robotics

iii
ACKNOWLEDGEMENTS

We would like to express our deepest gratitude to our guide. Dr. R. Dayana for
her valuable guidance, consistent encouragement, personal caring, timely help and
providing us with an excellent atmosphere for doing project. All through the work,
in spite of his busy schedule, she has extended cheerful and cordial support to us
for completing this project work.

iv
TABLE OF CONTENTS

ABSTRACT iii

ACKNOWLEDGEMENTS iv

LIST OF FIGURES vi

ABBREVIATIONS vii

1 INTRODUCTION viii
1.1 Problem Statement………………………………………………….viii
1.2 Engineering Standards ………………………… … …………… viii
1.3 Realistic Constraints………………………………………………ix

2 LITERATURE SURVEY xi

3 PROPOSED SYSTEM xii

4 COMPONENTS USED xiii


4.1 Hardware Used…………………………………… ……………….xiii
4.2 Software Used……………………………………… ……………. xiii
4.3 Working……………………………………………… …………….xiv
4.4 Flowchart……………………………………………………………xv

5 RESULT AND DISCUSSION xvi


5.1 Output…………………………………………… …………………xvi
5.2 Conclusion and Future Scope…………………………………………xvii

6 REFERENCE xix

7 APPENDIX xx

v
LIST OF FIGURES
Flow Chart…………………………………….xv

Output…………………………………………xvi

vi
ABBREVIATIONS
CNN-Convolutional Neural Network

GUI- Graphical User Interface

CLI- Command Line Interface

BGR- Blue Green Red

HSV- Hue Saturation Value

CV - Computer Vision

vii
CHAPTER 1

INTRODUCTION

Object detection is a computer vision task that involves identifying and localizing objects
within an image or video frame. It goes beyond classification by not only recognizing what
objects are present but also drawing bounding boxes around them to indicate their locations.
Object tracking extends object detection by following objects as they move across frames in a
video sequence. It involves associating the same object's identity over time.

1.1 PROBLEM STATEMENT


The problem of object detection involves developing algorithms that can accurately locate and
classify objects within an image or video frame. The goal is to identify the presence of various
objects, draw bounding boxes around them, and assign corresponding labels to each detected
object. This task is essential in computer vision applications like autonomous driving,
surveillance, and image-based search, where understanding the content of visual data is crucial
for decision-making. The challenge lies in achieving high accuracy, speed, and robustness in
detecting objects of various sizes, orientations, and in cluttered environments.

1.2 ENGINEERING STANDARDS


The approach provided in the previous code doesn't adhere to specific engineering standards
for object detection, as it's a basic method using edge detection and contour finding. However,
in the realm of engineering standards for object detection, several benchmarks and metrics are
commonly used to assess and compare the performance of object detection models or systems.

For instance, some key engineering standards and metrics applied to object detection tasks
include:

1. Accuracy Metrics: Measures like precision, recall, F1 score, mean Average Precision (mAP),
and Intersection over Union (IoU) are used to evaluate the accuracy and reliability of object
detection models. These metrics assess the model's ability to precisely locate and classify
objects within an image.

viii
2. Datasets: Engineering standards often rely on specific datasets like PASCAL VOC (Visual
Object Classes), COCO (Common Objects in Context), or ImageNet. These datasets contain
labeled images with various objects and are utilized for benchmarking the performance of
object detection models.

3. State-of-the-Art Models: Engineering standards are often based on the performance


comparison of state-of-the-art models in the field. Models like YOLO (You Only Look Once),
SSD (Single Shot MultiBox Detector), Faster R-CNN (Region-based Convolutional Neural
Networks), and their variations are benchmarks for accuracy and speed in object detection
tasks.

4. Training Protocols: Standards often encompass best practices in model training, validation,
and testing methodologies to ensure fairness and accuracy in the assessment of object detection
models.

The provided code does not adhere to these specific standards. Instead, it's a basic example
illustrating an elementary object detection approach using edge detection and contours. To meet
engineering standards, more sophisticated models trained on labeled datasets and validated
against specific metrics are typically employed.

1.3 REALISTIC CONSTRAINTS


The provided basic object detection using edge detection and contour finding in Python has
various realistic constraints:

1. Simplicity and Limitation: The approach is rudimentary and might not effectively handle
complex scenes, various lighting conditions, or objects with intricate backgrounds. It may
struggle to distinguish objects that are similar in color to the background or adjacent objects.

2. Lack of Specificity: This method solely detects edges and outlines of objects, which might
not accurately classify or precisely identify objects in detail. It's unable to recognize object
categories or fine-grained attributes.

3. Performance and Accuracy: The accuracy heavily depends on the quality of the edge
detection and the contours found. Noise or irregularities in the image may lead to inaccurate
results. It might not perform well in scenarios where objects have indistinct edges or are
partially occluded.

4. Limited Object Types: The method doesn't handle a wide variety of object types as it lacks
object-specific training or a diverse dataset to identify different categories of objects.

5. Speed and Efficiency: While this approach might be fast due to its simplicity, it might lack
efficiency and accuracy in complex scenes, making it unsuitable for real-time or production-
level applications.

ix
6. Not Scalable: It's not easily scalable to handle more complex scenarios or large datasets due
to its basic approach.

7. Dependency on Image Quality: The effectiveness heavily relies on the quality and clarity of
the input image. Noisy, low-resolution, or highly compressed images might negatively impact
the detection accuracy.

To overcome these constraints and create a more robust and accurate object detection system,
using pre-trained deep learning models, leveraging specific datasets for training, and
implementing neural networks that can learn object features from a wide variety of images are
commonly preferred in modern object detection applications.

x
CHAPTER 2

LITERATURE SURVEY

1. Author: Joseph Redmon, Santosh Divvala, Ross Girshick, and Ali Farhadi. "You Only Look
Once: Unified, Real-Time Object Detection" Date: 2016 - Prior work on object detection
repurposes classifiers to perform detection. Instead, we frame object detection as a regression
problem to spatially separated bounding boxes and associated class probabilities.

2. Author: Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. "Faster R-CNN: Towards
Real-Time Object Detection with Region Proposal Networks" Date: 2016 - A single neural
network predicts bounding boxes and class probabilities directly from full images in one
evaluation. Since the whole detection pipeline is a single network, it can be optimized end-to-
end directly on detection performance.

3. Author: Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed,
Cheng-Yang Fu, and Alexander C. Berg. "SSD: Single Shot MultiBox Detector" Date: 2016 -
Our unified architecture is extremely fast. Our base YOLO model processes images in real-
time at 45 frames per second. A smaller version of the network, Fast YOLO, processes an
astounding 155 frames per second while still achieving double the mAP of other real-time
detectors.

4. Author: Joseph Redmon and Ali Farhadi. "YOLOv3: An Incremental Improvement" Date:
2018 - YOLO makes more localization errors but is far less likely to predict false detections
where nothing exists. Finally, YOLO learns very general representations of objects. It
outperforms all other detection methods, including DPM and R-CNN, by a wide margin when
generalizing from natural images to artwork on both the Picasso Dataset and the People-Art
Dataset.

5. Author: Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. "Mask R-CNN"
Date: 2017 - datasets like COCO (Common Objects in Context), PASCAL VOC (Visual Object
Classes), and their significance in evaluating object detection models.

xi
CHAPTER 3

PROPOSED SYSTEM

Object Detection Using Color Thresholding and Contour Detection


Integration of Pre-Trained Models: Implement pre-trained deep learning models for object
detection. For instance, utilizing models like YOLO, SSD, or Faster R-CNN can significantly
enhance the accuracy and robustness of the detection process. Modularize Code: Structure the
code into modular components, allowing users to easily switch between different detection
methods or models. Create functions for different steps in the process, such as image
preprocessing, detection, and post-processing. User Interface and Image Input: Develop a
simple user interface for image input, allowing users to select or upload images for detection.
This could be a basic graphical user interface (GUI) or a command-line interface (CLI). Output
Visualization: Display the detection results more intuitively. Instead of just drawing bounding
boxes, show object classes, confidence scores, and potentially perform semantic segmentation
for more detailed object delineation.

Real-Time or Batch Processing: Enhance the system to handle real-time video streams for
continuous object detection or batch processing for multiple images in a folder. Error Handling
and Feedback: Implement error handling to provide meaningful feedback in case of errors, such
as file not found, invalid image format, or detection failures. Documentation and Usage
Guidelines: Include clear documentation, comments within the code, and a user guide, outlining
how to use the system, configure parameters, and interpret results. Performance Optimization:
Optimize the code for speed and resource efficiency, enabling faster processing, especially if
handling large images or real-time streams. Expandable Model Support: Make the system
extensible to easily integrate new object detection models, allowing future upgrades without
major code changes. Testing and Validation: Set up a testing framework to validate the system's
accuracy, performance, and reliability across various scenarios and datasets.

xii
CHAPTER 4

COMPONENTS USED

4.1 HARDWARE COMPONENTS

HP Pavilion

Microprocessor

Intel® Core™ i7-7500U (2.7 GHz base frequency, up to 3.5 GHz with Intel® Turbo Boost
Technology, 4 MB cache, 2 cores)

Flash cache

8 GB

Memory, standard

8 GB DDR4-2133 SDRAM (1 x 8 GB)

Video graphics

NVIDIA® GeForce® 940MX (4 GB DDR3 dedicated)

Hard drive

1 TB 5400 rpm SATA SSHD Display

35.6 cm (14") diagonal FHD IPS WLED-backlit multitouch-enabled edge-to-edge glass


(1920 x 1080)

4.2 SOFTWARE COMPONENTS

Operating system

Windows 11

Python Pycharm Community Edition 2021.3.Ink

xiii
4.3 WORKING

The provided Python code performs a basic form of object detection using color thresholding
and contour detection. It utilizes the OpenCV library for image processing. Initially, the code
reads an image file specified by the path ('your_image.jpg'). It then defines a color range using
lower and upper limits in the BGR (Blue-Green-Red) format to identify the color of the object
to be detected within the image. The script converts the image to the HSV (Hue-Saturation-
Value) color space, simplifying the process of color segmentation by better isolating the desired
color range. The next step involves creating a binary mask, marking the pixels that fall within
the specified color range.

The code then identifies contours within this mask using OpenCV's contour-finding function.
These contours outline areas of connected pixels sharing the same color characteristics. For
each detected contour, the script calculates a bounding rectangle and draws it onto the original
image. These rectangles demarcate the regions where the identified object is located. Finally,
the script displays the modified image, revealing the detected object enclosed within bounding
boxes. Users can adjust the color range parameters and experiment with different images to
detect objects based on distinctive colors. However, this method is basic and may not be highly
accurate or adaptable to various conditions compared to more advanced deep learning-based
object detection approaches like YOLO or SSD, which typically necessitate external models
and files for robust detection.

xiv
4.4 FLOW CHART

xv
CHAPTER 5
RESULT AND DISCUSSION

5.1 OUTPUT

Input Image

xvi
Output Image

5.2 CONCLUSION AND FUTURE SCOPE

In conclusion, the provided Python code demonstrates a simplistic approach to object detection
using color thresholding and contour detection without relying on external files or libraries
beyond OpenCV. It serves as a starting point for beginners to understand basic concepts in
image processing and contour analysis for object identification. While this method can detect
objects based on specific colors within an image, it's limited in accuracy and robustness,
particularly in scenarios with varying lighting conditions or complex backgrounds. For more
practical and reliable object detection, especially in real-world applications, leveraging pre-
trained deep learning models like YOLO, SSD, or Faster R-CNN would be more appropriate.
These models require external files and libraries to achieve more accurate and versatile object
detection capabilities across diverse and complex settings.

The field of object detection has seen significant advancements, particularly with the rise of
deep learning models and their applications. Techniques like YOLO (You Only Look Once),
Faster R-CNN, SSD (Single Shot MultiBox Detector), and Mask R-CNN have revolutionized

xvii
object detection by providing faster and more accurate methods for identifying and localizing
objects within images.

These models, introduced through influential papers by researchers like Joseph Redmon, Ali
Farhadi, Kaiming He, among others, have propelled the field forward. The development of
benchmark datasets such as COCO and ImageNet has facilitated a standardized approach for
evaluating the performance of object detection models, with metrics like mAP (mean Average
Precision) and IoU (Intersection over Union) serving as critical measures.

The challenges, however, persist. Object detection remains an active area of research due to the
complexities associated with detecting objects in varying contexts, handling occlusion, scale
variations, and dealing with real-time processing requirements. Furthermore, the trade-off
between speed and accuracy remains a key consideration in deploying these models for
practical applications.

Overall, the field continues to evolve, driven by ongoing research efforts to improve the
accuracy, efficiency, and versatility of object detection models, catering to diverse real-world
scenarios and applications, ranging from autonomous vehicles to surveillance systems, and
beyond. The future advancements are expected to focus on refining existing models and
creating innovative methodologies to address the challenges while improving the robustness
and real-time performance of object detection systems.

xviii
REFERENCES

1. Q. Zhao, P. Zheng, S. -T. Xu and X. Wu, "Object Detection With Deep Learning: A
Review," in IEEE Transactions on Neural Networks and Learning Systems, vol. 30, no.
11, pp. 3212-3232, Nov. 2019, doi: 10.1109/TNNLS.2018.2876865.

2. R. Padilla, S. L. Netto and E. A. B. da Silva, "A Survey on Performance Metrics for


Object-Detection Algorithms," 2020 International Conference on Systems, Signals and
Image Processing (IWSSIP), Niteroi, Brazil, 2020, pp. 237-242, doi:
10.1109/IWSSIP48289.2020.9145130.

3. Z. Zou, K. Chen, Z. Shi, Y. Guo and J. Ye, "Object Detection in 20 Years: A Survey,"
in Proceedings of the IEEE, vol. 111, no. 3, pp. 257-276, March 2023, doi:
10.1109/JPROC.2023.3238524.

4. L. Jiao et al., "A Survey of Deep Learning-Based Object Detection," in IEEE Access,
vol. 7, pp. 128837-128868, 2019, doi: 10.1109/ACCESS.2019.2939201.

5. Author: Richard Szeliski. "Computer Vision: Algorithms and Applications" Date: No


specific date for the book; the web version is regularly updated.

6. Authors: Ian Goodfellow, Yoshua Bengio, Aaron Courville. "Deep Learning" Date:
November 2016

7. Author: Aurélien Géron. "Hands-On Machine Learning with Scikit-Learn, Keras, and
TensorFlow" - Date: March 2019

8. Authors: Manisha Sharma, Jyotsna Kumar Mandal, Narendra Kumar Kamila. "Object
Detection in Computer Vision" - Date: November 2018

xix
APPENDIX

Object Detection Using Color Thresholding and Contour Detection

import cv2
import numpy as np

# Read the image

image = cv2.imread('your_image.jpg')

# Replace with the path to your image

# Define the color range for the object you want to detect

lower_color = np.array([65, 60, 60])

# Lower range of the color (in BGR format)

upper_color = np.array([80, 255, 255])

# Upper range of the color (in BGR format)

# Convert the image to the HSV color space

hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)

# Create a binary mask where the object falls within the color range

mask = cv2.inRange(hsv_image, lower_color, upper_color)

xx
# Find contours in the mask

contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL,


cv2.CHAIN_APPROX_SIMPLE)

# Loop through the detected contours and draw bounding boxes

for contour in contours:


x, y, w, h = cv2.boundingRect(contour)
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)

# Display the image with bounding boxes

cv2.imshow('Object Detection', image)


cv2.waitKey(0)
cv2.destroyAllWindows()

xxi

You might also like