matchnewimage.cpp

来自「这是一个用c++编写的实现指纹识别的程序」· C++ 代码 · 共 247 行

CPP
247
字号
// matchNewImage.cpp : implementation file
//

#include "stdafx.h"
#include "eFinger.h"
#include "matchNewImage.h"
#include "ip-header/fvs_enhancer.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// matchNewImage dialog


matchNewImage::matchNewImage(CWnd* pParent /*=NULL*/)
	: CDialog(matchNewImage::IDD, pParent)
{
	//{{AFX_DATA_INIT(matchNewImage)
	m_inputFile = _T("");
	//}}AFX_DATA_INIT
}


void matchNewImage::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(matchNewImage)
	DDX_Control(pDX, IDC_bmp5, m_bmp5);
	DDX_Control(pDX, IDC_bmp4, m_bmp4);
	DDX_Control(pDX, IDC_bmp3, m_bmp3);
	DDX_Control(pDX, IDC_bmp2, m_bmp2);
	DDX_Control(pDX, IDC_bmp1, m_bmp1);
	DDX_Text(pDX, IDC_inputFile, m_inputFile);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(matchNewImage, CDialog)
	//{{AFX_MSG_MAP(matchNewImage)
	ON_BN_CLICKED(IDC_browse, Onbrowse)
	ON_BN_CLICKED(IDC_next1, Onnext1)
	ON_BN_CLICKED(IDC_next2, Onnext2)
	ON_BN_CLICKED(IDC_next3, Onnext3)
	ON_BN_CLICKED(IDC_next4, Onnext4)
//	ON_BN_CLICKED(IDC_next5, Onnext5)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// matchNewImage message handlers



BOOL matchNewImage::GetBitmapFileName(TCHAR *filename, int len, HWND hWnd)
{
	OPENFILENAME	ofn;

	ZeroMemory(&ofn, sizeof(OPENFILENAME));
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = hWnd;
	ofn.lpstrFilter = _T("Bitmap Files (*.bmp)\0*.bmp\0All Files (*.*)\0*.*\0\0");
	ofn.lpstrFile = filename;
	ofn.nMaxFile = len;
	ofn.lpstrTitle = _T("Browse");
	ofn.Flags = /*OFN_FILEMUSTEXIST |*/ OFN_HIDEREADONLY;
	return GetOpenFileName(&ofn);
}

TCHAR  BitmapFilename[256];
TCHAR  outputFilename[256];


void matchNewImage::Onbrowse() 
{
	// TODO: Add your control notification handler code here

	GetBitmapFileName(BitmapFilename,sizeof(BitmapFilename) / sizeof(TCHAR), NULL);
	m_inputFile = CString(BitmapFilename);
	UpdateData(false);

	HBITMAP newBmp;
	newBmp = (HBITMAP) LoadImage(NULL,BitmapFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
	m_bmp1.SetBitmap(newBmp);
	
}

void matchNewImage::Onnext1() 
{
	// TODO: Add your control notification handler code here
	
	sprintf(outputFilename,"output.bmp");
//	enhance(BitmapFilename,outputFilename);

	HBITMAP newBmp;
	newBmp = (HBITMAP) LoadImage(NULL,outputFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
	m_bmp2.SetBitmap(newBmp);
	
}

void matchNewImage::Onnext2() 
{
	// TODO: Add your control notification handler code here
	//Binarize();
	AfxMessageBox(" Image Binarized ");

	HBITMAP newBmp;
	newBmp = (HBITMAP) LoadImage(NULL,"output_b.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
	m_bmp3.SetBitmap(newBmp);
	
	
}

void matchNewImage::Onnext3() 
{
	// TODO: Add your control notification handler code here
	Thinning();
	AfxMessageBox("thinning over");

	HBITMAP newBmp;
	newBmp = (HBITMAP) LoadImage(NULL,"output_t.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
	m_bmp4.SetBitmap(newBmp);
	
}

void matchNewImage::Onnext4() 
{
	// TODO: Add your control notification handler code here
	Minutiae();
	AfxMessageBox(" Minutiae detection over");

	HBITMAP newBmp;
	newBmp = (HBITMAP) LoadImage(NULL,"output_m.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
	m_bmp5.SetBitmap(newBmp);

	
}

void matchNewImage::Binarize(void)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    // Start the child process. 
    if( !CreateProcess( NULL, // No module name (use command line). 
        "exe/binarize.exe",			  // Command line. 
        NULL,             // Process handle not inheritable. 
        NULL,             // Thread handle not inheritable. 
        FALSE,            // Set handle inheritance to FALSE. 
        0,                // No creation flags. 
        NULL,             // Use parent's environment block. 
        NULL,             // Use parent's starting directory. 
        &si,              // Pointer to STARTUPINFO structure.
        &pi )             // Pointer to PROCESS_INFORMATION structure.
    ) 
    {
        //ErrorExit( "CreateProcess failed." );
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );

    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );


}

void matchNewImage::Thinning(void)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    // Start the child process. 
    if( !CreateProcess( NULL, // No module name (use command line). 
        "exe/thinning.exe",			  // Command line. 
        NULL,             // Process handle not inheritable. 
        NULL,             // Thread handle not inheritable. 
        FALSE,            // Set handle inheritance to FALSE. 
        0,                // No creation flags. 
        NULL,             // Use parent's environment block. 
        NULL,             // Use parent's starting directory. 
        &si,              // Pointer to STARTUPINFO structure.
        &pi )             // Pointer to PROCESS_INFORMATION structure.
    ) 
    {
        //ErrorExit( "CreateProcess failed." );
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );

    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );


}

void matchNewImage::Minutiae(void)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    // Start the child process. 
    if( !CreateProcess( NULL, // No module name (use command line). 
        "exe/minutiae.exe",			  // Command line. 
        NULL,             // Process handle not inheritable. 
        NULL,             // Thread handle not inheritable. 
        FALSE,            // Set handle inheritance to FALSE. 
        0,                // No creation flags. 
        NULL,             // Use parent's environment block. 
        NULL,             // Use parent's starting directory. 
        &si,              // Pointer to STARTUPINFO structure.
        &pi )             // Pointer to PROCESS_INFORMATION structure.
    ) 
    {
        //ErrorExit( "CreateProcess failed." );
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );

    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );


}

⌨️ 快捷键说明

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