我使用此代码检测到了眼睛:
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);
}
我想在不同的图片框中拍摄双眼的快照。任何人都可以帮助我理解如何拍摄个人眼睛的快照吗?
答案 0 :(得分: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);
}
右眼也一样......
作为示例,您可以使用: