OpenCV Tracker Element for Object Tracking

Vivek R requested to merge 123vivekr/gst-plugins-bad:tracker into master

What is it?

A tracker element based on OpenCV's long-term tracker algorithm implementation from here.

Sample pipeline: gst-launch-1.0 filesrc location=/home/vivek/Desktop/GStreamer_plugin/t.mp4 ! decodebin ! videoconvert ! cvtracker object-initial-x=175 object-initial-y=40 object-initial-width=300 object-initial-height=150 algorithm=1 ! videoconvert ! xvimagesink



The tracker element takes input: a bounding box to initiate the tracker with the object to be tracked and algorithm for tracking. The first frame passing through the tracker element is taken as the initialization frame and the tracker element tracks the object for the subsequent frames.


object-initial-x: bounding box's x co-ordinate

object-initial-y: bounding box's y co-ordinate

object-initial-width: bounding box's width

object-initial-height: bounding box's height

algorithm: choose from 7 different tracking algorithms [0-6]


Writes the tracked object's coordinates (x, y, width and height) to the GstVideoRegionOfInterest metadata to the buffer for each frame. Also draws a rectangle around the object on the video stream.


This element can be used to track any object using OpenCV's tracking implementation. The ROI stored in the metadata can be used to attach "silly hats" or filters to the area.

OPENCV PATCH FIX: While compiling gst-plugins-bad from the master branch, it left out the bgsegm.hpp header and the patch here fixes that.

Edited by Thibault Saunier

Merge request reports