How To Achieve Effective Motion Detection

SecuritySpy’s motion detection algorithm employs many techniques in order to accurately detect real motion events while minimising the rate of false-positive detections. But besides an effective algorithm, there are many choices about the setup and configuration of your video surveillance system that will help achieve reliable motion detection – these are outlined below.

1. Camera Angle

How you position and point the camera, as well as the focal length of the lens (how wide-angle it is) makes a big difference to the effectiveness of motion detection. The key points to consider are as follows:

  • The activity you want to capture should be relatively large in the frame. Don’t use a camera with a very wide-angle lens, as this will make objects and people appear very small – too small to trigger motion detection or make out any important features such as faces.
  • Point the camera downwards and don’t include any sky in the frame. At certain times of the day the sun may glare into the camera, which would impair its ability to render the scene with good enough definition, and may even damage its sensor.
  • Include just the area you want to capture in the frame; don’t include any irrelevant areas as this simply wastes the resolution of your camera.

Here is an example of a bad camera angle for motion detection:

Bad Camera Angle

Bad Camera Angle For Motion Detection

This is bad because: 1. the lens is too wide-angle, so the details of the cars are difficult to make out, let alone people; 2. lots of sky is included; and 3. unless you want to capture boats, the large area of water on the left is irrelevant wasted pixels.

Here is an example of a good camera angle for motion detection:

Good Camera Angle

Good Camera Angle For Motion Detection

This is good because the lens has the perfect length to focus on the area under surveillance, so that the people are large enough in the frame both for effective triggering of motion detection and for distinguishing facial features.

2. Mounting

It is vital that the camera itself does not move, as this would significantly compromise the effectiveness of motion detection. Make sure to mount the camera securely, using a sturdy bracket, on a fixed object such as a building. Avoid mounting cameras on trees or flimsy poles that can move in the wind.

3. Lighting

In low-light conditions, the camera may produce a significant amount of noise. This is because there is less light falling on each pixel in the image sensor, so the camera has to boost the signal from the sensor in order to produce a bright enough image, which also boosts the noise. Here is what this noise looks like – this is an enhanced crop of an image that shows a road at night:

Noisy Image

Noisy Image

SecuritySpy’s motion detection algorithm detects and accounts for such noise, in order to prevent it from triggering motion detection. It calculates the average amount of noise present in each pixel, and uses this to set a threshold above which to consider a change in the pixel intensity as “real” motion. Therefore, if the image is very noisy, this threshold is high, and it will take a lot more movement than normal to trigger motion detection. This results in real events being less likely to be detected (i.e. false negatives).

The solution is to install better lighting for the scene you want to capture – either visible or infra-red (if your camera is IR-sensitive).

Many cameras have built-in infrared LEDs for night vision. These work fine in limited circumstances, however they are typically not very effective beyond a few meters. They also have a further disadvantage when used outdoors in that they tend to attract insects, which fly around the camera, brightly lit by the IR light, triggering motion detection. You will get far better results if you use separate IR illuminators, which are typically much more powerful.

Infrared Illuminator

Infrared Illuminator


 4. Compression Settings

Video from IP cameras is compressed in one of three formats: JPEG, MPEG-4 or H.264. With the right compression settings, these formats can provide very high quality, but with the wrong compression settings they can cause unacceptable image degradation. Here is an example of an image with noticeable compression artefacts from low-quality H.264 compression, cropped and enhanced:

Bad Compression Artefacts

Bad Compression Artefacts

There will be a number of parameters that you can set in your network camera in order to control the quality of the image produced:

  • CBR vs. VBR [MPEG-4 and H.264]: CBR (Constant Bit Rate) compression produces a fixed amount of data per second, and tends to be what most cameras are set to by default. In this mode, the camera will increase and decrease its compression quality as required, in order to maintain this fixed bit rate. For complex scenes with a lot of movement, which would otherwise need more bits to encode accurately, this can result in the camera reducing its compression quality to unacceptable levels, thereby introducing the kind of artefacts shown above. VBR (Variable Bit Rate) is a much better mode to use as it does not suffer from this problem; after all we don’t really care about the precise bit rate produced by the camera, we just want good quality video. With VBR, the compressor will simply use more bits as required, in order to encode the scene accurately.
  • I-frame rate / GOV Length / Key frame rate [MPEG-4 and H.264]: this specifies how often the video stream contains I-frames, which are self-contained frames that encode the entire image. Between I-frames there are multiple P-frames (delta frames), which contain only the changes in the image since the last frame. A good value for this setting is to have an I-frame every 2 seconds or so (so if the frame rate is 10fps then an I-frame rate of 20 is good).
  • Quality setting [all formats]: this is as simple as it sounds: the higher this setting, the higher visual quality you are going to get (at the expense of larger files of course). Typically a medium-to-high value, or 60 on a 1-100 scale, will give good results, though this does vary between cameras so you may have to experiment a bit.

5. Frame Rate

Low frame rates will impair SecuritySpy’s ability to detect motion. The algorithm works best at around 10fps, but in general you should use a frame rate of at least 5fps for effective motion detection.

6. Masking

