Book Image

OpenCV Essentials

Book Image

OpenCV Essentials

Overview of this book

Table of Contents (15 chapters)
OpenCV Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

The Mean-Shift tracker


The Mean-Shift method allows you to locate the maximum of a density function given discrete data sampled from that function. It is, therefore, useful for detecting the modes of this density. Mean-Shift is an iterative method, and an initial estimation is needed.

The algorithm can be used for visual tracking. In this case, the color histogram of the tracked object is used to compute the confidence map. The simplest of such algorithm would create a confidence map in the new image based on the object histogram taken from the previous image, and Mean-Shift is used to find the peak of the confidence map near the object's previous position. The confidence map is a probability density function on the new image, assigning each pixel of the new image a probability, which is the probability of the pixel color occurring in the object in the previous image. Next, we show you an example (trackingMeanShift) using this function:

void trackingMeanShift(Mat& img, Rect search_window...