首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在c#中读取EmguCV视频

在c#中读取EmguCV视频
EN

Stack Overflow用户
提问于 2018-05-24 12:47:40
回答 1查看 1.1K关注 0票数 0

我正在开发一个项目,其中我需要从opnefile对话加载视频文件,但我不明白如何做到这一点。加载视频后,我还想停止或暂停视频以进行进一步处理。我使用的是EmguCV 3.0版本。

我的代码在这里。

代码语言:javascript
复制
OpenFileDialog ofd1 = new OpenFileDialog();
            ofd1.Filter = "All Videos Files |*.dat; *.wmv; *.3g2; *.3gp; *.3gp2; *.3gpp; *.amv; *.asf;  *.avi; *.bin; *.cue; *.divx; *.dv; *.flv; *.gxf; *.iso; *.m1v; *.m2v; *.m2t; *.m2ts; *.m4v; *.mkv; *.mov; *.mp2; *.mp2v; *.mp4; *.mp4v; *.mpa; *.mpe; *.mpeg; *.mpeg1; *.mpeg2; *.mpeg4; *.mpg; *.mpv2; *.mts; *.nsv; *.nuv; *.ogg; *.ogm; *.ogv; *.ogx; *.ps; *.rec; *.rm; *.rmvb; *.tod; *.ts; *.tts; *.vob; *.vro; *.webm";
            ofd1.InitialDirectory = @"C:\";
            ofd1.Title = "Please select a video file.";
            if (ofd1.ShowDialog() == DialogResult.OK)
            {
                vCapture = new Capture(ofd1.FileName.ToString());
                Image<Bgr, byte> img = vCapture.QueryFrame();
            }

收集帧流的下一步要做什么。

EN

回答 1

Stack Overflow用户

发布于 2018-06-28 04:06:20

查看EmguCV文档中的示例代码:http://www.emgu.com/wiki/index.php/Camera_Capture_in_7_lines_of_code

代码语言:javascript
复制
using Emgu.CV;
using Emgu.CV.UI;
using Emgu.CV.Structure;
using System.Drawing;
using System.Windows.Forms;
...

ImageViewer viewer = new ImageViewer(); //create an image viewer
Capture capture = new Capture(); //create a camera captue
Application.Idle += new EventHandler(delegate(object sender, EventArgs e)
{  //run this until application closed (close button click on image viewer)
   viewer.Image = capture.QueryFrame(); //draw the image obtained from camera
});
viewer.ShowDialog(); //show the image viewer

这将使您的代码类似于以下代码:

代码语言:javascript
复制
Image<Bgr, byte> img;
OpenFileDialog ofd1 = new OpenFileDialog();
ofd1.Filter = "All Videos Files |*.dat; *.wmv; *.3g2; *.3gp; *.3gp2; *.3gpp; *.amv; *.asf;  *.avi; *.bin; *.cue; *.divx; *.dv; *.flv; *.gxf; *.iso; *.m1v; *.m2v; *.m2t; *.m2ts; *.m4v; *.mkv; *.mov; *.mp2; *.mp2v; *.mp4; *.mp4v; *.mpa; *.mpe; *.mpeg; *.mpeg1; *.mpeg2; *.mpeg4; *.mpg; *.mpv2; *.mts; *.nsv; *.nuv; *.ogg; *.ogm; *.ogv; *.ogx; *.ps; *.rec; *.rm; *.rmvb; *.tod; *.ts; *.tts; *.vob; *.vro; *.webm";
ofd1.InitialDirectory = @"C:\";
ofd1.Title = "Please select a video file.";
if (ofd1.ShowDialog() == DialogResult.OK)
{
    vCapture = new Capture(ofd1.FileName.ToString());
    Application.Idle += new EventHandler(delegate(object sender, EventArgs e)
    {            
        img = vCapture.QueryFrame();
    }
}
vCapture.Start(); // play
vCapture.Pause(); // pause

然后你会想要把你的img交给你用来观看视频的任何东西。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50501176

复制
相关文章

相似问题

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