minexample.cpp

Frank Stähr, 2014-04-03 10:46 am

Download (625 Bytes)

 
1
#include <opencv2/highgui/highgui.hpp>
2
#include <time.h>
3
#include <iostream>
4
5
int main()
6
{
7
        cv::VideoCapture cap("d:/test.avi");
8
        cv::Mat frame;
9
        for (;;)
10
        {
11
                clock_t start = clock();
12
                cap >> frame;
13
                double time = clock() - start;
14
                if (time > 500)
15
                        std::cout << "Took to long: " << time << " milliseconds!\n";
16
                if (frame.empty())
17
                        break;
18
19
                /*
20
                // or use the following instead:
21
                clock_t start = clock();
22
                bool last = !cap.read(frame);
23
                double time = clock() - start;
24
                if (time > 500)
25
                        std::cout << " Took to long: " << time << " milliseconds!\n";
26
                if (last)
27
                        break;
28
                */
29
        }
30
}