MODAL Manual

(Text written in courier refers to internal variables, see Modal overview for more information)


Frame grabber:
md_configureVideo
md_setDelay

Video input:

md_grabFrame
md_newBg

Video Image operations:

md_calcDiff
md_calcBin
md_calcStat
md_calcImage
md_setImChain
md_getStat

Display images:

md_display
md_writeIm
md_writeCross
md_setDispIm

Configuring the algorithms:

md_setLayer
md_setThres
md_setThresMode
md_setBgMode
md_status

Saving images to file:

md_saveFrame

NAME

md_configureVideo - Configure the video source

SYNOPSIS

md_configureVideo ?fields zoom?

DESCRIPTION

This command changes the type and size of the video frames. If no arguments are given, it returns the current settings. The default values are fields = 2 and zoom = 2, which corresponds to a frame size of 320 x 240 pixels.
fields
This integer specifies the field mode which determines the type of video frame the video source will deliver. Valid values are 1 (fields; odd or even), 2 (frames; 2 non-interleaved fields) and 3 (odd fields only). By grabbing fields (1 or 3) instead of frames (2), only every second line in a normal frame is grabbed, resulting in a image that is compressed in the vertical direction. In advantage of this is that fingering artifacts can be avoided. If type 1 is used, frame rate may be doubled, (depending on the delay value, see below). If type 3 is used, the frame rate is not changed but, the image is more stable in the y direction than for type 1.
zoom
The zoom factor, is an integer specifying the denominator for the fraction of the original size to zoom. It ranges from 1 to 256. For some SGI VL devises, zoom must be 1.

NAME

md_setDelay - Change the value of the delay variable

SYNOPSIS

md_setDelay ?ticks?

DESCRIPTION

This command is used to change the number of clock ticks Modal should wait after grabbing a frame or field. For applications where frame rate is the most important factor, it is recommended to set delay to zero. The drawback is that Modal doesn't wait for the data to be written to the memory from the video source, and therefore applications will lag behind for some frames (see Modal overview for detailed information). If no argument is given, the current setting will be returned. The default value of delay is nine clock ticks, which is enough for the data of the largest possible frame to be written into memory.


NAME

md_grabFrame - Grab one frame from the video source to curr (current image)

SYNOPSIS

md_grabFrame

DESCRIPTION

This command grabs one video frame (or field) to memory and waits delay clock ticks to ensure that all data is written to memory, before passing an image to another operations, (see md_setDelay). If bgMode has the value moving (see md_setBgMode), the back ground image, bg, is set to the previously grabbed frame.


NAME

md_newBg - Grab one frame and update bg (the back ground image)

SYNOPSIS

md_newBg

DESCRIPTION

This command has two consequences. Firstly one frame will be grabbed into the curr image, and the bg image will copy it's data from curr. Here it's important to have an appropriate value for the delay. Secondly the bgMode is set to static.


NAME

md_calcDiff - Calculate the diff image

SYNOPSIS

md_calcDiff

DESCRIPTION

This operation calculates the absolute difference between the curr and bg image and creates the resulting diff image. Only color layers specified by the internal variable layer are affected by this operation.


NAME

md_calcBin - Calculate the bin image

SYNOPSIS

md_calcBin

DESCRIPTION

This image operation performs a thresholding on the diff image to create a binary output. Only color layers specified by the internal variable layer are affected by this operation. The thresholds for each color layer can be set separately, using md_setThres.


NAME

md_calcStat - Calculate statistics of the bin image

SYNOPSIS

md_calcStat

DESCRIPTION

This command calculates statistics of the bin image. Only layers specified by layer are used. If layer has the value all, the algorithm can be altered by setting thresMode to or instead of the default value and. The pixels contributing to the statistics must fulfill the following condition:
If thresMode = and: all three binary layers must be one
If thresMode = or: some of its binary layers must be one
The statistics calculated are:
area
center of gravitation (mean x, mean y)
left/right most x, upper/lower most y

NAME

md_calcImage - Calculate all images needed for the required result

SYNOPSIS

md_calcImage ?arg?

DESCRIPTION

This command uses the internal image chain (see Modal overview) to perform all required steps needed to calculate the required arg, which can be either an image (default, bg, curr, diff, bin) or stat. If no argument is given, the image specified by dispIm will be calculated. In all steps, md_calcImage uses only those color layers specified by layer. After completed operations, the state of the image chain is set to arg.


