Skip to content

Instantly share code, notes, and snippets.

@godspeed1989
Last active December 15, 2015 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godspeed1989/5254926 to your computer and use it in GitHub Desktop.
Save godspeed1989/5254926 to your computer and use it in GitHub Desktop.
printf FPS in opencv
cv::VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
{
printf("Camera open error.\n");
return -1;
}
char strfps[64] = "0 fps";
clock_t start = clock();
unsigned int fps = 0;
for(;;)
{
cap >> image;
detect_face(image, cascade, nestedCascade, scale);
fps++;
if(clock() - start > CLOCKS_PER_SEC)
{
sprintf(strfps, "%d fps", fps);
fps = 0;
start = clock();
}
putText(image, strfps, cv::Point(0,20), 3, 1, CV_RGB(25,200,25));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment