Image Processing Reference
In-Depth Information
If this difference is above a set threshold, we fire a "Motion Detected" event, which can activ-
ate a sound alarm, etc., to get the atention of the operator. We can adjust the threshold value
to make the detector more or less sensitive to pixel value changes. We can also display the
pixels that triggered the alarm visually. The parallel algorithm is shown in Pseudo-code 4:
Pseudo-code 4
//one thread for each pixel
foreach pixel p do
color_diff = prev_color(p) - curr_color(p)
// square of different
color_diff * = color_diff
// update previous color
prev_color(p) = curr_color(p)
// empirically chosen value.
// can be adjusted to make detector more
// or less sensitive to changes.
threshold = 5000
if ( color_diff > threshold ) then
fire "Motion Detected" event
current_color(p) = RED
leave pixel unchanged
OR make pixel gray
OR anything you want
4.2 Over a Line Motion Detector
Even though the Motion Detector algorithm presented earlier is a simple and useful algorithm,
many times we are interested only in a section of the live video feed. This algorithm is applic-
able when, for example, there is a busy road on the left and a restricted area on the right of the
ield of view of the camera. A single line can divide the live video feed into two areas. Since a
line is defined but only two points, an operator only needs to define these two points. Alarm
events get generated only if there is motion above the user-defined line. To implement this al-
gorithm, we will use the dot product of two vectors. There are two ways of calculating the dot
product of two vectors:
Search WWH ::

Custom Search