C# 视频播放

若是须要查看更多文章,请微信搜索公众号 csharp编程大全,须要进C#交流群群请加微信z438679770,备注进群, 我邀请你进群! ! !编程

主要是最基本的功能实现,后续会更新进一步的加工处理内容微信

emgucv采用的是V4.1.0.3420 VS版本2015ide

一开始 _capture.Start()后报错spa

 

错误 CS0012 类型“ExceptionHandler”在未引用的程序集中定义。必须添加对程序集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。orm

添加引用这个玩意就行了视频

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Emgu.CV;
using Emgu.Util;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.Util.TypeEnum;

namespace WindowsFormsApplication38
{
public partial class Form1 : Form
    {
// Capture是Emgu.CV提供的摄像头控制类,里面的ImageGrabbed事件表示的是获取到图片后触发。能够用来实现模拟摄像头视频获取(实际上是在picturebox中显示图片,因为很快,就跟视频同样)
// Capture另外一个很是关键的方法是QueryFrame()这个方法是用来获取当前的摄像头捕捉到的图面。
        VideoCapture _capture;
        Mat frame = new Mat();
public Form1()
        {
            InitializeComponent();
            _capture = new VideoCapture(@"C:\Users\Administrator\Desktop\video\vtest.avi");
// _capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight, 300);
//设置捕捉到帧的高度为320。
// _capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth,
//300);
//设置捕捉到帧的宽度为240。
// _capture.FlipHorizontal = true;
//捕捉到帧数据进行水平翻转。
            _capture.ImageGrabbed += _capture_ImageGrabbed;

            _capture.Start();
           
        }

void _capture_ImageGrabbed(object sender, EventArgs e)
        {
           

            _capture.Retrieve(frame, 0);

//var frame1 = _capture.Retrieve(frame,0);
            captureImageBox.Image = frame;




        }
    }
}
相关文章
相关标签/搜索