gpt4 book ai didi

c# - EmguCV 捕获错误 : Cannot implicitly convert type 'Emgu.CV.Mat' to 'Emgu. CV.Image

转载 作者:太空宇宙 更新时间:2023-11-03 18:27:25 28 4
gpt4 key购买 nike

我在 C# 中使用 EmguCV,当我想从网络摄像头抓取帧时遇到问题,语句中出现红色下划线:

imgOrg = capturecam.QueryFrame();

error: Cannot implicitly convert type 'Emgu.CV.Mat' to '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;
}
}
}

最佳答案

这个语句有效:

Image<Bgr, Byte> img = mat.ToImage<Bgr, Byte>();

关于c# - EmguCV 捕获错误 : Cannot implicitly convert type 'Emgu.CV.Mat' to 'Emgu. CV.Image<Emgu.CV.Structure.Bgr,byte>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31226020/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com