dll void Track() { if (capture.isOpened()) { // start! capture >> frame; if (frame.total() == 0) return; Mat img; im = frame; flip(im, im, 1); cvtColor(im, gray, CV_BGR2GRAY); vector<int> wSize1(1); vector<int> wSize2(3); wSize1[0] = 7; wSize2[0] = 11; wSize2[1] = 9; wSize2[2] = 7; vector<int> wSize; if (failed)wSize = wSize2; else wSize = wSize1; if (tracker.Track(gray, wSize, fpd, nIter, clamp, fTol, show) == 0) { int idx = tracker._clm.GetViewIdx(); failed = false; img = im.clone(); if (show) { Draw(im, tracker._shape, con, tri, tracker._clm._visi[idx]); } } else { if (show) { Mat R(im, cvRect(0, 0, 150, 50)); R = Scalar(0, 0, 255); } tracker.FrameReset(); failed = true; mp.FrameReset(); } if (fnum >= 9) { t1 = cvGetTickCount(); fps = 10.0 / ((double(t1 - t0) / cvGetTickFrequency()) / 1e+6); t0 = t1; fnum = 0; } else fnum += 1; if (mp.frame < 5) { mp.Calibrate(tracker._shape); mp.frame++; } if (mp.frame >= 5) { mp.EyeOpenL(img, tracker._shape); mp.EyeOpenR(img, tracker._shape); mp.MouthOpen(img, tracker._shape); mp.FaceRotation(tracker._shape); mp.OutPutValues(); } if (show) { sprintf(sss, "%d frames/sec", (int)round(fps)); text = sss; putText(im, text, Point(10, 20), CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(0, 0, 0)); imshow("TrackingInfo", im); } if (waitKey(1) >= 0); }
dll void ModelReset() { tracker.FrameReset(); mp.FrameReset(); }