void mouseHandler(int event, int x, int y, int flags, void *param) { switch (event) { case CV_EVENT_LBUTTONDOWN: initPoint = cvRect(cvRound(multiCamera.GetFrameWidth() / 2 - 10), cvRound(multiCamera.GetFrameHeight() / 2 - 10), 20, 20); if (x > initPoint.x && x < initPoint.x + initPoint.width && y > initPoint.y && y < initPoint.y + initPoint.height) { javaStartInterface.SetStart(true); } break; case CV_EVENT_RBUTTONDOWN: trackerDetector.lostTracking(); javaStartInterface.SetStart(false); break; } }
void mainWrapper() { (void) ftime(&tbi); (void) ftime(&tbf); // ESSE � O MILAGRE timestamp = ctime(&tbi.time); printf("%.19s.%hu %s", timestamp, tbi.millitm, ×tamp[20]); multiCamera.setup(javaStartInterface.GetIndexCAM()); cvNamedWindow(winName, CV_WINDOW_AUTOSIZE); cvSetMouseCallback(winName, mouseHandler, NULL); ofp = fopen("log.txt", "w"); fprintf(ofp, "timestamp\tfps\tLeftGazeX\tLeftGazeY\tRightGazeX\tRightGazeY\tLeftBlink\tRightBlink\t\n"); int freio = 0; for (;;) { nFrames++; double t = (double) cvGetTickCount(); if (multiCamera.queryFrame() == 0) continue; CvPoint startPoint = cvPoint(cvRound(multiCamera.GetFrameWidth() / 2), cvRound(multiCamera.GetFrameHeight() / 2)); if (javaStartInterface.IsStart()) { //double t = (double)cvGetTickCount(); trackerDetector.execute(multiCamera.GetFrame()); //t = (double)cvGetTickCount() - t; //printf( "%g\n", t/((double)cvGetTickFrequency()*1000.) ); //printf( "%d\n", FaceHeuristics::GazeLeftX ); cvCircle(multiCamera.GetFrame(), startPoint, 10, CV_RGB(255, 255, 255), 0); fprintf(ofp, "%g\t%g\t%d\t%d\t%d\t%d\t%d\t%d\t\n", t / ((double) cvGetTickFrequency()*1000.), getFPS(), getLeftGazeX(), getLeftGazeY(), getRightGazeX(), getRightGazeY(), getLeftBlink(), getRightBlink()); } else { cvCircle(multiCamera.GetFrame(), startPoint, 10, CV_RGB(255, 255, 255), -1); } if ((cvWaitKey(10) & 255) == 27) freio = 1; //break; //Test for Escape-key press if (javaStartInterface.IsStop()) freio = 1; //break; if (javaStartInterface.GetScreenWidth() > 0) cvMoveWindow(winName, cvRound(javaStartInterface.GetScreenWidth() / 2 - multiCamera.GetFrameWidth() / 2), cvRound(javaStartInterface.GetScreenHeight() / 2 - multiCamera.GetFrameHeight() / 2)); //cvSmooth( multiCamera.GetFrame() , BiFrame , CV_BILATERAL, 5, 5, sigma, sigma); cvShowImage(winName, multiCamera.GetFrame()); t = (double) cvGetTickCount() - t; loopTime = t / ((double) cvGetTickFrequency()*1000.); somaLoopTime += loopTime; if (somaLoopTime > 1000) { fps = nFrames; //printf( "%g\n", getFPS() ); nFrames = 0; somaLoopTime = 0; } if (freio) { //break; } } fclose(ofp); cvDestroyWindow(winName); exit(0); }