我已经从脸部检测到眼睛和嘴巴,.. 但是,嘴巴没有被正确检测到我将此代码应用于 3 张图片但它没有准确地检测到嘴巴你可以看到这里的图片 看到这里的示例图片 对于图 1,它检测到准确但对于 fig 2 和 fig3 它检测不准确
private void ProcessFrame(object sender, EventArgs arg)
{
Image InputImg = Image.FromFile(@"C:\Emgu\a.jpg");
Image<Bgr, byte> ImageFrame = new Image<Bgr, byte>(new Bitmap(InputImg));
if (ImageFrame != null) // confirm that image is valid 10
{
Image<Gray, byte> grayframe = ImageFrame.Convert<Gray, byte>();
var faces = grayframe.DetectHaarCascade(haarCascade, 1.4, 4,
HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(40, 40))[0];
var nos = grayframe.DetectHaarCascade(nose);
var eyes = grayframe.DetectHaarCascade(eye, 1.1, 1,
HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(20, 20));
foreach (var eye2 in eyes[0])
{
Rectangle eyeRect1 = eye2.rect;
ImageFrame.Draw(eyeRect1, new Bgr(Color.Pink), 2);
}
foreach (var noses1 in nos[0])
{
Rectangle noserect = noses1.rect;
ImageFrame.Draw(noserect, new Bgr(Color.Blue), 2);
}
foreach (var face in faces)
{
ImageFrame.Draw(face.rect, new Bgr(Color.Green), 3);
grayframe.ROI = face.rect;
var mouths = grayframe.DetectHaarCascade(mouth,
1.5, 10,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(20, 20));
grayframe.ROI = Rectangle.Empty;
foreach (var mouthsnap in mouths[0])
{
Rectangle mouthRect = mouthsnap.rect;
mouthRect.Offset(face.rect.X, face.rect.Y);
ImageFrame.Draw(mouthRect, new Bgr(Color.Red), 2);
}
}
}
CamImageBox.Image = ImageFrame;
}