1

我已经使用以下代码检测到眼睛:

MCvAvgComp[][] eyes = gray1.DetectHaarCascade(eye, 1.1, 1, 
       Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
gray1.ROI = Rectangle.Empty;
foreach (MCvAvgComp eyesnap in eyes[0])
{
    Rectangle eyeRect = eyesnap.rect;
    eyeRect.Offset(f.rect.X, f.rect.Y);
    nextFrame.Draw(eyeRect, new Bgr(Color.Green), 2);
}

我想在不同的图片框中拍摄两只眼睛的快照。任何人都可以帮助我了解如何拍摄单个眼睛的快照吗?

4

1 回答 1

1

您可以使用GetSubRect函数来获取子图像:

IImage eyeImg = nextFrame.GetSubRect(eyeRect);

或者

Bitmap eyeBmp = nextFrame.GetSubRect(eyeRect).Bitmap;

编辑

为左眼加载HaarCascade :

HaarCascade leftEye = new HaarCascade("leftEye.xml");

MCvAvgComp[][] foundLeftEyes = gray1.DetectHaarCascade(leftEye, 1.1, 1, 
       Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
gray1.ROI = Rectangle.Empty;
foreach (MCvAvgComp eyesnap in foundLeftEyes[0])
{
    Rectangle eyeRect = eyesnap.rect;
    eyeRect.Offset(f.rect.X, f.rect.Y);
    nextFrame.Draw(eyeRect, new Bgr(Color.Green), 2);
}

右眼也一样...

例如,您可以使用:

左眼 HaarCascade右眼 HaarCascade

于 2013-01-13T12:30:13.130 回答