0% found this document useful (0 votes)
37 views

An Intelligent Motion Detection Using Open CV

Uploaded by

estela dll
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

An Intelligent Motion Detection Using Open CV

Uploaded by

estela dll
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/359368941

An Intelligent Motion Detection Using OpenCV

Article · March 2022


DOI: 10.32628/IJSRSET22925

CITATIONS READS

8 3,427

5 authors, including:

Dr. Yusuf Perwej Nikhat Akhtar


ProfessorAmbalika Institute of Management & Technology Ambalika Institute of Management and Technology (AIMT), Lucknow, UP, India
91 PUBLICATIONS   1,040 CITATIONS    54 PUBLICATIONS   344 CITATIONS   

SEE PROFILE SEE PROFILE

Shivam Chaturvedi Shubham Mishra


Ambalika Institute of Management & Technology Board Of Technical Education Uttar Pradesh Lucknow
4 PUBLICATIONS   18 CITATIONS    59 PUBLICATIONS   367 CITATIONS   

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Phd Scholar View project

Developing an Intelligent System for Medical Diagnosis View project

All content following this page was uploaded by Dr. Yusuf Perwej on 21 March 2022.

The user has requested enhancement of the downloaded file.


International Journal of Scientific Research in Science, Engineering and Technology
Print ISSN: 2395-1990 | Online ISSN : 2394-4099 (www.ijsrset.com)
doi : https://doi.org/10.32628/IJSRSET22925

An Intelligent Motion Detection Using OpenCV


Shubham Mishra*1, Mrs Versha Verma 2 Dr. Nikhat Akhtar 3, Shivam Chaturvedi 4, Dr. Yusuf Perwej5
1*
B.Tech Scholar, Computer Science & Engineering, Ambalika Institute of Management & Technology, Lucknow, India
2
Assistant Professor, Department of Computer Science & Engineering, Ambalika Institute of Management & Technology,
Lucknow
3
Associate Professor, Department of Computer Science & Engineering, Ambalika Institute of Management and Technology,
Lucknow
4
Assistant Professor, Department of Computer Science & Engineering, Ambalika Institute of Management & Technology,
Lucknow
5
Professor, Department of Computer Science & Engineering, Ambalika Institute of Management and Technology, Lucknow,
India

ABSTRACT
Article Info A computer vision system's basic goal is to detect moving things. For many
Volume 9, Issue 2 applications, the performance of these systems is insufficient. One of the key
Page Number : 51-63 reasons is that dealing with numerous restrictions such as environmental
fluctuations makes the moving object detection process harder. Motion detection is
Publication Issue : a well-known computer technology associated with computer vision and image
March-April-2022 processing that focuses on detecting objects or instances of a specific class in digital
photos and videos (for example, humans, flowers, and animals). Face detection,
Article History character recognition, and vehicle calculation are just a few of the well-studied
Accepted : 05 March 2022 applications of object motion detection. Object detection has a wide range of
Published: 19 March 2022 applications, including retrieval and surveillance. Object counting is a step after
object detection that gets more exact and robust with the help of OpenCV. For
object detection and counting, OpenCV includes a number of useful techniques.
Object counting has a variety of applications in the fields of transportation,
medicine, and environmental science, among others. Computer vision and image
processing research is progressing rapidly and is being used to improve human lives.
To avoid the drawbacks of current and newly established techniques, the suggested
algorithm was tested on many open source images by imposing a single set of
variables. The motion detection software system proposed in this paper allows us to
see movement around an item or a visual area.
Keywords : Motion Detection, Object Recognition, OpenCV, Image Processing,
Baseline Frame, Pixel, Background Subtraction.

I. INTRODUCTION To solve this issue, the number of surveillance cameras


With the growth of technology, there is a growing has recently increased. Despite this, manually storing
worry for safety and security everywhere nowadays [1]. and monitoring data [2] on a continuous basis is tough.

Copyright: © the author(s), publisher and licensee Technoscience Academy. This is an open-access article distributed under the
terms of the Creative Commons Attribution Non-Commercial License, which permits unrestricted non-commercial use,
51
distribution, and reproduction in any medium, provided the original work is properly cited
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

