⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fingerdlg.cpp

📁 这是个手指指纹识别的源代码 ,也是从网络上下载的
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}
////////////////从右到左
for(i=5;i<295;i++)
{
j=299;
	while(j>0)
	{
	if(data[i][j]>220)
	j--;
	else
		break;
	}
for(k=-2;k<3;k++)
{
for(v=299;v>j;v--)
{
beijin[i+k][v]=255;
}
}
}
///////////////从上到下
for(i=5;i<295;i++)
{
j=0;
	while(j<300)
	{
	if(data[j][i]>220)
		j++;
	else
		break;
	}
for(k=-2;k<3;k++)
{
for(v=0;v<j;v++)
{
beijin[v][i+k]=255;
}
}
}
//////////////////从下到上
for(i=5;i<295;i++)
{
j=299;
	while(j>=0)
	{
	if(data[j][i]>220)
		j--;
	else
		break;
	}
for(k=-2;k<3;k++)
{
for(v=299;v>j;v--)
{
beijin[v][i+k]=255;
}
}
}
return 0;
}

long CFingerDlg::showdirect(int x1, int y1,int x2,int y2)
{
int t;
int sx,sy,wei,chu;
float x,y;
float dx,dy,k;
/////////////////
dx=(float)(x2-x1);
dy=(float)(y2-y1);

if(dx!=0||dy!=0)
{
	k=dy/dx;
	if(x1<x2)
{
	chu=x1+1;
	y=(float)(y1);
    wei=x2;
}
else
{
chu=x2+1;
y=(float)(y2);
wei=x1;
}

for(t=chu;t<wei;t++)
{
y=y+k;
sy=(int)(y+0.5);
data[t][sy]=150;
}
//////////////////////
k=dx/dy;
if(y1<y2)
{
x=(float)(x1);
chu=y1+1;
wei=y2;
}
else
{
x=(float)(x2);
chu=y2+1;
wei=y1;
}
for(t=chu;t<wei;t++)
{
x=x+k;
sx=(int)(x+0.5);
data[sx][t]=150;
}
}
//////////////////////////////////
else
{
///////////////////
if(dx==0)
{
	if(y1<y2)
{
	chu=y1+1;
    wei=y2;
}
	else
{
	chu=y2+1;
    wei=y1;
}
for(t=chu;t<wei;t++)
{
	data[t][x1]=150;   
}
}
/////////////////////
////////////////
else
{
if(dy==0)
{
if(x1<x2)
{
chu=x1+1;
wei=x2;
}
else
{
chu=x2+1;
wei=x1;
}
for(t=chu;t<wei;t++)
{
	data[t][y1]=150;
}
}
///////////////////////
}
}//////////else的结束;
ShowBmp();
return 1;
}

long CFingerDlg::neiborghtstart(int x, int y,int dxk,int dyk)
{
float flag;
int t;
float newstep;
float stept;
float shuc,shus,chang;
int i,j,linx,liny;
int ban[40][40];
bianhuan mo[80][80];
bianhuan biao;
int kuang;
kuang=20;
stept=1;
flag=4;
////////////////////////开始旋转变换
for(i=0;i<80;i++)
{
for(j=0;j<80;j++)
{
mo[i][j].color=255;
}
}
for(i=0;i<40;i++)
{
for(j=0;j<40;j++)
{
ban[i][j]=c[x-20+i][y-20+j];
}
}
ban[20][20]=255;
chang=(float)(sqrt(dxk*dxk+dyk*dyk));
shuc=dxk/chang;
shus=dyk/chang;
////////////////
for(i=0;i<40;i++)
{
for(j=0;j<40;j++)
{
if(ban[i][j]==0)///////很对
{
linx=int((i-20)*shuc+(j-20)*shus)+40;
liny=int((i-20)*(-shus)+(j-20)*shuc)+40;
mo[linx][liny].color=0;
mo[linx][liny].xzhou=x+i-20;
mo[linx][liny].yzhou=y+j-20;
}
}
}
////////////////////完成了旋转变换;
mo[40][40].color=255;
for(i=40;i<80;i++)
{
for(j=0;j<80;j++)
{
if(mo[i][j].color==0)
{
newstep=(float)fabs((float)(j-40)/(i-40));
if(newstep<=stept)
{
	mo[i][j].color=1;
	t=lianjie(x,y,mo[i][j].xzhou,mo[i][j].yzhou);
    if(t==1)/////////表示没有阻挡
	{
		if(newstep<flag)
	{
		flag=newstep;
		biao.color=0;
		biao.xzhou=mo[i][j].xzhou;
		biao.yzhou=mo[i][j].yzhou;
	}
	}
	
}
}
}
}

if(flag==4)
	return 1;///////////只有到了这个时候才返回1,因为范围内没有响应点
else
{
//shanhou(x,y,biao.xzhou,biao.yzhou);
for(i=40;i<80;i++)
{
for(j=0;j<80;j++)
{
if(mo[i][j].color==1||mo[i][j].color==2)
c[mo[i][j].xzhou][mo[i][j].yzhou]=255;
}
}
return 0;
}
}

