首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在VideoCapture中显示ListView帧

在VideoCapture中显示ListView帧
EN

Stack Overflow用户
提问于 2018-11-03 04:00:48
回答 1查看 343关注 0票数 0

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

这是我的代码样本。

代码语言:javascript
运行
复制
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不起作用。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-07 09:18:45

由于还没有人回答这个问题,我已经解决了这个问题,我会把代码发出来供将来参考。该帧将作为位图存储到图像列表中,并显示为列表视图。

代码语言:javascript
运行
复制
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;
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53128290

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档