亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

OpenCV學習——物體跟蹤的粒子濾波算法實現之位

系統 1709 0

/*
Computes the likelihood of there being a player at a given location in
an image

@param img image that has been converted to HSV colorspace using bgr2hsv()
@param r row location of center of window around which to compute likelihood
@param c col location of center of window around which to compute likelihood
@param w width of region over which to compute likelihood
@param h height of region over which to compute likelihood
@param ref_histo reference histogram for a player; must have been
normalized with normalize_histogram()

@return Returns the likelihood of there being a player at location
(\a r, \a c) in \a img
*/
float likelihood( IplImage* img, int r, int c,
int w, int h, histogram* ref_histo )
{
IplImage* tmp;
histogram* histo;
float d_sq;

/* extract region around (r,c) and compute and normalize its histogram */
cvSetImageROI( img, cvRect( c - w / 2, r - h / 2, w, h ) );
tmp = cvCreateImage( cvGetSize(img), IPL_DEPTH_32F, 3 );
cvCopy( img, tmp, NULL );
cvResetImageROI( img );
histo = calc_histogram( &tmp, 1 );
cvReleaseImage( &tmp );
normalize_histogram( histo );

/* compute likelihood as e^{\lambda D^2(h, h^*)} */
d_sq = histo_dist_sq( histo, ref_histo );
free( histo );
return exp( -LAMBDA * d_sq );
}

程序首先取出對相關粒子表示的區域,然后計算其直方圖,并且歸一化。將這個直方圖和原來用戶選定區域的直方圖傳入函數histo_dist_sq進行比較,最后返回e^(-Lambda*d_sq)返回,成為這個粒子的權重。

函數histo_dist_sq的實現如下:

/*
Computes squared distance metric based on the Battacharyya similarity
coefficient between histograms.

@param h1 first histogram; should be normalized
@param h2 second histogram; should be normalized

@return Returns a squared distance based on the Battacharyya similarity
coefficient between \a h1 and \a h2
*/
float histo_dist_sq( histogram* h1, histogram* h2 )
{
float* hist1, * hist2;
float sum = 0;
int i, n;

n = h1->n;
hist1 = h1->histo;
hist2 = h2->histo;

/*
According the the Battacharyya similarity coefficient,

D = \sqrt{ 1 - \sum_1^n{ \sqrt{ h_1(i) * h_2(i) } } }
*/
for( i = 0; i < n; i++ )
sum += sqrt( hist1[i]*hist2[i] );
return 1.0 - sum;
}

采用統計學上的巴氏距離 Bhattacharyya distance,根據wiki的描述, Bhattacharyya distance 描述的是兩個離散概率分布的相似性,它通常在分類操作中被用來度量不同類型的可分離性,也就是說這個距離算式就是評定相似度的。嚴格定義為:

For discrete probability distributions p and q over the same domain X, it is defined as:

where:

is the Bhattacharyya coefficient .

該程序中的算式和這個式子略有差別。

OpenCV學習——物體跟蹤的粒子濾波算法實現之位置可能性確定


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 天天性综合 | 国产香蕉精品视频在 | 91精品视频在线播放 | 精品久久洲久久久久护士免费 | 免费女人18毛片a级毛片视频 | 亚洲视频一区二区三区四区 | 亚洲精品国产综合一线久久 | 高清视频在线播放 | 婷婷射| 成年女人看片免费视频频 | 日本免费不卡视频 | 狠狠色伊人亚洲综合成人 | 国产精品久久久久久久9999 | 日本一区二区在线播放 | 天天操天天摸天天射 | 毛片机地 | 日本三级强在线观看 | 久久久久免费精品国产小说 | 日韩亚洲欧美一区二区三区 | 国产精品亚洲综合色拍 | 黄色免费看看 | 不卡的在线视频免费观看 | 在线免费国产视频 | 欧美另类交视频 | 欧美一级日本一级韩国一级 | 久久国产视屏 | 国产va免费高清在线观看 | 天天上天天干 | 日韩一区二区三区免费 | 国产精品日本一区二区在线播放 | 99久久一香蕉国产线看观看 | 久久亚洲国产成人亚 | 久久精品乱子伦免费 | 欧美成人精品一区二区 | 精品午夜久久影视 | 人体做爰aaaa免费 | 女人18毛片a级18毛多水真多 | 麻豆狠色伊人亚洲综合网站 | 真人一级毛片免费观看视频 | 狠狠色狠狠色综合系列 | 在线看片a |