Beispiel #1
0
        //student view image or upload image
        public ActionResult ResonpeRequest(int StudentID, int requestID, IEnumerable <HttpPostedFileBase> ImageFiles)
        {
            ViewBag.RequestID = requestID;
            ViewBag.StudentID = StudentID;
            var student = StuBO.GetStudentByID(StudentID);

            ViewBag.StudentCode = student.StudentCode;
            ViewBag.StudentName = student.FullName;

            List <RecognizerResult> Results = new List <RecognizerResult>();

            foreach (HttpPostedFileBase file in ImageFiles)
            {
                //Save file anh xuong
                String OldPath = Server.MapPath("~/Content/Temp/" + file.FileName);
                file.SaveAs(OldPath);

                //Resize file anh
                String NewPath = Server.MapPath("~/Content/Temp/Resized/" + file.FileName);
                FaceBusiness.ResizeImage(OldPath, NewPath);

                //Nhan dien khuon mat, cho vao danh sach
                RecognizerResult SingleResult = FaceBusiness.DetectFromImage(NewPath);
                Results.Add(SingleResult);
            }
            return(View("StudentImageResult", Results));
        }
Beispiel #2
0
        public ActionResult AddImages(IEnumerable <HttpPostedFileBase> ImageFiles)
        {
            List <RecognizerResult> Results = new List <RecognizerResult>();

            foreach (HttpPostedFileBase file in ImageFiles)
            {
                //Save file anh xuong
                String OldPath = Server.MapPath("~/Content/Temp/" + file.FileName);
                file.SaveAs(OldPath);

                //Resize file anh
                String NewPath = Server.MapPath("~/Content/Temp/Resized/" + file.FileName);
                FaceBusiness.ResizeImage(OldPath, NewPath);

                //Nhan dien khuon mat, cho vao danh sach
                RecognizerResult SingleResult = FaceBusiness.DetectFromImage(NewPath);
                Results.Add(SingleResult);
            }

            //Load may cai selectbox vao day
            var Students = StuBO.GetActiveStudents();

            ViewBag.Students = Students;

            return(View("AddImagesResult", Results));
        }
        public ActionResult CheckAttendanceAuto(int RollCallID, IEnumerable <HttpPostedFileBase> ImageFiles)
        {
            RollCall rollCall = RollBO.GetRollCallByID(RollCallID);

            List <String> ImagePaths = new List <string>();

            foreach (HttpPostedFileBase file in ImageFiles)
            {
                //Save file anh xuong
                String OldPath = Server.MapPath("~/Content/Temp/" + file.FileName);
                file.SaveAs(OldPath);

                //Resize file anh, luu vao thu muc log, ten mon hoc, ten lop
                String NewPath = Server.MapPath("~/Content/Log/"
                                                + rollCall.Class.ClassName + "_"
                                                + rollCall.Subject.ShortName + "_"
                                                + file.FileName);
                FaceBusiness.ResizeImage(OldPath, NewPath);
                ImagePaths.Add(NewPath);
            }
            //Nhan dien tung khuon mat trong anh
            List <RecognizerResult> Result = FaceBusiness.RecognizeStudentForAttendance(RollCallID, ImagePaths);
            //Dua reseult nay cho AttendanceBO xu ly
            AttendanceBusiness AttenBO = new AttendanceBusiness();
            AttendanceLog      Log     = AttenBO.WriteAttendanceAutoLog(RollCallID, Result);


            //Danh sach sinh vien trong log
            StudentBusiness StuBO    = new StudentBusiness();
            List <Student>  Students = StuBO.Find(stu => stu.StudentAttendances.
                                                  Any(attend => attend.LogID == Log.LogID && attend.IsPresent)).ToList();
            RollCall CurrentRollCall = RollBO.GetRollCallByID(RollCallID);

            //Tao model de show trong view
            AttendanceViewModel model = new AttendanceViewModel();

            model.CurrentRollCall = CurrentRollCall;
            model.PresentStudents = Students;
            model.RecognizeResult = Result;

            return(View(model));
        }
Beispiel #4
0
        public ActionResult RecognizeTesting(int RollCallID, IEnumerable <HttpPostedFileBase> ImageFiles)
        {
            List <String> ImagePaths = new List <string>();

            foreach (HttpPostedFileBase file in ImageFiles)
            {
                //Save file anh xuong
                String OldPath = Server.MapPath("~/Content/Temp/" + file.FileName);
                file.SaveAs(OldPath);

                //Resize file anh, luu vao thu muc log, ten mon hoc, ten lop
                String NewPath = Server.MapPath("~/Content/Temp/Resized/" + file.FileName);
                FaceBusiness.ResizeImage(OldPath, NewPath);
                ImagePaths.Add(NewPath);
            }
            //Nhan dien tung khuon mat trong anh
            List <RecognizerResult> Result = FaceBusiness.RecognizeStudentForAttendance(RollCallID, ImagePaths);

            return(View("RecognizeTestingResult", Result));
        }
        public ActionResult CheckAttendanceAuto(int RollCallID, List <HttpPostedFileBase> ImageFiles, DateTime?AttendanceDate)
        {
            RollCallBusiness RollBO  = new RollCallBusiness();
            var           rollCall   = RollBO.GetRollCallByID(RollCallID);
            List <String> ImagePaths = new List <string>();

            foreach (HttpPostedFileBase file in ImageFiles)
            {
                //Save file anh xuong
                String OldPath = Server.MapPath("~/Content/Temp/" + file.FileName);
                file.SaveAs(OldPath);

                //Resize file anh, luu vao thu muc log, nho them ngay thang truoc
                String NewPath = Server.MapPath("~/Content/Log/"
                                                + rollCall.Class.ClassName + "_"
                                                + rollCall.Subject.ShortName + "_"
                                                + file.FileName);
                FaceBusiness.ResizeImage(OldPath, NewPath);
                ImagePaths.Add(NewPath);

                //Nhan dien tung khuon mat trong anh
            }

            List <RecognizerResult> Results = FaceBusiness.RecognizeStudentForAttendance(RollCallID, ImagePaths);
            //Dua result nay cho AttendanceBO xu ly
            AttendanceBusiness AttenBO = new AttendanceBusiness();
            AttendanceLog      Log     = null;

            if (AttendanceDate == null)
            {
                Log = AttenBO.WriteAttendanceAutoLog(RollCallID, Results);
            }
            else
            {
                Log = AttenBO.WriteAttendanceAutoLog(RollCallID, Results, AttendanceDate.Value);
            }

            //Danh sach sinh vien trong log

            List <int> StudentIDs = AttenBO.GetStudentIDList(Results);

            //Lay danh sach sinh vien ton tai trong log
            StudentBusiness StuBO = new StudentBusiness();
            //List<Student> Students = StuBO.Find(stu => StudentIDs.Contains(stu.StudentID)).ToList();

            /*
             * var StudentsJson = Students.ToList().Select(s => new
             * {
             *  studentID = s.StudentID,
             *  studentCode = s.StudentCode,
             *  studentName = s.FullName
             * });
             */

            var StudentsJson = Log.StudentAttendances.Select(sa => new
            {
                studentID   = sa.StudentID,
                studentCode = sa.Student.StudentCode,
                studentName = sa.Student.FullName,
                isPresent   = sa.IsPresent
            });

            return(Json(StudentsJson, JsonRequestBehavior.AllowGet));
        }