当然没有小俊同志高深 。。。 = =
Mean Shift,业内人士称为Mean Sh!t,比较慢,剧烈运动的物体跟踪效果较差 好像是废话 = =
PDF截图两张 敏感部位
“敏感部位”代码
[size=3]int MeanShift::CalcHisSp(unsigned char* frame, float* histogram){
int pxValue = 0;
for(int i = 0 ; i < HISLENGTH; i++)
histogram[i] = 0;
for(int j = max(0,cY - trackWinHeight / 2);j < min(cY + trackWinHeight / 2,imgH - 1); j ++){
for(int i = max(0,cX - TrackwWidth/ 2); i < min(cX + TrackwWidth/ 2,imgW - 1);i ++){
pixel r = frame[j * imgW * 3 + i * 3] / 16;
pixel g = frame[j * imgW * 3 + i * 3 + 1] / 16;
pixel b = frame[j * imgW * 3 + i * 3 + 2] / 16;
histogram[256 * (int)r + 16 * (int)g + (int)b] += 1;
pxValue ++;
}
}
for(int i = 0; i < HISLENGTH; i ++)
histogram[i] /= pxValue;
else
{
return 0;
}
return pxValue;
}
void MeanShift::MSPSp(unsigned char * frame){
float weights[HISLENGTH];
float newX = 0.0;
float newY = 0.0;
for (int i=0;i<HISLENGTH;i++)
{
if (currHistogram[i] >0.0 )
weights[i] = (float)tempHistogram[i]/(float)currHistogram[i];
else
weights[i] = 0;
}
float sumOfWeights = 0.0;
for(int j = max(0,cY - trackWinHeight / 2);j < min(cY + trackWinHeight / 2,imgH - 1); j ++){
for(int i = max(0,cX - TrackwWidth/ 2); i < min(cX + TrackwWidth/ 2,imgW - 1);i ++){
pixel r = frame[j * imgW * 3 + i * 3] / 16;
pixel g = frame[j * imgW * 3 + i * 3 + 1] / 16;
pixel b = frame[j * imgW * 3 + i * 3 + 2] / 16;
int ptr = (int)(256 * (int)r + 16 * (int)g + (int)b);
newX += (weights[ptr] * (float)i);
newY += (weights[ptr] * (float)j);
sumOfWeights += weights[ptr];
}
}
if(sumOfWeights != 0){
cX = int((newX/sumOfWeights) + 0.5);
cY = int((newY/sumOfWeights) + 0.5);
}
return;
}
void MeanShift::MSTP(unsigned char* frame,int frameNumber)
{
if(frameNumber == 0){
CalcHisSp(frame ,this->tempHistogram);
}
else
{
int stopThreshold = 10;
int iteratorCoumt = 0;
while(iteratorCoumt < stopThreshold){
CalcHisSp(frame ,this->currHistogram);
MSPSp(frame);
iteratorCoumt++;
}
}
}
[/size]
misuzu什么的最喜欢了
YDD_CVPR_05.pdf
571.13KB
PDF
66次下载
预览
200字以内,仅用于支线交流,主线讨论请采用回复功能。