【问题标题】:stream camera ip emgucv流摄像头 ip emgucv
【发布时间】: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;
        }
    }
    

    }

【问题讨论】:

标签: c# emgucv


【解决方案1】:

尝试将 Mat 解析为 Image 使用这个

Mat frame = new Mat();
_capture.Retrieve(frame, 0);

captureImageBox.Image = frame.ToImage<Bgr, Byte>();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多