Grid structure / grid sensitivity
Overview
A sensitivity grid is applied to the video frames. This grid defines the areas of the image where motion must be detected. The grid divides the image into rows and columns, defining cells. The sensitivity of each cell can be set from 0 (no motion detection) to 9 (maximal motion sensitivity).
E.g. if the video frame is 320 x 240 and the grid size is 32 x 24, each cell is 10 x 10.
One motion ratio is calculated per cell, and the OnMotionDetected event reports the X and Y coordinates of the cell that reported the highest motion ratio.
Common grid sizes range from 2 x 2 to 30 x 30, but any grid size can be used, from 1 x 1 to the width x height size of the video frame.
The grid is defined by a simple string that can be set and retrieved with the MotionDetector_Grid property, which makes it easy to save it to and retrieve it from the registry (see "Grid layout" below).
Grid setup
The sensitivity of each cell can be set programmatically by assigning the MotionDetector_Grid property, or interactively through a dialog invoked by MotionDetector_ShowGridDialog. This dialog shows the grid superimposed on the current video image: clicking on a cell enables or disables the motion detection in this cell.
Grid structure
The grid divides the video frame into equally spaced rows and columns, defining cells. The minimum size is 1 x 1, the maximum size is the size of the frame.
The value associated with each cell represents the sensitivity of this cell, from 0 (no motion sensitivity) to 9 (maximal motion sensitivity).
Sample grids:
2 x 2 grid:
0 6
6 6
10 x 8 grid:
0 0 0 0 0 0 0 0 0 0
7 7 7 7 7 7 7 7 7 7
7 7 7 7 7 7 7 7 7 7
7 7 7 7 7 7 7 7 7 7
7 7 7 7 7 7 7 7 7 7
7 7 7 7 7 7 7 7 7 7
7 7 7 7 7 7 7 7 7 7
7 7 7 7 7 7 7 7 7 7
4 x 8 grid:
8 8 0 0
8 8 0 0
8 8 0 0
8 8 0 0
8 8 0 0
8 8 0 0
8 8 0 0
8 8 0 0
If the grid oversizes the frame (the grid has more columns than the frame width and/or more rows than the frame height, in pixels), the motion detection is done on the top/left part of the grid that covers the frame, and the parts that oversize the frame are ignored.
Grid layout
The grid is set and retrieved as a linear string layout of the sensitivity of each cell. This layout makes it easy to store the grid in the registry and to retrieve it as a simple string.
The grid string begins with the 1st row, followed by a blank separator, the 2nd row, a blank separator, the 3rd row, and so on. E.g., for a 10 x 10 grid, the string:
"0000044441 5555555551 4444444441 5555555551 6666666661 6666666661 6666666661 3333333331 0000000000 0000000000"
corresponds to the following 2D grid:
0 0 0 0 0 4 4 4 4 1
5 5 5 5 5 5 5 5 5 1
4 4 4 4 4 4 4 4 4 1
5 5 5 5 5 5 5 5 5 1
6 6 6 6 6 6 6 6 6 1
6 6 6 6 6 6 6 6 6 1
6 6 6 6 6 6 6 6 6 1
3 3 3 3 3 3 3 3 3 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
In this sample, the 5 top/left cells and the 2 bottom rows do not detect motion, and the most sensitive part of the frame is located on the 5th, 6th and 7th rows.