There are various ways to complete this task without a machine vision system's artificial approach of
involving humans. In visual surveillance systems, detecting motion in comparison to human vision.
detecting moving objects in real time is a difficult task. So our plan was to take a picture from a webcam at
It's frequently used as a starting point for more regular intervals (make it the current picture) and
advanced processing, such as classification of the compare it to a previous picture; if there was a
detected moving item. In the processing of video in a significant difference, we would save both pictures
surveillance system, object identification and tracking otherwise, we would free memory from the old picture
are critical. It is frequently used as a starting point for and make the new picture the current picture. The
more advanced processing, such as classification of the detection and recording of the entire movement
detected moving item. In the processing of video in a process is included in motion detection. The goal of
surveillance system, object identification and tracking motion detection [8] is to detect movement in a certain
are [3] critical. It allows multiple processor vision area automatically. The goal of motion detection is to
applications to extract information from frames and find movement in a specific area. This region is always
video sequences, such as CCTV surveillance, embodied in a zone of awareness, which is referred to
understanding an activity in focus, analyzing traffic as the field of vision in camera geometry. It's also
flow, and classifying and tracking an object. This referred to as a monitored area of the environment.
demonstrates that detecting and tracking an item is a The environment with moving items and activity is the
critical area of research in computer vision, with area of attention in this scenario. A human, an animal,
applications in a variety of surveillance systems. In or an item can all be considered a zone of interest,
today's world, motion detection [4] surveillance and which is defined by the phrase moving object.
security systems are increasingly widespread. Retail
outlets, banks, supermarkets, airports, business II. Related Work
buildings, and even private residences all have this
type of system. Analogue and digital video surveillance In recent years, a large variety of moving object
and security systems [5] are the two types of systems detection algorithms has been reported. Mahbub et al.
available. Cameras are employed in traditional security [9] suggested a statistical backdrop modeling-based
systems to provide analogue video images to monitors technique. This method matches every edge segment
or time-lapse video cassette recorders (VCR). Although of the current frame with every edge segment of the
numerous local image processing [6] functions can be background to detect moving objects. This approach,
used to improve the system application, this however, fails to detect a moving edge segment that
necessitates a large amount of processing power and intersects with a backdrop edge segment. Geetha priya.
high-power hardware. Despite the widespread use of S et al. [10], is to detect objects utilizing the You Only
digital video surveillance and security systems, Look Once (YOLO) technique. When compared to
analogue systems remain a cost-effective alternative. other object detection methods, this technique has
The most common cameras utilized in the system are significant advantages. . Other algorithms, such as
charge coupled devices (CCD) cameras and digital Convolutional Neural Network and Fast Convolutional
cameras. The ability to detect movement is referred to Neural Network, do not look at the image completely,
as motion detection. There are numerous methods for whereas YOLO does, by predicting the bounding boxes
detecting motion [7]. The traditional method is to use using convolutional networks and the class
either an active or a passive sensor. "Vision motion probabilities for these boxes, and detects the image
detection" is a new approach for detecting motion. It is faster than other algorithms. Tahkker and Kapadia
built OpenCV for Android in [11]. Their goal was to

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 52
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

offer readers a sense of what they'd need to get started proposed by Mahbub et al., [16]. This approach detects
using OpenCV on Android. The effects of applying moving objects by comparing every edge segment of
several filters to an image, such as color conversion, the current frame to every backdrop edge segment [17].
grey scale, and dilation, were exhibited by the authors. This approach, however, fails to detect a moving edge
The authors also put the features to the test on three segment that intersects with a backdrop edge segment.
different devices to see how long it took the algorithms Islam and Lee [18] proposed a particle filter-based
to complete. The authors created an instruction guide technique for moving object tracking in which the
with theory behind it on how to use OpenCV for image shape similarity of a template and estimated regions in
recognition in [12]. The paper covers image processing a video scene is assessed by their normalised cross-
and OpenCV many machine learning [13] techniques. correlation of distance transformed pictures. Dunne
and Matuszewski [19] proposed an object detection
The authors [14] attempt to develop a good motion system that uses a localised temporal difference change
detection system for critical sectors such as banks and detector and a particle filter type likelihood detector to
businesses. They begin by taking sample images from a determine a spot within a detected item where a
web cam that is recording images, then storing those particle filter tracker may be initialised. Shin and Hong
images in a buffer to calculate the difference between [20] described a method for restoring a crisp outline of
the sampled images. When they detect movement, a an object and a loss part by applying edge information
counter is raised, and when it reaches a specific level, and a boosting factor in response to a change in the
they transmit a message to a mobile phone indicating input image [21]. Finally, the item is recovered by
that movement has occurred and sound a buzzer. This analysing and removing the shadow cast by the object
paper discusses certain image processing techniques during the entire procedure.
that we selected to use in our solution. [15]Wei, Li, and
Yue offer a foreground-background motion detection III. Computer Vision
system for tracking moving objects from a video
camera in [15]. The authors achieved this by basing Computer vision (CV) is a branch of computer science
their approach on a probability density function called concerned with enabling computers to comprehend
the Gaussian Mixture Model (GMM). To reduce images. Martin Minsky challenged his undergraduate
processing time, the scientists tweaked the classic Gerald Jay Sussman in the early 1970s/late 1960s to
GMM algorithm by modifying the Gaussian link a computer to a camera and have the machine
parameters and number of components. To make describe what it saw [22]. Computer Vision (CV) is a
foreground-background segmentation, the authors topic of study that aims to create techniques that allow
employed their GMM algorithm on each pixel in each computers to "see" and interpret the content of digital
frame. The authors make the frame binary once the pictures like photographs and movies. Because people,
foreground and background have been established, including very young children, can solve the problem
with the foreground becoming white (moving items) of computer vision, it looks to be straightforward.
and the backdrop becoming black (none moving Despite this, it is still largely an unsolved subject,
objects). The authors then apply filters to the binary owing to both a lack of understanding of biological
images to reduce noise such as wind, light, and vision and the complexity of vision perception in a
shadows. dynamic and nearly infinitely altering physical reality.
In recent years, a large variety of moving object The 1990s and 2000s were known as the "golden era"
detection algorithms has been reported. A approach of computer vision [23], as this was when modern
based on statistical background modelling was computer vision became a reality. Feature extraction

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 53
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

