EmguCV捕获错误:无法将类型'Emgu.CV.Mat'隐式转换为'Emgu.CV.Image <Emgu.CV.Structure.Bgr,byte>

Nou*_*med 1 c# emgucv webcam-capture

我正在使用带有C#的EmguCV,当我想从我的网络摄像头抓取帧时我遇到了问题,声明中出现了红色下划线:

imgOrg = capturecam.QueryFrame();
Run Code Online (Sandbox Code Playgroud)

错误:无法将类型'Emgu.CV.Mat'隐式转换为'Emgu.CV.Image'

我怎么解决这个问题?

我的代码:

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.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.UI;

namespace test2
{
    public partial class Form1 : Form
    {
        Image<Bgr, Byte> imgOrg; //image type RGB (or Bgr as we say in Open CV)
        private Capture capturecam;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                capturecam = new Capture();
            }
            catch (NullReferenceException exception)
            {
                MessageBox.Show(exception.Message);
                return;
            }
            Application.Idle += new EventHandler(ProcessFunction);

        }
        private void ProcessFunction(object sender, EventArgs arg)
        {
            imgOrg = capturecam.QueryFrame(); // error line
            imageBox1.Image = imgOrg;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

小智 6

该声明有效:

Image<Bgr, Byte> img = mat.ToImage<Bgr, Byte>();
Run Code Online (Sandbox Code Playgroud)