我正在开发一个项目,其中我需要从opnefile对话加载视频文件,但我不明白如何做到这一点。加载视频后,我还想停止或暂停视频以进行进一步处理。我使用的是EmguCV 3.0版本。
我的代码在这里。
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();
}收集帧流的下一步要做什么。
发布于 2018-06-28 04:06:20
查看EmguCV文档中的示例代码:http://www.emgu.com/wiki/index.php/Camera_Capture_in_7_lines_of_code
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这将使您的代码类似于以下代码:
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交给你用来观看视频的任何东西。
https://stackoverflow.com/questions/50501176
复制相似问题