Escolar Documentos
Profissional Documentos
Cultura Documentos
= 9 8 9 8
(
9 8
j i
t I t I
N
t D
5.(
-here N is the numer of pi#els in the image used as scaling factor7
9 8
i
t I
is the
image I at time i 7
9 8
j
t I
is the image I at time
j
and
9 8t D
is the normali,ed
sum of asolute difference for that time.
In an ideal case when there is no motion
9 8 9 8
j i
t I t I =
5.)
==
$igure 5.5 ;ariance ;alues as Reference for Threshold
Chapter 5. Software Design and Implementation Activation of Recording Based on Motion
and
0 9 8 = t D
. Cowever noise is alwa!s presented in images and a etter model of the
images in the asence of motion will e
9 8 9 8 9 8 p n t I t I
j i
+ =
5.=
-here
9 8 p n
is a noise signal.
The value
9 8t D
that represents the normali,ed sum of asolute difference can e
used as a reference to e compared with a threshold value as shown in figure 5.A
elow.
The aove figure shows a test case that contains a large change in the scene eing
monitored ! the camera this was done ! moving the camera. During the time efore
the camera was moved the SAD value was around (.*E and when the camera was
moved the SAD value was around ).). If the threshold for detection was fi#ed around
the value less than ).) it will continuousl! detect motion after the camera stop
moving.
=D
$igure 5.A Direct Threshold for SAD ;alues
Chapter 5. Software Design and Implementation Activation of Recording Based on Motion
To overcome this prolem the same solution that was applied to the correlation
algorithm will e used. The variance value was computed after collecting two SAD
values and the result is shown for the same test case in figure 5.E elow.
This approach solve the need for continuousl! reBestimate the threshold value.
Choosing a threshold of (F(0
B=
will detect the times when onl! the camera is moved.
This results into a roust motion detection algorithm that can not e affected !
illumination change and camera movements.
=5
$igure 5.E ;ariance ;alues as Reference for Threshold
Chapter 5. Software Design and Implementation Activation of Recording Based on Motion
5.2.* #ctions on Motion "etection
Before e#plaining series of actions happen when motion is detected it is worth to
mention that the values of variance that was calculated whether it was aove or elow
the threshold will e stored in an arra!7 where it will e used later to produce a plot of
frame numer ;s. the variance value. This plot helps in comparing the variance
values against the threshold to e ale to choose the optimum threshold value.
-henever the variance value is less than threshold the image will e dropped and
onl! the variance value will e recorded. Cowever when the variance value is greater
than threshold se1uence of actions is eing started as shown in figure 5.* elow.
As the aove flow chart show a numer of activities happen when motion is detected.
$irst the serial port is eing triggered ! a pulse from the 5CH this pulse is used to
activate e#ternal circuits connected to the 5C. Also a log file is eing created and then
appended with information aout the time and date of motion also the frame numer
in which motion occur is eing recorded in the log file. Another process is to displa!
the image that was detected on the monitor. $inall! the image that was detected in
motion will e converted to a movie frame and will e added to the film structure.
=A
$igure 5.* Actions on Motion Detection
Time
Date
$rameI
&pdate
"og $ile
Trigger
Serial
5ort
Displa!
Image
Convert
Image to
$rame
Stop
Start
Chapter 5. Software Design and Implementation Activation of Recording Based on Motion
5.2.5 +rea, and clear Process
After motion detection algorithm applied on the images the program chec's if the stop
utton on %&I was pressed. If it was pressed the flag value will e changed from one
to ,ero and the program will rea' and terminate the loop then it will return the
control to the %&I. 4e#t oth serial port o6ect and video o6ect will e cleared. This
process is considered as a cleaning stage where the devises connected to the 5C
through those o6ects will e released and the memor! space will e freed.
5.2.- "ata .ecord
$inall! when the program is terminated a data collection process starts where variale
and arra!s that contain result of data on the memor! will e stored on the hard dis'.
This approach was used to separate the real time image processing from results
processing. This has the advantage of calling ac' these data whenever it is re1uired.
The variales that are eing stored from memor! to the hard dis' are variance values
and the movie structure that contain the entire frames with motion.
At this point the control will e returned to the %&I where the operator can callac'
the results that where archived while the s!stem was turned on.
4e#t section will e#plain the design of the %&I highlighting each utton results and
callac's.
5.! /raphical $ser Inter&ace "esign
The %&I was designed to facilitate interactive s!stem operation. %&I can e used to
setup the program7 launch it7 stop it and displa! results. During setup stage the
operator is promoted to choose a motion detection algorithm and select degree of the
detection sensitivit!. -henever the startJstop toggle utton is pressed the s!stem will
e launched and the selected program will e called to perform the calculations until
the startJstop utton is pressed again which will terminate the calculation and return
control to %&I. Results can e viewed as a log file7 movie and plot of frame numer
vs. variance value. $igure 5.: illustrate a flow chart of the steps performed using the
%&I.
=E
Chapter 5. Software Design and Implementation Activation of Recording Based on Motion
The complete %&I code is included in the appendi#.
=*
?nd
Start
Clear all 5revious -or'
;ariale Initiali,ation + Setup
"aunch program
Call Selected main 5rogram
Terminate 5rogram
;iew Results
Start Again
4< 3es
?#it
$igure 5.: %&I flow Chart
Chapter 5. Software Design and Implementation Activation of Recording Based on Motion
The %&I as shown in figure 5.(0 was designed using MAT"AB %&I Builder. It
consists of two radio uttons7 two sliders7 two static te#t o#7 four push uttons and a
toggle utton. Sliders and radio uttons were used to prevent entering a wrong value
or selection.
The radio uttons are eing used to choose either SAD algorithm or )D cross
correlation algorithm. Both algorithms can not e selected at the same time.
Sliders are used to select how sensitive the detection is7 ma#imum sensitivit! is
achieved ! moving the slider to the left. The static te#t show the instantaneous value
of the threshold as read from the sliders. -hen %&I first launch it will select the
optimum value for oth algorithms as default vale.
=:
$igure 5.(0 %&I "a!out Design
Chapter 5. Software Design and Implementation Activation of Recording Based on Motion
Moving to the control panel Start J Stop utton is used to launch the program when it
is first pushed and to terminate the program when it is pushed again. $igure 5.(( show
flow chart of commands e#ecuted when this utton is pressed.
-henever the StartJStop utton is first pushed it will set the value of the flag to ( then
it will chec' the value of the radio uttons to determine which main program to
launch.
A log file that contains information aout time and date of motions with frame
numer is eing opened when the log file icon is pushed.
The program is eing closed and MAT"AB is shutdown when the e#it utton is
pushed.
-henever the show movie icon is pushed7 MAT"AB will load the film structure that
was created efore from the hard dis' then it will convert the structure into a movie
and displa! it on the screen at a rate of 5 frames per seconds. $inall! the movie
created will e compressed using the Indeo= compression techni1ue and will e saved
on the hard dis' under the name Kfilm.aviL. $igure 5.() elow show the commands
e#ecuted when this icon is pushed.
D0
$igure 5.(( StartJStop utton flow chart
Start
I& start0stop
Flag12 Flag11
.un 2"
Corr.m
.un S#".m
Stop
Pressed Impressed
.adio 'utton
value
1 2
Chapter 5. Software Design and Implementation Activation of Recording Based on Motion
The last utton which is the show plot icon loads the values of the variance to plot it
against the frame numer as shown elow in figure 5.(=.
5ress
ed
3es 4o
Star
t
Stop
"oad $ilm Structure
Convert to Movie +
Displa!
Compress Movie + save
Storage
Storage
D(
$igure 5.() Movie Button Callac's
5ress
3es 4o
Star
t
Stop
"oad ;ariance ;alues
Show 5lot
Storage
$igure 5.(= 5lot Button Callac's