我刚刚复制了一个程序来通过视频检测人脸,但是视频捕获确实很慢,而且我不知道如何解决它!每次更改FPS时,都会返回相同的值59.98 ... 我在Stack中尝试了很多解决方案(主要使用C ++语言和线程或计时器tick),但仍然得到相同的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 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 = "";
.
.
.
}