Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Let us start with our Code Explanation

Importing Libraries!!

FASTER THAN PYTHON!!

As the name suggests Python time


module allows to work with time in
Python. It allows functionality like
getting the current time, pausing the
Program from executing, etc. So
before starting with this module we
need to import it
Preparing the WebCam

0,1 specifies the no. of webCam


we specify the fourcc variable. FourCC is a
4-byte code used to specify the video codec.

A codec compresses or
decompresses media files such
as songs or videos

web cam takes some time (a second or two) to load, if next


code start running than it can give error because of not
getting images input from web cam.Basically it's for code
running everytime without fails

Variable initialization to capture the


background when the object is needed to be
made invisible
To know more about fourcc, link is in the description
When Loop starts , the MAGIC starts to begin!!

For and While Loop:

Number of iterations you put here entirely depends on


you but here we are taking more so that a clearer
image is obtained for the background

cap.isOpened make sure while loop keeps


running until the webcam is capturing
COLOR SPACE CONVERSION

RGB matrices superimpose to


form a image.

Image stored in computer in matrix format.


The Hue values are actually distributed over a
circle (range between 0-360 degrees) but in
OpenCV to fit into 8bit value the range is from
0-180.
LETS PLAY WITH PIXELS WITH NUMPY

Mask will separate out color


falling in this range with the
help of cv.inRange function

MORPH MORPH
NOISE
Bitwise Operators on Work

AND NOT
Inverse the pixels
Applies to the part where the red
color object is not there and here
the current video works
Applies where mask is true a
initially clicked background
Superimpose the res 1 applied here
and res 2

If this area is true


than the initially
captured
background will be
applied on this

You might also like