long CFingerDlg::lianjie(int x1, int y1, int x2, int y2)
{
int i,j;
int t;
int sx,sy,wei,chu;
float x,y;
float dx,dy,k;
/////////////////
dx=(float)(x2-x1);
dy=(float)(y2-y1);
for(i=0;i<60;i++)
{
for(j=0;j<60;j++)
{
lianban[i][j]=255;
}
}

if(dx!=0||dy!=0)
{
	k=dy/dx;
	if(x1<x2)
{
	chu=30;
	y=30;
    wei=x2-x1+30;
}
else
{
chu=x2-x1+30;
y=(float)(y2-y1+30);
wei=30;
}

for(t=chu;t<wei;t++)
{
y=y+k;
sy=(int)(y+0.5);
lianban[t][sy]=0;
}
//////////////////////
k=dx/dy;
if(y1<y2)
{
x=30;
chu=30;
wei=y2-y1+30;
}
else
{
x=(float)(x2-x1+30);
chu=y2-y1+30;
wei=30;
}
for(t=chu;t<wei;t++)
{
x=x+k;
sx=(int)(x+0.5);
lianban[sx][t]=0;
}
}
//////////////////////////////////
else
{
///////////////////
if(dx==0)
{
	if(y1<y2)
{
	chu=30;
    wei=y2-y1+30;
}
	else
{
	chu=y2-y1+30;
    wei=30;
}
for(t=chu;t<wei;t++)
{
	lianban[t][30]=0;   
}
}
/////////////////////
////////////////
else
{
if(dy==0)
{
if(x1<x2)
{
chu=30;
wei=x2-x1+30;
}
else
{
chu=x2-x1+30;
wei=30;
}
for(t=chu;t<wei;t++)
{
	lianban[t][30]=0;
}
}
///////////////////////
}
}//////////else的结束;
lianban[0][0]=255;
lianban[x2-x1+30][y2-y1+30]=255;
for(i=0;i<60;i++)
{
for(j=0;j<60;j++)
{
if(lianban[i][j]==0)
if(data[i+x1-30][j+y1-30]==0)
return 0;//////////表示连接有交叉点;
}
}
return 1;
}

