Skip to main content


Showing posts from January, 2020

Video tutorial of OpenCV tracking API, the simplest code ever

This tutorial focus on single target tracking in OpenCV 4 contribution tracking API. The code is included and contains under 60 simple lines and described in the 7 minutes of a youtube video as well. You will learn to use OpenCV tracking API to follow single object in a video sequence.  Let me know what do you think in the comment. Feel free to try the code down here.   Opencv tracking API example goal The goal of this example is to use a mouse to select the region in the image. This region will use the selected region to initialize the tracker. The selected region will be tracked by the tracker available in the OpenCV tracking module. This module is available in opencv_contrib libraries. Environment Opencv tracking contribution modules It is important to install opencv with contribution modules. You can found this tutorial for windows here  opencv 4 contrib modules  . You need to exclude Gstreamer. This is not needed for Tracking API. This will enable you to use functiona

Opencv mouse drawing C++ tutorial, mouse setMouseCallback region selection

This c++ Opencv tutorial shows you how to draw a rectangle by mouse over the object. The purpose of this is to take a Region of interest for your tracker or any other crop region applications. This is a very useful task. I created a youtube video with who explanation, but everything will be described in the following text.  Opencv video example and code explanation I try to explain the code and functionality as well on this youtube video. The video describes the code and shows mouse in action drawing the rectangle and update based on actual mouse move.  The opencv mouse call back function code basic description  The first is a structure called initRoi that represents the global state of the mouse. The members of the structure are initial coordinates of mouse x and y, some indicator init that something happened and actual coordinates of x and y. The structure is global, where members are accessible by SelectedRoi.init, SelectedRoi.initX, SelectedRoi.initY, Sele