【问题标题】:Emgu CV Image Capture using C#Emgu CV 图像捕获使用 C#
【发布时间】:2017-12-24 01:20:25
【问题描述】:

我使用的是 Emgu CV 2.4.0.1717,每当我声明 Mat 类时,它都不存在。我正在尝试使用可以捕获图像的 c# 创建一个应用程序。这是我的面部识别项目。

我试图声明一个 Mat 对象,但它不存在。我尝试过使用其他版本的 Emgu CV 并且效果很好。然而,HaarCascade 并不存在。它说我应该改用 CascadeClassifier 但仍然有错误。这是我的代码:

public partial class Camera : Form
{

    private VideoCapture cap;
    private HaarCascade haar;

    private void Camera_Load(object sender, EventArgs e)
    {
        // passing 0 gets zeroth webcam
        cap = new VideoCapture(0);
        // adjust path to find your xml
        haar = new HaarCascade(
        "haarcascade_frontalface_default.xml");
    } 

    private void timer1_Tick(object sender, EventArgs e)
    {
        using (Image<Bgr, byte> nextFrame = cap.QueryFrame())
        {
            if (nextFrame != null)
            {

                Image<Gray, byte> grayframe = nextFrame.Convert<Gray, byte>();
                var faces =
                    grayframe.DetectHaarCascade(
                        haar, 1.4, 4,
                        HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                        new Size(nextFrame.Width / 8, nextFrame.Height / 8)
                        )[0];

                foreach (var face in faces)
                {
                    nextFrame.Draw(face.rect, new Bgr(0, double.MaxValue, 0), 3);
                }
                imgCamUser.Image = nextFrame.ToBitmap();
            }
        }
    }
}

【问题讨论】:

    标签: c# emgucv face-detection face-recognition


    【解决方案1】:

    您尝试访问的 Mat 类来自 emgucv 3+。并且 HaarCascade 类是 emgu 的低版本。

    您需要将您的 emgu 从 here 升级到 emgu 3,并使用 CascadeClassifier 而不是 HaarCascade。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多