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. Motion does not use color in detecting motion.
The reference frame itself is recursifly 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.
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 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 it the box) around the center of the movement.
When labelling is enabled the location box is calculated based on all the labelled areas which size is above the set threshold.
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 of pixels that continuously changes preventing a swinging branch on a tree from being detected as motion. When the pixel has been quiet for a while the smart mask slowly reactivates the motion detection again.
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 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).
Normally only one device can use a video device, to enable other programs access to the motion data we use a special device driver called a video loopback. A video loopback consists out of two video devices one is feeded from motion the other can be used by an other program as if it was a normal video device. This makes realtime viewing or remote surveillance possible.
When you start Motion it creates many threads. Especially when you have more than one camera. The Overview Of Threads In Motion
topic explains a little more detail of the many threads.
- 11 Jul 2005