gpt4 book ai didi

C# Emgu,无法找到 Capture 和 HaarCascade

转载 作者:行者123 更新时间:2023-11-30 14:06:39 32 4
gpt4 key购买 nike

我错过了什么?

VS 无法找到 Capture 和 HaarCascade。我添加了所有 opencv .dll 和“始终复制”。

Copy always

并添加了 Emgu 的引用。

References

我的 Emgu 是 emgucv-windesktop 3.2.0.2682-сuda。 Visual Studio 2017

    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.Util;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;
using System.Windows;

namespace Emgu.FaceDetection
{
public partial class Form1 : Form
{
private Capture cap;
private HaarCascade haar;
public Form1()
{
InitializeComponent();
}
}
}

最佳答案

在使用 EmguCV3.X 时不能使用 HaarCascade,它已被弃用并替换为 CascadeClassifier

参见 here for an explination ,摘要已更改为类似于此的内容:

CascadeClassifier _cascadeClassifier = new CascadeClassifier(@"C:\OPENCV_3.0.0\opencv\build\etc\haarcascades\" + "haarcascade_frontalface_alt2.xml");

可以找到使用 3.X 的更完整的示例和教程 here ,该博客的一个片段:

private CascadeClassifier _cascadeClassifier;
_cascadeClassifier = new CascadeClassifier(Application.StartupPath + "/haarcascade_frontalface_alt_tree.xml");
using (var imageFrame = _capture.QueryFrame().ToImage<Bgr, Byte>())
{
if (imageFrame != null)
{
var grayframe = imageFrame.Convert<Gray, byte>();
var faces = _cascadeClassifier.DetectMultiScale(grayframe, 1.1, 10, Size.Empty); //the actual face detection happens here


foreach (var face in faces)
{
imageFrame.Draw(face, new Bgr(Color.BurlyWood), 3); //the detected face(s) is highlighted here using a box that is drawn around it/them

}
}
imgCamUser.Image = imageFrame;
}

关于C# Emgu,无法找到 Capture 和 HaarCascade,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46410342/

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