public static RollSystemMobile.Models.RecognizerResult RecognizeStudentForAttendance(int RollCallID, String ImagePath)
        {
            //Dua ID cua roll call, cac hinh da up, cho ra danh sach ket qua

            FaceRecognizer FaceRec = CreateRollCallRecognizer(RollCallID);


            RollSystemMobile.Models.RecognizerResult Result = RecognizeFromImage(FaceRec, ImagePath);

            //Dung xong nho dispose cho nhe bo nho
            FaceRec.Dispose();
            return(Result);
        }
        private static RollSystemMobile.Models.RecognizerResult RecognizeFromImage(FaceRecognizer FaceRec, String ImagePath)
        {
            RollSystemMobile.Models.RecognizerResult Result = new RollSystemMobile.Models.RecognizerResult();
            //Lay moi ten anh, ko lay toan bo duong dan
            Result.ImageLink = System.IO.Path.GetFileName(ImagePath);

            //Dua anh vao, dua ket qua ra
            if (Haar == null)
            {
                Haar = new HaarCascade(HAAR_XML_PATH);
            }

            //Chuyen anh trang den roi bat dau recognize
            Image <Bgr, byte>  RawImage = new Image <Bgr, byte>(ImagePath);
            Image <Gray, byte> Image    = RawImage.Clone().Convert <Gray, byte>();

            var FacesDetected = Image.DetectHaarCascade(Haar, DETECT_SCALE, MIN_NEIGHBOR,
                                                        0, new System.Drawing.Size(MIN_SIZE, MIN_SIZE))[0];

            foreach (var Face in FacesDetected)
            {
                RollSystemMobile.Models.FaceRegion FaceReg = new RollSystemMobile.Models.FaceRegion(Face.rect.X, Face.rect.Y,
                                                                                                    Face.rect.Width, Face.rect.Height);

                //Nhan dien face la cua ai.
                Image <Gray, byte> FaceImage = Image.Copy(Face.rect).Resize(TRAINING_DATA_SIZE,
                                                                            TRAINING_DATA_SIZE, INTER.CV_INTER_CUBIC);
                FaceImage._EqualizeHist();
                FaceRecognizer.PredictionResult PR = FaceRec.Predict(FaceImage);
                FaceReg.StudentID   = PR.Label;
                FaceReg.StudentName = GetUserName(PR);
                Result.FaceList.Add(FaceReg);
            }

            return(Result);
        }