int stasm_init_ext( // extended version of stasm_init const char* datadir, // in: directory of face detector files int trace, // in: 0 normal use, 1 trace to stdout and stasm.log void* detparams) // in: NULL or face detector parameters { int returnval = 1; // assume success CatchOpenCvErrs(); try { print_g = (trace != 0); trace_g = (trace != 0); if (mods_g.empty()) // not yet initialized? { if (trace) { // Open a log file in the current directory (if possible). // After the log file is opened, lprintf and stasm_printf // will print to stasm.log (as well as to stdout). OpenLogFile(); } lprintf("Stasm version %s%s\n", stasm_VERSION, trace? " Logging to stasm.log": ""); CV_Assert(datadir && datadir[0] && STRNLEN(datadir, SLEN) < SLEN); InitMods(mods_g, datadir); // init ASM model(s) facedet_g.OpenFaceDetector_(datadir, detparams); OpenEyeMouthDetectors(mods_g, datadir); } CheckStasmInit(); } catch(...) { mods_g.clear(); returnval = 0; // a call was made to Err or a CV_Assert failed } UncatchOpenCvErrs(); return returnval; }
void InitMods( // initialize ASM model vec_Mod& mods, // out: ASM model (only one model in this version of Stasm) const char* datadir) // in: directory of face detector files { if (mods.empty()) // models not yet initialized? { mods.resize(1); // 1 model static const Mod mod_yaw00( // constructor, see asm.h EYAW00, // eyaw ESTART_EYES, // estart datadir, yaw00_meanshape, yaw00_eigvals, yaw00_eigvecs, 20, // neigs (value from empirical testing) 1.5, // bmax (value from empirical testing) SHAPEHACKS_DEFAULT | SHAPEHACKS_SHIFT_TEMPLE_OUT, // hackbits YAW00_DESCMODS, // defined in yaw00.mh NELEMS(YAW00_DESCMODS)); mods[0] = &mod_yaw00; } }