howto create a mask

Detection mask is a simple grayscale bitmap which tells avrecord how much the difference between two particular pixels should be for them to be counted as motion pixels. A mask is scaled to the dimentions of captured frames so that each pixel of a frame has corresponding pixel in the mask. The grater the value of a mask pixel (i.e. the lighter it’s color) is, the lower is the threshold for the corresponding pixel of captured frame.

Suppose you want a motion in some area of a frame did not trigger recording. To exclude this area from motion detection you should create a mask. To make one you may use any image editor that supports the BMP file format, though I recommend to use GIMP for convenience. It would be easier to make a mask on top of an actual captured frame, which you may acquire by making a screenshot of a previously captured movie.

Assume you’ve done it and opened the screenshot in GIMP:

Suppose also that the motion of leaves in the upper left corner is triggering recording too often in which you’re not interested. So let’s mask them.

First you need to make a new layer for the mask:

And fill it with white. White mask means no masking:

Next you need to change the rendering mode of the new layer to “Multiply” to make the screenshot visible again:

Then you should set the foreground color to black and using a brush (or any other mean of your choice) fill the area with leaves with black. Note that the new layer should still be selected:

Now remember: black color means no motion would be detected in this area ever. What if the gecko crawls on the branch under the leaves? If so, let’s make space around the branch detectable, but only partially. For that set foreground color to white and it’s opacity somewhat less than 100%, e.g. 20% Now paint around the branch:

You should notice some transparency in the lower mask region now. This means some quick and extensive motion should be detected there.

The mask has been created and all that’s left is to save it properly. Change image mode to grayscale for smaller file size:

 And change rendering mode of the mask layer back no “Norma”:

Now you see only the mask in it’s true form. It should be saved in BMP format:

While saving GIMP may request to export the image for it contains layers and transparency. Let it do the work.

Now place your ready to use mask file somewhere and point to that location in the configuration file to enable masking:

	//logfile path
	log_file   = "./avrecord.log";

	//output directory where generated movies will be saved
	output_dir = "./";

	//name template for output movies. For format description see: man date
	filename   = "movie-%Y-%m-%d_%H-%M.avi";

	mask_file = "/path/to/mask/file.bmp";

That’s it!

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>