private async void Add_Person_Button_Click(object sender, RoutedEventArgs e) { string popupmessage = ""; var db = new SQLiteConnection(_dbPath); db.CreateTable <Person>(); var maximumPrimaryKey = db.Table <Person>().OrderByDescending(m => m.Id).FirstOrDefault(); Person person = new Person() { Id = (maximumPrimaryKey == null ? 1 : maximumPrimaryKey.Id + 1), LastName = LastName_Entry.Text, FirstName = FirstName_Entry.Text, ImagePath = imagepath, DateRegistered = DateTime.UtcNow, ImageName = imageName }; popupmessage = person.LastName + " " + person.FirstName + " will be saved"; //PopUp MessageDialog showDialog = new MessageDialog(popupmessage); showDialog.Commands.Add(new UICommand("Yes") { Id = 0 }); showDialog.Commands.Add(new UICommand("No") { Id = 1 }); showDialog.DefaultCommandIndex = 0; showDialog.CancelCommandIndex = 1; var result = await showDialog.ShowAsync(); if ((int)result.Id == 0) { db.Insert(person); allitem = "The user " + LastName_Entry.Text + " " + FirstName_Entry.Text + ", has been added to the system. You can now sign " + FirstName_Entry.Text + " in for today, or you can go to the people page, to see all users."; readText(allitem); var fileinfo = new FileInfo(imagepath); BlobConstructors.UploadFile(fileinfo, BlobConstructors.Blobconnectionstring, BlobConstructors.containername); LastName_Entry.Text = " "; FirstName_Entry.Text = " "; User_Image.Visibility = Visibility.Collapsed; Capture_Person_Button.Visibility = Visibility.Collapsed; Add_Person_Button.Visibility = Visibility.Collapsed; } else { allitem = "The user " + LastName_Entry.Text + " " + FirstName_Entry.Text + ", has not been added to the system."; readText(allitem); } }
private async void Detect_Person_Button_Click(object sender, RoutedEventArgs e) { var fileinfo = new FileInfo(imagepathHolder); BlobConstructors.UploadFile(fileinfo, BlobConstructors.Blobconnectionstring, BlobConstructors.containername2); IFaceClient client = CompareFaceConstructor.Authenticate(ENDPOINT, SUBSCRIPTION_KEY); // Find Similar - find a similar face from a list of faces. // var result = await CompareFaceConstructor.FindSimilar(client, BlobConstructors.blobBaseUrl, imageName, BlobConstructors.blobBaseUrl2, RecognitionModel.Recognition04, imageNames); string _dbPath = Database_Connection._dbpath; //Verify(client, IMAGE_BASE_URL, RECOGNITION_MODEL4).Wait(); //// Identify - recognize a face(s) in a person group (a person group is created in this example). /// GetRecognisedUserViewModel Identity = new GetRecognisedUserViewModel(); try { Identity = await CompareFaceConstructor.IdentifyInPersonGroup(client, personDictionary, BlobConstructors.blobBaseUrl, BlobConstructors.blobBaseUrl2, imageName, RECOGNITION_MODEL4); string Message = ""; var db = new SQLiteConnection(_dbPath); var dz = new SQLiteConnection(_dbPath); db.CreateTable <Models.Person>(); db.CreateTable <Models.Attendance>(); //var p = db.Table<Models.Person>().Where(m => m.ImageName == result.Result).FirstOrDefault(); int way = int.Parse(Identity.highestperson.Name); var p = db.Table <Models.Person>().Where(m => m.Id == way).FirstOrDefault(); var Count = db.Table <Models.Attendance>().Count(); //Books_Label.Text = result.Output.ToString(); //readText(result.ToString()); if (Identity.ConfidenceLevel > 0.7) { Message = "Welcome back " + p.LastName + " " + p.FirstName + " , You have been logged in. Have a pleasant day!"; Books_Label.Text = Identity.Answers; Attendance attendance = new Attendance() { Id = Count + 1, FirstName = p.FirstName, Date_Signed_In_Date_and_Time = DateTime.UtcNow, LastName = p.LastName, User_ID = p.Id }; db.Insert(attendance); readText(Message); } else { var confipercentage = Identity.ConfidenceLevel * 100; Message = "I am not comfortable this is who i think this is. i am only " + confipercentage + " percent sure, that this is" + p.FirstName + " " + p.LastName + "."; readText(Message); } } catch { readText("Face not detected from Image or Server cannot be reached"); } //// LargePersonGroup - create, then get data. //LargePersonGroup(client, IMAGE_BASE_URL, RECOGNITION_MODEL4).Wait(); //// Group faces - automatically group similar faces. //Group(client, IMAGE_BASE_URL, RECOGNITION_MODEL4).Wait(); }