Reputation: 73
HI Im using the code for face detection. but not im going to continue with face recognition. But im get stack here where, how for the next step. However, im using the emgu version 2.2
if (faces.Length > 0)
{
foreach (var face in faces)
{
ImageFrame.Draw(face.rect, new Bgr(Color.Green), 2);
//Extract face
ExtractedFace = new Bitmap(face.rect.Width, face.rect.Height);
FaceConvas = Graphics.FromImage(ExtractedFace);
FaceConvas.DrawImage(GrayBmpInput, 0, 0, face.rect, GraphicsUnit.Pixel);
ExtcFacesArr[faceNo] = ExtractedFace;
faceNo++;
}
faceNo = 0;
picExtcFaces.Image = ExtcFacesArr[faceNo];
CamImageBox.Image = ImageFrame;
}
}
Where should i continue with the face recognition and do have any good reference online in C# code?
Upvotes: 0
Views: 1163
Reputation: 465
You code is almost correct, but i think you do not have idea what to do next.I am doing face recognition in one of my app for showing a mask on face.I am doing like this.
Image mask = Image.FromFile("mask.png");
public Bitmap getFacedBitmap(Bitmap bbb)
{
using (Image<Bgr, byte> nextFrame = new Image<Bgr, byte>(bbb))
{
if (nextFrame != null)
{
// there's only one channel (greyscale), hence the zero index
//var faces = nextFrame.DetectHaarCascade(haar)[0];
Image<Gray, byte> grayframe = nextFrame.Convert<Gray, byte>();
//Image<Gray, Byte> gray = nextFrame.Convert<Gray, Byte>();
var faces = grayframe.DetectHaarCascade(haar, 1.3, 2, HAAR_DETECTION_TYPE.SCALE_IMAGE, new Size(nextFrame.Width / 8, nextFrame.Height / 8))[0];
if (faces.Length > 0)
{
foreach (var face in faces)
{
//ImageFrame.Draw(face.rect, new Bgr(Color.Green), 2);
//
using(Graphics g = Graphics.FromImage(bbb))
{
g.DrawImage(mask,face.rect);
g.Save()
}
}
}
}
}
retun bbb;
}
Upvotes: 1