and object recognition algorithms were developed, as classifier model gives more accurate results than
well as computer vision tools like OpenCV. Today, existing approaches, which use both SIFT and tensor
computer vision is frequently combined with machine features for feature extraction and DNN for
learning algorithms, which can be trained to detect classification, according to simulation findings.
specific properties or objects, such as the number of
people in an image [24]. Computer vision may be 3.1 Relationship between computer vision and AI
employed in a variety of fields, including medicine,
where a computer can analyse photographs of patients Computer vision is a topic of study that focuses on
to spot tumours [25]. It's also utilised in smart cars like assisting computers in seeing, as demonstrated in
Mobileye [26] to recognise people and barriers on the figure 1. It is a multidisciplinary area that can be
road in order to avoid collisions. categorised as a subfield of artificial intelligence and
machine learning, and it may employ specialised
For tracking things in video frames, the author [27] approaches as well as general learning algorithms.
suggested using an object detection technique. The
simulation results suggest that this technique is
effective, precise, and robust for detecting generic
object classes with good performance. The focus
should also be on improving categorization accuracy in
real-time object identification. By using big data
analytics, Ben Ayed et al. [28] proposed a method for
detecting text data based on a texture in video frames.
The video frames are broken down into fixed-size
Figure 1 The Relationship between Computer Vision
blocks, which are then analysed using the Haar
& AI
wavelet transform technique. They also classified the
text and non-text blocks using a neural network [29].
3. 2 Computer vision and image processing
However, this research should focus on extracting
regions in order to remove noisy regions and exclude
Image processing is not the same as computer vision.
text-like sections. Non-panoramic background
The process of creating a new image from an old image
modelling was suggested and modelled by Viswanath
[33], usually by simplifying or enhancing the content
et al. [30]. They modelled the entire visual element
in some way, is known as image processing. It is a sort
with a single Spatio-temporal Gaussian using this
of digital signal processing that is unconcerned with
method. The results of the simulations suggest that this
image content interpretation. The image processing,
technology is capable of detecting moving compounds
such as pre-processing images, may be required for a
with fewer false alarms. This solution, however, fails
certain computer vision system.
when the required characteristics are not available
Normalizing the image's photometric attributes, such
from the section. By combining Tensor features with a
as brightness and colour. Cropping an image's limits, as
SIFT [31] technique to identifying the identified items
in cantering an object in a photograph. Removing
using Deep Neural Network (DNN)[32], Najva and
digital noise from an image, such as low-light digital
Bijoy suggested a model for object recognition and
artefacts.
classification in films. The DNN, like the human brain,
is capable of managing massive higher-dimensional
3.3 Motion detection
data with billions of parameters. The proposed

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 54
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

the intensity of white light, with a range of 0-255,


When motion is detected, motion detection can be where 0 is black and 255 is white.
utilised to automatically execute a task. For example,
motion detection can be used to light a room when IV. OpenCV
people enter it or to detect criminal activities in
security systems [34]. To detect motion, a variety of OpenCV (Open Source Computer Vision Library) is a
instruments are available, including hardware such as free software library for computer vision and machine
infrared sensors (IR sensors) and software such as learning. Artificial Intelligence relies on or is mostly
image processing techniques. An infrared sensor based on computer vision. Self-driving cars, robotics,
detects the infrared radiation that human bodies emit and picture editing apps all rely heavily on computer
when they generate heat. By comparing two photos [6] vision. OpenCV was an Android application subsystem
with each other, motion can be detected by image for capturing, processing, and analysing pictures [36].
processing. This is accomplished by comparing pixels The OpenCV branch indicated the issues that needed
in the identical locations in the two photos. If the to be resolved in order to capture a photo and
photos are identical, there is no difference between determine whether or not movement had happened.
two pixels. However, if the photos are dissimilar, the OpenCV is a large open-source library for computer
pixel difference between some pixels will be more than vision, machine learning, and image processing that
zero. When comparing an image of an empty room to currently plays a critical part in real-time operations,
an image of the same room with people inside, which are critical in today's systems It may be used to
discrepancies in the pixels where the individuals are in detect items, faces, and even human handwriting in
the image will appear. photos and movies. Python can process the OpenCV
array structure for analysis when it is combined with
3.4 Digital imaging other libraries such as Numpuy. We employ vector
space and execute mathematical operations on these
Pixels are minuscule bits that make up a computer features to recognise visual patterns and their various
image [35]. A pixel is made up of three smaller sub features. More than 2500 optimised algorithms are
pixels, each of which represents a single colour (red, included in the library, which contains a
green, or blue) (RGB). Each sub pixel can change the comprehensive mix of both classic and cutting-edge
brightness of its colour by changing its digital value computer vision and machine learning techniques.
between 0-255. This means that each pixel may OpenCV was created with image processing in mind.
produce a colour combination of 256 × 256 x 256, or The Image Processing coder was considered when
more than 16.7 million distinct colours. A High designing each function and data structure. Matlab, on
Definition (HD) image has a horizontal resolution of the other hand, is a very generic programming
1920 pixels and a vertical resolution of 1080 pixels, language. In the form of toolboxes, we can get nearly
totaling over 2 million pixels. Image processing can be anything in the world. An algorithm analyses
used to alter the appearance of digital images by sequential video frames and outputs the movement of
altering the image data, which means the pixel data. targets between the frames to conduct video tracking.
Image processing methods, for example, can be used to There are many different algorithms, each with its own
convert a coloured image [6] to a grey scaled image. In set of advantages and disadvantages. When choose the
a grey scaled image, there are no RGB values in the sub algorithm to utilise, it's crucial to keep the intended
pixels; instead, there is just one data value that defines usage in mind.

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 55
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

