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

📄 fingerdbm.cpp

📁 指纹识别源码 希望朋友们多多指教 阅后敬请提出宝贵意见
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	{
		m_pSet->Update();
		m_pSet->Requery();
	}
	catch(CDBException *e)
	{
		MessageBox(CString("更新记录错误")+e->m_strError);
		e->Delete();
		return;
	}


//	m_pSet->AddNew()

}

void CFingerDBM::OnAdd() 
{
	// TODO: Add your control notification handler code here
//	m_idcard = "" ;
	m_capnum = 0 ;
//	m_name ="" ;
	int check;
	check=GetCheckedRadioButton(IDC_QUALITY_A,IDC_QUALITY_C);
	if(check)	
		CheckDlgButton(check,0);
	check=GetCheckedRadioButton(IDC_FINGER_1,IDC_FINGER_10);
	if(check)	
		CheckDlgButton(check,0);
	check=GetCheckedRadioButton(IDC_TYPE_LEFT,IDC_TYPE_QITA);
	if(check)	
		CheckDlgButton(check,0);
   	if(m_Image.m_hWnd==NULL)
    	return ;
	memset(sbmp->m_Bmp_pBmpValue,255,sbmp->m_Width*sbmp->m_Height);
    sbmp->DrawDib(m_Image.GetDC(),1,0,0);
	m_Image.GetDC()->TextOut(0,120,"请从BMP文件或采集仪导入指纹图象");
//	sbmp->m_Width=sbmp->m_Height=0;
	UpdateData(false);
    try
	{
	  m_pSet->AddNew();
	}
	catch(CDBException *e)
	{
		MessageBox(CString("添加新记录错误")+e->m_strError);
		e->Delete();
		return;
	}

	
}

void CFingerDBM::OnDelete() 
{
	// TODO: Add your control notification handler code here
	if(MessageBox("真的要删除吗?","注意",MB_OKCANCEL)!=1)
		return;
	CString sql;
	sql="delete from finger";
//	CDa
//	m_pSet->
//	AFX_ODBC_CALL(::SQLSetPos(m_pSet->m_hstmt, wRow, SQL_DELETE, wLockType));
    try
	{
	m_pSet->Delete();
	m_pSet->Requery();
	}
	catch(CDBException *e)
	{
		MessageBox(CString("删除记录错误")+e->m_strError);
		e->Delete();
		return;
	}

}


void CFingerDBM::OnChangeDb() 
{
	// TODO: Add your control notification handler code here
	m_pSet->Edit();
	MessageBox("可以直接在对应的输入框或按纽上更改,完成后单击更新","注意",MB_OK);

}

void CFingerDBM::OnInportBmpfile() 
{
	// TODO: Add your control notification handler code here
	CFileDialog fg(TRUE, // TRUE for FileOpen, FALSE for FileSaveAs
		"*.bmp",
		NULL,
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		"位图文件(*.bmp)|*.bmp",
		this);
	if(fg.DoModal() == IDOK)
	{
		CString fn;
		fn=fg.GetFileName();
		sbmp->ReadFile(fn);
		CPaintDC dc(this); // device context for painting
    	sbmp->DrawDib(m_Image.GetDC(),1,0,0);
//	    UpdateData(FALSE);

	}


}

void CFingerDBM::OnRecordFirst() 
{
	// TODO: Add your command handler code here
	m_pSet->MoveFirst();
	this->BindData();
}

void CFingerDBM::OnRecordLast() 
{
	// TODO: Add your command handler code here
	m_pSet->MoveLast();
	this->BindData();
}

void CFingerDBM::OnRecordNext() 
{
	// TODO: Add your command handler code here
	this->OnNext();
}

void CFingerDBM::OnRecordPrev() 
{
	// TODO: Add your command handler code here
	this->OnPrevior();
}

