1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | //cam open cv::VideoCapture cap(0); if (!cap.isOpened()){ MessageBox(_T("Cam is not open")); return; } //calculate fps values time_t start, end; double seconds; float dFps; int count = 0; //window create image_window win; //frame cv::Mat temp; //Start Time time(&start); // Grab and process frames until the main window is closed by the user. while (!win.is_closed()){ // Grab a frame cap >> temp; //End Time time(&end); //frame plus count++; seconds = difftime(end, start); dFps = count / seconds; cv_image<bgr_pixel> cimg(temp); rectangle r; //r.set_top(10); //r.set_bottom(10); //r.set_left(10); //r.set_right(10); stringstream ss; ss << "fps : " << dFps << endl; string str; str = ss.str(); // Display it all on the screen win.clear_overlay(); win.set_image(cimg); win.add_overlay(dlib::image_window::overlay_rect(r, rgb_pixel(255, 0, 0), str)); } | cs |
fps를 출력하는 부분이 이상함(윈도우창 내부가 아니라 테두리에 걸쳐서 시작함)
추후에 수정!