OpenCV에서 총 프레임 수를 계산하는 방법을 배웁니다. OpenCV를 사용하여 비디오의 총 프레임 수를 계산하고 표시하는 것은 기본입니다. 그러나 우리는 실시간 비디오 프레임의 총 수를 셀 수 없다는 점을 염두에 두어야 합니다. 실시간 동영상에는 특정 프레임 수가 없기 때문입니다.
다음 프로그램은 총 프레임 수를 계산하여 콘솔 창에 표시합니다.
예
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main() {
int frame_Number;//Declaring an integervariable to store the number of total frames//
VideoCapture cap("video.mp4");//Declaring an object to capture stream of frames from default camera//
frame_Number = cap.get(CAP_PROP_FRAME_COUNT);//Getting the total number of frames//
cout << "Total Number of frames are:" << frame_Number << endl;//Showing the number in console window//
system("pause");//Pausing the system to see the result//
cap.release();//Releasing the buffer memory//
return 0;
} 출력으로 정수 값을 얻습니다.
출력
