Emgu Capture以超快的速度播放视频

a43*_*511 6 emgucv

当我使用Emgu播放视频时,它的播放速度比应该的速度快.这是相关的代码.

public Form1()
{
    InitializeComponent();

    _capture = new Capture("test.avi");
    Application.Idle += RefreshFrames;
}

protected void RefreshFrames(object sender, EventArgs e)
{
    imageBox.Image = _capture.QueryFrame();
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用Capture对象上的SetCaptureProperty方法设置FPS,但它仍然以超快速运动方式播放.

Chr*_*ris 11

当您的程序没有调用其他函数并且您的计算机具有可用资源时,将调用Application.Idle句柄.它不是设计为在设定的时间段调用.而是设置一个计时器并使用它的滴答功能来设置播放速度.

Timer My_Time = new Timer();
int FPS = 30;

public Form1()
{
    InitializeComponent();

    //Frame Rate
    My_Timer.Interval = 1000 / FPS;
    My_Timer.Tick += new EventHandler(My_Timer_Tick);
    My_Timer.Start();
    _capture = new Capture("test.avi");   
}

private void My_Timer_Tick(object sender, EventArgs e)
{
    imageBox.Image = _capture.QueryFrame();
}
Run Code Online (Sandbox Code Playgroud)

上面的代码应该按照您的意愿进行,调整FPS以获得所需的播放速度.如果您还需要其他信息,请告诉我,

干杯

克里斯