I have created an application in C# that, when triggered, opens the camera and detects a face, placing a square around it. When I run this application in debug mode, it works correctly. However, when I build a release version, it throws an exception.
using Emgu.CV;
using Emgu.CV.Structure;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace FaceDetectionAndRecognition
{
public partial class Form1 : Form
{
private HaarCascade faceDetected;
private Image<Bgr, Byte> Frame;
private Capture camera;
private Image<Gray, byte> grayFace = null;
public Form1()
{
InitializeComponent();
faceDetected = new HaarCascade("haarcascade_frontalface_default.xml");
camera = new Capture();
camera.QueryFrame();
Application.Idle += new EventHandler(FrameProcedure);
camera.FlipHorizontal = true;
}
private void FrameProcedure(object sender, EventArgs e)
{
Frame = camera.QueryFrame().Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
grayFace = Frame.Convert<Gray, Byte>();
MCvAvgComp[][] facesDetectedNow = grayFace.DetectHaarCascade(faceDetected, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
foreach (MCvAvgComp f in facesDetectedNow[0])
{
Frame.Draw(f.rect, new Bgr(Color.Red), 2);
}
cameraBox.Size = new Size(640, 480);
cameraBox.Image = Frame.ToBitmap();
}
}
}
And I receive this error, commonly referred to as an exception.
Can anyone help me find a solution to this issue?