void CFingerDBM::OnRequryDb() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
/*	if(m_sql=="") 
	{
		MessageBox("在SQL语句框中输入SQL语句","注意",MB_OK);
		return;
	}
*/	m_pSet->m_strFilter=m_sql;
	if(m_pSet->IsOpen())
		m_pSet->Close();
	m_pSet->Open();
    this->BindData();
}

void CFingerDBM::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	
	CRecordView::OnKeyUp(nChar, nRepCnt, nFlags);
	if(nChar==13)
	{
		if(this->GetFocus()==this->GetDlgItem(IDC_SQL_EDIT))
			this->OnRequryDb();
	}

}

void CFingerDBM::OnTitezheng() 
{
	// TODO: Add your control notification handler code here

	int quli,type;
	memset(m_Minutia,0,MAXNUM*DIM+4);
    int cenx,ceny;
	unsigned char cimage[IMAGEWIDTH*IMAGEHEIGHT];
	memset(cimage,0,IMAGEWIDTH*IMAGEHEIGHT);
	if(!GetMinutia(sbmp->m_Bmp_pBmpValue,cimage,sbmp->m_Height,sbmp->m_Width ,m_Minutia,quli,type,cenx,ceny))
	{
		MessageBox("图像不合格","注意",MB_OK);
		return;
	}
	if(quli!=m_quality)
		CheckRadioButton(IDC_QUALITY_A,IDC_QUALITY_C,IDC_QUALITY_A+quli-1);
	if(type!=m_type)
		CheckRadioButton(IDC_TYPE_LEFT,IDC_TYPE_QITA,IDC_TYPE_LEFT+type-1);
	MINUTIASTRU tm[MAXNUM],bad[MAXNUM];
	CENTER core1;
	m_centerx=cenx;m_centery=ceny;
	core1.x=cenx;core1.y=IMAGEHEIGHT-ceny;
	int num1=0;
	for(int rcl = 0; rcl <m_Minutia[0]; rcl++)
	{
		tm[rcl].x = m_Minutia[rcl*DIM+4];
		tm[rcl].y = m_Minutia[rcl*DIM+5];
		tm[rcl].direction = m_Minutia[rcl*DIM+6]*2;
		if(m_Minutia[rcl*DIM+7]>0)
		{
		bad[num1].x = m_Minutia[rcl*DIM+4];
        bad[num1].y = m_Minutia[rcl*DIM+5];
		bad[num1].direction =m_Minutia[rcl*DIM+6]*2;
		num1++;
		}
	}
    cbmp->m_Bmp_pBmpValue=cimage;
    cbmp->DrawDib(m_CutImage.GetDC(),1,0,0);
	DrawMinutia(
			this->m_CutImage.m_hWnd ,//HWND		hWnd,			//父窗口句柄
			this->m_CutImage.GetDC(),//CDC			*pDC,			//父窗口DC
			0,//short		x,				//图象的位置(相对于父窗口的左上角)
			0,//short		y,
	    	200,
	    	256,
			cimage ,		//256灰度的图象数据
    		200,
	    	256,
			m_Minutia[0],	//特征点个数
			tm,//MINUTIASTRU *lpMinutia1,	//特征点结构数组
	        0,//short		MinutiaNum2,
			NULL,//MINUTIASTRU *lpMinutia2,
			num1,//short		MinutiaNum2,
			bad,//MINUTIASTRU *lpMinutia2,
		//	0,//short		MinutiaNum3,
		//	NULL,//MINUTIASTRU *lpMinutia3,
			&core1,//NULL,//CENTER		*lpMainCenter,	//主中心结构指针
			NULL,//CENTER		*lpAidCenter,	//副中心结构指针
			NULL,//DELTA		*lpLeftDelta,	//左三角结构指针
			NULL,//DELTA		*lpRightDelta,	//右三角结构指针
			TRUE//bool		whetherDraw		//true,显示特征点和中心三角;false 不显示
			);
	UpdateData(false);

	
}

