如何使用C++在OpenCV获取FPS值?
为了获取FPS值,我们使用了'get()'命令和'CAP_PROP_FPS'作为'get()'的参数。此参数以整数形式返回FPS。
在程序开始时,我们定义了一个名为'FPS'的整型变量。然后我们使用 FPS = cap.get(CAP_PROP_FPS); 将FPS值存储在该变量中。
以下程序获取视频的FPS并将其显示在控制台窗口中。
范例
#include<opencv2/opencv.hpp>//OpenCV header to use VideoCapture class//
#include<iostream>
using namespace std;
using namespace cv;
int main() {
int FPS;//Declaring an integer variable to store the number of total frames//
VideoCapture cap("video1.mp4");//Declaring an object to capture stream of frames from default camera//
FPS = cap.get(CAP_PROP_FPS);//Getting the total number of frames//
cout << "Total Number of frames are:" << FPS << endl;//Showing the number in console window//
system("pause");//Pausing the system to see the result
cap.release();//Releasing the buffer memory//
return 0;
}启动此程序后,我们将在控制台窗口中获取FPS值。
输出

广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C编程
C++
C#
MongoDB
MySQL
Javascript
PHP