segmentation: GStreamer Bad Plugins 1.0 Plugins Reference Manual

## segmentation segmentation |

## Properties

gfloat | learning-rate | Read / Write
GstSegmentationMethod | method | Read / Write
gboolean | test-mode | Read / Write

## Types and Values

struct | GstSegmentation

## Description

This element creates and updates a fg/bg model using one of several approaches. The one called "codebook" refers to the codebook approach following the opencv O'Reilly book [1] implementation of the algorithm described in K. Kim, T. H. Chalidabhongse, D. Harwood and L. Davis [2]. BackgroundSubtractorMOG [3], or MOG for shorts, refers to a Gaussian Mixture-based Background/Foreground Segmentation Algorithm. OpenCV MOG implements the algorithm described in [4]. BackgroundSubtractorMOG2 [5], refers to another Gaussian Mixture-based Background/Foreground segmentation algorithm. OpenCV MOG2 implements the algorithm described in [6] and [7].

[1] Learning OpenCV: Computer Vision with the OpenCV Library by Gary Bradski and Adrian Kaehler, Published by O'Reilly Media, October 3, 2008 [2] "Real-time Foreground-Background Segmentation using Codebook Model", Real-time Imaging, Volume 11, Issue 3, Pages 167-256, June 2005. [3] http://opencv.itseez.com/modules/video/doc/motion_analysis_and_object_tracking.htmlbackgroundsubtractormog [4] P. KadewTraKuPong and R. Bowden, "An improved adaptive background mixture model for real-time tracking with shadow detection", Proc. 2nd European Workshop on Advanced Video-Based Surveillance Systems, 2001 [5] http://opencv.itseez.com/modules/video/doc/motion_analysis_and_object_tracking.htmlbackgroundsubtractormog2 [6] Z.Zivkovic, "Improved adaptive Gausian mixture model for background subtraction", International Conference Pattern Recognition, UK, August, 2004. [7] Z.Zivkovic, F. van der Heijden, "Efficient Adaptive Density Estimation per Image Pixel for the Task of Background Subtraction", Pattern Recognition Letters, vol. 27, no. 7, pages 773-780, 2006.

### Example launch line

    1
    gst-launch-1.0  v4l2src device=/dev/video0 ! videoconvert ! segmentation test-mode=true method=2 ! videoconvert ! ximagesink

## Synopsis

### Element Information

plugin | opencv
author | Miguel Casas-Sanchez <miguelecasassanchez@gmail.com>
class | Filter/Effect/Video

### Element Pads

name | sink
direction | sink
presence | always
details | video/x-raw, format=(string)RGBA, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]

name | src
direction | source
presence | always
details | video/x-raw, format=(string)RGBA, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]

## Functions

## Types and Values

### struct GstSegmentation

    struct GstSegmentation {
      GstOpencvVideoFilter element;
      gint method;

      gboolean test_mode;
      gint width, height;

      cv::Mat cvRGB;
      cv::Mat cvYUV;

      cv::Mat cvFG;               /*  used for the alpha BW 1ch image composition */
      cv::Mat ch1, ch2, ch3;
      int framecount;

      /* for codebook approach */
      codeBook *TcodeBook;
      int learning_interval;

      /* for MOG methods */
      cv::Ptr<cv::BackgroundSubtractor> mog;                   /* cv::BackgroundSubtractorMOG */
      cv::Ptr<cv::BackgroundSubtractorMOG2> mog2;                   /* cv::BackgroundSubtractorMOG2 */

      double learning_rate;
    };

## Property Details

### The `“learning-rate”` property

      “learning-rate”            gfloat

Speed with which a motionless foreground pixel would become background (inverse of number of frames).

Owner: GstSegmentation

Flags: Read / Write

Allowed values: [0,1]

Default value: 0.01

### The `“method”` property

      “method”                   GstSegmentationMethod

Segmentation method to use.

Owner: GstSegmentation

Flags: Read / Write

Default value: Mixture-of-Gaussians segmentation (Zivkovic2004)

### The `“test-mode”` property

      “test-mode”                gboolean

If true, the output RGB is overwritten with the calculated foreground (white color).

Owner: GstSegmentation

Flags: Read / Write

Default value: FALSE