Skip to main content

Motion Detection

Motion Detection Overview

Motion detection is a key feature to maximize the number of streams that can be processed on a server. When you use motion detection, EyesOnIt compares the current frame to a previous frame to determine if anything has changed. This is a quick operation compared with running the full EyesOnIt Large Vision Model. If nothing has changed since the previous frame, no further processing needs to be done.

The example of monitoring a driveway for the presence of a vehicle should clarify the value of motion detection. We only want an alert when a vehicle appears in the driveway. We don’t want an alert when there is no vehicle present, and we don’t want a duplicate alert when a vehicle remains in the driveway. When a vehicle appears in the driveway, it will be moving. With motion detection, we can detect that movement and then trigger the full EyesOnIt model to see if the motion represents a vehicle or something else like an animal or the wind blowing the nearby trees. This combination of motion detection and object description processing reduces server load while also reducing false alerts.

To clarify motion detection further, look at the two images below. These two images represent successive frames in a video file. In the second frame, the areas are highlighted where the image has changed from the first frame to the next. As you can see, the changed areas of the image include pixels behind the vehicle, pixels in the shadow in front of the vehicle, and pixels around different features of the vehicle. The changed areas are represented as multiple distinct contours. Some of these contours are large and some are small. We’ll refer to these images when we explain the motion detection settings that EyesOnIt offers.

EyesOnIt motion detection without contours

EyesOnIt motion detection with contours

Motion Detection Settings

The EyesOnIt motion detection settings are shown below:

EyesOnIt motion detection with contours

The Interval to Check for Motion setting is the time in seconds between each check for motion. Based on the example above, EyesOnIt would check for motion once per second. During that check, it compares the current frame with the previous frame which was saved from last motion check. If motion is detected between these two frames, EyesOnIt performs further processing on the current frame. You can optimize the use of your CPU and GPU by setting this value as high as you can without missing motion.

Note: the Frame Rate setting could limit motion detection. If the Frame Rate is one (one frame per second) but Interval to Check for Motion is .5 (2 checks per second), EyesOnIt will only check for motion once per second because it only reads one frame per second from the video. Make sure that the Frame Rate setting is high enough to provide frames at the interval desired for motion detection.

The Motion Detection Threshold represents the amount of change that constitutes motion. If the motion area were a perfect rectangle, we could easily calculate that area as the width times the height of the rectangle. As you see in the image above, the areas of change between the images are not even remotely rectangular. Estimating the motion detection threshold can be tricky. A general rule of thumb is to use 20% of the object size as the motion area. In our example, the vehicle is roughly 250 pixels wide and 300 pixels tall, for an area of 75,000 pixels:

EyesOnIt motion detection threshold image

15,000 pixels (20% of 75,000) is a reasonable starting point for our motion threshold.

To determine the motion detection threshold, consider capturing a single frame of your video that shows your object at full resolution using a tool like VLC Media Player. Then, open the image in an image editor and measure the width and height of the object in pixels. The area of the object is the width multiplied by the height. After you calculate the area, apply the 20% estimate mentioned above. If your object is generally moving slowly, or if your value for motion detection seconds is low, the amount of motion between each motion check may be lower than 20% of the object size and you may need to decrease your motion detection threshold. The opposite is true if your object is generally moving quickly or if teh value for motion detection seconds is high.

If you find that motion is not being detected when it should be, make your Motion Detection Threshold smaller. If you find that motion is being detected when it shouldn’t be, make your Motion Detection Threshold larger. It may also be helpful, if possible, to adjust your detection region so that it does not include areas of extraneous motion such as blowing trees.

The No Motion Check Seconds setting lets you set an interval to check for objects even if no motion has been detected. This can be helpful to catch the situation where objects may move into your video frame very slowly, thus generating motion areas that are below your typical Motion Threshold. In our vehicle example, a vehicle could drive into the driveway very slowly and not trigger the EyesOnIt motion detection. By looking for vehicles every five seconds, we can be sure that we will detect a slow-moving vehicle. If slow-moving objects are not a concern, you can set this value to a large number so the no-motion check rarely if ever occurs.