void CFingerDBM::OnInportCapture() 
{
	// TODO: Add your control notification handler code here
   if(theApp.cap_type==1)//////////光电指纹采集仪采集图像/////////////////////
   {
	CScanDialog gfr(sbmp);
    	if(gfr.DoModal()==IDOK)
		{
			RECT rc;
			GetDlgItem(IDC_FINGER_BMP)->GetWindowRect(&rc);
			InvalidateRect(&rc);
		}
   }
  else if(theApp.cap_type==2)/////////////电容传感器采集指纹图像////////////
  {
	  CZhongzhGetBmp zz;
	zz.GetBmp(sbmp);
	RECT rc;
	GetDlgItem(IDC_FINGER_BMP)->GetWindowRect(&rc);
	InvalidateRect(&rc);
  }

	

}

void CFingerDBM::OnCreateFeature() 
{
	// TODO: Add your command handler code here
	if(MessageBox("真的创建或更新用于加速识别的特征库吗?注意:这可能需要一些时间(随数据库大小而定)","注意",MB_OKCANCEL)!=1)
		return;
	if(theApp.testdb)
		GlobalFree(theApp.testdb);
	{
	//	theApp.num=m_pSet->GetRecordCount();
	//	if(theApp.num==-1)
		{
			m_pSet->MoveFirst();
			while(!m_pSet->IsEOF())
			{
				theApp.num++;
				m_pSet->MoveNext();
			}
		}
		if(!theApp.num) return;
		theApp.testdb=(FPTEST*)GlobalAlloc(GMEM_FIXED,theApp.num*sizeof(FPTEST));
		if(!theApp.testdb)
		{
			MessageBox("内存不足");
			return;
		}
	    m_pSet->MoveFirst();
		FPTEST *test;
		test=theApp.testdb;
    	while(!m_pSet->IsEOF())
		{
			if(!m_pSet->m_name.IsEmpty())
			{
				//test->ID=m_pSet->m_id;
				memcpy(test->name,m_pSet->m_name.GetBuffer(10),m_pSet->m_name.GetLength());
				test->name[m_pSet->m_name.GetLength()]='\0';
				test->type=m_pSet->m_type;
				test->centerx=m_pSet->m_centerx;
				test->centery=m_pSet->m_centery;
				test->quality=m_pSet->m_quality;
				test->fingerIndex=m_pSet->m_serial;
				memcpy(test->minu,m_pSet->m_feature.GetData(),MAXNUM*DIM+4);
				test++;
			}
        	m_pSet->MoveNext();
		}
	}
	MessageBox("用于加速识别的特征库成功创建!","注意",MB_OK);

	
}

void CFingerDBM::OnUpdateCreateFeature(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

int CFingerDBM::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CRecordView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	CDC *pDC=this->GetDC();
	COLORREF cr;
	cr=pDC->SetBkColor(RGB(255,0,0));

	return 0;
}

HBRUSH CFingerDBM::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CRecordView::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	if(nCtlColor==CTLCOLOR_EDIT||nCtlColor==CTLCOLOR_LISTBOX)
		return hbr;
	else
	{
		pDC->SetBkMode(TRANSPARENT);
		pDC->SetTextColor(theApp.m_textcolor);
		return ((HBRUSH)::GetStockObject(HOLLOW_BRUSH));
	}

	// TODO: Return a different brush if the default is not desired
	return hbr;
}
BOOL CFingerDBM::OnEraseBkgnd(CDC* pDC) 
{
	theApp.backbmp.ReadFile(theApp.m_backfilename);//"c:\\z1.bmp"	
	CRect rect;
	GetClientRect(&rect);
	for (int nX = 0; nX < rect.Width(); nX +=theApp.backbmp. m_Width)
		for (int nY = 0; nY < rect.Height(); nY +=theApp.backbmp. m_Height)
			theApp.backbmp.DrawDib(pDC,1,nX,nY);
	return TRUE;
}

⌨️ 快捷键说明

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