/*"G:\\Picture\\Lighting\\FaceFP_2.txt"*/ void GetFaceFromTxt(const string txtname, vector<Face>& vfaces) { size_t maxSize = 1000; ///vpaths.size() string sign; int id; vector<string> vpaths(maxSize); //文件路径 vector<Vec4f> vpoints(maxSize); //两眼坐标点 vector<int> vids(maxSize); //人脸ID号 vector<string> vsigns(maxSize); //标记 vector<Mat> vmfaces(maxSize); //归一化人脸区域 ReadTxt(txtname, vpaths, vpoints, ' '); //读入文件名和两眼坐标 for (size_t i = 0; i<maxSize; i++) //分解文件名,得到ID和状态标志 { string path = vpaths[i]; ReadFilename(path, id, sign); vids.push_back(id); vsigns.push_back(sign); } for (size_t j = 0; j<maxSize; j++) { string long_path = "G:\\Picture\\pose\\" + vpaths[j].substr(0, vpaths[j].size()-1) + ".jpg"; //分割得到的文件名多出一个空格,-1去除 Mat image = imread(long_path, 0); if (!image.empty()) { Point2f pLeft = Point2f(vpoints[j][0],vpoints[j][1]); Point2f pRight = Point2f(vpoints[j][2],vpoints[j][3]); #if 0 //光照时需归一化 Mat dst = alignFace(image, pRight, pLeft); //尺寸归一化 #elif 0 //头部姿态标记两眼距离 Mat dst = image; line(dst, pLeft, pRight, Scalar(0, 0, 0), 2, 8); circle(dst, pLeft, 2, Scalar(255, 255, 255), 2, 8); circle(dst, pRight, 2, Scalar(255, 255, 255), 2, 8); #else 1 //对称性 Mat dst = AlignFace(image, pRight, pLeft); //尺寸归一化 #endif vmfaces.push_back(dst); /* imshow("image", dst); waitKey(0);*/ } } //将人脸各项信息存入Face for (size_t m = 0; m<maxSize; m++) { Face mface; mface.filename = vpaths[m]; mface.id = vids[m]; mface.sign = vsigns[m]; mface.eyePoints = vpoints[m]; mface.face = vmfaces[m]; mface.value = 0.0; vfaces.push_back(mface); } }
static bool ParseLogbookContent(const char *_line, RecordedFlightInfo &info) { NMEAInputLine line(_line); unsigned n; return line.Skip() && line.ReadChecked(n) && ReadFilename(line, info) > 0 && ReadDate(line, info.date) && ReadTime(line, info.start_time) && ReadTime(line, info.end_time); }
/*======================================================================*/ long ConfirmFile( char *filename, char *prompt ) { /*** See if the file exists and if not, prompt the user for some input. ***/ while (! CheckExist( filename )) { printf(" The files %s does not exist\n" " enter q to quit\n", filename); ReadFilename( prompt, filename ); if ( filename[0] == 'q' ) return(ERR_MISC); } return( 0 ); }
int GetFaceFromFilename(const string filePath, const Vec4f point, Face& faces) { string sign; int id; string filename = GetFilenameFromPath(filePath); ReadFilename(filename, id, sign); Mat image = imread(filePath, 0); if (image.empty()) return 0; //图片读取失败,返回 Point2f pLeft = Point2f(point[0],point[1]); Point2f pRight = Point2f(point[2],point[3]); Mat dst = AlignFace(image, pRight, pLeft); //尺寸归一化 faces.filename = filePath; faces.id = id; faces.sign = sign; faces.eyePoints = point; faces.face = dst; faces.value = 0.0; return 1; }
int main(int argc, char* argv[]) { int argbase; int ErrVal; char FileName[0x100]; printf("Remove 1 Sample Delays\n----------------------\n\n"); ErrVal = 0; MAX_SMALL_DELAY = 0x0000; argbase = 1; while(argbase < argc && argv[argbase][0] == '-') { if (! strncmp(argv[argbase], "-delay:", 7)) { MAX_SMALL_DELAY = (UINT16)strtoul(argv[argbase] + 7, NULL, 0); argbase ++; } else { break; } } if (! MAX_SMALL_DELAY) MAX_SMALL_DELAY = 1; printf("File Name:\t"); if (argc <= argbase + 0) { ReadFilename(FileName, sizeof(FileName)); } else { strcpy(FileName, argv[argbase + 0]); printf("%s\n", FileName); } if (! strlen(FileName)) return 0; if (! OpenVGMFile(FileName)) { printf("Error opening the file!\n"); ErrVal = 1; goto EndProgram; } printf("\n"); RoundVGMData(); if (DidSomething) { if (argc > argbase + 1) strcpy(FileName, argv[argbase + 1]); else strcpy(FileName, ""); if (FileName[0] == '\0') { strcpy(FileName, FileBase); strcat(FileName, "_no1smpl.vgm"); } WriteVGMFile(FileName); } free(VGMData); free(DstData); EndProgram: DblClickWait(argv[0]); return ErrVal; }
int main(int argc, char* argv[]) { int argbase; int ErrVal; char FileName[0x100]; UINT8 CurROM; printf("VGM Sample-ROM Optimizer\n------------------------\n\n"); ErrVal = 0; argbase = 1; printf("File Name:\t"); if (argc <= argbase + 0) { ReadFilename(FileName, sizeof(FileName)); } else { strcpy(FileName, argv[argbase + 0]); printf("%s\n", FileName); } if (! strlen(FileName)) return 1; if (! OpenVGMFile(FileName)) { printf("Error opening the file!\n"); ErrVal = 1; goto EndProgram; } printf("\n"); DstData = NULL; for (CurROM = 0x00; CurROM < ROM_TYPES; CurROM ++) { ROMRgnLst[CurROM][0x00].Regions = NULL; ROMRgnLst[CurROM][0x01].Regions = NULL; } if (! VGMHead.lngHzSPCM && ! VGMHead.lngHzYM2608 && ! VGMHead.lngHzYM2610 && ! VGMHead.lngHzY8950 && ! VGMHead.lngHzYMZ280B && ! VGMHead.lngHzRF5C68 && ! VGMHead.lngHzRF5C164 && ! VGMHead.lngHzYMF271 && ! VGMHead.lngHzOKIM6295 && ! VGMHead.lngHzK054539 && ! VGMHead.lngHzC140 && ! VGMHead.lngHzK053260 && ! VGMHead.lngHzQSound && ! VGMHead.lngHzUPD7759 && ! VGMHead.lngHzMultiPCM && ! VGMHead.lngHzNESAPU && ! VGMHead.lngHzES5503 && /*! VGMHead.lngHzES5506 &&*/ ! VGMHead.lngHzGA20 && ! VGMHead.lngHzX1_010 && ! VGMHead.lngHzC352 && ! VGMHead.lngHzYMF278B) { printf("No chips with Sample-ROM used!\n"); ErrVal = 2; goto BreakProgress; } CancelFlag = false; FindUsedROMData(); if (CancelFlag) { ErrVal = 9; goto BreakProgress; } EnumerateROMRegions(); OptimizeVGMSampleROM(); if (DstDataLen < VGMDataLen) { if (argc > argbase + 1) strcpy(FileName, argv[argbase + 1]); else strcpy(FileName, ""); if (FileName[0] == '\0') { strcpy(FileName, FileBase); strcat(FileName, "_optimized.vgm"); } WriteVGMFile(FileName); } BreakProgress: free(VGMData); free(DstData); for (CurROM = 0x00; CurROM < ROM_TYPES; CurROM ++) { free(ROMRgnLst[CurROM][0x00].Regions); ROMRgnLst[CurROM][0x00].Regions = NULL; free(ROMRgnLst[CurROM][0x01].Regions); ROMRgnLst[CurROM][0x01].Regions = NULL; } EndProgram: DblClickWait(argv[0]); return ErrVal; }