私はOpenCVが初めてです。
C# と Visual Studio 2015 で Emgu CV 3.1 ライブラリを使用しています。
WebCam からライブ ビデオを読み取る際に問題に直面しています。Capture() コンストラクターで例外が発生した理由がわかりません。私はそれに私の2日を無駄にしました。
Plzzz は私を助けて、Visual Studio 2015 の Emgu CV 3.1 で解決策を提供してくれます。TypeInitializationException が発生しました。例外の写真もアップロードします。 TypeInitializationException はこちら
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.Structure;
namespace FaceRecognition_3._0
{
public partial class Form1 : Form
{
private Capture _capture;
private CascadeClassifier _cascadeClassifier;
public Form1()
{
InitializeComponent();
_capture = new Capture();
imgCamUser.Image = _capture.QueryFrame();
startProcess();
}
public void startProcess()
{
_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;
}
}
}
}
`