Movement/Motion Detection

The Movement detection module provides a way to detect image changes as a result of movement. Movement can be an easy way to segment an object of interest from the background.

Any pixel that is different enough in color or intensity is preserved; pixels that have not changed are set to black (default). To change the sensitivity of this comparison increase or decrease the ‘Difference Amount’ within the movement dialog interface.

To create a movement mask (i.e. set changed pixels to white) click to ‘Set Movement to White’.

If you want to show the pixels that are still uncheck the ‘Set Still to Black’.

To prevent still images from being further processed you can chose to stop processing of the image processing pipeline if the movement detected is below a certain percent of the image size or if no movement is detected above a certain threshold. Setting either will stop image processing and continue with the next frame grabbed from the video source. This is particularly useful when streaming the video source to an AVI file where you only want to record images with movement and not still images.

For global movements or large objects use the ‘Stop below Movement Percent’ as this ensure that small image aberrations do not make it through. Often due to overhead lights or specula effects pixels can abruptly change for an instance to a different color/intensity. However, if small movements need to be detected use the ‘Stop below Pixel Difference’ which will stop processing as long as all pixel differences are below the specified amount. With this condition even a single pixel above the specified value will allow the image to continue thought the processing pipeline.

Unchecking both ‘Set Movement to White’ and ‘Set Still to Black’ is a great way to stabilize a still image and remove the flickering effects due to overhead lighting or poor quality cameras.

Note that using a mean filter before the movement detected is often recommended as another way to reduce any abrupt pixel changes. Spurious pixel values will be more common on lower quality cameras so the values you use may need to be updated when changing cameras.



1. Background Image - Select the reference frame to use when comparing frames for movement. The more frames used the more stable the reference image will be but changes are detected slower.

2. Continuous Update - Specify if the reference frame should be continuously updated or stop after the specified number of frames have occurred.

3. Threshold - Specify the pixel difference amount that needs to be exceeded in order for movement to be detected.

4. Technique - Select which type of comparison you want.

RGB Difference - sum of differences of each pixel RGB channel

Max RGB Difference - sum of maximum red or green or blue difference between pixels

RGB Squared Difference - sum of squared 'RGB Difference' that helps to better reduce low noise

RGB Percent Difference - sum of percent difference between RGB pixels. Since darker pixels contain more noise use the threshold value below to ignore pixel values lower than the specified threshold. The percent mode helps to eliminate white or black background pixel issues.

Intensity Difference - sum of intensity differences only (grayscale comparison)

Color Difference - sum of CrCb (chroma) values. Note that color differences are VERY small so you will need to set the 'Difference Threshold' to a very small amount (1 - 3)

Texture Difference - a small window is used to calculate a measure of texture within the window. This amount is also calculated in the background image. The difference of the two is then used as the threshold value. This allows you to tell when a part of an image's texture (i.e. smooth or not smooth) changes. Note that this is less lighting sensitive as the texture measure is relative to the local window.

Flow Difference - the translation of a pixel is summed over the entire image. The translation of a pixel is defined as the location in the next image that is closest in value to the previous pixel. This is also know as optical flow

5. Set Movement to Actual - sets any detected movement to the current pixel values.

6. Set Movement to White - sets any detected movement to white. This can be used to create a movement mask.

7. Set Movement to Gray - sets any detected movement to an intensity that represents the amount of detected movement.

8. Set Still to Black - sets any non-movement pixels to black.

9. Anti - Auto Adjustment - if your camera does not provide the option to freeze white balance or auto exposure select this checkbox. The current image's lighting will then be adjusted (reversed) to the previous image's lighting parameters to ensure that comparisons are done within the same lighting conditions. Ideally you can switch these off on the camera to avoid sudden light adjustments that cause a global difference in images.

10. Reduce global movement - if your camera moves in any way the entire image may suddenly not compare well with the previous image and cause a large amount of detected movement. This checkbox activates a method to attempt to reduce this issue such that only local movements within the image is detected. Note, this method is CPU intensive and should only be used if needed.

11. Area of consideration Window - for all techniques checking a single pixel at a time will typically cause a lot of noise to be produced depending on the camera that you are using. Normally a single pixel's color/intensity will change significantly from one image to the next unless you are using a higher end machine vision camera. Because of this, it is best to sample a group of pixels (i.e. small window) and run the comparison against that group of pixels rather than an individual one. The Window Size parameter allows you to specify the size of this window. Smaller windows will produce more noise, larger windows will filter out smaller changes.

12. Area of consideration Blob - similar to the Window Size this selection will group pixels of similar color together before running the analysis. This will ensure that objects comprised of similar pixels will be analyzed together.

13. Difference Threshold High Amount - specifies the threshold amount for many of the techniques. The lower the value the smaller the difference between the images need to be in order to signal movement. The higher the value the larger the difference needs to be in order to signal movement.

