如果需要查看更多文章,請微信搜索公眾號 csharp編程大全,需要進C#交流群群請加微信z438679770,備注進群, 我邀請你進群! ! !

主要是最基本的功能實作,后續會更新進一步的加工處理內容
emgucv采用的是V4.1.0.3420 VS版本2015
一開始 _capture.Start()后報錯
錯誤 CS0012 型別“ExceptionHandler”在未參考的程式集中定義,必須添加對程式集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的參考,
添加參考這個玩意就好了

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;
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/227000.html
標籤:C#
下一篇:C# 程式禁止重復啟動
