问一下用emgu CV怎么样播放本地的视频文件并提取帧呢,用Capture类实现

.Net技术 码拜 8年前 (2017-04-29) 2335次浏览
本人在网上参考人家的写法:

private void button1_Click(object sender, EventArgs e)
        {
            Capture capture = new Capture("d:\1.mp4");
            while (true)
            {
                Image<Bgr, Byte> frame = capture.QueryFrame();
                if (frame != null)
                {
                    Image<Gray,byte> grayFrame = frame.Convert<Gray,byte>();
                    grayFrame.Resize(this.Width,this.Height,INTER.CV_INTER_CUBIC);
                    this.imageBox1.Image = grayFrame;
                   // RefreshPictureBoxDelegate fresh = this.RefreshPictureBox;
                    //this.BeginInvoke(fresh,grayFrame.ToBitmap());
                    //imageBox1.Image = frame;
                }
                //Thread.Sleep(500);
            }
        }
        public delegate void RefreshPictureBoxDelegate(Bitmap frame);
        private void RefreshPictureBox(Bitmap frame)  
        {  
           this.pictureBox1.Image = frame;
           //this.imageBox1.Image = frame;
        }

这样界面会卡死,问一下怎么解决去播放视频,或有个emgu CV播放视频文件的例子呢

解决方案

30

public partial class Form1 : Form
{
    Capture _capture;
    public Form1()
    {
        InitializeComponent();
        _capture = new Capture();
        _capture.ImageGrabbed += _capture_ImageGrabbed;
        _capture.Start();
    }
    void _capture_ImageGrabbed(object sender, EventArgs e)
    {
        var frame = _capture.RetrieveBgrFrame();
        pic.Image = frame.Bitmap;
    }
}

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明问一下用emgu CV怎么样播放本地的视频文件并提取帧呢,用Capture类实现
喜欢 (0)
[1034331897@qq.com]
分享 (0)