NTCC Report File
NTCC Report File
INFORMATION TECHNOLOGY
KOLKATA
AMITY UNIVERSITY KOLKATA
PROJECT REPORT
ON
SHAPE ANALYSIS OF A SPECTACULAR OBJECT
A report submitted in partial fulfilment of the requirement for the
Bachelor of Computer Applications course (2021-2024) of Amity
University.
Submitted to: Submitted by:
The author attests that permission has been obtained for the
use of any copyrighted material appearing in the report other
than brief excerpts requiring only proper acknowledgement in
scholarly writing and all such use is acknowledged.
Signature:
Date:
CERTIFICATE
Date:
Name of Guide:
Designation Department of
(Faculty Guide):
ACKNOWLEDGEMENT
Yours Sincerely
ARIJIT NANDI
BCA (2021-2024)
TABLE OF CONTENTS
Topics
ABSTRACT
INTRODUCTION
METHODOLOGY
RESULT
CONCLUSION
REFERENCES
ABSTRACT
METHODOLOGY
Approach
Import module
Import image
Convert it to grayscale image
Apply thresholding on image and then find out contours.
Run a loop in the range of contours and iterate through it.
In this loop draw a outline of shapes (Using drawContours() ) and
find out center point of shape.
Classify the detected shape on the basis of a number of contour points
it has and put the detected shape name at the center point of shape.
Function Used
cv2.findContours(): Basically, this method find outs all the boundary
points of shape in image.
Syntax: cv2.findContours(src, contour_retrieval,
contours_approximation)
Parameters:
src: input image n-dimensional (but for in our example we are going
to use 2 dimensional image which is
mostly preferred.)
contour_retrieval:
cv.RETR_EXTERNAL:retrieves only the extreme outer contours
cv.RETR_LIST:retrieves all of the contours without establishing any
hierarchical relationships.
cv.RETR_TREE:retrieves all of the contours and reconstructs a full
hierarchy of nested contours.
contours_approximation:
cv.CHAIN_APPROX_NONE: It will store all the boundary points.
cv.CHAIN_APPROX_SIMPLE: It will store number of end
points(eg.In case of rectangle it will store 4)
Return value: list of contour points
Parameters:
CODE:
INPUT:
import cv2
import numpy as np
from matplotlib import pyplot as plt
# reading image
img = cv2.imread('shapes.png')
i=0
elif len(approx) == 4:
cv2.putText(img, 'Quadrilateral', (x, y),
cv2.FONT_HERSHEY_SIMPLEX, 0.6,
(255, 255, 255), 2)
elif len(approx) == 5:
cv2.putText(img, 'Pentagon', (x, y),
cv2.FONT_HERSHEY_SIMPLEX, 0.6,
(255, 255, 255), 2)
elif len(approx) == 6:
cv2.putText(img, 'Hexagon', (x, y),
cv2.FONT_HERSHEY_SIMPLEX, 0.6,
(255, 255, 255), 2)
else:
cv2.putText(img, 'circle', (x, y),
cv2.FONT_HERSHEY_SIMPLEX, 0.6,
(255, 255, 255), 2)
# displaying the image after drawing contours
cv2.imshow('shapes', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
RESULT
REFERENCES
www.geeksforgeeks.org
www.javapoint.com
www.wikipedia.org