http://wiki.opencv.org.cn/index.php/Cv运动分析与对象跟踪
http://wiki.opencv.org.cn/index.php/增强现实%28AR%29
opencv2中的segmentMotion内部调用的还是cvSegmentMotion这个函数。
void cv::segmentMotion(InputArray _mhi, OutputArray _segmask,
vector<Rect>& boundingRects,
double timestamp, double segThresh)
{
Mat mhi = _mhi.getMat();
_segmask.create(mhi.size(), CV_32F);
CvMat c_mhi = mhi, c_segmask = _segmask.getMat();
Ptr<CvMemStorage> storage = cvCreateMemStorage();
Seq<CvConnectedComp> comps = cvSegmentMotion(&c_mhi, &c_segmask, storage, timestamp, segThresh);
Seq<CvConnectedComp>::const_iterator it(comps);
size_t i, ncomps = comps.size();
boundingRects.resize(ncomps);
for( i = 0; i < ncomps; i++, ++it)
boundingRects[i] = (*it).rect;
}
CvSeq* cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask, CvMemStorage* storage,
double timestamp, double seg_thresh );
mhi 运动历史图像
seg_mask 发现应当存储的 mask 的图像, 单通道, 32bits, 浮点数.
storage 包含运动连通域序列的内存存储仓
timestamp 当前时间,毫秒单位
seg_thresh 分割阈值,推荐等于或大于运动历史“每步”之间的间隔。
函数 cvSegmentMotion 寻找所有的运动分割,并且在seg_mask 用不同的单独数字(1,2,...)