long CFingerDlg::showlian(int x, int y,int dxk,int dyk)
{
float newstep;
float stept;
float shuc,shus,chang;
int i,j,linx,liny;
bianhuan mo[120][120];
stept=0.5;
////////////////////////开始旋转变换
for(i=0;i<120;i++)
{
for(j=0;j<120;j++)
{
mo[i][j].color=255;
mo[i][j].xzhou=0;
mo[i][j].yzhou=0;
}
}
chang=(float)(sqrt(dxk*dxk+dyk*dyk));
shuc=dxk/chang;
shus=dyk/chang;
////////////////
for(i=0;i<60;i++)
{
for(j=0;j<60;j++)
{
linx=int((i-30)*shuc+(j-30)*shus)+60;
liny=int((i-30)*(-shus)+(j-30)*shuc)+60;
mo[linx][liny].color=150;
mo[linx][liny].xzhou=x+i-30;
mo[linx][liny].yzhou=y+j-30;
}
}
////////////////////完成了旋转变换;
for(i=60;i<120;i++)
{
for(j=0;j<120;j++)
{
newstep=(float)fabs((float)(j-60)/(i-60));
if(newstep<=stept&&mo[i][j].color==150)
{
	mo[i][j].color=0;
}
}
}
for(i=60;i<120;i++)
{
for(j=0;j<120;j++)
{
if(mo[i][j].color==0)
{
data[mo[i][j].xzhou][mo[i][j].yzhou]=100;
}
}
}
ShowBmp();
///MessageBox("dsafdsa");
	return 1;
}
long CFingerDlg::panduanmid(int x, int y)
{
int i;
int v;
int a[8],b[8];
int t;
int flag;
/////////////////////////
i=0;
flag=0;
t=0;
a[0]=x+1;
b[0]=y;
a[1]=x-1;
b[1]=y;
a[2]=x;
b[2]=y+1;
a[3]=x;
b[3]=y-1;
a[4]=x-1;
b[4]=y-1;
a[5]=x-1;
b[5]=y+1;
a[6]=x+1;
b[6]=y-1;
a[7]=x+1;
b[7]=y+1;
while(i<8)
{
if(show[a[i]][b[i]]==255&&data[a[i]][b[i]]==0)
{
v=shun(x,y,20);
if(v==0)
return 0;////////////只要有一个不成立就不成立;
}
i++;
}
return 1;
}
int CFingerDlg::fencha(int type) 
{
	// TODO: Add your control notification handler code here
	getendandstart();
	BYTE zai[300][300];
	int i,j;
	int t;
	t=0;
	for(i=0;i<300;i++)
	{
	for(j=0;j<300;j++)
	{
	zai[i][j]=255;
	}
	}
	for(i=0;i<300;i++)
	{
	for(j=0;j<300;j++)
		if(mart[i][j]==5)
		{
			t=panduanmid(i,j);
            if(t==1)
			{
				zai[i][j]=0;
			}
			qingshow(20);
		}
	}
///////////////////////

    for(i=0;i<300;i++)
	{
    for(j=0;j<300;j++)
	{
    if(zai[i][j]==0)
	{
	data[i][j+1]=20;
	data[i+1][j+1]=20;
	data[i+1][j]=20;
	data[i+1][j-1]=20;
	data[i][j-1]=20;
	data[i-1][j-1]=20;
	data[i-1][j]=20;
	data[i-1][j+1]=20;
	}
	}
	}
	ShowBmp();
	return 1;
}