V. Existing Problem 6.1 Capturing phase

The main goal of this paper is to allow a simple camera We must first acquire live photos of the area to be
connected to a general-purpose computer to detect observed and kept under observation in order to detect
items passing through it, as well as how long the object motion. This is accomplished by utilising a webcam
stayed in the area where the camera is located. As a that continuously transmits a succession of photos at a
result, this software can be used for monitoring. To specific frame rate (frames per second).
begin, you'll use a camera to capture the first frame, as 6.2 Comparing phase
seen in figure 2. This frame will be used as the starting
point. The phase difference between this baseline To evaluate whether any motion is present in the live
frame and the new frame with the object will be images, we compare the live images provided by the
calculated to identify motion. Delta frames will be the webcam to each other so that we may detect changes
name of the new frames. Then you'll use pixel intensity in these frames and so forecast the appearance of some
to fine-tune your delta frame. Threshold will be the motion.
name of the refined frame. Then you'll use advanced
image processing techniques like Shadow Removal,
Dilation, Contouring, and others to catch substantial
items on the Threshold frame. Here's a visual
representation of what you'll accomplish. You'll be
able to record the timestamps of objects entering and
exiting the frame. As a result, you'll be able to
determine the screen-on time.

Figure 3 Flow Diagram

6.3 Storage phase

If motion is detected, we must store the frames in


memory so that the user may see them soon. This also
aids the user in presenting legal proof of certain
Figure 2 The Detected Object inappropriate behaviour, as video coverage can be
utilised as evidence in court.
VI. Proposed Methodology
6.4 System indicating phase
In our project, we wanted to create a surveillance
system that can not only detect motion but also notify When motion is detected, the user may want to be
the user of the intrusion, capture film from the notified through SMS right away that there has been
moment the motion was detected, and send SMS to the an incursion identified by the software, which is why
user's mobile phone (see figure 3). The system the software includes an alarm system. If any kind of
architecture will work in the following manner. motion is detected, this alarm system immediately

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 56
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

