static void ProcessShapes( const ShapeFile& sh, // in FILE* fitfile) // in { Pacifier pacifier(sh.nshapes_); // only used if quiet_g for (int ishape = 0; ishape < sh.nshapes_; ishape++) { if (quiet_g) pacifier.Print_(ishape); else { if (sh.nshapes_ > 1) lprintf("%*d ", NumDigits(sh.nshapes_), ishape); lprintf("%*.*s:%s", sh.nchar_, sh.nchar_, sh.bases_[ishape].c_str(), trace_g? "\n": " "); } if (ignore_multiface_imgs_g && (sh.bits_[ishape] & AT_MultiFace)) { printf_g("multiple face, skipping\n"); continue; // note continue } const char* imgpath = PathGivenDirs(sh.bases_[ishape], sh.dirs_, sh.shapepath_); Image img(cv::imread(imgpath, CV_LOAD_IMAGE_GRAYSCALE)); if (!img.data) Err("Cannot load %s", imgpath); const clock_t start_time = clock(); const Shape refshape(sh.shapes_[ishape]); const Shape refshape17(Shape17OrEmpty(refshape)); if (refshape17.rows) // converted to a Shape17? SanityCheckShape17(refshape17); if (!stasm_open_image((const char*)img.data, img.cols, img.rows, imgpath, 0 /*multi*/, minwidth_g)) Err("stasm_open_image failed: %s", stasm_lasterr()); clock_t start_time1 = clock(); const double facedet_time = double(start_time1 - start_time) / CLOCKS_PER_SEC; int foundface = false; float estyaw = 0; // estimated yaw float landmarks[2 * stasm_NLANDMARKS]; // x,y coords if (!stasm_search_auto_ext(&foundface, landmarks, &estyaw)) Err("stasm_search_auto failed: %s", stasm_lasterr()); const Shape shape(LandmarksAsShape(landmarks)); const double asmsearch_time = double(clock() - start_time) / CLOCKS_PER_SEC; ProcessFace(img, imgpath, foundface, shape, estyaw, facedet_time, asmsearch_time, refshape, fitfile, sh, ishape); } if (quiet_g) { pacifier.End_(); printf("\n"); } }
void instance_halls_of_stone::Update(uint32 uiDiff) { if (m_auiEncounter[TYPE_TRIBUNAL] == IN_PROGRESS) { for (uint8 i = 0; i < MAX_FACES; ++i) { if (!m_aFaces[i].m_bIsActive) continue; if (m_aFaces[i].m_uiTimer < uiDiff) ProcessFace(i); else m_aFaces[i].m_uiTimer -= uiDiff; } } }
static void ProcessImg( const char* imgpath) // in { Image img(cv::imread(imgpath, CV_LOAD_IMAGE_GRAYSCALE)); if (!img.data) Err("Cannot load %s", imgpath); if (!stasm_open_image((const char*)img.data, img.cols, img.rows, imgpath, multiface_g, minwidth_g)) Err("stasm_open_image failed: %s", stasm_lasterr()); CImage cimg; // color version of image if (writeimgs_g) // actually need the color image? cvtColor(img, cimg, CV_GRAY2BGR); int nfaces = 0; while (1) { if (trace_g && nfaces > 0 && multiface_g) stasm_printf("\n%d: ", nfaces); int foundface; float landmarks[2 * stasm_NLANDMARKS]; // x,y coords if (!stasm_search_auto(&foundface, landmarks)) Err("stasm_search_auto failed: %s", stasm_lasterr()); if (!foundface) break; // note break ProcessFace(cimg, landmarks, nfaces, Base(imgpath)); nfaces++; } if (trace_g) lprintf("\n"); if (writeimgs_g && nfaces) { // write as a bmp not as a jpg because don't want blurred shape lines char newpath[SLEN]; sprintf(newpath, "%s_stasm.bmp", Base(imgpath)); lprintf("%s ", newpath); if (!cv::imwrite(newpath, cimg)) Err("Could not write %s", newpath); } lprintf("%d face%s\n", nfaces, plural(nfaces)); }
bool slFileObj::Load() { Reset(); ScenePtr = mScene; FILE* infile = fopen(mFilename, "r"); FileLineNumber = 0; if (!infile) { fprintf(stderr, "LoadObjFile: Unable to open file: %s\n", mFilename); return false; } char inbuffer[1026]; while (true) { if (!fgets(inbuffer, 1026, infile)) { fclose(infile); PrintCmdNotSupportedErrors(stderr); return true; } FileLineNumber++; char* findStart = Preparse(inbuffer); if (findStart == 0 || (*findStart) == '#') { continue; //Ignore if a comment or a blank line } bool parseErrorOccurred = false; char theCommand[17]; int scanCode = sscanf(inbuffer, "%16s", theCommand); if (scanCode != 1) { parseErrorOccurred = true; } int cmdNum = GetCommandNumber(theCommand); if (cmdNum == -1) { AddUnsupportedCmd(theCommand); continue; } char* args = ScanForSecondField(findStart); bool ok = true; switch (cmdNum) { case 0: //'v' command { vec4* vertData = Vertices.Add(); ok = ReadVectorR4Hg(args, vertData); } break; case 1: //"vt" command { vec2* texData = TextureCoords.Add(); ok = ReadTexCoords(args, texData); } break; case 2: //The 'f' command { ok = ProcessFace(args , mDefaultMat); } break; case 3: //'l' command UnsupportedLines(); break; default: parseErrorOccurred = true; break; } if (!ok) { parseErrorOccurred = true; } } }