MODAL Examples


The frame grabber and image display

Start a tcl shell and load the package (output in orange):
/usr/local/bin/tclsh
% load MODAL
VideoServer: ready to serve
Frame size: 320 x 240

Grab a back ground image, bg,  and display it:
% md_newBg
% md_writeIm bg

Grab a new frame from the video to curr and display it:
% md_grabFrame
% md_writeIm curr

Calculate the absolute difference and display the resulting diff image:
% md_calcDiff
% md_writeIm diff

Threshold the diff image and display the resulting bin image:
% md_calcBin
% md_writeIm bin

Calculate the statistics, write a cross at (xmean, ymean) in the curr image, and display it:
% md_calcStat
% set x [md_getStat mean x];
0.686699
% set y [md_getStat mean y];
0.583233
% md_writeCross $x $y;
% md_writeIm curr


Script that compares a background image with new video input
 
#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "@" 
load MODAL
md_newBg;
set areaThreshold 0.01
while {1} {
    md_grabFrame;
    md_calcDiff;
    md_calcBin;
    md_calcStat;
    if {[md_getStat area] > $areaThreshold} {
        set x [md_getStat mean x]
        set y [md_getStat mean y] 
        puts "Movement at: x = $x y = $y"
    }
}
Output: 
VideoServer: ready to serve
Frame size: 320 x 240
Movement at: x = 0.715089 y = 0.412059


(etc.)


Return to Modal Home Page


(Last updated October 22, 1998)