0

I'm using the Emgu CV 2.4.0.1717 and whenever I declare the Mat class it does not exist. I am trying to create an application using c# that can capture an image. This is for my Facial Recognition project.

I was trying to declare a Mat object but it does not exist. I've tried using other versions of Emgu CV and it worked. However, the HaarCascade does not exist. It stated that I should use CascadeClassifier instead but there's still an error. Here is my code:

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();
            }
        }
    }
}
Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
redpranger
  • 21
  • 1
  • 1
  • 5

1 Answers1

0

Mat class you are trying to access is from emgucv 3+. and the HaarCascade class is in lower version of emgu.

You need to upgrade your emgu to emgu 3 from here and use CascadeClassifier instead of HaarCascade.

Nabeel Zafar
  • 191
  • 10