long int workTime;
workTime = mTime->wSecond*1000+mTime->wMilliseconds;
fingA = picture->AnalysePicture();
fingA.SaveFing(GetSAV(picture->getPathSrc()));
GetSystemTime(mTime);
workTime = mTime->wSecond*1000+mTime->wMilliseconds - workTime;
workTime = (workTime<0)?60000+workTime:workTime;
delete(mTime);
m_scantime = workTime;
Invalidate();
}
void CFingerAnalyserDlg::OnBnClickedCompare()
{
if(fingA.size() == 0)
MessageBox("Отпечаток не обработан", "Ошибка");
return;
fingR.Convert(fingA);
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;
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;
while(pos)
CString fileName = dlg.GetNextPathName(pos).MakeLower();
if(fileName.Find(".bmp") == -1) continue;
TAnalysePicture *loadingPic;
loadingPic = new TAnalysePicture(fileName, this->GetDC());
m_workFile = fileName;
fingA = loadingPic->AnalysePicture();
if(fingA.size() < MIN_SIZE) {MessageBox("Отпечаток не пригоден для сохраниения в базу!", fileName); continue;}
if(fingA.size() > MAX_SIZE) {MessageBox("Отпечаток не пригоден для сохраниения в базу!", fileName); continue;}
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;
fread((void*)&count, sizeof(count), 1, fbse);
for(;count > 0; count--)
finf.Scanf(fbse);
bse->push_back(finf);
list<TCompareFing> *CFingerAnalyserDlg::CompareWithBase()
//сравнить точку с точками в БД
listTInfo *bse;
list<TCompareFing> *cFng;
cFng = new list<TCompareFing>;
bse = LoadDB(db_file);
if(bse->empty())
MessageBox("База данных отпечатков пуста", "Сообщение", MB_OK);
return cFng;
TAbsFing aFng;
TRelFing baseFng;
compare_progress.SetRange(0, (short)bse->size());
for(list<TInfo>::iterator ibse = bse->begin();
ibse != bse->end(); ibse++)
if(!aFng.LoadFing(GetSAV(ibse->src))) continue;
baseFng.Convert(aFng);
TCompareFing compareRes = fingR.Compare(baseFng);
compareRes.name = ibse->src;
cFng->push_back(compareRes);
compare_progress.SetPos((int)cFng->size());
bse->clear();
compare_progress.SetPos(0);
delete(bse);
void CFingerAnalyserDlg::OnBnClickedButtonPrev(){ ShowBase(false);}
void CFingerAnalyserDlg::OnBnClickedButtonNext(){ ShowBase(true);}
void CFingerAnalyserDlg::ShowBase(bool key, bool next)
//key - направление перемотки по базе (влево, вправо)
//next - нужно ли переходить к следующему отпечатку
if(!compareResult) return;
if(compareResult->size() == 0)
if(showIter == NULL) showIter = compareResult->begin();
else
if(next)
if(key)
showIter++;
if(showIter == compareResult->end())
showIter = compareResult->begin();
if(showIter == compareResult->begin())
showIter = compareResult->end();
showIter--;
TFingPicture *pic;
pic = new TFingPicture(this->GetDC());
if(!pic->Load(BLANK)) return;
CPaintDC dc(this); // device context for painting
list<TPairSur>::iterator is = showIter->surdots.begin();
list<TPairAbsDot>::iterator id = showIter->dots.begin();
for(; id != showIter->dots.end(); id++, is++)
COLORREF col;
if(is->first->empty()) col = 0xBBBBBB;
else col = (id->first.type)?0xff0000:0x000000;
pic->Line(id->first.coord, id->first.coord, 5, col);
pic->Line(id->first.coord,
CPoint(id->first.coord.x+(int)(10.0*cos(id->first.alpha)),id->first.coord.y-(int)(10.0*sin(id->first.alpha))),
2, col);
if(is->first->empty()) continue; //окружения для этой точки нет
//проверка, что "мышь" находится над точкой
if( abs(mouse_pos.x-id->first.coord.x)<6 && abs(mouse_pos.y-id->first.coord.y)<6 )
TFingPicture pic2(this->GetDC());
if(!pic2.Load(BLANK)) return;
pic2.Copy(*picture->GetPic2());
for(listTRelDot::iterator ii = is->first->begin(); ii != is->first->end(); ii++)
COLORREF cl = 0x554444;
CPoint cd;
cd.x = (long)(id->first.coord.x - ii->l * cos(ii->a1*M_PI/180.0 - id->first.alpha));
cd.y = (long)(id->first.coord.y - ii->l * sin(ii->a1*M_PI/180.0 - id->first.alpha));
pic->Line(id->first.coord, cd, 1, cl);
for(listTRelDot::iterator ii = is->second->begin(); ii != is->second->end(); ii++)
cd.x = (long)(id->second.coord.x - ii->l * cos(ii->a1*M_PI/180.0 - id->second.alpha));
cd.y = (long)(id->second.coord.y - ii->l * sin(ii->a1*M_PI/180.0 - id->second.alpha));
pic2.Line(id->second.coord, cd, 1, cl);
pic2.Show(545, 45);
if (pic != NULL)
pic->Show(110, 45);
m_workFile = showIter->name;
UpdateData(false);
delete(pic);
void CFingerAnalyserDlg::PrintReport(CString file, CString report)
FILE *outf = fopen("report.txt", "a");
CString msg = "\n------ "+file+" ------\n"+report;
fprintf(outf, msg);
Страницы: 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, 30