Professional Documents
Culture Documents
ROBOTICS CLUB
IIT GUWAHATI
Topics, we are going to cover:
● Introduction to computer vision
● Understanding Image and colour model
● Basics of OpenCV
● Geometric transformation of image
● Drawing and writing texts on image
● Contours
● Edge and corner detection
● Object detection
● Colour recognition
● Introduction to Deep Learning
What is Computer Vision?
“Computer Vision is an interdisciplinary scientific field that deals with how computers can be
made to gain high-level understanding from digital images or videos.” -Wikipedia
What is Computer Vision?
“Computer Vision is an interdisciplinary scientific field that deals with how computers can be
made to gain high-level understanding from digital images or videos.” -Wikipedia
01 FACE RECOGNITION 02 OBJECT RECOGNITION
Here you could describe the
topic of the section
2. Digital Image : A digital image is composed of a finite number of elements, each of which has a particular
location and value. These elements are referred to as pels, pixels, picture elements or image elements. A digital
image is a numeric representation, normally binary, of a two-dimensional image.
1. Grayscale images
2. RGB images
A Grayscale Image
A Grayscale Image
A (digital) color image is a digital image that includes color information for each
pixel.
1.RGB
2.HSV
RGB Color Model
The RGB color model is an additive color model in which red, green and blue light
are added together in various ways to reproduce a broad array of colors
RGB Color Model
It consists of three matrices consisting of intensity of three primary colors i.e.red,
blue and green for a particular pixel.
HSV Color Model
The HSV color wheel is sometimes depicted as a cone or cylinder, but always with
these three components HSV (hue, saturation, value):
Hue : Hue is the color portion of the color model, expressed as a number from 0 to
360 degrees:
Saturation : Saturation is the amount of gray in the color, from 0 to 100 percent.
Reducing the saturation toward zero to introduce more gray produces a faded
effect. Sometimes, saturation is expressed in a range from just 0–1, where 0 is gray
and 1 is a primary color.
Value (or Brightness) : Value works in conjunction with saturation and describes the
brightness or intensity of the color, from 0–100 percent, where 0 is completely
black, and 100 is the brightest and reveals the most color.
HSV Color Model
What is a video consists of ?
Digital video is an electronic representation of moving visual images (video) in the form of
encoded digital data. This is in contrast to analog video, which represents moving visual
images with analog signals. Digital video comprises a series of digital images displayed in
rapid succession.
Frame Rate : Frame rate is the number of images showed in succession per second. It is
defined as the speed of displaying images.
Higher the frame rate, Higher the video quality, Higher the storage data.
Normal used frame rates: 24, 30, 60 ( also 25, 50 and many more...)
Getting
Started with
Images
What is OpenCV
❏ OpenCV (Open Source Computer Vision Library) is an open
source computer vision and machine learning software library.
❏ It is used for all sorts of image and video analysis, like facial
recognition and detection, license plate reading, photo editing,
advanced robotic vision, optical character recognition, and a
whole lot more.
❏ We will be using Python as the programming language as it has
other libraries like numpy,matplotlib,sciPy to which makes our
task easier.
Important Functions
CV2.imread()
1st argument is name of image or the location of the image and 2nd argument
is a flag .
Example - cv2.imread('messi5.jpg',0)
Example - cv2.imread('C:\\User\Desktop\messi.jpg',0)
CV2.imshow()
Example - cv2.imshow('image',img)
Important Functions
CV2.imwrite()
1st argument is name you want to give to your image and 2nd argument is the
image itself .
CV2.waitKey()
cv2.destroyAllWindows()
cv2.VideoCapture()
To capture a video, you need to create a VideoCapture object.
Its argument can be either the device index or the name of a video file.
● cv2.VideoCapture(‘car.mp4’)
→ Used to play any saved video
● cv2.VideoCapture(0)
→ used to take video from laptop webcam
● cv2.VideoCapture(1)
→ used to take video from any external camera
Important Functions
cv2.cvtColor(input_image, cv2.COLOR_BGR2GRAY)
used to convert BGR image to Gray Scale image
cv2.cvtColor(input_image, cv2.COLOR_BGR2HSV)
used to convert BGR image to HSV Scale image
Geometric
Transformation
of Image
Learn to apply different geometric transformation to images
like Scaling ,translation, rotation, affine transformation etc .
SCALING
❏ Scaling is just resizing of the image.
❏ OpenCV comes with a function cv2.resize() for this purpose.
❏ Syntax - cv2.resize(src, dsize, fx(opt), fy(opt), interpolation)
❏ The size of the image can be specified manually, or you can specify the scaling factor.
Parameters:-
❏ Src - Input image
❏ dsize - output image size; if it equals zero, it is computed as:
dsize = Size(round(fx*src.cols), round(fy*src.rows))
❏ fx - scale factor along the horizontal axis; when it equals 0, it is computed as
fx=(double)dsize.width/src.cols
SCALING
❏ Rotation of an image for an angle theta is achieved by the transformation matrix of the
form
Drawing a circle:- To draw a circle, you need its center coordinates and radius
**We can have a -1 for thickness. This implies the protest will be filled ,so we will get a Filled
in circle.
cv2.putText()
org: It is the coordinates of the bottom-left corner of the text string in the image.
font: It denotes the font type. Some of font types are FONT_HERSHEY_SIMPLEX,
FONT_HERSHEY_PLAIN, , etc.
lineType: This is an optional parameter.It gives the type of the line to be used.
bottomLeftOrigin: This is an optional parameter. When it is true, the image data origin
is at the bottom-left corner. Otherwise, it is at the top-left corner.
Blurring and
Filtering
BLURRING
Blurring is commonly used for reducing image noises and
making image smooth.
BLURRING
cv2.blur() or cv2.boxfilter()
It simply takes the average of all the pixels under kernel area and
replace the central element with this average.
cv2.GaussianBlur()
cv2.findContours(), cv2.drawContours()
Arguments-
❏ first one is source image, second is contour retrieval mode, third is
contour approximation method. And it outputs the image, contours
and hierarchy.
❏ contours is a Python list of all the contours in the image. Each
individual contour is a Numpy array of (x,y) coordinates of boundary
points of the object.
Contours