Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C++

Cách lấy giá trị FPS video trong OpenCV C++


Giới thiệu

Dùng VideoCapture::get(CAP_PROP_FPS) để lấy FPS (frames per second) của file video. Trả về giá trị số thực.

Chương trình lấy FPS

#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;

int main() {
    int FPS;
    VideoCapture cap("video1.mp4");
    FPS = cap.get(CAP_PROP_FPS);
    cout << "Tổng số khung hình mỗi giây (FPS): " << FPS << endl;
    system("pause");
    cap.release();
    return 0;
}

Kết quả

Console in ra giá trị FPS của file video (ví dụ: 30).