generates a wav file format audible alert signal. This which is the basic concept. The current picture fk is
aids in the prevention of any form of security breach then subtracted from the previously stored background
at the time. When motion is detected, a location with image B, and if the pixel difference is more than the
photographs of the intruder is given to the user, and an bound threshold, the pixel to pixel[35]on the moving
SMS is sent to the user's cell phone at the same time. target, or as the background pixel, is determined. To
accomplish motion detection success, the threshold of
6.5 Image segmentation the background subtraction must be carefully chosen.
Images are frequently just interested in certain sections The accuracy of motion detection is critical. The
of the research and use of images. Goals or foreground threshold value is too low, resulting in a significant
are terms used to describe these elements (as other number of false change points; the threshold value is
parts of the background). To identify and analyse the too high, limiting the range of movement changes. The
target in the image, we must first isolate it from the rest proper threshold request responds to the impact that
of the image. The term "image segmentation" refers to sceneries and cameras have on colour wavelengths and
the process of dividing an image into sections, each changes in lighting conditions, thus the dynamic
with its own set of properties, in order to extract the threshold should be chosen. In the case of fixed
target of interest. Threshold segmentation [37] is the cameras, background subtractions are used for motion
picture segmentation method employed in this paper. detection [40]. It has the advantages of being simple to
To put it another way, the grey scale image deploy, quick and successful detection, and the ability
segmentation threshold is used to define a range in an to deliver the target's complete feature data. The flaws
image that is compared to the threshold and [35] then are common in the moves of the occasions, making the
separated into two categories, foreground and background image tough to obtain. The immovable
background, based on the results. There are two background difference is especially sensitive to
fundamental processes in threshold segmentation. changes in dynamic settings, such as slow shifts in
Determine the threshold first. In the second step above, indoor lighting.
the pixel value will be compared to the threshold value
T to calculate the threshold value, which is the most VII. Implementation
important step in partition. There is an optimum
threshold based on several picture segmentation goals To begin with, Python should be used to install Python
[38] in the threshold selection. We can adjust the 3 or above, pandas, and OpenCV. To open the camera
image for segmentation if we can identify an adequate and capture video frames, OpenCV includes built-in
threshold. Many alternative ways for detecting moving functions. The camera is connected to your computer's
targets can be employed with an intelligent video hardware port number 0 as "0”. We can enter the port
surveillance system, including background subtraction number if you have several cameras, external cameras,
and frame difference methods. These strategies have or a CCTV system installed. We change the colour
benefits and drawbacks, which will be discussed below. frame to a grey frame because we don't need an extra
layer of colour. Image smoothing is achieved by
6.6 Background subtraction method Gaussian Blur, which improves detection accuracy [41].
The width and height of the Gaussian Kernel are
The background subtraction method is a technique for defined in the second parameter of the Gaussian Blur
detecting moving targets that uses the difference function, and the standard deviation value is provided
between the current image and the background image in the third parameter. Because this is a series of
[39]. The first frame image is saved as a backdrop image, higher-order differential calculus theorems, you can

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 57
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

use standard kernel size values of (21,21) and standard- greater the number of iterations, the smoother the
deviation values of 0. The first frame will be used as the result, and the longer the processing time. As a result,
starting point. it is recommended that it be kept at 3. The structural
element is denoted by the "None" option in the dilate
The phase difference between this baseline frame and function, which is not required in our scenario. We
the additional frames containing some item will be need to discover contours in our frame once it has been
calculated to detect motion. There should be no filtered. A curve along which a function has a constant
movement in front of the camera when shooting the value at all points is called a contour. In order to
first frame. You don't want to process the first frame determine the size and placement of the object, we
any further once you've obtained it. Use the continue need contours in our current frame. To accomplish this,
statement if you want to skip the next stages. We must we use the locate counters method to pass a copy of the
now determine the difference between the first and filtered frame. We identify contours using a replica of
current frames [42]. As a result, we use the abs diff the filtered frame rather than the original since we
function to create an alternative frame, which we refer don't want to mess with the original filtered frame. It
to as a delta frame. In our use case, simply discovering becomes a little hard here since the contours must be
a difference will not suffice, thus we must establish a stored in a tuple, and you only want the first element
pixel threshold value that can be deemed a real object. of the tuple.
As a rule of thumb, the threshold value should be 30
pixels, and the colour of the threshold value should be The syntax for declaring a tuple in Python 3 may be
white (color code: 255). The Thresh binary function found here (name,). We now need to find only the
returns a tuple value, with the resulting threshold external contours of objects on our filtered layer, as any
frame contained solely in the second item ([0] is the contours other than the extreme external ones are
first item and [1] is the second item). The binary worthless in our use case. To optimise the process of
threshold function is a non-continuous function that retrieving the contours, we must apply some
only accepts two discrete values: 0 or 1. We regard the approximation approaches. Any curve approximation
current frame's status to be 0 if there is no object in or curve interpolation method can be used, but the
front of the camera and 1 if there is an object in front Simple Chain Approximation rule compresses
of the camera. horizontal, vertical, and diagonal segments and only
leaves their end points. As a result, we can quickly
Each component of an object casts shadows on the obtain the best-fit contour. We don't want to catch
background or on other components of the item. This small stuff like insects, but rather significant objects
could be perplexing. For example, the nose casts a like humans and animals. The notion of contour area
shadow on your lips, any larger stationary object casts can be used to personalise this. Those items with an
shadows on smaller things placed nearby, fluttering area of less than 10,000 pixels are skipped in this case.
light sources, various light sources with varying We set the status=1 for contours with an area greater
luminous intensities, curtains in your room, light than this, indicating that the object has been detected.
source direction and viewing angle, and so on. These Using the bounding Rect function, we can now capture
are some of the anomalies that have been discovered in the contour's coordinates. Then, we use these
real-time captured frames. As a result, we must filter coordinates to draw a rectangle of the desired color and
the image to reduce these forms of disturbances. We thickness on the colored frame. This rectangle depicts
can control the degree of smoothness in the Dilate the actual detected object. The status_list stores the
function by adjusting the number of iterations. The values 0 no object detected and 1 object detected.

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 58
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

application to stop taking video from the camera and


