【发布时间】:2016-12-22 08:01:25
【问题描述】:
您好,当我使用 emgucv 将此代码运行到 c# 以在图片框中查看实时 ip 摄像头时,它会显示错误 在这部分:
Mat frame = new Mat();
_capture.Retrieve(frame, 0);
captureImageBox.Image = frame;
错误提示
无法在 emgu.cv.imag 中转换类型 emgu.cv.mat...
我需要更改哪些代码行才能正确运行它......
规格
- Visual Studio 2015
-
emgucv v3.1 x64
public partial class Form1 : Form { private Capture _capture = null; private bool _captureInProgress; public Form1() { InitializeComponent(); CvInvoke.UseOpenCL = false; try { _capture = new Capture("http://webcam.st-malo.com/axis-cgi/mjpg/video.cgi?"); _capture.ImageGrabbed += ProcessFrame; } catch (NullReferenceException excpt) { MessageBox.Show(excpt.Message); } } private void ProcessFrame(object sender, EventArgs arg) { Mat frame = new Mat(); _capture.Retrieve(frame, 0); captureImageBox.Image = frame; } private void captureButton_Click(object sender, EventArgs e) { if (_capture != null) { if (_captureInProgress) { //stop the capture captureButton.Text = "Start Capture"; _capture.Pause(); } else { //start the capture captureButton.Text = "Stop"; _capture.Start(); } _captureInProgress = !_captureInProgress; } }}
【问题讨论】:
-
您需要使用
ToImage(emgu.com/wiki/files/3.1.0/document/html/…) 将Mat转换为image数据类型