void VideoInput::updateFrame() { static HiResTimer timer; // Start the timer for fps calculations if(frameCount == 1) timer.start(); static double trackerResolution = frame.size().height; frameCount++; // Every 20 frames, calculate the fps and reset timer if(frameCount % 20 == 0) { timer.stop(); frameRate = (double) 20 / (timer.getElapsedTime()/1000.0); timer.start(); } if (!(captureFromVideo && frameCount == 1)) { // If capturing from video and video size is not equal to desired resolution, carry on with resizing if (captureFromVideo && videoResolution != trackerResolution) { cv::Mat temp_image; _capture.read(temp_image); cv::Mat roi = temp_image; if (videoResolution == 720 && trackerResolution == 480) { roi = temp_image(cv::Rect(160, 0, 960, 720)); } else if (videoResolution == 1080 && trackerResolution == 480) { roi = temp_image(cv::Rect(240, 0, 1440, 1080)); } resize(roi, frame, frame.size(), 0, 0, CV_INTER_CUBIC); } else { _capture.read(frame); } } if(frame.empty()) { throw Utils::QuitNow(); } if (!captureFromVideo) { flip(frame, frame, 1); } copyToDebugFrame(); cvtColor(frame, frameGrey, CV_BGR2GRAY); }
HiResTimer* InitTimer(int clock_number) { HiResTimer* timer; timer = HiResTimer::getHiResTimer(clock_number); //for keeping time timer->init(); timer->start(); return (timer); }