EMGU CV C#从USB摄像头捕获而不是内置网络摄像头

时间:2017-04-04 12:26:21

标签: c# emgucv

这是代码:

public partial class Form1 : Form { private Capture _capture = null; private Image<Bgr, Byte> frame; public Form1() { InitializeComponent(); } private void captureFrame(object sender, EventArgs e) { //frame = _capture.QueryFrame(); frame = _capture.RetrieveBgrFrame(); Bgr color = frame[10,10]; Byte blue = (Byte)color.Blue; Byte red = (Byte)color.Red; Byte green = (Byte)color.Green; pictureBox1.Image = frame.ToBitmap(); } private void button1_Click(object sender, EventArgs e) { //-> Create a List to store for ComboCameras List<KeyValuePair<int, string>> ListCamerasData = new List<KeyValuePair<int, string>>(); //-> Find systems cameras with DirectShow.Net dll DsDevice[] _SystemCamereas = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); int _DeviceIndex = 0; foreach (DirectShowLib.DsDevice _Camera in _SystemCamereas) { ListCamerasData.Add(new KeyValuePair<int, string>(_DeviceIndex, _Camera.Name)); _DeviceIndex++; } if (button1.Text == "PLAY") { _capture = null; _capture = new Capture(0); _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS, 30); _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 480); _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 640); button1.Text = "STOP"; Application.Idle += captureFrame; } else { Application.Idle -= captureFrame; button1.Text = "PLAY"; _capture.Stop(); if (_capture != null) _capture.Dispose(); } } }

在ListCamerasData中我可以看到2个摄像头0 - 来自笔记本电脑的摄像头和1 - SMI Video Grabber。

如果我更改_capture = new Capture(0); ==&GT;&GT; _capture = new Capture(1);洞程序冻结了。

如何从相机SMI视频Grabber中捕获?

0 个答案:

没有答案