GravityTrack.cpp
上传用户:smdfuse
上传日期:2015-11-06
资源大小:98k
文件大小:1k
- #include "StdAfx.h"
- #include "GravityTrack.h"
- /******************************************************/
- /* 函数名称:
- /* GravityTrack
- /*
- /* 函数参数:
- /* unsigned char* sGray-输入灰度图像
- /* int sWidth-图像宽度
- /* int sHeight-图像高度
- /* int sThreshold-目标域值
- /*
- /* 说明:
- /* 形心法目标跟踪程序
- /*******************************************************/
- /*WININFO GravityTrack (unsigned char* sGray, int sWidth, int sHeight, int sThreshold)
- {
- WININFO win;
- win.w = 0;
- win.h = 0;
- win.pt.x = 0;
- win.pt.y = 0;
- win.flag = FALSE;
-
- int M00bh = 0;
- int M01bh = 0;
- int M10bh = 0;
- int iLine,i,j;
- for(j=EDGE_SPACE;j<sHeight-EDGE_SPACE;j++)
- {
- iLine = 0;
- for(i=EDGE_SPACE;i<sWidth-EDGE_SPACE;i++)
- {
- int k = sWidth*j+i;
- if(sGray[k]>sThreshold)
- {
- iLine++;
- M01bh+=i;
- M10bh+=j;
- }
- }
- M00bh+=iLine;
- if(win.w<iLine) win.w = iLine;
- if(iLine>0) win.h++;
- }
- //if(M00bh>10)
- //{
- win.pt.x = int(M01bh/M00bh+0.5);
- win.pt.y = int(M10bh/M00bh+0.5);
- win.w = win.w/2+EDGE_DRAW;
- win.h = win.h/2+EDGE_DRAW;
- //win.flag = TRUE;
- //}
- return win;
- }
- */