, m_mouse_y(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
CFingerAnalyserDlg::~CFingerAnalyserDlg()
delete(fp);
delete(picture);
if(compareResult)
for(list<TCompareFing>::iterator i = compareResult->begin();
i != compareResult->end();
i++)
list<TPairSur>::iterator j;
for(j=i->surdots.begin(); j!=i->surdots.end(); j++)
j->first->clear(); delete(j->first);
j->second->clear(); delete(j->second);
compareResult->clear();
delete(compareResult);
compareResult = NULL;
void CFingerAnalyserDlg::DoDataExchange(CDataExchange* pDX)
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_SPEC_DOT, m_kolDots);
DDX_Control(pDX, IDC_LOAD_PROGRESS, loadProgress);
DDX_Text(pDX, IDC_WORK_FILE, m_workFile);
DDX_Control(pDX, IDC_LOAD_COMPARE_PROGRESS, compare_progress);
DDX_Text(pDX, IDC_TEMESCAN, m_scantime);
DDX_Check(pDX, IDC_SHOW_BASE, m_show_base);
BEGIN_MESSAGE_MAP(CFingerAnalyserDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_OPEN_FILE, OnBnClickedOpenFile)
ON_BN_CLICKED(IDC_EXIT, OnBnClickedExit)
ON_WM_CLOSE()
ON_WM_ACTIVATE()
ON_BN_CLICKED(IDC_ANALYSE, OnBnClickedAnalyse)
ON_BN_CLICKED(IDC_COMPARE, OnBnClickedCompare)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_SAVE_TO_DB, OnBnClickedSaveToDb)
ON_BN_CLICKED(IDC_BUTTON_PREV, OnBnClickedButtonPrev)
ON_BN_CLICKED(IDC_BUTTON_NEXT, OnBnClickedButtonNext)
ON_BN_CLICKED(IDC_SHOW_BASE, OnBnClickedShowBase)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
// CFingerAnalyserDlg message handlers
BOOL CFingerAnalyserDlg::OnInitDialog()
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
fp = new TFingPicture(this->GetDC());
char fullpath[200];
_fullpath(fullpath, NULL, 200);
sav_path = fullpath;
sav_path += "\\sav\\";
db_file = sav_path + "fingbase.bse";
return TRUE; // return TRUE unless you set the focus to a control
void CFingerAnalyserDlg::OnSysCommand(UINT nID, LPARAM lParam)
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
CAboutDlg dlgAbout;
dlgAbout.DoModal();
else
CDialog::OnSysCommand(nID, lParam);
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CFingerAnalyserDlg::OnPaint()
CPaintDC dc(this); // device context for painting
if(m_show_base)
{//режим просмотра базы
ShowBase(true, false);
{//режим просмотра открытого образа
if (picture != NULL)
picture->GetPic1()->Show(110, 45);
picture->GetPic2()->Show(545, 45);
m_kolDots = (int)fingA.size();
UpdateData(false);
CDialog::OnPaint();
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CFingerAnalyserDlg::OnQueryDragIcon()
return static_cast<HCURSOR>(m_hIcon);
void CFingerAnalyserDlg::OnBnClickedOpenFile()
char szFilters[]= "Образы (*.bmp)|*.bmp|All Files (*.*)|*.*||";
CFileDialog dlg(TRUE, "bmp", "*.bmp", OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
if(dlg.DoModal() != IDOK)
return; //никаких файлов не открыли
if(dlg.GetFileExt().CompareNoCase("bmp"))
return; //открытый файл не имеет расширеня .bmp
CString fileName = dlg.GetFileName();
picture = new TAnalysePicture(fileName, this->GetDC());
m_workFile = fileName;
j->first->clear();
delete(j->first);
j->second->clear();
delete(j->second);
m_show_base = false;
Invalidate();
void CFingerAnalyserDlg::OnBnClickedExit()
CDialog::SendMessage(WM_CLOSE);
void CFingerAnalyserDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
CDialog::OnActivate(nState, pWndOther, bMinimized);
// pWndOther->SetProperty(
void CFingerAnalyserDlg::OnBnClickedAnalyse()
if(picture == NULL) return;
LPSYSTEMTIME mTime;
mTime = new SYSTEMTIME;
GetSystemTime(mTime);
long int workTime;
workTime = mTime->wSecond*1000+mTime->wMilliseconds;
fingA = picture->AnalysePicture();
fingA.SaveFing(GetSAV(picture->getPathSrc()));
workTime = mTime->wSecond*1000+mTime->wMilliseconds - workTime;
workTime = (workTime<0)?60000+workTime:workTime;
delete(mTime);
m_scantime = workTime;
void CFingerAnalyserDlg::OnBnClickedCompare()
if(fingA.size() == 0)
MessageBox("Отпечаток не обработан", "Ошибка");
return;
fingR.Convert(fingA);
showIter = NULL;
compareResult = CompareWithBase();
if(compareResult->size() == 0) return;
CString sOut="";
CString s="";
int mlevel = min(i->nfng,m_kolDots);
int percent;
if(mlevel > 10) mlevel = 10;
if(i->cDot > mlevel) percent = 100;
else percent = (int)(100.0*i->cDot/(double)mlevel + 0.5);
if(percent == 0) continue;
s.Format("%d %d %% %s\n", i->cDot, percent, i->name);
sOut += s;
if(sOut.GetLength()==0) sOut = "Ни одного отпечатка не найдено!\n";
CString kol; kol.Format("\n Всего в базе: %d", compareResult->size());
sOut += kol;
PrintReport(picture->getPathSrc(), sOut);
MessageBox(sOut, picture->getPathSrc());
void CFingerAnalyserDlg::OnTimer(UINT nIDEvent)
CDialog::OnTimer(nIDEvent);
void CFingerAnalyserDlg::OnBnClickedSaveToDb()
char szFilters[] = "Образы (*.bmp)|*.bmp|All Files (*.*)|*.*||";
CFileDialog dlg( TRUE, "bmp", "*.bmp",
OFN_FILEMUSTEXIST| OFN_HIDEREADONLY| OFN_ALLOWMULTISELECT,
szFilters, this);
if(dlg.DoModal() == IDOK)
listTInfo *fingDB = LoadDB(db_file);
FILE *fbse = fopen(db_file, "wb");
if(fbse == NULL)
MessageBox("Невозможно создать базу данных с отпечатками", "Ошибка создания БД", MB_OK);
POSITION pos, posStart;
TInfo newFingInDB;
pos = posStart = dlg.GetStartPosition();
int kolFile = 0;
while(pos)
dlg.GetNextPathName(pos);
kolFile++;
pos = posStart;
loadProgress.SetRange(0, kolFile);
int progressPos = 1;
CString fileName = dlg.GetNextPathName(pos).MakeLower();
if(fileName.Find(".bmp") == -1) continue;
TAnalysePicture *loadingPic;
loadingPic = new TAnalysePicture(fileName, this->GetDC());
fingA = loadingPic->AnalysePicture();
if(fingA.size() < MIN_SIZE)
MessageBox("Отпечаток не пригоден для сохраниения в базу!", fileName);
continue;
if(fingA.size() > MAX_SIZE)
fingA.SaveFing(GetSAV(fileName));
newFingInDB.src = fileName;
fingDB->remove(newFingInDB);
fingDB->push_back(newFingInDB);
loadProgress.SetPos(progressPos);
progressPos++;
delete(loadingPic);
loadProgress.SetPos(0);
int count = 0;
fwrite((void*)&count, sizeof(count), 1, fbse);
for(list<TInfo>::iterator iter = fingDB->begin(); iter != fingDB->end(); iter++)
iter->Printf(fbse);
count++;
fseek(fbse, 0, SEEK_SET);
fingDB->clear();
delete(fingDB);
fclose(fbse);
listTInfo *CFingerAnalyserDlg::LoadDB(CString dbFile)
//загрузить точки из БД
listTInfo *bse = new listTInfo();
TInfo finf; //данные по отпечатку
FILE *fbse = fopen(dbFile, "rb");
// MessageBox("Невозможно загрузить базу данных с отпечатками", "Ошибка загрузки БД", MB_OK);
return bse;
Страницы: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29