In SecuritySpy you can specify a mask in order to ignore certain parts of the video image for motion detection; this can be an effective way to reduce false-positive detections. Typically you will want to mask out objects that move in the wind (e.g. trees and plants), or areas of the image where you are not interested in detecting motion. However, make sure that you do not mask out more of the frame than necessary – the algorithm works best when it has plenty of pixels to work with. Here is an example of effective masking to ignore the road and the tree on the right side of the frame:


Cyclist - Original


Cyclist - With Mask

With Mask

7. Trigger Time

In SecuritySpy, under Preferences -> Cameras -> Setup, there is a trigger time setting. This specifies the minimum duration of continuous motion that will cause a motion detection trigger. By default this is 1 second, and you should not reduce this unless you have good reason to do so. Real motion (e.g. a person walking) is continuous movement that will typically last significantly longer than one second and hence will be detected, whereas many types of false motion (e.g. leaves blowing in the wind or snow falling close to the camera) exhibits a staccato start-stop-start-stop pattern, which will be effectively filtered out by this feature. If your camera angle is sufficiently wide so that the motion you want to capture lasts much longer than one second, then you may want to increase the trigger time for more effective rejection of false motion, if you are finding this a problem.

12 thoughts on “How To Achieve Effective Motion Detection

  1. CBH4

    Do you regularly update and add features to your software or is there a new version periodically for a fee?
    I have a late 2013 iMac -is that sufficient?
    I am looking at 4 Hikvision 2024 type cameras. I have a 3 tb add on HD on the Mac —can I use that effectively or would I need a dvr? I would want to monitor on the Mac as well as on iOS —is that doable?
    I expect I would need a Ethernet switch to connect the cameras to my google mesh system?
    Any advice past your website?

    1. Ben Software Post author

      We update SecuritySpy very frequently, and typically only charge for major updates every few years. You can see the history of updates on the SecuritySpy Version History page. The Terms & Conditions, where we spell out the update and support provision, is on the SecuritySpy Download page.

      All Hikvision cameras work well with SecuritySpy – you will be able to add them to SecuritySpy on your Mac, and use SecuritySpy to view and record the cameras on your Mac. We also have an iOS app for viewing on your iPhone, iPad or Apple TV. With SecuritySpy, you will not need a separate DVR/NVR device.

      It is definitely best if you can connect the cameras by wired Ethernet to a high-quality Ethernet switch. You should also connect your Mac into this switch using wired Ethernet. Our SecuritySpy Installation Manual has lots of useful information about setting up your system.

  2. Camilo Orozco

    Hello, I love your software!, I have a 16 camera license. Is there a way to “Browse” my server’s video footage using my macbook pro? (like browsing the video on the server)
    Thank you.

      1. Camilo Orozco

        Thank you. I got my iphone, ipad and my Macbook (via web-browser) to work with my server, but I can’t “view” the footage as I do on the server (command B -browser-), All my footage is captured by motion each motion on a single video file, so all I get to see is a bunch of video files.
        What I want to achieve is viewing my footage – when I am away from my server- as I do it in the server – with the browser feature-
        Thank you.

        1. Ben Software Post author

          Hi Camilo,

          The Browser feature is only available directly in the software’s macOS user interface I’m afraid. It sounds like you have remote monitoring set up correctly, and you are able to view the captured footage in the intended way from your iOS devices and using a web browser. This is the way that you can view footage remotely.

          Hope this helps,

  3. luca ferrucci

    Hi everyone, I noticed that with the new version 5 when a mask is active it is also displayed via iOS in my iPhone, in the old version this did not happen, so to visualize the whole image, it is possible to eliminate this problem?

    1. Ben Software Post author

      It sounds like you are using the “Video Blanking Mask”. This is configured under Preferences -> Cameras -> Setup, and is designed to permanently blank out areas of the image.

      If however you want to mask of areas of the image to be ignored by the motion detection, you need to use the “Motion Detection Mask”, which is configured via Preferences -> Cameras -> Triggers. So, I suggest that you clear the Video Blanking Mask, and use the Motion Detection Mask instead.

  4. R. Taylor

    I love this app, I have a 4 cam license. We’re using it to monitor our dogs inside our house.
    I’m curious if there is a way to program the PTZ presets using the iPhone app.

    Thank you

    1. Ben Software Post author

      Great to hear you like the software! At this time it is possible to recall PTZ presets via the iOS app, but not to set them. For this you will have to use a web browser or macOS SecuritySpy. We’ll see if we can add this function in a future update.

  5. William Simpson

    Hello i am using a camera with motion detection o protect two cars on my drive.
    I am using default motion detection settings and most of the time motion of cars and people is detected correctly but sometimes i can drive onto the drive get out and enter the house without being detected at all
    Any ideas?

    1. Ben Software Post author

      I’m sure that with some settings tweaks you can resolve this problem. Firstly, I would recommend you reading these two blog posts:

      How To Achieve Effective Motion Detection

      Optimising SecuritySpy’s AI Object Detection

      If you are still having problems, please email and we will help you with this directly.


Leave a Reply to Ben Software Cancel reply

Your email address will not be published. Required fields are marked *