如何使用emgucv保存特定的视频帧? [英] How to save particular frame of video using emgucv?

查看:388
本文介绍了如何使用emgucv保存特定的视频帧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码没有错误,但不保存任何框架。当我暂停视频时,我想保存当前帧。



我尝试过:



my code without error but don't save any frame. when I pause the video I want to save the current frame.

What I have tried:

<pre>
<pre>namespace VideoCaptureApplication1
{
    public partial class Form2 : Form
    {
        private Capture _capture = null;
        Image<Bgr, Byte> frame;
        double FrameRate = 0;
        double TotalFrames = 0;
        double Framesno = 0;
        bool IsPlaying = false;
        
        public Form2()
        {
            InitializeComponent();
        }







private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
           
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                { 
                    _capture = null;
                    _capture = new Capture(openFileDialog1.FileName);

                    FrameRate = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS);
                    TotalFrames = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_COUNT);
                    Application.Idle += ProcessFrame ;
                    IsPlaying = true;
                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }
        }

private void ProcessFrame(object sender, EventArgs arg)
        {
            try
            {
                Framesno = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES);
                frame = _capture.QueryFrame();


                if (frame != null && IsPlaying==true)
                {
                    pictureBox1.Image = frame.ToBitmap();

                    
                        Thread.Sleep((int)(1000.0 / FrameRate));
                    }
                  
                }
                    catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
 private void button4_Click(object sender, EventArgs e)
        {
            
            frame.Save("D\\" + Frame.ToString()+".jpg");

           
        }

推荐答案

如果你没有逐步执行代码调试器看看每个中间步骤发生了什么,你怎么期待别人呢?



当你更好地了解问题时,逐步执行代码并回来是因为没有其他人可以。



这叫做测试。
If you didn't "step through the code" with the debugger to see what happened in every intermediate step, how do you expect someone else to?

Step through the code and come back when you have a better idea where the problem is because no one else can.

It's called "testing".


这篇关于如何使用emgucv保存特定的视频帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