【问题标题】:Emgu Capture plays video super fastEmgu Capture 以超快的速度播放视频
【发布时间】:2011-10-05 21:58:50
【问题描述】:

当我使用 Emgu 播放视频时,它的播放速度比应有的要快得多。这是相关代码。

public Form1()
{
    InitializeComponent();

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

protected void RefreshFrames(object sender, EventArgs e)
{
    imageBox.Image = _capture.QueryFrame();
}

我尝试在 Capture 对象上使用 SetCaptureProperty 方法设置 FPS,但它仍然以超快动作播放。

【问题讨论】:

    标签: emgucv


    【解决方案1】:

    当您的程序没有调用其他函数并且您的计算机有可用资源时,将调用 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();
    }
    

    上面的代码应该做你想做的事,调整 FPS 以获得所需的播放速度。如果您还需要什么,请告诉我,

    干杯

    克里斯

    【讨论】:

    【解决方案2】:
    public Form1()
    {
        InitializeComponent();
    
        _capture = new Capture("test.avi");
        Application.Idle += RefreshFrames;
    }
    
    protected void RefreshFrames(object sender, EventArgs e)
    {
        imageBox.Image = _capture.QueryFrame();
    
        Thread.sleep(1000/FrameRate);
    }
    

    使用 thread.sleep 将播放速度设置为实时。你可以很容易地做到这一点 使用这个:)

    【讨论】:

      猜你喜欢
      • 2018-08-28
      • 1970-01-01
      • 2011-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-28
      • 2015-12-18
      • 1970-01-01
      相关资源
      最近更新 更多