【问题标题】:Show VideoCapture Frames in ListView在 ListView 中显示 VideoCapture 帧
【发布时间】:2018-11-03 04:00:48
【问题描述】:

我正在尝试在列表视图或图像列表中一一生成所选视频的所有帧,是否可以不先将帧保存为图像?

这是我的示例代码。

string name = @"E:\Videos\Anime\eyeshield\Eyeshield 21 Episode 1.flv";
VideoCapture _capture;
_capture = new VideoCapture(name);

List<Image<Bgr, Byte>> image_array = new List<Image<Bgr, Byte>>();

double totalFrames =_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
double fps = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
double frameNumber = 0.0;
bool Reading = true;

 while (Reading)
        {
            _capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.PosFrames, frameNumber);
            Image<Bgr, Byte> frame = _capture.QueryFrame().ToImage<Bgr, Byte>();
            if (frame != null)
            {
                //Display the image_array frame in listView1 or imageList1 one by one
            }
            else
            {
                Reading = false;
            }

            frameNumber++;
        }

Here 可能与我的目标输出类似,但语法 QueryFrame().Copy 不起作用。

【问题讨论】:

    标签: c# vb.net emgucv


    【解决方案1】:

    由于仍然没有人回答这个问题,我已经解决了这个问题,我将发布代码以供将来参考。该框架将作为位图存储到图像列表并显示到列表视图。

    double TotalFrame;
    int FrameNo = 1;
    bool IsReadingFrame;
    VideoCapture capture;
    
    System.Windows.Forms.ImageList myImageList = new ImageList();
    
    public Form1()
    {
      InitializeComponent();
      listViewFile.LargeImageList = myImageListLarge;
    
      if (capture==null)
      {
        return;
      }
      IsReadingFrame = true;
      ReadAllFrames();
    }
    
    private async void ReadAllFrames()
    {
      Mat m = new Mat();
      while (IsReadingFrame == true && FrameNo <= TotalFrame)
      {
        listViewFile.Items.Add(new ListViewItem { ImageIndex = FrameNo, Text = 
        FrameNo.ToString() });
        capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.PosFrames, FrameNo);
        capture.Read(m);
        pictureBox1.Image = m.Bitmap;
    
        myImageList.ImageSize = new Size(80, 80);
        myImageList.Images.Add(m.Bitmap);
    
        listViewFile.LargeImageList = myImageList;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-05
      • 1970-01-01
      • 1970-01-01
      • 2019-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多