如何获取视频捕获对象的帧率 (fps/每秒帧数)

7
我正在使用opencv/javacv的videocapture对象捕获和处理视频帧。我不知道如何获取帧率。我想要一个在直播视频捕获过程中后台运行的计时器。当检测到人脸时,它应该暂停并在稍后继续。由于haarcascade文件的处理,每个帧的处理时间都很长。请问如何调整帧速率。
   System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
   VideoCapture camera = new VideoCapture(0);

我不知道如何在Java中实现,但在C/C++中,我会使用VideoCapture :: get(CV_CAP_PROP_FPS),请看这里:http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get - Engine
谢谢,我看过这个,但在Java中不可能,这就是问题所在。 - slaveCoder
3个回答

4
您可以从VideoCapture中提取各种参数,例如帧速率、帧高度、帧宽度等。
cv::VideoCapture input_video;
 if(input_video.open(my_device))
 {
    std::cout<<"Video file open "<<std::endl;
 }
 else
 {
    std::cout<<"Not able to Video file open "<<std::endl;

 }
int fps = input_video.get(CV_CAP_PROP_FPS);
int frameCount = input_video.get(CV_CAP_PROP_FRAME_COUNT);
double fheight = input_video.get(CV_CAP_PROP_FRAME_HEIGHT);
double fwidth = input_video.get(CV_CAP_PROP_FRAME_WIDTH);

2
 System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
 VideoCapture VC = new VideoCapture(0);

//First you requried open Camera.

VC.open();

//Now for geting 'Frame per secand"

VC.get(Videoio.CAP_PROP_FPS); // it returns FPS(Frame per secand)

//Now for seting 'Frame per secand"

VC.set(Videoio.CAP_PROP_FPS,10.0);//in this 10.0 is value for FPS,its double value.
VC.relase();

1

这个 答案 对我很有帮助。有一个常量列表和它们的值。只需要把值放到VideoCapture的get()方法中。例如,videoCapture.get(5),会返回视频的FPS


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接