Motion Detection Algorithm
In this project, our team are using C# to program a software that will able to perform motion detection and tracking. (Special thanks to codeproject.com for providing the references)
Comparing Current Frame with the Previous Frame (RGB)
image = Current frame captured
currentFrame = current frame grayscaled
backgroundFrame = Previous frame
Then frame comparison was performed,
Temp1 = currentFrame - backgroundFrame
Then the red channel of image was replaced with the red channel of Temp1.
The result shown in Figure 1,

Figure 1
Disadvantage: If object moves very slowly, the frame to frame change will be small. It willl probably fail to detect motion.
New approach is used: Background frame is moved to the current frame on the specified amount (1 level per frame).
The result of this new approach is shown in Figure 2,

Figure 2
Applying Pixellate filter will resulting:

Figure 3
Optimization is done to the result of Pixellate filter by determining the outer most pixel. Hence resulting:

Figure 4
After optimization, the result is processed using the Blob Counter from aForge.net libraries. The Blob Counter will numbered the object and determine the position and dimension of the moving object. This resulting the boxed object shown below.

Figure 5
Other funtions in the software
This software has the function to select any camera connected to the computer (if more than 1 camera connected).
This software can 'box' multiple moving object. But since we are only interested in the first moving object (spotlight can only spot 1 object), only the first object detected will be 'boxed'.
There is also a function to record video only when motion is detected. This will save the hard disk space.