How to calculate the fps of a video (with processing) using opencv
22:41 17 Jan 2018

I can't seem to figure out what is wrong with the code fragment I have...it keeps on outputting over 200 fps for some reason. I tested with OpenCV and the unprocessed video is about 30 fps.

int n_frame = 0;
Mat previous;
auto start = chrono::high_resolution_clock::now();
while (m_cap.isOpened()) {
    if (n_frame % 100 == 1) {
        auto end = chrono::high_resolution_clock::now();    
        auto time = chrono::duration_cast(end - start);
        cout << "the fps is: " << 1.0 / (static_cast(time.count()) / n_frame) << endl;
        //cin.ignore(1000, '\n');
    }
    n_frame++;
    cout << "frame number: " << n_frame << endl;
    Mat frame, original;

    m_cap >> frame;
    if (frame.empty())
        break;


//do some video processing down here eg thresholding
}
c++ opencv frame-rate