采用 CAMSHIFT 算法快速跟踪和检测运动目标的 C/C++ 源代码

在实现运动目标的跟踪的过程中,发现网上流传很广的一段跟踪与检测源代码,大家可以在各个网站上都找到其踪影。为了方便查阅和参考,特转发如下:

因为转发地址不可考,就在此先谢谢提供最初版本的前辈。

This application demonstrates a fast, simple color tracking algorithm that can be used to track faces, hands . The CAMSHIFT algorithm is a modification of the Meanshift algorithm which is a robust statistical method of finding the mode (top) of a probability distribution. Both CAMSHIFT and Meanshift algorithms exist in the library. While it is a very fast and simple method of tracking, because CAMSHIFT tracks the center and size of the probability distribution of an object, it is only as good as the probability distribution that you produce for the object. Typically the probability distribution is derived from color via a histogram, although it could be produced from correlation, recognition scores or bolstered by frame differencing or motion detection schemes, or joint probabilities of different colors/motions etc. In this application, we use only the most simplistic approach: A 1-D Hue histogram is sampled from the object in an HSV color space version of the image. To produce the probability image to track, histogram “back projection” (we replace image pixels by their histogram hue value) is used.

算法的详细情况,请看论文:

笔者在VC6.0中,代码通过编译,,可以正常使用。但是如果将该代码转换到MFC中,则会出现,cvSetMouseCallback()函数不断报错的情况出现。笔者在网上搜索解决方法,高手们的建议,一个方向是:用MFC自行提供的消息机制,但是如何使用,并没有说。一个方向是:将该函数在声明的时候定义为static类型。但是解决方法回复为,即使定义后,仍然无法解决该问题。笔者查阅了大量的网页,还有侯俊杰老师的《深入浅出MFC,解决了该问题,可以使程序在MFC中正常运行。

方法比较简单,希望,懂得如何利用MFC消息机制的高手,提点一二

具体解决方法,见下篇文章

别想一下造出大海,必须先由小河川开始。

采用 CAMSHIFT 算法快速跟踪和检测运动目标的 C/C++ 源代码

相关文章:

你感兴趣的文章:

标签云: