Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Emgu.CV.Util.CvException:&x27;OpenCV:cv::XMLParser::parse';错误C#_C#_Opencv_Exception_Emgucv - Fatal编程技术网

Emgu.CV.Util.CvException:&x27;OpenCV:cv::XMLParser::parse';错误C#

Emgu.CV.Util.CvException:&x27;OpenCV:cv::XMLParser::parse';错误C#,c#,opencv,exception,emgucv,C#,Opencv,Exception,Emgucv,你好, 在我用c#编写的人脸识别程序中,我打开程序时出错。 Forum1代码: using AForge.Video; using AForge.Video.DirectShow; using Emgu.CV; using Emgu.CV.Structure; using System; using System.Drawing; using System.Windows.Forms; namespace FaceApp { public partial class Form1 : Form

你好
在我用c#编写的人脸识别程序中,我打开程序时出错。
Forum1代码:

using AForge.Video;
using AForge.Video.DirectShow;
using Emgu.CV;
using Emgu.CV.Structure;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace FaceApp
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    FilterInfoCollection filter;
    VideoCaptureDevice device;

    CascadeClassifier cascadeClassifier = new CascadeClassifier("haarcascade_frontalface_alt_tree.xml");

    private void Form1_Load(object sender, EventArgs e)
    {
        filter = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        foreach (FilterInfo device in filter)
            comboBox1.Items.Add(device.Name);
        comboBox1.SelectedIndex = 0;
        device = new VideoCaptureDevice();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        device = new VideoCaptureDevice(filter[comboBox1.SelectedIndex].MonikerString);
        device.NewFrame += Device_NewFrame;
        device.Start();
    }

    private void Device_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();
        Image<Bgr, byte> grayImage = new Image<Bgr, byte>(bitmap);
        Rectangle[] rectangles = cascadeClassifier.DetectMultiScale(grayImage, 1.2, 1);
        foreach (Rectangle rectangle in rectangles)
        {
            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                using (Pen pen = new Pen(Color.Red, 1))
                {
                    graphics.DrawRectangle(pen, rectangle);
                }
            }
        }
        pictureBox1.Image = bitmap;
    }

    private void button2_Click(object sender, EventArgs e)
    {
        if (device.IsRunning)
            device.Stop();
    }
}
}
错误:未处理异常

Emgu.CV.Util.CvException: 'OpenCV: cv::XMLParser::parse'
我在互联网上搜索了一下错误,但没有找到解决方案。
我在下面写的代码也不起作用

private static readonly CascadeClassifier Classifier = new CascadeClassifier("haarcascade_frontalface_alt_tree.xml");
// or
private readonly CascadeClassifier Classifier = new CascadeClassifier("haarcascade_frontalface_alt_tree.xml");

我如何解决这个问题?

我知道我的答案晚了,但这对那些面临同样问题的人会有帮助。我面临同样的问题,这是由于xml文件。我从EmguCV github页面下载了haarcascades。

我知道我的答案晚了,但它对那些面临同样问题的人会有帮助。我面临同样的问题,这是由于xml文件。我从EmguCV github页面下载了haarcascades

private static readonly CascadeClassifier Classifier = new CascadeClassifier("haarcascade_frontalface_alt_tree.xml");
// or
private readonly CascadeClassifier Classifier = new CascadeClassifier("haarcascade_frontalface_alt_tree.xml");