📄 flog.cpp
字号:
ngMaxLev = -100; ngMinLev = 100; igLev = 100;igVal0 = igVal1 = ngWorseVal = ngBetterVal = 0;igLEyeVal0 = igLEyeVal1 = ngWorseLEyeVal = ngBetterLEyeVal = 0;igREyeVal0 = igREyeVal1 = ngWorseREyeVal = ngBetterREyeVal = 0;igMouthVal0 = igMouthVal1 = ngWorseMouthVal = ngBetterMouthVal = 0;igPointVal0 = igPointVal1 = ngWorsePointVal = ngBetterPointVal = 0;ngDone[0] = ngDone[1] = 0;ngFilePrefixChange[0] = ngFilePrefixChange[1] = 0;memset(gFit, 0, sizeof(gFit));memset(gVal0, 0, sizeof(gVal0));memset(gVal1, 0, sizeof(gVal1));memset(gLEyeFit, 0, sizeof(gLEyeFit));memset(gLEyeVal0, 0, sizeof(gLEyeVal0));memset(gLEyeVal1, 0, sizeof(gLEyeVal1));memset(gREyeFit, 0, sizeof(gREyeFit));memset(gREyeVal0, 0, sizeof(gREyeVal0));memset(gREyeVal1, 0, sizeof(gREyeVal1));memset(gMouthFit, 0, sizeof(gMouthFit));memset(gMouthVal0, 0, sizeof(gMouthVal0));memset(gMouthVal1, 0, sizeof(gMouthVal1));memset(gPointFit, 0, sizeof(gPointFit));memset(gPointVal0, 0, sizeof(gPointVal0));memset(gPointVal1, 0, sizeof(gPointVal1));memset(gMax, 0, sizeof(gMax));memset(ngFit, 0, sizeof(ngFit));memset(ngMax, 0, sizeof(ngMax));gTime[0] = gTime[1] = 0;}//-----------------------------------------------------------------------------static char cGetPrefix (void){if (igPrefix) { if (cgPrefix1) return cgPrefix1; else return '*'; }else { if (cgPrefix0) return cgPrefix0; else return '*'; }}//-----------------------------------------------------------------------------static void DumpVal (double aVal[], int i, int n, FILE *pFile){if (i < n) Fprintf(pFile, "%8.5f ", aVal[i]);else Fprintf(pFile, " ");}static void Dump (void){FILE *pFile = Fopen("flog.dat", "w");lprintf("Dumping to flog.dat");Fprintf(pFile, " FitA FitB LEyeA LEyeB REyeA REyeB MouthA MouthB PointA PointB\n");for (int i = 0; i < ngFit[0][0]; i++) { Fprintf(pFile, "%3.3d ", i+1); DumpVal(gVal0, i, ngFit[0][0], pFile); DumpVal(gVal1, i, ngFit[0][1], pFile); DumpVal(gLEyeVal0, i, ngLEyeFit[0][0], pFile); DumpVal(gLEyeVal1, i, ngLEyeFit[0][1], pFile); DumpVal(gLEyeVal0, i, ngREyeFit[0][0], pFile); DumpVal(gLEyeVal1, i, ngREyeFit[0][1], pFile); DumpVal(gMouthVal0, i, ngMouthFit[0][0], pFile); DumpVal(gMouthVal1, i, ngMouthFit[0][1], pFile); DumpVal(gPointVal0, i, ngPointFit[0][0], pFile); DumpVal(gPointVal1, i, ngPointFit[0][1], pFile); Fprintf(pFile, "\n"); }fclose(pFile);lprintf("\n");}//-----------------------------------------------------------------------------int main (int argc, char *argv[]){bool fFull = false, fHashPrefix = false, fAppendToLog = false;lprintf("flog version 1.5: ");while (--argc > 0 && (*++argv)[0] == '-') { lprintf("-%c ", *(*argv + 1)); switch (*(*argv + 1)) { case 'a': fAppendToLog = true; break; case 'f': fFull = true; break; case 'p': fHashPrefix = true; break; default: printf( "\nBad flag -%c\n\n" "Usage: flog [-dfp]\n" "Reads ../masm/ms.log and ../masm/masm.log\n" "-a append to log file\n" "-f show full results\n" "-p use #prefix comments in log file for setting prefixes\n", *(*argv + 1)); return -1; break; } }Init(VERBOSE, fAppendToLog, "flog.log");// show warnings and errors in masm.logFILE *pFile = fopen("masm.log", "r");if (pFile) lprintf("reading masm.log\n");else if (pFile = fopen("../masm/masm.log", "r")) lprintf("reading ../masm/masm.log\n");if (pFile) { int nLine = 0; bool fGotGeneratedMsg = false; while (fgets(sgLine, NLINE-1, pFile)) { nLine++; if (strstr(sgLine, "Err:") || strstr(sgLine, "Msg:") || strstr(sgLine, "Warning:")) // echo any lines that have the given strings in them lprintf("%d: %s", ngLine, sgLine); if (strncmp(sgLine, "Generated ", strlen("Generated ")) == 0) fGotGeneratedMsg = true; } if (!fGotGeneratedMsg) Err("../masm/masm.log doesn't have a \"Generated \" message (masm probably terminated early)"); fclose(pFile); }// process ms.logpFile = fopen("ms.log", "r");if (pFile) lprintf("reading ms.log\n");else if (pFile = fopen("../masm/ms.log", "r")) lprintf("reading ../masm/ms.log\n");else Err("Can't open ms.log or ../masm/ms.log");while (fgets(sgLine, NLINE-1, pFile)) { char *p; ngLine++; if (strstr(sgLine, "Err:") || strstr(sgLine, "Msg:") || strstr(sgLine, "Warning:")) // echo any lines that have the given strings in them { lprintf("%d: %s", ngLine, sgLine); continue; // prevents us reading the error msg as a valid line } if (fHashPrefix && 0 == strncmp(sgLine, "#Prefix ", 7)) { if (sgLine[8] != 'A' && sgLine[8] != 'B') Err("Line %d: Prefix is neither A nor B\n%s", ngLine, sgLine); SetPrefix(sgLine + 8); continue; } if (sgLine[0] == '#') // comment? continue; // A Reading c:/a1/faces/BioId/v12-bmp/BioId_0001.bmp if (0 == strnicmp(sgLine+2, "Reading ", 8)) { char sDrive[_MAX_DRIVE], sDir[_MAX_DIR], sFname[_MAX_FNAME], sExt[_MAX_EXT]; _splitpath(sgLine+10, sDrive, sDir, sFname, sExt); if (stricmp(sExt, ".bmp\n") && stricmp(sExt, ".pgm\n") && stricmp(sExt, ".jpg\n")) Err("Line %d: Can't get image name\n%s", ngLine, sgLine); if (!fHashPrefix) SetPrefix(sgLine); if (cgFilePrefix[0] == 0) cgFilePrefix[0] = sFname[0]; if (sFname[0] != sgFname[0]) // changed file prefix? { if (ngFilePrefixChange[igPrefix]) { Warn("Line %d: ignoring new file prefix (file %s) because only two file prefixes allowed", ngLine, sFname); fgIgnore = true; } else { fgIgnore = false; if (igPrefix == 0) ASSERT(ngDone[1] == igVal1 && ngDone[1] == igLEyeVal1 && ngDone[1] == igREyeVal1 && ngDone[1] == igMouthVal1); else ASSERT(ngDone[1] == igVal1 && ngDone[1] == igLEyeVal1 && ngDone[1] == igREyeVal1 && ngDone[1] == igMouthVal1); ngFilePrefixChange[igPrefix] = ngDone[igPrefix]; cgFilePrefix[1] = sFname[0]; } } strcpy(sgFname, sFname); continue; // NOTE CONTINUE } if (fgIgnore) continue; // NOTE CONTINUE // A StartShape EyeToEye 13% EarToEar 18% LEyeToChin 9% Fit 0.162 Max 0.301 at 4 LEyeFit 0.034 REyeFit 0.143 MouthFit 0.198 PointFit35 0.1290 12.7 x 12.4 y 2.5 // But ignore: Align StartShape to ...NnShape "2000 m000_11.pgm" if (!strstr(sgLine, "Align") && (p = strstr(sgLine, "StartShape "))) { float EyeToEye = -999, EarToEar = -999, EyeToChin = -999; char s[FLEN]; if ((sscanf(p, "%s %s %f%s %s %f%s %s %f", s, s, &EyeToEye, s, s, &EarToEar, s, s, &EyeToChin) != 9) || EyeToEye == -999 || EarToEar == -999 || EyeToChin == -999) Err("Line %d: Can't read %s", ngLine, sgLine); if (fabs(EyeToEye) > 20) lprintf("%c %s StartShape EyeToEye %g%%\n", cGetPrefix(), sgFname, EyeToEye); if (fabs(EarToEar) > 20) lprintf("%c %s StartShape EarToEar %g%%\n", cGetPrefix(), sgFname, EarToEar); if (fabs(EyeToChin) > 30) lprintf("%c %s StartShape LEyeToChin %g%%\n", cGetPrefix(), sgFname, EyeToChin); igLev = BASE_SHAPE_LEV; // for " Fit " match and others below } // Align StartShape to NnShape "2000 000_31.pgm" NnShapeVsRefShape EyeToEye 98% if (igPrefix == 0 && (p = strstr(sgLine, "NnShapeVsRefShape "))) { float EyeToEye = -999; char s[FLEN]; if ((sscanf(p, "%s %s %f", s, s, &EyeToEye) != 3) || EyeToEye == -999) Err("Line %d: Can't read %s", ngLine, sgLine); if (fabs(EyeToEye) > 15) lprintf("%c %s NnShape EyeToEye %g\n", cGetPrefix(), sgFname, EyeToEye); } // full Lev 0 Scale 1.000 ASM search 500 eig 486 497 483 483 483 Fit 1.4 Max 3.0 at 24 if (p = strstr(sgLine, " Lev ")) { int iPrevLev = igLev; igLev = -1; if ((sscanf(p + 5, "%d", &igLev) != 1) || igLev < 0 || igLev > CONF_nLevs) Err("Line %d: Can't read level\n%s", ngLine, sgLine); if (igLev > ngMaxLev) ngMaxLev = igLev; if (igLev < ngMinLev) ngMinLev = igLev; if (!fHashPrefix) SetPrefix(sgLine); } // Lev 0 Scale 1.000 ASM search 500 eig 486 497 483 483 483 Fit 1.4 Max 3.0 at 24 if (p = strstr(sgLine, " Fit ")) { float Float = -999; if ((sscanf(p + 5, "%f", &Float) != 1) || Float == -999) Err("Line %d: Can't read Fit\n%s", ngLine, sgLine); gFit[igLev][igPrefix] += Float; ngFit[igLev][igPrefix]++; if (igLev == 0) { if (Float > 20) // print excessively high Fits, means something's up lprintf("%c %s Fit %g\n", cGetPrefix(), sgFname, Float); if (igPrefix == 0) { gVal0[igVal0] = Float; if (++igVal0 >= CONF_nMaxMatDim) SysErr("Too many Fit results, max is %d", CONF_nMaxMatDim); } else { gVal1[igVal1] = Float; if (Float > gVal0[igVal1]) ngWorseVal++; if (Float < gVal0[igVal1]) ngBetterVal++; if (++igVal1 >= CONF_nMaxMatDim) SysErr("Too many Fit results, max is %d", CONF_nMaxMatDim); } } } if (p = strstr(sgLine, " LEyeFit ")) { float Float = -999; if ((sscanf(p + 8, "%f", &Float) != 1) || Float == -999) Err("Line %d: Can't read LEyeFit\n%s", ngLine, sgLine); gLEyeFit[igLev][igPrefix] += Float; ngLEyeFit[igLev][igPrefix]++; if (igLev == 0) { if (Float > 10) // print excessively high LEyeFits, means something's up lprintf("%c %s LEyeFit %g\n", cGetPrefix(), sgFname, Float); if (igPrefix == 0) { gLEyeVal0[igLEyeVal0] = Float; if (++igLEyeVal0 >= CONF_nMaxMatDim) SysErr("Too many LEyeFit results, max is %d", CONF_nMaxMatDim); } else { gLEyeVal1[igLEyeVal1] = Float; if (Float > gLEyeVal0[igLEyeVal1]) ngWorseLEyeVal++; if (Float < gLEyeVal0[igLEyeVal1]) ngBetterLEyeVal++; if (++igLEyeVal1 >= CONF_nMaxMatDim) SysErr("Too many LEyeFit results, max is %d", CONF_nMaxMatDim); } } } if (p = strstr(sgLine, " REyeFit ")) { float Float = -999; if ((sscanf(p + 8, "%f", &Float) != 1) || Float == -999) Err("Line %d: Can't read REyeFit\n%s", ngLine, sgLine); gREyeFit[igLev][igPrefix] += Float; ngREyeFit[igLev][igPrefix]++; if (igLev == 0) { if (Float > 10) // print excessively high REyeFits, means something's up lprintf("%c %s REyeFit %g\n", cGetPrefix(), sgFname, Float); if (igPrefix == 0) { gREyeVal0[igREyeVal0] = Float; if (++igREyeVal0 >= CONF_nMaxMatDim) SysErr("Too many REyeFit results, max is %d", CONF_nMaxMatDim); } else { gREyeVal1[igREyeVal1] = Float; if (Float > gREyeVal0[igREyeVal1]) ngWorseREyeVal++; if (Float < gREyeVal0[igREyeVal1]) ngBetterREyeVal++; if (++igREyeVal1 >= CONF_nMaxMatDim) SysErr("Too many REyeFit results, max is %d", CONF_nMaxMatDim); } } } if (p = strstr(sgLine, " MouthFit ")) { float Float = -999; if ((sscanf(p + 10, "%f", &Float) != 1) || Float == -999) Err("Line %d: Can't read MouthFit\n%s", ngLine, sgLine); gMouthFit[igLev][igPrefix] += Float; ngMouthFit[igLev][igPrefix]++; if (igLev == 0) { if (Float > 12) // print excessively high MouthFits, means something's up lprintf("%c %s MouthFit %g\n", cGetPrefix(), sgFname, Float); if (igPrefix == 0) { gMouthVal0[igMouthVal0] = Float; if (++igMouthVal0 >= CONF_nMaxMatDim) SysErr("Too many MouthFit results, max is %d", CONF_nMaxMatDim); } else { gMouthVal1[igMouthVal1] = Float; if (Float > gMouthVal0[igMouthVal1]) ngWorseMouthVal++; if (Float < gMouthVal0[igMouthVal1]) ngBetterMouthVal++; if (++igMouthVal1 >= CONF_nMaxMatDim) SysErr("Too many MouthFit results, max is %d", CONF_nMaxMatDim); } } } if (p = strstr(sgLine, " PointFit")) { float Float = -999; int iPoint = -1; if ((sscanf(p + 9, "%d", &iPoint) != 1) || iPoint < 0) Err("Line %d: Can't read point from PointFit\n%s", ngLine, sgLine); if ((sscanf(p + 12, "%f", &Float) != 1) || Float == -999) Err("Line %d: Can't read PointFit\n%s", ngLine, sgLine); if (igPoint != -1 && iPoint != igPoint) { ngPointFit[0][0] = 0; // this hack prevents point fit from being displayed later Warn("Line %d: PointFit%d doesn't match previous PointFit%d\n%s", ngLine, iPoint, igPoint, sgLine); } igPoint = iPoint; gPointFit[igLev][igPrefix] += Float; ngPointFit[igLev][igPrefix]++; if (igLev == 0) { if (Float > 20) // print excessively high PointFits, means something's up lprintf("%c %s PointFit %g\n", cGetPrefix(), sgFname, Float); if (igPrefix == 0) { gPointVal0[igPointVal0] = Float; if (++igPointVal0 >= CONF_nMaxMatDim) SysErr("Too many PointFit results, max is %d", CONF_nMaxMatDim); } else { gPointVal1[igPointVal1] = Float; if (Float > gPointVal0[igPointVal1]) ngWorsePointVal++; if (Float < gPointVal0[igPointVal1]) ngBetterPointVal++; if (++igPointVal1 >= CONF_nMaxMatDim) SysErr("Too many PointFit results, max is %d", CONF_nMaxMatDim); } } } // Lev 0 Scale 1.000 ASM search 500 eig 486 497 483 483 483 Fit 1.4 Max 3.0 at 24 if (p = strstr(sgLine, " Max ")) { float Float = -999; if ((sscanf(p + 5, "%f", &Float) != 1) || Float == -999) Err("Line %d: Can't read Max\n%s", ngLine, sgLine); gMax[igLev][igPrefix] += Float; ngMax[igLev][igPrefix]++; } // B0001_01 [done in 0.11 secs, 0.11 secs per image] if (p = strstr(sgLine, " [done in ")) { float Float = -999; if ((sscanf(p+10, "%f", &Float) != 1) || Float == -999) Err("Line %d: Can't read time\n%s", ngLine, sgLine); gTime[igPrefix] += Float; ngDone[igPrefix]++; } }fclose(pFile);if (cgPrefix0 == 0) lprintf("No prefixes seen\n");if (ngDone[0] || ngDone[1]) { CheckThatAllNsMatch(); Dump(); ShowTotals(fFull); }else lprintf("No results");return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -