Image Processing Reference
This algorithm detects motion on the line. Because the line could be very skinny, depending
on its slope, only a few pixels could end up exactly on the line. For this reason, we can
make the line thicker by adjusting the limits of the dot product. Instead of checking if the dot
product is equal to exactly zero, we can check if the dot product is between the positive and
negative n , where n is a user-specified value. The algorithm in Pseudo-code 6 illustrates the
Line Crossing Detector.
One problem with this algorithm is that the thickness of the line depends on the distance
between the points A and B that specify the line. To fix this, we need to calculate the distance
(length) between the two points as shown below:
// find length of line
LEN = sqrt(distX*distX+distY*distY);
if if(LEN equals 0) then
and then we need to replace in Pseudo-code 6
if ( r >= -200 && r <= 200 ) then
if (r/LEN >= -X && r/LEN <= X) then
Now the width of the line does not depend on the distance of the A and B points. The value
of X specifies the thickness of the line, and it does not depend on the length of the vector .
This is very useful when the user wants to dynamically adjust the position and orientation of
the line by manipulating the points A and B .
Figure 3 is a snapshot of our application showing motion detection above a user-speciied
line and also motion on the line, in real time on a video feed with resolution 1920 × 1080.
FIGURE 3 Snapshot showing motion detected above a user-specified line and on the line.