## grabcut grabcut |

## Properties

gfloat | scale | Read / Write
gboolean | test-mode | Read / Write

## Types and Values

struct | GstGrabcut

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GstObject
                ╰── GstElement
                    ╰── GstBaseTransform
                        ╰── GstVideoFilter
                            ╰── GstOpencvVideoFilter
                                ╰── GstGrabcut

## Description

This element is a wrapper around OpenCV grabcut implementation. GrabCut is an image segmentation method based on graph cuts technique. It can be seen as a way of fine-grain segmenting the image from some FG and BG "seed" areas. The OpenCV implementation follows the article [1]. The "seed" areas are taken in this element from either an input bounding box coming from a face detection, or from alpha channel values. The input box is taken from a "face" event such as the one generated from the 'facedetect' element. The Alpha channel values should be one of the following (cv.hpp): enum{ GC_BGD = 0, //!< background GC_FGD = 1, //!< foreground GC_PR_BGD = 2, //!< most probably background GC_PR_FGD = 3 //!< most probably foreground }; with values over GC_PR_FGD interpreted as GC_PR_FGD. IN CASE OF no alpha mask input (all 0's or all 1's), the 'GstOpenCvFaceDetect-face' downstream event is used to create a bbox of PR_FG elements. If both foreground alpha is not specified and there is no face detection, nothing is done.

[1] C. Rother, V. Kolmogorov, and A. Blake, "GrabCut: Interactive foreground extraction using iterated graph cuts, ACM Trans. Graph., vol. 23, pp. 309–314, 2004.

### Example launch line

    1
    gst-launch-1.0 --gst-debug=grabcut=4  v4l2src device=/dev/video0 ! videoconvert ! grabcut ! videoconvert ! video/x-raw,width=320,height=240 ! ximagesink

Another example launch line

    1
    gst-launch-1.0 --gst-debug=grabcut=4  v4l2src device=/dev/video0 ! videoconvert ! facedetect display=0 ! videoconvert ! grabcut test-mode=true ! videoconvert ! video/x-raw,width=320,height=240 ! 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 GstGrabcut

    struct GstGrabcut;

## Property Details

### The `“scale”` property

      “scale”                    gfloat

Grow factor for the face bounding box, if present.

Flags: Read / Write

Allowed values: [1,4]

Default value: 1.6

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

      “test-mode”                gboolean

If true, the output RGB is overwritten with the segmented foreground. Alpha channel same as normal case .

Flags: Read / Write

Default value: FALSE