PROPOSED DETECTION SYSTEMPROPOSED DETECTION SYSTEM
5.3 Motion Detection Using Sum of Absolute Difference (SAD) Motion Detection Using Sum of Absolute Difference (SAD)
5.3 Motion Detection Using Sum of Absolute Difference (SAD)
T
Where N N is the number of pixels in the image used as scaling factor,is the number of pixels in the image used as scaling factor, )
D is the normalized sum of absolute difference for that time.is the normalized sum of absolute difference for that time.
In an ideal case when there is no motion In an ideal case when there is no motion
)
and
and D D((t t )) ==00. However noise is always presented in images and a better model of . However noise is always presented in images and a better model of the images in the absence of motion will be
the images in the absence of motion will be
) ) ( ( ) ) ( ( ) ) (
(t t I I t t nn pp I
I ii == j j ++
Where
Where nn(( p p)) is a noise signal.is a noise signal.
The value
The value D D((t t )) that represents the normalized sum of absolute difference can bethat represents the normalized sum of absolute difference can be used as a reference to be compared with a threshold value as shown in figure 9 used as a reference to be compared with a threshold value as shown in figure 9 below.
below.
The figure also shows a test case that contains a large change in the scene being The figure also shows a test case that contains a large change in the scene being monitored by the camera this was done by moving the camera. During the time monitored by the camera this was done by moving the camera. During the time before the camera was moved the SAD value was around 1.87 and when the camera before the camera was moved the SAD value was around 1.87 and when the camera was moved the SAD value was around 2.2. If the threshold for detection was fixed was moved the SAD value was around 2.2. If the threshold for detection was fixed around the value less than 2.2 it will continuously detect motion after the camera stop around the value less than 2.2 it will continuously detect motion after the camera stop moving.
moving.
Figure 9 Direct Thresholds for SAD Values Figure 9 Direct Thresholds for SAD Values
Th
This is appapproaroach ch solsolve ve the the neeneed d for for concontintinuouuously sly re-ere-estistimatmate e the the thrthreshesholdold value. Choosing a threshold of 1*10
value. Choosing a threshold of 1*10-3-3 will detect the times when only the camera iswill detect the times when only the camera is moved. This results into a robust motion detection algorithm that can not be affected moved. This results into a robust motion detection algorithm that can not be affected by illumination change and camera movements. worth to mention that the values of variance that was calculated whether it was above worth to mention that the values of variance that was calculated whether it was above or below the threshold will be stored in an array, where it will be used later to or below the threshold will be stored in an array, where it will be used later to produce a plot of frame number Vs. the variance value. This plot helps in comparing produce a plot of frame number Vs. the variance value. This plot helps in comparing the variance values against the threshold to be able to choose the optimum threshold the variance values against the threshold to be able to choose the optimum threshold value.
value.
Whenever the variance value is less than threshold the image will be dropped Whenever the variance value is less than threshold the image will be dropped and only the variance value will be recorded. However when the variance value is and only the variance value will be recorded. However when the variance value is greater than threshold sequence of actions is being started as shown in figure 10
As the above flow
As the above flow chart show a number of chart show a number of activitactivities happen when motion isies happen when motion is detected. First the serial port is being triggered by a pulse from the PC; this pulse is detected. First the serial port is being triggered by a pulse from the PC; this pulse is used to activate external circuits connected to the PC. Also a log file is being created used to activate external circuits connected to the PC. Also a log file is being created and then appended with information about the time and
and then appended with information about the time and date of motion also the framedate of motion also the frame number in which motion occur is being recorded in the log file. Another process is to number in which motion occur is being recorded in the log file. Another process is to display the image that was detected on the monitor. Finally the image that was display the image that was detected on the monitor. Finally the image that was detect
detected in motion will be converted to a ed in motion will be converted to a movimovie frame and e frame and will be added to the filmwill be added to the film structure.
structure.
5.3.2 Break and clear Process 5.3.2 Break and clear Process
After motion detection algorithm applied on the
After motion detection algorithm applied on the images the program checks if images the program checks if the stop button on GUI was pressed. If it was pressed the flag value will be changed the stop button on GUI was pressed. If it was pressed the flag value will be changed from one to zero and the program will break and terminate the loop then it will return from one to zero and the program will break and terminate the loop then it will return the control to the GUI. Next both serial port object and video object will be cleared.
the control to the GUI. Next both serial port object and video object will be cleared.
This process is considered as a cleaning stage where the devises connected to the PC This process is considered as a cleaning stage where the devises connected to the PC through those objects will be released and the memory space will be freed.
through those objects will be released and the memory space will be freed.
5.3.3 Data Record 5.3.3 Data Record
Finally when the program is terminated a data collection process starts where Finally when the program is terminated a data collection process starts where variable and arrays that contain result of data on the memory will be stored on the variable and arrays that contain result of data on the memory will be stored on the hard disk. This approach was used to separate the real time image processing from hard disk. This approach was used to separate the real time image processing from results processing. This has the advantage of calling back these data whenever it is results processing. This has the advantage of calling back these data whenever it is required. The variables that are being stored from memory to the hard disk are required. The variables that are being stored from memory to the hard disk are variance values and the movie structure that contain the entire frames with motion.
variance values and the movie structure that contain the entire frames with motion.
At this point the control will be returned to the GUI where the operator can callback At this point the control will be returned to the GUI where the operator can callback the results that where archived while the system was turned on. Next section will the results that where archived while the system was turned on. Next section will explain the design of the GUI highlighting each button results and callbacks.
explain the design of the GUI highlighting each button results and callbacks.
Fig 11 Flow chart for SAD algoritham Fig 11 Flow chart for SAD algoritham
Fig 12 Frame separation Fig 12 Frame separation
Fig 13 Divide Quadrants Fig 13 Divide Quadrants
START START
IMAGE ACQUISTION IMAGE ACQUISTION
FRAME SEPARATION FRAME SEPARATION
DIVIDE QUADRANTS DIVIDE QUADRANTS
SUM OF SUM OF
ABSOLUT DIFFERENCE ABSOLUT DIFFERENCE
>T
>T DATADATA RECORD RECORD
5.3.4 Graphical User Interface Design 5.3.4 Graphical User Interface Design
The GUI was designed to facilitate interactive system operation. GUI can be The GUI was designed to facilitate interactive system operation. GUI can be used to setup the program, launch it, stop it and display results.
used to setup the program, launch it, stop it and display results.
End End Start Start
Clear all Previous Work Clear all Previous Work
Variable Initialization & Setup Variable Initialization & Setup
Launch program Launch program
Call Selected main Program Call Selected main Program
Terminate Program Terminate Program
View Results View Results
Start Again Start Again
NO NO Yes
Yes
Exit Exit
Figure 14 GUI flow Chart Figure 14 GUI flow Chart
During setup stage the operator is promoted to choose a motion detection During setup stage the operator is promoted to choose a motion detection alg
algoriorithm thm and and selselect ect degdegree ree of of the the detdetectection ion sensensitsitivitivity y WheWhenevnever er the the stastart/srt/stoptop toggle button is pressed the system will be launched and the selected program will be toggle button is pressed the system will be launched and the selected program will be called to perform the calculations until the start/stop button is pressed again which called to perform the calculations until the start/stop button is pressed again which will terminat
will terminate e the calculatithe calculation and on and return contreturn control to rol to GUI. ResultGUI. Results can s can be viewed as abe viewed as a log file, movie and plot of frame number vs. variance value. Figure 14 illustrate a log file, movie and plot of frame number vs. variance value. Figure 14 illustrate a flow chart of the steps performed using the GUI.
flow chart of the steps performed using the GUI.