如何在opencvsharp视频捕捉库中设置FPS? [英] How to set FPS in opencvsharp videocapture library?
本文介绍了如何在opencvsharp视频捕捉库中设置FPS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚复制了一个程序,通过视频检测人脸,但视频捕捉真的很慢,我不知道如何解决它!每当我更改FPS时,返回值为59.98 ...我在Stack中尝试了很多解决方案(主要使用C ++语言和线程或计时器滴答)但仍然得到相同的fps。
我尝试了什么:
private void StartButton_Click( object sender,EventArgs e)
{
grabber = new VideoCapture(videoPath);
grabber.QueryFrame();
// System.Threading.Thread.Sleep(1000);
grabber .SetCaptureProperty(CapProp.Fps, 100 ); // fps设置默认值5
Console.WriteLine( 显示FPS - >>>> + grabber.GetCaptureProperty(CapProp.Fps));
Application.Idle + = new EventHandler(FrameGrabber);
StartButton.Enabled = false ;
}
void FrameGrabber( object sender,EventArgs e)
{
currentFrame = grabber.QuerySmallFrame(); // Orginalley使用QueryFrame()方法。
Image< Bgr,Byte> currentImageFrame = currentFrame.ToImage< Bgr,Byte>();
currentImageFrame.Resize( 320 , 240 ,Emgu.CV.CvEnum.Inter.Cubic) ;
gray = currentImageFrame.Convert< Gray,byte>();
Rectangle [] facesDetected = Face.DetectMultiScale(灰色, 1 。 01 , 7 , new 大小( 30 , 30 ));
numberLabel.Text = ;
。
。
。
}
解决方案
FPS是你的显卡功能的一个功能。卡片越低,FPS越低。 FPS不是你设定的东西。阅读该卡的供应商文档。
90 FPS是支持VR的卡(不会让人生病),并且是高端的。
I just copied an program to detect faces through video but the video capture is really slow, and i dont know how to fix it! Every time when I change the FPS same value is return which is 59.98... I try lots of solution in Stack (mostly use C++ language and thread or timer tick ) but still I get the same fps.
What I have tried:
private void StartButton_Click(object sender, EventArgs e)
{
grabber = new VideoCapture(videoPath);
grabber.QueryFrame();
//System.Threading.Thread.Sleep(1000);
grabber.SetCaptureProperty(CapProp.Fps, 100); //fps setting default 5
Console.WriteLine("Show FPS ->>>> " + grabber.GetCaptureProperty(CapProp.Fps));
Application.Idle += new EventHandler(FrameGrabber);
StartButton.Enabled = false;
}
void FrameGrabber(object sender, EventArgs e)
{
currentFrame = grabber.QuerySmallFrame(); //Orginalley use QueryFrame() method.
Image<Bgr, Byte> currentImageFrame = currentFrame.ToImage<Bgr, Byte>();
currentImageFrame.Resize(320, 240, Emgu.CV.CvEnum.Inter.Cubic);
gray = currentImageFrame.Convert<Gray, byte>();
Rectangle[] facesDetected = Face.DetectMultiScale(gray, 1.01, 7, new Size(30, 30));
numberLabel.Text = "";
.
.
.
}
解决方案
FPS is a function of your graphics card abilities. The lower the FPS, the lamer the card. FPS is not something you "set". Read the vendor documentation for that card.
90 FPS is a card that supports VR (without making people sick), and is on the high-end.
这篇关于如何在opencvsharp视频捕捉库中设置FPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文