generate time data afterwards. The real image output
created by the application is shown below. The first
image depicts the four types of frames found in the
baseline frame depicted in Figure 2, whereas the
second image depicts the four types of frames found in
the frame with objects depicted in figure 5.All
timestamps have been stored in the panda's data-frame
until now. We will export our data-frame to a CSV file
on our local drive, as illustrated in figure 6, to gain
insights from the data created. Please remember to
Figure 4 The Baseline Frames release the video variable, as it has been taking up a lot
of memory. Also destroy all windows to avoid getting
The point at which this status value changes from 0 to any errors. This is how the generated CSV looks like.
1 indicates that the object has entered the frame. We can see, there that object has been detected 3 times
Similarly, when this status value goes from 1 to 0, the till the program has ended. We can see the start and
object is no longer visible in the frame. As a result, we end time and calculate the time when the object was
take the time-stamp of these two toggle events from in front of the camera.
the status list's last two values.
You can compare frames by using the imshow function,
which allows you to display each frame in its own
window.

Figure 6 The Output Format

VIII. Results and Discussion

The “Smart webcam motion detection surveillance


system” is a home/office security system that can be
very useful in situations when security is a concern.
The methods used by thieves and robbers to steal have
improved dramatically as a result of technological
advancements in the modern world. As a result,
Figure 5 The Frame with Detected Object surveillance systems must evolve to keep pace with the
changing world. Video surveillance and monitoring
To delay the action until a key is pressed, we utilise the are the most recent technologies utilised in the fight
waitKey method. We use waitKey to acquire a against theft and destruction. It is possible to monitor
continuous live feed from the camera in this case (1). and collect every inch and second of the region of
Simply hit the "Q" key on the keyboard to stop the interest utilising technology. In digital video
video from being captured. We also need to record the surveillance systems, motion detection is the most
last time "Q" was pushed, as this will force the crucial function. It allows the camera to capture only

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 59
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

when necessary rather than all of the time, resulting in takes for an entity to transition from its original
a significant decrease in storage capacity. When condition to its final state, as in biology and chemical
unexpected motion is detected, an alarm can be studies. From here on out, there are a plethora of topics
activated. Personnel are no longer required to monitor that can be investigated further. For instance, the
at all times as a result of this. The motion detector fills methodologies presented could be improved to suit
the requirement for a low-cost, tiny security system in various problem-specific or domain-specific
everyday life. Computerized home-based security can applications. Also, more helpful methods and
develop a lot with the coming future. Future is algorithms, such as those involving tracking the item
promising and easier with innovative technologies. that causes the motion events, such as those using
optical flows or also known as picture flows, could be
IX. Conclusion implemented to improve the procedures. Human
motions are detected in this area. Future works may,
To sum up, our application demonstrates what tasks however, desire to recognize the human body stance
can be accomplished with the help of computer vision, or gesture registered by the algorithm used in the
such as creating surveillance-based simple applications prototype system.
and more advanced AI integrated applications that can
use machine learning to implement tasks such as facial
recognition, emotion detection, object detection, and XI. REFERENCES
so on. Video surveillance and monitoring are the most
recent technologies utilized in the fight against theft [1]. P. S. Von and U. Lichtenthaler, "The role of
and destruction. It is possible to monitor and collect innovation intermediaries in the markets for
every inch and second of the region of interest utilizing technology", Int. J. Technol. Intell. Plan., vol. 7,
technology. In digital video surveillance systems, no. 2, pp. 128, Jan. 2011
motion detection is the most crucial function. It allows [2]. Yusuf Perwej, “An Experiential Study of the Big
the camera to capture only when necessary rather than Data”, International Transaction of Electrical
all of the time, resulting in a significant decrease in and Computer Engineers System (ITECES), USA,
storage capacity. When unexpected motion is detected, Science and Education Publishing, Volume 4,
an alarm can be activated. This relieves personnel from No. 1, Pages 14-25, 2017 DOI: 10.12691/iteces-4-
constant monitoring. The motion detector fills the 1-3
requirement for a low-cost, modest security system in [3]. Weiming Hu, Tieniu Tan, Liang Wang and Steve
everyday life. Computerized home-based security has Maybank, "A Survey on Visual Surveillance of
a lot of potential in the future. With breakthrough Object Motion and Behaviors", IEEE Trans. on
technologies, the future seems bright and easier. Systems Man and Cybernetics-Part C:
Applications and Reviews, vol. 34, no. 3, pp. 334-
X. Future Work 352, August 2004
[4]. Yusuf Perwej, Prof. Syed Qamar Abbas, Jai
This programme can be used for surveillance to Pratap Dixit, Nikhat Akhtar, Anurag Kumar
safeguard any area or important object from Jaiswal, “A Systematic Literature Review on the
unauthorized access, as well as to determine the length Cyber Security”, International Journal of
of time that an unauthorized human or object attempts Scientific Research and Management (IJSRM),
to breach the perimeter or gain access to the protected Volume 9, Issue 12, Pages 669 - 710, 2021 DOI:
object. It can also be used to determine how long it 10.18535/ijsrm/v9i12.ec04

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 60
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