long CFingerDlg::shun(int x, int y,int c)
{
int len,glen;
int biao;
int t;
int flag;
int nextx,nexty;
int i,j;
//////////////////////////
len=0;
glen=20;
biao=0;
flag=0;
i=x;
j=y;
nextx=i;
nexty=j;
//0表示没有占用的终结点,1表示被占用的终结点,5表示没有被占用的分叉点,6表示被占用的分叉点;
while(flag==0)//////////
{
	t=searcharendpoint(i,j,x,y);
	if(t==1)//////表示没有特殊点;
	{
    t=getendpoint(i,j);
	if(t==2)
	{
	biao=1;
	}
	flag=1;
	}
	else
	{
		if(data[i+1][j]<10 &&show[i+1][j]==255)
	{
       nextx=i+1;
	   nexty=j;
       show[i+1][j]=c;

	}///////////扫描一点;
    else
	{
		if(data[i-1][j]<10 &&show[i-1][j]==255)
	{
       nextx=i-1;
	   nexty=j;
       show[i-1][j]=c;

	}///////////////////扫描二点
    else
	{
		if(data[i][j+1]<10 && show[i][j+1]==255)
	{
       nextx=i;
	   nexty=j+1;
       show[i][j+1]=c;

	}////////////////扫描三点;
    else
	{
		if(data[i][j-1]<10 &&show[i][j-1]==255)
	{
       nextx=i;
	   nexty=j-1;
       show[i][j-1]=c;

	}/////////////////扫描四点;
    else
	{
		if(data[i-1][j-1]<10&&show[i-1][j-1]==255)
	{
       nextx=i-1;
	   nexty=j-1;
       show[i-1][j-1]=c;

	}///////////////////扫描五点;
    else
	{
		if(data[i-1][j+1]<10 &&show[i-1][j+1]==255)
	{
       nextx=i-1;
	   nexty=j+1;
       show[i-1][j+1]=c;

	}/////////////////////扫描六点;
    else
	{
		if(data[i+1][j-1]<10 &&show[i+1][j-1]==255)
	{
       nextx=i+1;
	   nexty=j-1;
       show[i+1][j-1]=c;
	}/////////////////////扫描七点;
    else
	{
		if(data[i+1][j+1]<10 &&show[i+1][j+1]==255)
	{
       nextx=i+1;
	   nexty=j+1;
       show[i+1][j+1]=c;

	}////////////////扫描八点
	else
	{
	flag=1;
	biao=1;
	}
	}
	}
	}
	}
	}
	}
	}
	}
	i=nextx;
	j=nexty;
	len++;
	if(len>glen)
		flag=1;
}//////////////循环结束;
//MessageBox("ttttt");
//showshow();

if(biao==1)
	return 0;//正常返回;
else
	return 1;//不正常返回;
}

long CFingerDlg::qingshow(int c)
{
int i,j;
for(i=0;i<300;i++)
{
for(j=0;j<300;j++)
{
if(show[i][j]==c)
show[i][j]=255;
}
}
return 0;
}

int CFingerDlg::SetCustom(CString SQL,int type)
{
_variant_t vNull;
vNull.vt=VT_ERROR;
vNull.scode=DISP_E_PARAMNOTFOUND;
_variant_t vRecsAffected(0L);
int t;
m_pRs=NULL;
m_piAdoRecordBinding=NULL;
m_com->CommandText=_bstr_t(SQL);
m_pRs.CreateInstance(__uuidof(Recordset)); 
m_pRs->PutRefActiveConnection( m_con );
m_pRs->Open(_variant_t(SQL),vtMissing,adOpenKeyset,adLockBatchOptimistic, -1);
if(FAILED(m_pRs->QueryInterface(__uuidof(IADORecordBinding),(LPVOID*)&m_piAdoRecordBinding)))
_com_issue_error(E_NOINTERFACE);
m_piAdoRecordBinding->BindToRecordset(&m_rsCustom);
t=refreshCustom(type);
if(t==1)
{
	return 1;
}
else 
{
return 0;
}
}

int CFingerDlg::refreshCustom(int type)
{
int v;
CCustomRs*  pRs;
pRs=GetCustom();
if(m_pRs->GetRecordCount()>0)
{
m_EmployeeId=pRs->m_m_sEmployeeId;
m_EmployeeName=pRs->m_m_sEmployeeName;
m_EmployeeDepartName=pRs->m_m_sEmployeeDepartName;
m_TimeType=pRs->m_m_iTimeCount;
if(type!=3)
{
v=getWhich();
if(v==3)
{
return 0;
}
if(v==1)
{
	m_TimeOnCharge=pRs->m_m_tTimeBeOn1;
	m_TimeOutCharge=pRs->m_m_tTimeBeOut1;
}
else
{
	m_TimeOnCharge=pRs->m_m_tTimeBeOn2;
	m_TimeOutCharge=pRs->m_m_tTimeBeOut2;
}
UpdateData(FALSE);
return 1;
}
else
{
m_TimeOnCharge=pRs->m_m_tTimeBeOn2;
m_TimeOutCharge=pRs->m_m_tTimeBeOut2;
UpdateData(FALSE);
return 1;
}
}
else
{
	m_EmployeeId=_T("");
	m_EmployeeName=_T("");
    m_EmployeeDepartName=_T("");
	m_TimeType=0;
    UpdateData(FALSE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -