Motion - Config Option Mask File

mask_file

  • Type: String
  • Range / Valid values: Max 4095 characters
  • Default: Not defined
  • Group: Motion Detection

PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. , PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format.

Full path of the PGM (portable gray map) mask file (binary format).

If you have one or more areas of the camera image in which you do NOT want motion detected (e.g. a tree that moves in the wind or a corner of the picture where you can see cars/pedestrians passing by) you need a mask file. This file is a picture that you create in your favorite photo editing program. The areas that you want detected must be white. The error that you want ignored must be black. The pgm image must be the same size (number of pixels high and wide) as the pictures that are taken by the camera (video4linux device).

You can adjust sensitivity by using gray tones.

If you do not have a mask file disable this option by not having it in the config file or comment it out ("#"or ";" as first character in line). If you are using the rotate option, note that the mask is applied after the rotation.

Detailed Description

The mask file must be a pgm format image file (portable gray map). Note that you must choose the BINARY (raw) format, and the code requires that the whitespace between the width and height values at the start of the file takes the form of a single space character. This is the line after the "P5". If yours doesn't, you may need to use a hex editor to modify it.

The feature is simple. Create an image of exact the same size as the ones you get from your video device (camera). Make a purely white picture and paint the areas that you want to mask out black. You can also make gray areas where you want to lower the sensitivity to motion. Normally you will stick to pure black and white.

One easy method for generating the mask file is as follows.

You can just take a motion captured picture, edit it with black and white for the mask and save it as a pgm file. If you cannot save in this format save as a grayscale jpg and then you can convert it to pgm format with

djpeg -grayscale -pnm [inputfile] > mask.pgm

(assuming you have djpeg installed - part of the jpeg lib package).

Note that the mask file option masks off the detection of motion. The entire picture is still shown on the picture. This means that you cannot use the feature to mask off an area that you do not want people to see.

Below are an example of a webcam picture and a mask file to prevent the detection cars in the street.

Normal picture. Notice the street is visible through the hedge.

Mask file (converted to png format so it can be shown by your web browser)

This same mask feature can be used to mask off individual pixels of unimportant motion. For example, any edge will typically show some noise. Leaves moving in the wind cause noise, but only at the edges of the leaves. You may not want to mask off the entire area.
Topic revision: r9 - 10 Aug 2016, ChrisAAA
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.