[5]. Xia Dong, Kedian Wang and Guohua Jia, (IJARCCE), Volume 4, Issue 2, Pages 10 - 16,
"Moving Object and Shadow Detection Based on 2015, DOI: 10.17148/IJARCCE.2015.4203
RGB Color Space and Edge Ratio", IEEE 2nd [14]. Thomas, Ashraf, Lal, Mathew,Jayashree,
International Conference on Image and Signal Security enhancement using motion detection,
Processing, pp. 1-5, Oct. 2009 Signal Processing, Communication, Computing
[6]. Yusuf Perwej, Asif Perwej, Firoj Parwej, “An and Networking Technologies (ICSCCN), 2011
Adaptive Watermarking Technique for the International Conference on, Thuckafay, pp.
copyright of digital images and Digital Image 552-557, 2011
Protection”, International journal of Multimedia [15]. Wei, Li, Yue. A Foreground-background
& Its Applications (IJMA), USA , Volume 4, No.2, Segmentation Algorithm for Video Sequences.
Pages 21- 38, 2012, DOI: 10.5121/ijma.2012.4202 Jiangnan Univ. China. 2015
[7]. Y. A. Wang and E. H. Adelson, "Representing [16]. M. Murshed, A. Ramirez, O. Chae, “Statistical
moving images with layers", IEEE Transactions Background Modeling: An Edge Segment Based
on Image Processing, vol. 3, no. 11, pp. 625-638, Moving Object Detection Approach”, Proc. of
Sept. 1994 IEEE International Conf. on Advanced Video
[8]. Y. You, S. Gong, C. Liu, "Adaptive moving object and Signal Based Surveillance, (2010), pp. 300-
detection algorithm based on back ground 305.
subtraction and motion estimation", Int. J. [17]. Yusuf Perwej, “An Optimal Approach to Edge
Advancements in Computing Technology, vol. 5, Detection Using Fuzzy Rule and Sobel Method”,
no. 6, pp. 357-363, 2013 International Journal of Advanced Research in
[9]. 9M. Murshed, A. Ramirez, O. Chae, “Statistical Electrical, Electronics and Instrumentation
Background Modeling: An Edge Segment Based Engineering, Volume 4, Issue 11, Pages 9161-
Moving Object Detection Approach”, Proc. of 9179, 2015, DOI:
IEEE International Conf. on Advanced Video 10.15662/IJAREEIE.2015.0411054
and Signal Based Surveillance, pp. 300-305, 2010 [18]. Md. Z. Islam, C.M. Oh and C. W. Lee, “Video
[10]. Geethapriya. S, N. Duraimurugan, S.P. Based Moving Object Tracking by Particle
Chokkalingam, “Real-Time Object Detection Filter”, International Journal of Signal
with Yolo”, International Journal of Engineering Processing, Image Processing and Pattern, vol. 2,
and Advanced Technology (IJEAT) ISSN: 2249 – no. 1, pp. 119–132., 2009
8958, Volume-8, Issue-3S, February 2019. [19]. P. Dunne and B. J. Matuszewski, “Histogram
[11]. Thakker and Kapadia, Image processing on Based Detection of Moving Objects for Tracker
embedded platform Android, Computer, Initialization in Surveillance Video”,
Communication and Control (IC4), 2015 International Journal of Grid and Distributed
International Conference on, Indore, pp. 1-6, Computing, vol. 4, no. 3, pp. 71-78, 2011
2015 [20]. N. R. Shin and K. Hong, “A Study on the
[12]. Marengoni and Stringhini. High Level Computer Development of Multiple Objects Extraction
Vision using OpenCV. 2011. Universidade Method Using Difference Image Edge
Presbiteriana Mackenzie. Information”, International Journal of Energy,
[13]. Yusuf Perwej, “An Evaluation of Deep Learning Information and Comm., vol. 2, no. 2, pp. 108–
Miniature Concerning in Soft Computing”, 120, 2011
International Journal of Advanced Research in [21]. Yusuf Perwej, Firoj Parwej, Asif Perwej, “
Computer and Communication Engineering Copyright Protection of Digital Images Using

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 61
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

