<< Chapter < Page Chapter >> Page >

High-level python implementation

The Python OpenCV library exposes an API for the entire Canny edge detection algorithm. The Canny algorithm issimilar to, but more nuanced than, our algorithm, substituting our selective thresholding procedure for hysteresis. However,the end results are very similar. As is evident from Listing 5, the procedure is very straightforward.

Listing 5. python implementation of canny edge detection with opencv

LOW_THRESHOLD = 100 HIGH_THRESHOLD = 200edges = cv2.Canny(img, LOW_THRESHOLD, HIGH_THRESHOLD)

Motion detection algorithm

Our motion detection algorithm compares the edges from two frames temporally separated by a small interval of time and attempts to estimate regions of the frame that exhibitmovement or motion. This process is then repeated continuously to provide a real-time visualization of the regions ofmovement in a continuous video stream. The motion detection algorithm we present is composed of the following steps:

  1. Given two frames F1 and F2 separated by a time interval of Δt, compute its edges E1 and E2.
  2. Create a strict binary difference matrix D0 between E1 and E2 whose value is high at locations at which anedge is present in frame but not the other, and low at locations at which both frames have an edge or no edge.
  3. Apply a parameter-controlled movement tolerance thresholding operation to the matrix D0 to obtainmatrix D, in order to suppress potential false positives of detected motion from incidental camera movement.

F1 and F2 are obtained by sampling frames from a continuous video stream, a task aided by the OpenCV C library.Thus, the time interval Δt will be small enough for a realtime algorithm. The edges E1 and E2 are computed with theedge detection algorithm of Section II. Below, we explore, in greater depth, the procedures for building a thresholdeddiffrence matrix and finally estimating the motion area by analyzing a spatial difference density map.

Thresholded frame-by-frame difference map

The preliminary requirement in determining areas of motion from two frames is a systematic method of determining andquantifying the differences between two frames separated by a small Δt. Intuitively, areas of motion within the time intervalΔt should exist at locations at which the difference between the two frames is large. This process is then continuouslyrepeated for every pair of input frames in order to create a realtime motion detector. In our algorithm, we quantify differenceson a binary basis using edge data from our edge detection algorithm, then determine motion locations from a thresholdeddensity map of the difference matrix D. More formally, we begin with a matrix D0 created from asimple comparison of E1 and E2. Then, for each location (i, j) in D0, a thresholded differencematrix D is created by considering a box of constant size b x b around that pixel and suppressing the value of the surroundingpixels to 0 if its value matches that at D0[i,j]. This step isdesigned to reduce false positives of motion detection arising from stray movement of the frame (e.g. camera shake). Thecomputation of D is demonstrated in Algorithm 2. The output matrix is then used as input to building a spatial differencedensity map, from which we estimate motion locations.

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Elec 301 projects fall 2015. OpenStax CNX. Jan 04, 2016 Download for free at https://legacy.cnx.org/content/col11950/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Elec 301 projects fall 2015' conversation and receive update notifications?

Ask