MODAL Overview


MODAL is a package of tools for SGI video handling together with a set of image operations, which are useful for movement detection and localization. The video tools are based on SGIs Digital Media buffers. MODAL has a set of internal variables that stores image data and determines the way algorithms are performed. Many of these parameters can be changed by Tcl/Tk commands, providing a flexible set of tools for video image processing. All commands in the package start with the prefix md_ which makes it easy to separate ordinary Tcl/Tk commands from MODAL commands. Text written in courier refers to names of the internal variables.


Internal Variables
MODALs internal variables can be divided into images and modifiers. The images store image data for grabbed frames, back ground images, and intermediate steps of the image operations. The modifiers are used to change the behavior of the algorithms.

Images
Image name Description Command to change the image
default Black image none
bg The back ground image md_newBg or md_grabFrame
curr The last grabbed video frame (or field)  md_grabFrame
diff The absolute difference between curr and bg md_calcDiff
bin Thresholded bin image. Three binary color layers.  md_calcBin
 

Modifiers
Modifier name Description Command to change modifier Valid values
fields The field mode of the frame grabber md_configureVideo 1 (fields), 2 (frames) and 3 (odd fields)
zoom The size of the image frames md_configureVideo Integer between 1 and 256
delay Number of clock ticks to wait after each grab. md_setDelay Integer >= 0
tRed tGreen tBlue Thresholds for the different color layers md_setThres Numerical values between 0 and 1
layer Color layer(s) to perform calculations on md_setLayer all (0), red (3), green (2), blue (1)
thresMode Specifies how the layers should be combined when calculating statistics md_setThresMode and (0), or (1)
bgMode Specifies how bg should be updated md_setBgMode static (0), moving (1)
dispIm Default image to display or calculate md_setDispIm default (0), bg (1), curr (2), diff (3), bin (4)
imChain The state of the image chain md_setImChain default (0), bg (1), curr (2), diff (3), bin (4), stat (5)
 

The Buffer
The storage structure in the memory used to write the image data from the video on, is a ring buffer with space for four images. The DMbuffer real-time visual data transport facility, operates with pointers to the place in memory where the data is written. In this way the image content is not moved, but only pointers to it, making the application much faster. When grabbing a frame in MODAL, the pointer to the image data is by default returned before all video data has been written to memory. This is important to be aware of when writing applications with MODAL, since a sequence of operations may be made with the "old" data of the image if the delay variable is too small. In this case the application will lag four frames. Note that for certain in appropriate values of delay, only parts of the image data may have been written. In applications where frame rate is the most important factor, the delay should be set to zero. The lagging is the price we have to pay for higher frame rate.

A frame grab goes through the following steps:
 
1) If bgMode = moving: set the bg pointer to the curr pointer
2) Set the curr pointer to point at the next buffer
3) Start write image data to the place where curr points
4) Wait delay clock ticks
5) Return the curr pointer
 
 
 
 

The image chain
The command md_calcImage ?arg? uses the image chain to perform all the necessary calculations needed to create the required output. If, for example, the current state of the image chain is diff, and the arg = stat, the commands md_calcBin and md_calcStat will be performed in an optimal way. If a new video frame is grabbed, the state of the image chain will be set to curr, and another call for md_calcImage with the same argument would pull the chain through all intermediate images and perform the final md_calcStat.



Return to Modal Home Page


(Last updated October 7, 1998)