Robust Watermarking Based on Joint DLT and [32]. Yusuf Perwej, “An Evaluation of Deep Learning
DWT ”, International Journal of Scientific & Miniature Concerning in Soft Computing”,
Engineering Research (IJSER), France, Volume International Journal of Advanced Research in
3, Issue 6, Pages 1- 9, 2012 Computer and Communication Engineering
[22]. Papert, The summer vision project, (IJARCCE), Volume 4, Issue 2, Pages 10 - 16,
Massachusetts Institute of technology, 1996 2015, DOI: 10.17148/IJARCCE.2015.4203
[23]. Efstration Graves, A brief history of computer [33]. Ankit Kumar, Neha kulshrestha, Yusuf Perwej,
vision [Internet]. 2016 [updated 05/05-2016, Ashish Kumar Srivastava, Chandan Mani
cited 05/05-2016]. Tripathi, “The Assay of Potholes and Road
[24]. Roqueiro, Petrushin, Counting people using Damage Detection”, International Journal of
video cameras, Department of Computer Scientific Research in Computer Science,
Science, University of Illinois at Chicago, Engineering and Information Technology, Vol.
Chicago, IL 60607, USA, 2006 8, Issue 1, Pages 202-211, January-February-
[25]. Havaei1, Jodoin1, Efficient interactive brain 2022, DOI: 10.32628/CSEIT228135
tumor segmentation as within-brain kNN [34]. L. Li, W. Huang, I. Y.H. Gu, Q. Tian, "Statistical
classification. University Sherbrooke, Canada. modeling of complex backgrounds for
2014 foreground object detection," in IEEE
[26]. Mobileye, Mobileye - Our Vision. 2016 [updated Transactions on Image Processing, vol. 13, no.
04/25-2016, cited 25/04-2016] 11, pp:1459-1472, 2004
[27]. Guo, L., Liao, Y., Luo, D. Generic Object [35]. Dictionary. Pixel: Define pixel [Internet]. 2016
Detection Using Improved Gentle boost [updated 12/05-2016, cited 12/05-2016].
Classifier. Phys. Procedia 25, 1528–1535, 2012, [36]. G. Bradski, A. Kaehler, O' Reilly, Learning
doi:10.1016/j.phpro.2012.03.272 OpenCV, 2008
[28]. Ben Ayed, A., Ben Halima, M., & Alimi, A.M., [37]. Yusuf Perwej, Shaikh Abdul Hannan, Nikhat
2015. MapReduce-based text detection in big Akhtar, “The State-of-the-Art Handwritten
data natural scene videos. Procedia Comput. Sci. Recognition of Arabic Script Using Simplified
53, 216–223. doi:10.1016/j.procs.2015.07.297 Fuzzy ARTMAP and Hidden Markov Models”,
[29]. Yusuf Perwej, “Recurrent Neural Network International Journal of Computer Science and
Method in Arabic Words Recognition System”, Telecommunications, Volume, Issue 8, Pages 26
International Journal of Computer Science and - 32, 2014
Telecommunications (IJCST), UK, London [38]. D Lin, J Dai, J Jia et al., "Scribblesup: Scribble-
Volume 3, Issue 11, Pages 43-48, 2012 supervised convolutional networks for semantic
[30]. Viswanath, A., Kumari, R. & Senthamilarasu, V., segmentation", II Proceedings of the IEEE Conf.
2015. Background Modelling from a Moving on Computer Vision and Pattern Recognition,
Camera. Procedia - Procedia Comput. Sci. 58, pp. 3159-3167, 2016
289–296. doi:10.1016/j.procs.2015.08.023 [39]. G. Yao, T. Lei, J. Zhong, P. Jiang and W. Jia,
[31]. Najva, N. & Bijoy, K.E., 2016. SIFT and Tensor- "Comparative Evaluation of Background
Based Object Detection and Classification in Subtraction Algorithms in Remote Scene Videos
Videos Using Deep Neural Networks. Procedia Captured by MWIR Sensors", Sensors, vol. 17,
Comput. Sci. 93, 351–358. no. 9, pp. 1945, Aug. 2017
doi:10.1016/j.procs.2016.07.220 [40]. M. Piccardi, "Background subtraction
techniques: a review", Systems Man and

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 62
Shubham Mishra et al Int J Sci Res Sci Eng Technol, March-April-2022, 9 (2) : 51-63

Cybernetics2004 IEEE International


Conference, vol. 4, pp. 30997-3104, 2004
[41]. Yusuf Perwej, Nikhat Akhtar, Firoj Parwej, “The
Kingdom of Saudi Arabia Vehicle License Plate
Recognition using Learning Vector Quantization
Artificial Neural Network”, International
Journal of Computer Applications (IJCA), USA,
Volume 98, No.11, Pages 32 – 38, 2014, DOI:
10.5120/17230-7556
[42]. M. Piccardi, "Background subtraction
techniques: a review", IEEE International
Conference on Systems Man and Cybernetics,
pp. 3099-3104, 2004

Cite this article as :

Shubham Mishra, Mrs. Versha Verma, Dr. Nikhat


Akhtar, Shivam Chaturvedi, Dr. Yusuf Perwej, "An
Intelligent Motion Detection Using OpenCV",
International Journal of Scientific Research in Science,
Engineering and Technology (IJSRSET), Online ISSN :
2394-4099, Print ISSN : 2395-1990, Volume 9 Issue 2,
pp. 51-63, March-April 2022. Available at doi :
https://doi.org/10.32628/IJSRSET22925
Journal URL : https://ijsrset.com/IJSRSET22925

International Journal of Scientific Research in Science, Engineering and Technology | www.ijsrset.com | Vol 9 | Issue 2 63

View publication stats

You might also like