private string[] imageCheckRecognize(Image <Gray, byte> image)
        {
            string matchedResult = eigenRecog.Recognise(image);

            string[] matchedData = matchedResult.Split(' ');
            return(matchedData);
        }
Exemple #2
0
        private void test()
        {
            Image <Gray, byte> testImage = new Image <Gray, byte>("E:/Images/tmp.jpg");

            result          = Eigen_Recog.Recognise(testImage);
            distance        = Eigen_Recog.Get_Eigen_Distance;
            textBox1.Text   = result;
            textBox2.Text   = distance.ToString();
            imageBox7.Image = testImage;
            imageBox1.Image = db.getResultImage(result);
        }
        private void ProcessFrame(object sender, EventArgs arg)
        {
            if (imageFrame != null)
            {
                Image <Gray, byte> greyImage = imageFrame.Copy().Convert <Gray, byte>();
                greyImage = greyImage.SmoothMedian(3);

                //stopWatch.Start();
                var faces = face.Detect(greyImage, 1.3, 6, HAAR_DETECTION_TYPE.FIND_BIGGEST_OBJECT, new Size(120, 120), new Size(300, 300));

                if (faces.Length == 0)
                {
                    var eyeObjects = eyeWithGlass.DetectMultiScale(greyImage, 1.3, 6, minEye, maxEye);
                    if (eyeObjects.Length == 2)
                    {
                        #region comment

                        /*Console.WriteLine("helper");
                         * if(eyeObjects[0].X > eyeObjects[1].X)
                         * {
                         *   var temp = eyeObjects[0];
                         *   eyeObjects[0] = eyeObjects[1];
                         *   eyeObjects[1] = temp;
                         * }
                         * int betweeneLength = eyeObjects[1].X - eyeObjects[0].X;
                         * int middleposition = eyeObjects[0].X + ((betweeneLength + eyeObjects[1].Width )/ 2);
                         * int forheadpeak = (int)(0.8 * betweeneLength);//
                         * int forheadpeakpeak = (int)(0.7 * betweeneLength);//
                         * int forheadbelowpeak = (int)(0.4 * betweeneLength);
                         * int foreheadpoint = (int)(0.6 * betweeneLength);
                         * int neareyebrowpoint = (int)(0.2 * betweeneLength);
                         * int lefteyebrowpoint = eyeObjects[0].X;//
                         * int righteyebrowpoint = eyeObjects[0].X + betweeneLength + eyeObjects[1].Width;//
                         * //int nosepoint =
                         * int xx = (int)((5.0 / 12.0) * betweeneLength);
                         * int margin = (int)((1.5 / 8.0) * betweeneLength);
                         *
                         * int x1 = (int)((1.0 / 16.0) * betweeneLength);
                         *
                         *
                         * int round = 3;
                         * int around = round-2;
                         * double tempcolor = 0;
                         * for (int i = 0; i<round; i++)
                         * {
                         *   for (int j = 0; j < round; j++)
                         *   {
                         *       tempcolor += greyImage[middleposition - around + i, eyeObjects[0].Y + forheadpeak - around + j].Intensity;
                         *   }
                         * }
                         * Gray skincolor = new Gray(tempcolor/(round*round));
                         * Point[] p = new Point[7];
                         * p[0] = new Point(middleposition, eyeObjects[0].Y - forheadpeak);
                         *
                         * p[1] = new Point(eyeObjects[0].X + (eyeObjects[0].Width / 2), eyeObjects[0].Y - forheadpeakpeak);
                         * p[2] = new Point(eyeObjects[0].X - x1, eyeObjects[0].Y - forheadbelowpeak);
                         * p[3] = new Point(lefteyebrowpoint - margin, eyeObjects[0].Y + (eyeObjects[0].Height/6));
                         *
                         * p[4] = new Point(righteyebrowpoint + margin, eyeObjects[0].Y + (eyeObjects[0].Height /6));
                         * p[5] = new Point(righteyebrowpoint + x1, eyeObjects[0].Y - forheadbelowpeak);
                         * p[6] = new Point(eyeObjects[1].X + (eyeObjects[1].Width / 2), eyeObjects[0].Y - forheadpeakpeak);
                         *
                         * //imageFrame.Draw(new Rectangle(new Point(eyeObjects[0].X, eyeObjects[0].Y), new Size(betweeneLength + eyeObjects[1].Width, eyeObjects[0].Height)), new Bgr(Color.Aqua), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(middleposition,eyeObjects[0].Y+ foreheadpoint), 1), new Bgr(Color.Yellow), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(middleposition,eyeObjects[0].Y - forheadpeak), 1), new Bgr(Color.Yellow), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(middleposition, eyeObjects[0].Y - neareyebrowpoint), 1), new Bgr(Color.Gold), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(lefteyebrowpoint - margin, eyeObjects[0].Y), 1), new Bgr(Color.AliceBlue), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(righteyebrowpoint + margin, eyeObjects[0].Y), 1), new Bgr(Color.AliceBlue), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(lefteyebrowpoint, eyeObjects[0].Y - neareyebrowpoint), 1), new Bgr(Color.LimeGreen), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(righteyebrowpoint, eyeObjects[0].Y - neareyebrowpoint), 1), new Bgr(Color.LimeGreen), 2);
                         * //imageFrame.DrawPolyline(p,true, new Bgr(Color.Azure), 2);
                         * greyImage.FillConvexPoly(p, skincolor);
                         * //imageFrame.Draw(new CircleF(new PointF(eyeObjects[0].X - x1, eyeObjects[0].Y - forheadbelowpeak), 1), new Bgr(Color.LimeGreen), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(righteyebrowpoint + x1, eyeObjects[0].Y - forheadbelowpeak), 1), new Bgr(Color.LimeGreen), 2);
                         *
                         * //imageFrame.Draw(new CircleF(new PointF(eyeObjects[0].X + (eyeObjects[0].Width / 2), eyeObjects[0].Y - forheadpeakpeak), 1), new Bgr(Color.LimeGreen), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(eyeObjects[1].X + (eyeObjects[1].Width / 2), eyeObjects[0].Y - forheadpeakpeak), 1), new Bgr(Color.LimeGreen), 2);
                         */
                        #endregion
                    }
                    else //not see eye in frame
                    {
                        learningTag        = true;
                        name               = "Processing...";
                        userid             = "Processing...";
                        timestampFlag      = true;
                        faceRectangle      = Rectangle.Empty;
                        realfaceRectangle  = Rectangle.Empty;
                        label2.ForeColor   = Color.DeepSkyBlue;
                        label2.Text        = "Idle";
                        progressBar1.Value = 0;
                        recogNameResult.Clear();
                        recogDistanceResult.Clear();
                        Console.WriteLine("Clear");
                    }

                    ARDisplayFlag = false;
                }
                else
                {
                    Parallel.ForEach(faces, facecount =>
                    {
                        try {
                            facePosition      = new Point(facecount.rect.X, facecount.rect.Y);
                            faceRectangleSize = new Size(facecount.rect.Width, facecount.rect.Height);
                            faceRectangle     = new Rectangle(facePosition, faceRectangleSize);
                            greyImage.ROI     = faceRectangle;
                            var eyeObjects    = eyeWithGlass.DetectMultiScale(greyImage, 1.3, 6, minEye, maxEye);
                            greyImage.ROI     = Rectangle.Empty;
                            if (eyeObjects.Length == 2)
                            {
                                Console.WriteLine("eye detected...");
                                if (eyeObjects[0].X > eyeObjects[1].X)
                                {
                                    var temp      = eyeObjects[0];
                                    eyeObjects[0] = eyeObjects[1];
                                    eyeObjects[1] = temp;
                                }

                                int betweeneLength    = eyeObjects[1].X - eyeObjects[0].X;
                                int lefteyebrowpoint  = eyeObjects[0].X;                       //
                                int righteyebrowpoint = eyeObjects[1].X + eyeObjects[1].Width; //
                                int margin            = (int)((1.5 / 8.0) * betweeneLength);
                                int neareyebrowpoint  = (int)(0.2 * betweeneLength);
                                int faceheight        = (int)(2.3 * betweeneLength);

                                realFacePosition      = new Point(facePosition.X + lefteyebrowpoint - margin, facePosition.Y + eyeObjects[0].Y - neareyebrowpoint);
                                realfaceRectangleSize = new Size((righteyebrowpoint + margin) - (lefteyebrowpoint - margin), faceheight);
                                realfaceRectangle     = new Rectangle(realFacePosition, realfaceRectangleSize);

                                greyImage.ROI = realfaceRectangle;
                                imageroi      = greyImage.Copy();
                                greyImage.ROI = Rectangle.Empty;

                                if (eigenRecog.IsTrained)
                                {
                                    imageroi._EqualizeHist();
                                    imageroi = imageroi.Resize(ROIwidth, ROIheight, INTER.CV_INTER_LINEAR);
                                    Image <Gray, byte> plainImage = imageroi.Copy();

                                    imageroi.FillConvexPoly(pL, new Gray(128));
                                    imageroi.FillConvexPoly(pR, new Gray(128));

                                    //find the most relative face
                                    progressBar1.Value = recogNameResult.Count;
                                    if (recogNameResult.Count == maxImageCount && !ARDisplayFlag)
                                    {
                                        Console.WriteLine("Processing...");
                                        int max         = 0;
                                        string mostFace = "";

                                        double euclidVal = 0;
                                        foreach (string value in recogNameResult.Distinct())
                                        {
                                            Console.WriteLine("\"{0}\" occurs {1} time(s).\n", value, recogNameResult.Count(v => v == value));
                                            if (recogNameResult.Count(v => v == value) > max)
                                            {
                                                max      = recogNameResult.Count(v => v == value);
                                                mostFace = value;
                                            }
                                        }
                                        name   = mostFace;
                                        userid = mydb.getUserIdFromSerrogate(name);
                                        if (learningTag && !(name.Equals("UnknownNull") || name.Equals("UnknownFace")))
                                        {
                                            learnImage    = imageroi;
                                            matchedResult = eigenRecog.Recognise(learnImage);
                                            //matchedResult = fishRecog.Recognise(learnImage);
                                            string[] matchedData = matchedResult.Split(' ');
                                            if ((Double.Parse(matchedData[1]) <= eigenRecog.getRecognizeTreshold) && (Double.Parse(matchedData[1]) != 0))
                                            //if ((Double.Parse(matchedData[1]) <= fishRecog.getRecognizeTreshold) && (Double.Parse(matchedData[1]) != 0))
                                            {
                                                int ItemIndex = 0;
                                                List <double> recogResultSum = new List <double>();
                                                foreach (var item in recogNameResult)
                                                {
                                                    if (mydb.getUserIdFromSerrogate(item).Equals(userid) && !item.Equals("UnknownNull"))
                                                    {
                                                        recogResultSum.Add(recogDistanceResult[ItemIndex]);
                                                    }
                                                    ItemIndex++;
                                                }
                                                meanDistance = recogResultSum.Sum() / recogResultSum.Count;
                                                euclidVal    = falsePositiveCheck(mydb.getComputeResultImage(name), imageroi.Copy());
                                                if (euclidVal < 9000)
                                                {
                                                    confident = (((double)recogResultSum.Count / (double)maxImageCount) * 100) * (1.00 - (euclidVal - (meanDistance * 130 / 100)) / 4500.00);
                                                    if (confident > 100)
                                                    {
                                                        confident = 100;
                                                    }
                                                    if (confident >= 80)
                                                    //if (meanDistance <= fishRecog.getRecognizeTreshold)
                                                    {
                                                        learnImage.Save(folderPath + tempPath);
                                                        plainImage.Save(folderPath + tempPath2);
                                                        Console.WriteLine(folderPath + tempPath);
                                                        string dbPath      = (folderPath + tempPath).Replace("\\", "/");
                                                        string dbPathPlain = (folderPath + tempPath2).Replace("\\", "/");
                                                        mydb.InsertImageTraining(int.Parse(userid), dbPathPlain, dbPath, false);
                                                        //
                                                        //auto train
                                                        //
                                                        if (mydb.getSpecifyImageCount(userid) > 5)
                                                        {
                                                            mydb.DeleteOldestImage(userid);
                                                        }
                                                        //eigenRecog.reloadData();
                                                        //fishRecog.reloadData();
                                                        learningTag = false;
                                                        Console.WriteLine("Learning:" + userid + "  Distance:" + meanDistance);
                                                    }
                                                    else
                                                    {
                                                        Console.WriteLine("Distance:" + meanDistance + "\n");
                                                    }
                                                }
                                            }
                                            if (timestampFlag)
                                            {
                                                Image <Gray, byte> resultImage = imageroi;
                                                resultImage.Save(folderPath + tempPath);
                                                Console.WriteLine(folderPath + tempPath);
                                                string dbPath = (folderPath + tempPath).Replace("\\", "/");
                                                mydb.InsertTimestamp(userid, Environment.MachineName, confident.ToString(), dbPath, meanDistance.ToString(), euclidVal.ToString());
                                                timestampFlag = false;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("recognizing...");
                                        matchedResult = eigenRecog.Recognise(imageroi); //get serro+distance
                                        Console.WriteLine("Result:" + matchedResult + "\n");
                                        string[] matchedData = matchedResult.Split(' ');
                                        if (!matchedResult[0].Equals("UnknownNull") && !matchedResult[0].Equals("UnknownFace"))
                                        {
                                            //Console.WriteLine(matchedData[0] +" "+ matchedData[1]);
                                            recogNameResult.Add(matchedData[0]);
                                            recogDistanceResult.Add(Double.Parse(matchedData[1]));
                                            //File.AppendAllText(@"C:\Users\Xypher\Desktop\test2.csv", matchedData[1]+"\r\n");
                                        }
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    });
                }

                /*stopWatch.Stop();
                 * TimeSpan ts = stopWatch.Elapsed;
                 *
                 * string elapsedTime = String.Format("{0}",ts.TotalMilliseconds * 10000);
                 * stopWatch.Reset();*/
            }
        }
Exemple #4
0
        private void ProcessFrame(object sender, EventArgs arg)
        {
            if (imageFrame != null)
            {
                Image <Gray, byte> greyImage = imageFrame.Copy().Convert <Gray, byte>();


                //greyImage._SmoothGaussian(3);
                //greyImage._EqualizeHist();
                stopWatch.Start();
                var faces = face.Detect(greyImage, 1.2, 6, HAAR_DETECTION_TYPE.FIND_BIGGEST_OBJECT, new Size(120, 120), new Size(200, 200));

                if (faces.Length == 0)
                {
                    var eyeObjects = eyeWithGlass.DetectMultiScale(greyImage, 1.2, 6, minEye, maxEye);
                    if (eyeObjects.Length == 2)
                    {
                        #region comment

                        /*Console.WriteLine("helper");
                         * if(eyeObjects[0].X > eyeObjects[1].X)
                         * {
                         *  var temp = eyeObjects[0];
                         *  eyeObjects[0] = eyeObjects[1];
                         *  eyeObjects[1] = temp;
                         * }
                         * int betweeneLength = eyeObjects[1].X - eyeObjects[0].X;
                         * int middleposition = eyeObjects[0].X + ((betweeneLength + eyeObjects[1].Width )/ 2);
                         * int forheadpeak = (int)(0.8 * betweeneLength);//
                         * int forheadpeakpeak = (int)(0.7 * betweeneLength);//
                         * int forheadbelowpeak = (int)(0.4 * betweeneLength);
                         * int foreheadpoint = (int)(0.6 * betweeneLength);
                         * int neareyebrowpoint = (int)(0.2 * betweeneLength);
                         * int lefteyebrowpoint = eyeObjects[0].X;//
                         * int righteyebrowpoint = eyeObjects[0].X + betweeneLength + eyeObjects[1].Width;//
                         * //int nosepoint =
                         * int xx = (int)((5.0 / 12.0) * betweeneLength);
                         * int xxx = (int)((1.5 / 8.0) * betweeneLength);
                         *
                         * int x1 = (int)((1.0 / 16.0) * betweeneLength);
                         *
                         *
                         * int round = 3;
                         * int around = round-2;
                         * double tempcolor = 0;
                         * for (int i = 0; i<round; i++)
                         * {
                         *  for (int j = 0; j < round; j++)
                         *  {
                         *      tempcolor += greyImage[middleposition - around + i, eyeObjects[0].Y + forheadpeak - around + j].Intensity;
                         *  }
                         * }
                         * Gray skincolor = new Gray(tempcolor/(round*round));
                         * Point[] p = new Point[7];
                         * p[0] = new Point(middleposition, eyeObjects[0].Y - forheadpeak);
                         *
                         * p[1] = new Point(eyeObjects[0].X + (eyeObjects[0].Width / 2), eyeObjects[0].Y - forheadpeakpeak);
                         * p[2] = new Point(eyeObjects[0].X - x1, eyeObjects[0].Y - forheadbelowpeak);
                         * p[3] = new Point(lefteyebrowpoint - xxx, eyeObjects[0].Y + (eyeObjects[0].Height/6));
                         *
                         * p[4] = new Point(righteyebrowpoint + xxx, eyeObjects[0].Y + (eyeObjects[0].Height /6));
                         * p[5] = new Point(righteyebrowpoint + x1, eyeObjects[0].Y - forheadbelowpeak);
                         * p[6] = new Point(eyeObjects[1].X + (eyeObjects[1].Width / 2), eyeObjects[0].Y - forheadpeakpeak);
                         *
                         * //imageFrame.Draw(new Rectangle(new Point(eyeObjects[0].X, eyeObjects[0].Y), new Size(betweeneLength + eyeObjects[1].Width, eyeObjects[0].Height)), new Bgr(Color.Aqua), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(middleposition,eyeObjects[0].Y+ foreheadpoint), 1), new Bgr(Color.Yellow), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(middleposition,eyeObjects[0].Y - forheadpeak), 1), new Bgr(Color.Yellow), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(middleposition, eyeObjects[0].Y - neareyebrowpoint), 1), new Bgr(Color.Gold), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(lefteyebrowpoint - xxx, eyeObjects[0].Y), 1), new Bgr(Color.AliceBlue), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(righteyebrowpoint + xxx, eyeObjects[0].Y), 1), new Bgr(Color.AliceBlue), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(lefteyebrowpoint, eyeObjects[0].Y - neareyebrowpoint), 1), new Bgr(Color.LimeGreen), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(righteyebrowpoint, eyeObjects[0].Y - neareyebrowpoint), 1), new Bgr(Color.LimeGreen), 2);
                         * //imageFrame.DrawPolyline(p,true, new Bgr(Color.Azure), 2);
                         * greyImage.FillConvexPoly(p, skincolor);
                         * //imageFrame.Draw(new CircleF(new PointF(eyeObjects[0].X - x1, eyeObjects[0].Y - forheadbelowpeak), 1), new Bgr(Color.LimeGreen), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(righteyebrowpoint + x1, eyeObjects[0].Y - forheadbelowpeak), 1), new Bgr(Color.LimeGreen), 2);
                         *
                         * //imageFrame.Draw(new CircleF(new PointF(eyeObjects[0].X + (eyeObjects[0].Width / 2), eyeObjects[0].Y - forheadpeakpeak), 1), new Bgr(Color.LimeGreen), 2);
                         * //imageFrame.Draw(new CircleF(new PointF(eyeObjects[1].X + (eyeObjects[1].Width / 2), eyeObjects[0].Y - forheadpeakpeak), 1), new Bgr(Color.LimeGreen), 2);
                         */
                        #endregion
                    }
                    else //not see eye in frame
                    {
                        name              = "Processing...";
                        learningTag       = true;
                        faceRectangle     = Rectangle.Empty;
                        realfaceRectangle = Rectangle.Empty;
                        recogNameResult.Clear();
                        recogDistanceResult.Clear();
                        Console.WriteLine("Clear");
                    }
                }
                else
                {
                    Parallel.ForEach(faces, facecount =>
                    {
                        try
                        {
                            facePosition      = new Point(facecount.rect.X, facecount.rect.Y);
                            faceRectangleSize = new Size(facecount.rect.Width, facecount.rect.Height);
                            faceRectangle     = new Rectangle(facePosition, faceRectangleSize);
                            greyImage.ROI     = faceRectangle;
                            var eyeObjects    = eyeWithGlass.DetectMultiScale(greyImage, 1.2, 6, minEye, maxEye);
                            greyImage.ROI     = System.Drawing.Rectangle.Empty;
                            if (eyeObjects.Length == 2)
                            {
                                Console.WriteLine("eye detected...");
                                if (eyeObjects[0].X > eyeObjects[1].X)
                                {
                                    var temp      = eyeObjects[0];
                                    eyeObjects[0] = eyeObjects[1];
                                    eyeObjects[1] = temp;
                                }

                                int betweeneLength    = eyeObjects[1].X - eyeObjects[0].X;
                                int lefteyebrowpoint  = eyeObjects[0].X;                                        //
                                int righteyebrowpoint = eyeObjects[0].X + betweeneLength + eyeObjects[1].Width; //
                                int xxx = (int)((1.5 / 8.0) * betweeneLength);
                                int neareyebrowpoint = (int)(0.2 * betweeneLength);
                                int faceheight       = (int)(2.3 * betweeneLength);

                                realFacePosition      = new Point(facePosition.X + lefteyebrowpoint - xxx, facePosition.Y + eyeObjects[0].Y - neareyebrowpoint);
                                realfaceRectangleSize = new Size((righteyebrowpoint + xxx) - (lefteyebrowpoint - xxx), faceheight);
                                realfaceRectangle     = new Rectangle(realFacePosition, realfaceRectangleSize);


                                greyImage.ROI = realfaceRectangle;
                                imageroi      = greyImage.Copy();
                                greyImage.ROI = new Rectangle();


                                if (eigenRecog.IsTrained)
                                {
                                    imageroi._EqualizeHist();
                                    imageroi = imageroi.Resize(ROIwidth, ROIheight, INTER.CV_INTER_LINEAR);

                                    //find the most relative face
                                    if (recogNameResult.Count == maxImageCount)
                                    {
                                        Console.WriteLine("Processing...");
                                        int max         = 0;
                                        string mostFace = "";
                                        foreach (string value in recogNameResult.Distinct())
                                        {
                                            Console.WriteLine("\"{0}\" occurs {1} time(s).\n", value, recogNameResult.Count(v => v == value));
                                            if (recogNameResult.Count(v => v == value) > max)
                                            {
                                                max      = recogNameResult.Count(v => v == value);
                                                mostFace = value;
                                            }
                                        }
                                        name = mostFace;
                                        if (learningTag && !(name.Equals("UnknownNull") || name.Equals("UnknownFace")))
                                        {
                                            learnImage           = imageroi;
                                            matchedResult        = eigenRecog.Recognise(learnImage);
                                            string[] matchedData = matchedResult.Split(' ');
                                            if ((Double.Parse(matchedData[1]) <= eigenRecog.getRecognizeTreshold) && (Double.Parse(matchedData[1]) != 0))
                                            {
                                                meanDistance = recogDistanceResult.Sum() / maxImageCount;
                                                if (meanDistance <= eigenRecog.getRecognizeTreshold)
                                                {
                                                    learnImage.Save(tempPath);
                                                    mydb.InsertImageTraining(name, tempPath, false);
                                                    if (mydb.getSpecifyImageCount(name) > 3)
                                                    {
                                                        mydb.DeleteOldestImage(name);
                                                    }
                                                    eigenRecog.reloadData();
                                                    learningTag = false;
                                                    Console.WriteLine("Learning:" + name + "  Distance:" + meanDistance);
                                                }
                                                else
                                                {
                                                    Console.WriteLine("Distance:" + meanDistance + "\n");
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("recognizing...");
                                        matchedResult = eigenRecog.Recognise(imageroi);
                                        Console.WriteLine("Result:" + matchedResult + "\n");
                                        File.AppendAllText(@logFolder + logName + "_ver1.0.txt", "Result:" + matchedResult + "\r\n");
                                        string[] matchedData = matchedResult.Split(' ');
                                        if (!matchedResult[0].Equals("UnknownNull") && !matchedResult[0].Equals("UnknownFace"))
                                        {
                                            //Console.WriteLine(matchedData[0] +" "+ matchedData[1]);
                                            recogNameResult.Add(matchedData[0]);
                                            recogDistanceResult.Add(Double.Parse(matchedData[1]));
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.Write(e);
                        }
                    });
                }
                stopWatch.Stop();
                TimeSpan ts = stopWatch.Elapsed;

                // Format and display the TimeSpan value.
                string elapsedTime = String.Format("{0}",

                                                   ts.TotalMilliseconds * 10000);
                textBox2.Text = elapsedTime;
                //listView1.Items.Add(elapsedTime);
                //File.AppendAllText(@logFolder + logName + "_ver1.0.txt", "Frametime: "+elapsedTime+"\r\n");
                stopWatch.Reset();
            }
        }