AI-Powered Motion Detection

In our macOS CCTV software SecuritySpy, deciding whether to trigger recording and actions (e.g. notifications) is a two-step process. Firstly, a motion-detection algorithm determines whether there is some interesting movement happening. Next, the image is cropped to the area of movement and passed to a neural-network classifier to determine whether there is an object of interest present, like a human, vehicle or animal.

The classifier in SecuritySpy is based on a ResNet-50 neural network, custom-trained on over 100,000 real CCTV images from thousands of different cameras. It is a highly optimised, powerful network, producing very accurate results (around 97% for humans and vehicles).

In contrast, until now, the motion detection algorithm has been fairly simple. It has worked via pixel-based comparisons between successive video frames, with some additional filtering to help ignore extraneous movement caused by noise, transient motion and lighting changes.

This standard motion detection is fast and very effective in controlled environments that don’t suffer from a lot of extraneous motion. However, it is less effective in more challenging outdoor environments, where movement caused by shadows, swaying plants, snow, rain and so on can cause a high number of false-positive detections. In such situations, it maintains high sensitivity (ability to detect true motion when it occurs), but suffers from poor specificity (ability to accurately ignore extraneous movement).

SecuritySpy’s classifier is able to filter out virtually all these false-positives, however even if only 3% of false-positive detections get through the classifier, in particularly challenging situations where the motion detector is generating large numbers of false-positives, inevitably there will still be a significant number getting through and causing triggers.

Standard Motion Detection Pipeline

Standard motion detection pipeline: with False Positives (FP) greatly outnumbering True Positives (TP), even though the classifier is very accurate, a significant number still get through and cause triggers

This is solved by SecuritySpy’s new neural-network based motion detector. Built from the ground up and trained on tens of thousands of image sequences, this is a bespoke lightweight CNN (Convolutional Neural Network) featuring residual connections and multi-scale pooling for real-time motion detection and location. It outputs highly accurate predictions, even in challenging outdoor situations.

The new neural network is specifically trained to ignore common extraneous motion. In particular, rain and snow at night gets brightly lit by cameras’ built-in infrared lighting, causing large white constantly-moving streaks across the image. Other motion like trees swaying, lighting shifts, and camera shaking are also effectively ignored.

With the output of the new AI-powered motion detector being far more accurate, far fewer false-positives are sent to the classifier, which in turn will then cause far fewer false-positive triggers of recording or actions.

AI Motion Detection Pipeline

AI motion detection pipeline: with far fewer false-positives getting through to the classifier stage, virtually all false-positive triggers can be avoided

Performance Considerations

Due to the powerful Neural Engine module built into Apple Silicon chips, the new AI motion detector runs just as fast, if not faster, than the standard algorithm (in around 0.7 ms per frame). Therefore, on Apple Silicon Macs, SecuritySpy will default to this method for all cameras.

However, the ability to execute neural networks on Intel Macs varies significantly. SecuritySpy will attempt to first benchmark the performance of the new AI, and will use this information to automatically decide how many cameras to apply it to.

You can check how fast each neural network runs on your Mac by selecting the menu item at SecuritySpy > Debug > Run AI Test. Here’s an example:

SecuritySpy AI Test Window

AI Test window in SecuritySpy. Bonus feature: drag and drop an image file onto any of the image squares to test the classifier on your own images!

If this indicates that all your cameras can be covered by the new AI motion detection algorithm, then you don’t need to take any action; all your cameras will automatically benefit from the new AI.

However, if this indicates that the number of cameras the AI algorithm can be applied to is lower than the number of cameras that you are using, then only a subset of your cameras will benefit from the new AI. By default, SecuritySpy applies this preferentially to the first cameras in the list.

Alternatively, you can specify yourself which cameras should use Standard vs. AI motion detection – in this way, you can apply the AI only to the most important cameras for you, or only those that are currently producing significant numbers of false-positive detections. You will find this option under Settings > Cameras > Triggers > Advanced Options:

SecuritySpy Advanced Trigger Options

AI-powered motion detection was introduced in SecuritySpy version 6.10, and is available on all Macs that are running macOS 10.15 or later.

6 thoughts on “AI-Powered Motion Detection

  1. Peter Schneider

    This is great news. The question that comes to mind on the AI Object Detection Thresholds is what the appropriate use of the sliders is. When it states that “lower thresholds make detection more likely” does that mean that setting Animal to 25 is going to be better at identifying an actual animal, or that it would more easily be fooled into detecting something as an animal? then does this mean the 100 would only report an Animal when it is 100% knowing that it is an animal?

    Reply
    1. Ben Software Post author

      Your description of how the sliders work is basically correct. A threshold of 100 will cause a trigger only if the system is extremely sure that that object is present (but in practice, 100 is usually far too high). In summary:

      Lower thresholds make it more likely that a particular object will be detected. This increases the true-positive rate (making it more likely that the real presence of a particular object – even if it’s a bit hidden, or in poor light, or at a weird angle etc. – will cause a trigger), at the expensive of also increasing the false-positive rate (making it more likely that random noise, or something that looks a bit like the object but isn’t, causes a trigger).

      Higher thresholds make it less likely that a particular object will be detected. This decreases the false-positive rate (giving you less erroneous triggers) at the expense of also decreasing the true-positive rate (missing more real objects).

      Where you set these sliders depends on your personal preference of the tradeoff between missed events vs. erroneous triggers. 50 works well in most cases, but an adjustment between 30-70 or so is reasonable if you so choose.

      Reply
  2. Radek

    Ben, while SS 6.10 was still in beta, it was mentioned that AI-powered object detection works best on Apple Silicon processors. However, using this feature on an Intel-based Mac might still be reasonable if it’s a newer model. In my case, I have a 2018 Mac Mini with an Intel i3 processor and 32 GB of RAM. Can I switch to AI-powered object detection without worrying that my Mac will consume too many system resources?

    Reply
    1. Ben Software Post author

      Yes, new new AI will certainly run fast enough on relatively modern Intel Macs too. On Intel, SecuritySpy will first test the execution time of the new AI, and will use this benchmark to automatically apply it to as many cameras as it determines is reasonable. You can check how many cameras will be covered by opening the “AI Test” window (SecuritySpy menu > Debug > Run AI Test). Please report back what this shows for the performance metrics on your machine.

      Reply
  3. Radek

    AI Test Summary

    Total object detection results:
    • 12 correct, 0 incorrect
    • Processing time: 42.2 ms per frame (maximum usage: 21 cameras)
    • Motion detection speed: 8.6 ms per frame (maximum usage: 17 cameras)

    Software version: 6.10
    macOS version: 15.4.1
    Mac model: Macmini8,1
    Metal device: Intel(R) UHD Graphics 630

    Image Analysis Results
    1. Image 1 (Man pushing luggage cart in an airport):
    • Human: 98%
    • Vehicle: 1%
    • Animal: 1%
    2. Image 2 (Blue car parked near a building):
    • Human: 2%
    • Vehicle: 98%
    • Animal: 1%
    3. Image 3 (Man standing next to a white car):
    • Human: 96%
    • Vehicle: 98%
    • Animal: 3%
    4. Image 4 (Building with a red roof):
    • Human: 2%
    • Vehicle: 1%
    • Animal: 0%

    Reply
    1. Ben Software Post author

      Great. On your Mac, the new AI runs in 8.6ms per frame, which is fast enough to apply it to quite a few cameras! SecuritySpy will do this for you automatically, but if you want to, you can specify which cameras should use the AI via Settings > Cameras > Triggers > Advanced Options.

      Reply

Leave a Reply

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