14. Difference Threshold Low Amount - once a pixel is determined as being movement, this threshold allows other pixels that are neighbors to the pixel just detected to also be trigger as movement despite them having a lower activation value. This hysteresis allows moving objects to grow larger to include more appropriate borders where pixel comparisons are not as significantly different than the "High Threshold Amount".

15. Stop Below Movement Percent specifies how much movement needs to be detected for the module to signal that something has changed in the image. If nothing is detected then the entire image is set to black.

16. Stop Below Pixel Difference specifies that if all pixel difference values are below the specified amount then the image will be considered still even if the percentage of pixels changed exceeds the above percent.


Ideally to detect movement your camera needs to maintain the lighting conditions from one image frame to the next. You may be able to turn off auto-exposure or auto-shutter speeds by examining your camera options. Select the options button in the main RoboRealm dialog, then one of the Video Capture or Video Format buttons to see if your camera provides a manual override of setting these parameters. You can test the lighting issue by setting the movement detector to use the last 50 previous frames to calculate the RGB difference. Once these settings have been made the current image will eventually go to black assuming no movement is within the camera's view. If you then hold up a white sheet of paper in front of the camera you will suddenly see the entire background change since the white sheet of paper will have caused your camera to shift intensity values. This changing of pixel values moves the pixel intensity outside the "difference amount" and therefore the entire image will appear to have moved. Switching the camera to manual mode will prevent this intensity shift from happening. If you are not able to switch to manual mode select the 'Anti - Auto Adjustment' checkbox which will attempt to undo these lighting changes by your camera.

When using the movement detector you may notice issues with black streaks or spots in the resulting movement mask. These spots are caused by dark background pixels. Ideally to create an appropriate mask (similar to green screen or blue screening) your background should be as planar as possible and not include the color that the foreground will. For example, using a white sheet as a background and then standing in front of the background with a white shirt on will not allow you to segment your white shirt ... the shirt and white background are considered as the same color and therefore no movement will be detected. This also frequently happens for black areas since the absence of light in shadows will cause confusion if your foreground object has any shadows in it.


MOVEMENT_PIXELS - number of pixels that have changed from frame to frame
MOVEMENT_PERCENT - percent of pixels that have changed from frame to frame

See Also

Optical Flow

 New Post 

Movement Related Forum PostsLast postPostsViews
Detection of motion
I want to detect any particular motion in a Live streaming video....... How can I proceed can u please help me out as I m new to...
5 years 2 1329
Changes in the image
Dear STeven, I have two photos. 1.jpg - an empty table. 2.jpg - a table with a plate. As to me to f...
7 years 3 1692
vehicle counting
hi, I try to do this post. ...
7 years 4 2211
Speed Trap Application
It’s been a while since I have played with RR.   My family and I relocated from Chicago to Atlanta and that pretty muc...
8 years 9 2486
People tracking in street within zones
I want to do some people tracking on a publicly available webcam. If people walk in certain areas I want Roborealm to send a key...
8 years 2 2106
Roborealm precision?
I'm a brewer.  I love to brew in my garage in the Summer.  The problem is the bugs. They've invaded. Time ...
8 years 3 2322
Movement Tracking
I am currently in the process of creating a 'rover' robot that uses a camera to detect the movement of people, and accordingly...
8 years 2 1969
Identifying a Pet
I'm very new to this and would really like someone to give me a general guide to the steps needed to having a cat (or dog, etc....
8 years 2 1967
saving image
How do i setup saving an image that has the center of gravity displayed on it? I am scanning images...
9 years 6 2035
car tracking number
hi , i m new using roborealm       i have question about the car tracking at here :...
9 years 2 2341
tenvis jpt3815w not working with motion detection
Hi all, I'm new here, just a quick question if anyone had a similar issue. I can view my ip camera in roborealm ...
9 years 3 2716
Bus/Coach detection (al same colour)
Hi, Can anyone give me advice the best way to go about counting passing vehicles, specifically, the...
9 years 2 2065
Detection of Cars and Motobikes
Hi everyone, I'm just posting up ask you lot with the experiences what would be the best way of de...
10 years 2 2348
Using version 2.44.29 the "Movement Function" in Pixels or Percent does not work anymore I was using 2.42.13 un...
10 years 2 2098
please help to make face/body folower for DV cam rotation head
Dear Roborealmer, I am planing to build an automation platform that can move left and right (single...
11 years 7 3332
Automated Rifle target Scoring
Hi Everyone, I was hoping I could get some ideas thrown around for a project I am working on for a...
11 years 8 11042
Object strobing
If i strobe an object (at a fixed frequency) in a scene, can roborealm mask out the scene leaving only the area of the strobing...
11 years 9 2651
Counting cars
I'm trying to count the number of cars entering or exiting a junction, on multiple lanes. I've tried to make a running program...
11 years 4 3735