Measure OpenCV FPS

后端 未结 4 1254
别那么骄傲
别那么骄傲 2021-02-08 19:32

I\'m looking for a correct way to measure openCV FPS. I\'ve found several ways to do it. but none of them looks right for me.

The first one I\'ve tested, uses ti

4条回答
  •  爱一瞬间的悲伤
    2021-02-08 20:28

    You can use opencv helper cv::getTickCount()

    #include 
    #include 
    
    #include "opencv2/core.hpp"
    #include "opencv2/core/utility.hpp"
    #include "opencv2/video.hpp"
    #include "opencv2/highgui.hpp"
    
    using namespace cv;
    
    
    int main(int ac, char** av) {
    
        VideoCapture capture(0);
        Mat frame;
    
        for (;;) {
    
            int64 start = cv::getTickCount();
    
            capture >> frame;
            if (frame.empty())
                break;
    
            /* do some image processing here */
    
            char key = (char)waitKey(1);
    
            double fps = cv::getTickFrequency() / (cv::getTickCount() - start);
            std::cout << "FPS : " << fps << std::endl;
        }
        return 0;
    }
    

提交回复
热议问题