Motion - Motion Technology

Technology

Detecting motion

Motion detects motion by comparing the intensity of pixels in a fresh grabbed image with a reference image. Color information is not utilized. If there is no motion and no noise new_image-ref_image should be zero. If there has been a change in the picture the result will be different. To prevent noise being seen as motion the change has to exceed a threshold and there have to be a certain number of changed pixels before a motion is declared.

The reference frame itself is recursively updated with the new picture, so after it has been updated with pictureN it will consist out of: 1/2*pictureN + 1/4*pictureN-1 + 1/8*pictureN-2 and so on.

Locating motion

Of all pixels that have changed between the reference frame and the new frame the average x and y values are calculated, this will be used as the center of the movement. After that the average distance of every change pixel to this point will be calculated. A box is now drawn at twice the average x and y distances (3 times the positive average y distance to make sure heads are in the box) around the center of the movement.

When labelling is enabled the location box is calculated based on all the labelled areas whose size is above a threshold.

Motion masks

If you have a certain part of the image in which you don't want motion detected you can use a mask to filter it out. If the mask is white the pixel is used for detection for full. If the mask is black the pixel is not detected at all. With grayscales you can select the sensitivity of the detection in certain areas.

An example mask: mask.pgm

Motion has an additional smart mask feature. This feature will slowly mask out pixels that continuously change, preventing a swinging branch on a tree from being detected as motion. After the pixel has been quiet for a while, the smart mask slowly reactivates the motion detection again.

Webcam

Since version 3.0.0 motion has a built-in webcam. This is done with a mini http server which serves jpeg images with the MIME type multipart/x-mixed-replace. This can be viewed with Netscape and Firefox or with other browsers (but not Chrome) using a simple java applet such as Cambozola. With Firefox you normally have to refresh the browser window once to get the stream flowing (you can change this behaviour setting browser.cache.check_doc_frequency = 1).

Video loopback

Normally only one device can use a video device. To enable other programs to access the motion data, we use a special device driver called a video loopback. A video loopback consists of two video devices, where one is fed from motion and the other can be used by another program as if it was a normal video device. This makes realtime viewing or remote surveillance possible.

Threads

When you start Motion it creates many threads. Especially when you have more than one camera. The Overview Of Threads In Motion topic explains in more detail the many threads.
Topic revision: r9 - 07 Aug 2016, KennethLavrsen
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.