NAME

md_ setImChain - Set imChain, the state of the image chain

SYNOPSIS

md_setImChain ?arg?

DESCRIPTION

This method can be used to force the image chain into the state given by arg, (default, bg, curr, diff, bin or stat). Normally the image chain is handled automatically by the image operations, but in some cases it may be desirable to control the chain manually by this command. If no argument is given, the current state of the chain is returned.


NAME

md_getStat - Get the calculated statistics

SYNOPSIS

md_getStat ?area? ?type axis?

DESCRIPTION

This command outputs the required statistics. The arguments are either area, in which case the area of the segmented region(s) expressed as the fraction of the total image area is returned, or type followed by axis, where type takes the values min, mean or max, and axis takes the values x or y. The result is expressed as the fraction of the size of the required image dimension, with the origo in the upper left corner, the x-axis horizontal to the right and the y-axis vertical downwards. If area is zero, all results will be zero.


NAME

md_display - Handle the display

SYNOPSIS

md_display ?mode?

DESCRIPTION

This command is used to manually set up an non existing display (mode = on) or to close an existing one (mode = off). The size of the display is the same as the size of the video grabber. If md_configureVideo is used to change the size, an open display will automatically be closed. If no arguments is given, the current state of the display will be returned.


NAME

md_writeIm - Write an image to the display

SYNOPSIS

md_writeIm ?image?

DESCRIPTION

Writes image (default, bg, curr, diff or bin) to the display. If no argument is given, the image specified by dispIm will be displayed.


NAME

md_writeCross - Write a red cross in the curr image.

SYNOPSIS

md_writeCross ?x y?

DESCRIPTION

Writes a red cross at x y in the curr image. The coordinates, x y, for the cross should be specified as a fraction of the image width and image height respectively. If no arguments are given, the center of gravitation obtained in the last performed md_calcStat is used.


NAME

md_setDispIm - Change the value of dispIm

SYNOPSIS

md_setDispIm ?image?

DESCRIPTION

The value of dispIm will be set to image (default, bg, curr, diff or bin). If no argument is given, the current value of dispIm will be returned.


NAME

md_setLayer - Set the layer variable

SYNOPSIS

md_setLayer ?layer?

DESCRIPTION

Set the layer variable to layer. Valid values for the argument are all, red, green or blue. If no argument is given, the current value of layer is returned.


NAME

md_setThres - Set the thresholds for the different color layers

SYNOPSIS

md_setThres arg ?value?

DESCRIPTION

This command sets the threshold which are used in md_calcBin. The thresholds of the different color layers can be set to different values between 0 and 1. Valid values for arg are all, red, green or blue. The default values are red = green = blue = 0.100. If the second argument is omitted, the current value of the in arg specified layer(s) will be returned. If arg = all, all thresholds will be set to value, else if arg = red, green or blue, only the threshold for the specified layer will be changed.


NAME

md_setThresMode - Change the thresMode variable

SYNOPSIS

md_setThresMode ?mode?

DESCRIPTION

This command sets the thresMode variable, which determines how the different binary color layers of the bin image should be combined, when calculating the statistics. The argument takes the values and (the default value), or or (optional value). See md_calcStat for further information.


NAME

md_setBgMode - Set the bgMode variable

SYNOPSIS

md_setBgMode ?bgmode?

DESCRIPTION

This command is used to set the bgMode variable. This variable determines how the bg image is updated in a sequence of frame grabs. If bgmode = static, bg will be a fixed image, which can only be changed by md_newBg. If bgmode = moving, bg will become the last but one grabbed frame each time a new frame is grabbed, (with possibly some frames lagging, if delay is too small). In this way two successive frames will be used by md_calcDiff, which is appropriate if motion is to be detected. If no argument is given, the current bgMode is returned.


NAME

md_status - Get the current values of all internal variables

SYNOPSIS

md_status

DESCRIPTION

This command outputs the status of all the internal variables and thresholds. See Modal overview for the definitions of the variables and their possible values.


NAME

md_saveFrame - Save the curr image to file

SYNOPSIS

md_saveFrame ?fname?

DESCRIPTION

This command saves the content of the curr image to a file with the name fname. The image is saved in the portable pixmap file format, with the magic number P3 (i.e. ascii characters). If no argument is given, the file will get the name frame.ppm.



Return to Modal Home Page


(Last updated October 22, 1998)