I WANT TO DETECT ONLY UNIQUE FACES FROM A VIDEO USING FACE DETECTION FROM EACH FRAME OF THE VIDEO BUT ONLY WANT TO SAVE UNIQUE FACES TO MY FOLDER FROM ALL THE DETECTED FILES this is the code i am using for processing frame
private void ProcessFrame(object sender, EventArgs e)
{
try
{
if (videoCapture != null && videoCapture.Ptr != IntPtr.Zero)
{
videoCapture.Retrieve(frame, 0);
currentFrame = frame.ToImage<Bgr, byte>().Resize(picCapture.Width, picCapture.Height, Emgu.CV.CvEnum.Inter.Cubic);
if (facesDetectionEnabled)
{
Mat grayImage = new Mat();
CvInvoke.CvtColor(currentFrame, grayImage, ColorConversion.Bgr2Gray);
CvInvoke.EqualizeHist(grayImage, grayImage);
System.Drawing.Rectangle[] faces = faceCasacdeClassifier.DetectMultiScale(grayImage, 1.1, 3);
if (faces.Length > 0)
{
foreach (var face in faces)
{
CvInvoke.Rectangle(currentFrame, face, new Bgr(System.Drawing.Color.Red).MCvScalar, 2);
Image<Bgr, byte> resultImage = currentFrame.Convert<Bgr, byte>();
resultImage.ROI = face;
picDetected.SizeMode = PictureBoxSizeMode.StretchImage;
picDetected.Image = resultImage.AsBitmap();
if (EnableSaveImage)
{
string path = Value.ValueG._DataFilePath + "\\Video\\FaceFind\\Video" + Value.ValueG._CaseVideo_Id;
string path1 = System.IO.Directory.GetCurrentDirectory() + @"\TrainedImages";
System.IO.Directory.CreateDirectory(path1);
if (!System.IO.Directory.Exists(path))
System.IO.Directory.CreateDirectory(path);
Task.Factory.StartNew(() =>
{
for (int i = 0; i < 1; i++)
{
resultImage.Resize(200, 200, Inter.Cubic).Save(path + @"\" + txtPersonName.Text + "_" + DateTime.Now.ToString("hh-mm-ss") + ".jpg");
Thread.Sleep(1000);
}
});
}
EnableSaveImage = true;
if (btnAddPerson.InvokeRequired)
{
btnAddPerson.Invoke(new ThreadStart(delegate
{
btnAddPerson.Enabled = true;
}));
}
}
}
}
picCapture.Image = currentFrame.AsBitmap();
}
if (currentFrame != null)
{
currentFrame.Dispose();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
}
}
What I have tried:
I HAVE TRIED MANY WAYS BUT THE PROBLEM COMING IS IT IS DETECTING THE SAME FACE AGAIN AND AGAIN WITH FRAME AND SAVING THEM TO THE FOLDER WHERE I WANT IT TO SAVE ONLY ONE UNIQUE FACE OF A PARTICULAR PERSON TO THE FOLDER IAM USING Emgu.CV,FaceRecognitionDotNet,DlibDotNet .iam doing it in c# windows forms
IS THERE ANY WAY TO SAVE THE UNIQUE FACES ONLY FROM THE VIDEO AND REMOVE THE FACES WHICHN ARE REPEATING.THIS PROCESS SHOULD WORK WHILE PROCESSING OF THE VIDEO