GStreamer Motion Detection

From RidgeRun Developer Wiki



Introduction to GStreamer Motion Detection

Nowadays, thanks to the advances in the technology fields, smart electronic devices, automation, computer science, artificial intelligence (AI), and embedded systems, we are capable to build more and more complex systems that incorporate many different features. One important feature that a lot of new systems and products of different industry areas try to incorporate is the capability to detect motion.

Let us start by defining motion detection as the process of detecting a change in the position of an object relative to its surroundings or a change in the surroundings relative to an object. With the proliferation of low-cost digital cameras able to shoot video and the popularization of modern devices to incorporate cameras, it is possible to use the output of such a camera to detect motion in its field of view using software algorithms. This solution is particularly attractive when the intent is to record video triggered by motion detection or trigger an alarm, as no hardware beyond the camera and computer is needed.

One of the most important areas that require their systems to have motion detection capability is Video Surveillance. In video surveillance, motion detection refers to the capability of the surveillance system to detect motion and capture the events. Motion detection is usually a software-based monitoring algorithm that, when it detects motions will signal the surveillance camera to begin capturing the event. Modern motion detection surveillance systems with AI incorporated can analyze the type of motion to see if it warrants an alarm or not, for example by tracking the motion trajectory of the object or by identifying the object under movement.

RidgeRun has developed two different software solutions that allow you to easily and efficiently add video-based motion detection capability to your system or product. Both solutions are based on GStreamer and delivered as a GStreamer plugin. The solutions differ between them in the implemented algorithm, software capabilities, and system requirements, to fit a wide range of systems. GStreamer is a commonly used framework for multimedia applications, known to be popular due to its flexibility in the app features design, simplicity of usage, portability, and efficiency. If you want to read more about GStreamer advantages please follow this link: Why RidgeRun Loves GStreamer.

Below you will find a summary of the two Motion Detection solutions provided by RidgeRun:

  • GStreamer Background Subtraction Camera-Based Motion Detection Plugin
  • GStreamer DispTEC Motion Detection Plugin
GStreamer Motion Detection plugin
GStreamer Motion Detection plugin

GStreamer Background Subtraction Camera-Based Motion Detection Plugin

RidgeRun has developed a Motion Detection GStreamer element that is able to detect motion from an incoming video image of a steady camera that does not move. The element implements the approximate median method for background subtraction with an adapting background algorithm. This method matches other higher-complexity algorithms in performance while being resilient to constant noise or sudden light changes happening in the scene.

When the camera is steady and fixed in a position, a common motion detection video approach is to perform background subtraction. With background subtraction, a static scene model is built, which is called the background. Incoming frames are compared to the background in order to detect regions of movement. Motion detection algorithms generally work by comparing the incoming video image to a reference image. The reference image could be previous frames or a predefined background. Motion detection is accomplished by analyzing deviations from the reference and attributing the difference either to the presence of motion or due to noise, such as untended motion on the camera mount.

This motion detection GStreamer element has been developed for GStreamer 1.0 and 0.10 versions. The element runs in any platform (hardware independent) since the motion detection algorithm is executed by the general-purpose processor (CPU), and do not depend on external computer vision libraries. The gst-motion-detect element is optimized and highly configurable, both for controlling the approximate median algorithm, as well as for minimizing CPU load to obtain the best performance accordingly to the user needs, allowing it to be integrated into highly constrained embedded systems.

If you are interested in this solution please follow this link for detailed information:

Key features

  • Detect motion from an incoming video image of a steady and fixed position camera
  • Implements the approximate median method for background subtraction with adapting background algorithm
  • The element triggers start/stop motion signals that could be the input of a separate/independent control application
  • Configurable region of interest (ROI) in the image frame to detect motion only on that specific region of the image
  • Configurable Interval Frame Analysis, so only analyze every nth frame reducing the required computational resources
  • Motion trace visualization feature: motion trace color foreground pixels with alpha changed to visually show the motion trail overlayed in the current video feed
  • Runs on any platform (hardware independent)
  • Optimized and highly configurable, both for controlling the approximate median algorithm, as well for minimizing CPU load to obtain the best performance.
  • Suited for highly constrained embedded systems
  • Tested in the following platforms:
    • IMX6 / IMX7 / IMX8
    • NVIDIA JETSON family: TX1, TX2, Nano, Xavier, Xavier NX
    • PC X86

Pros vs Cons

Pros

  • Suited for highly constrained embedded systems due to few system requirements
  • Do not depends on external computer vision or video processing libraries. GStreamer is the only dependency
  • The element is open for HW acceleration implementations depending on the platform (GPU, DSP, NEON, etc). Not supported by default
  • Available for GStreamer 1.0 and 0.10 versions
  • Easy integration with different custom control applications due to its independent motion detection design from the control logic. The element triggers motion detected signals that could be interfaced with any custom application.

Cons

  • Designed for steady and fixed position cameras video feed. It does not work for cameras that move while capturing video
  • Hardware acceleration is not supported by default but could be implemented if desired by the customer

GStreamer DispTEC Motion Detection Plugin

The GstDispTEC motion detection is a GStreamer element which integrates DispTEC library's algorithms for motion detection, making it possible to incorporate their functionality into GStreamer pipelines, such as motion detection in a video sequence, even with non-stationary cameras! This allows the user to strengthen image analysis, by connecting its own applications to the pipeline for receiving the analysis data.

The motion detection element is based on DispTEC's MCD and SCBU algorithms, designed to run on both CPU and GPU. Its primary feature is the motion detection inside a non-stationary capture, although it can also be used on stationary captures. Dtmotion is the designed GStreamer element that integrates the previously described capabilities into a videofilter derived element that can be easily incorporated into a pipeline. It receives any input and generates a new frame built upon a binary mask that exposes the detected motion.

If you are interested in this solution please follow this link for detailed information:

Key features

  • Detect motion inside a non-stationary camera video feed. That means that even if the camera is moving while capturing video (for example a drone), the element is capable to detect objects moving on the scene
  • Outputs a new frame built upon a binary mask that exposes the detected motion
  • Offers two different algorithms for motion detection:
    • MCD algorithm is faster, especially for smaller resolutions, and the result contains less noise than its counterpart
    • SCBU adjusts better to brightness changes on the captured video but it is more sensible to fast changes in movement. The output is more uniform but contains more noise than MCD
  • Both MCD and SCBU algorithms are available to run on CPU or GPU, depending on the target application.
  • Offers the following properties to tune up the algorithm behavior for the target application:
    • max-learning-rate
    • grid-size
    • block-size
  • Tested in the following platforms:
    • NVIDIA JETSON family: TX1, TX2, Nano, Xavier, Xavier NX
    • PC X86

Pros vs Cons

Pros

  • Works great on both steadily fixed position cameras and non-stationary cameras
  • Hardware acceleration on GPU is supported and can be enabled/disabled by the user

Cons

  • Depends on external computer vision and video processing libraries like DispTEC and OpenCV and a system capable to support those libraries




For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.


Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.