private void newButton_Click(object sender, EventArgs e) { var db = new SimpleDialogBox("Enter new name", "Last, First", "Last, First"); if (db.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { String[] names = db.GetResult().Split(new char[] {','}); String firstName = "", lastName = ""; lastName = names[0]; if (names.Length > 1) firstName = names[1]; AssignFace(_fm.AddPerson(firstName, lastName)); } catch (Exception ex) { MessageBox.Show("Problem! " + ex.Message); } } RefreshDropDown(); }
private void scanPics() { MessageBox.Show("WARNING: Special test mode"); CAPI.DetectFaceInVideo("1", false, ".", "haarcascade_frontalface_alt2.xml", 1.0); if (XMLFileComboBox.EditValue == null || XMLFileComboBox.EditValue.ToString().Length < 3) { MessageBox.Show("Select an XML file"); return; } String path = Properties.Settings.Default.DetectionDropZone; if (MessageBox.Show("Are you happy with using this path: " + path, "Happy?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { var ofd = new FolderBrowserDialog(); ofd.RootFolder = Environment.SpecialFolder.MyComputer; ofd.Description = "Where are the faces to scan?"; ofd.SelectedPath = Properties.Settings.Default.DetectionDropZone; if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; path = ofd.SelectedPath + "\\"; } var sd = new SimpleDialogBox("Settings", "Enter settings name.\n A subdirectory with this name will be created.", ""); if (sd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; if (sd.GetResult().Equals("")) { MessageBox.Show("Enter something pls."); return; } _fm.ScanFaces(path, sd.GetResult(), XMLFileComboBox.EditValue.ToString()); }
private void ImportScannedFaces_ItemClick(object sender, ItemClickEventArgs e) { var ofd = new OpenFileDialog(); ofd.Filter = "All Files|*.csv"; ofd.Title = "Optional - enter name of mapping file. Columns should be: face file name, first name, last name"; Dictionary<String, int> mappingFile = null; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var persons = _fm.GetPersons().ToDictionary(x => x.Value.DisplayName, x => x.Key); List<String> lines = File.ReadAllLines(ofd.FileName).ToList(); mappingFile = lines.Select(x => x.Split(new char[] { ',' })) .ToDictionary(x => x[0], x => { var displayName = x[2] + ", " + x[1]; return persons[displayName]; }); } var sd1 = new SimpleDialogBox("Enter name", "Enter a name for the face set that will be created:", ""); if (sd1.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string runname = sd1.GetResult().Trim(); pictureBrowserControl1.importAlreadyScanned(runname, null, mappingFile); }
private void mergeFaceSetsButton_ItemClick(object sender, ItemClickEventArgs e) { var sd1 = new SimpleDialogBox("Face Sets", "Enter ';' separated list of face sets to merge", ""); if (sd1.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string lastname = sd1.GetResult().Trim(); var fsetnames = sd1.GetResult().Split(new char[] { ';'}).ToArray(); var fukeys = new List<int>(); foreach (String fsetname in fsetnames) { var fs = _fm.GetFaceSet(fsetname); if (fs.Count() == 0) { MessageBox.Show("Invalid face set name = " + fsetname); return; } fukeys.AddRange(fs); } sd1 = new SimpleDialogBox("Loaded " + fukeys.Count() + " Faces", "Enter name for new face set", ""); if (sd1.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string newname = sd1.GetResult().Trim(); _fm.NewFaceSet(newname, fukeys); }
private void ImportFeretButton_ItemClick(object sender, ItemClickEventArgs e) { var ofd = new FolderBrowserDialog(); ofd.RootFolder = Environment.SpecialFolder.MyComputer; ofd.Description = "Path to already-scanned faces:"; ofd.SelectedPath = Properties.Settings.Default.DetectionDropZone; if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; String path = ofd.SelectedPath + "\\"; var sd1 = new SimpleDialogBox("face set name", "Enter a name for the face set that will be created:", ""); if (sd1.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string runname = sd1.GetResult().Trim(); sd1 = new SimpleDialogBox("last name", "Enter a last name for the persons that will be created:", ""); if (sd1.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string lastname = sd1.GetResult().Trim(); _fm.ImportFeretFaces(path, lastname, runname); pictureBrowserControl1.RefreshPictureGrid(); personBrowserControl1.Init(this); }
private void ImportCSVButton_ItemClick(object sender, ItemClickEventArgs e) { var sd = new SimpleDialogBox("Enter prefix", "Enter prefix (this will be the 'last name' of the pseudo-persons created):", ""); if (sd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string lastname = sd.GetResult().Trim(); var sd1 = new SimpleDialogBox("Enter name", "Enter a name for the face set that will be created:", ""); if (sd1.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string runname = sd1.GetResult().Trim(); var ofd = new OpenFileDialog(); ofd.Filter = "All Files|*.*"; ofd.Title = "Select a CSV file"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { MessageBox.Show("Your file name is " + ofd.FileName); string[] lines = File.ReadAllLines(ofd.FileName); List<String> persons = new List<string>(); Dictionary<String /* face file */, String/* person */> faceDic = new Dictionary<string,string>(); foreach (string line in lines) { string[] items = line.Split(new char[] { ';' }); string person = lastname + "," + items[1].Trim(); if (!persons.Contains(person)) persons.Add(person); faceDic[items[0]] = person; } _fm.ImportCSVFaces(faceDic, runname); pictureBrowserControl1.RefreshPictureGrid(); personBrowserControl1.Init(this); } }
private void importButton_ItemClick(object sender, ItemClickEventArgs e) { var sd1 = new SimpleDialogBox("Enter name", "Enter a name for the face set that will be created:", ""); if (sd1.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string runname = sd1.GetResult().Trim(); if (MessageBox.Show("Cascade File Name is " + XMLFileComboBox.EditValue, "check", MessageBoxButtons.OKCancel) != System.Windows.Forms.DialogResult.OK) return; pictureBrowserControl1.import(runname, (String) XMLFileComboBox.EditValue); }
private void detectionSettingButton_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var dbox = new SimpleDialogBox("Change Face Detection Setting", "New face detection setting ID?", _fm.CurrentSettingID.ToString()); if (dbox.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!_fm.SetSetting(int.Parse(dbox.GetResult()))) MessageBox.Show("That ID does not exist."); else Text = ModelInfo == null ? "Nothing Loaded" : ModelInfo.DescriptionText; } }
private void convertPPMToJPGButton_ItemClick(object sender, ItemClickEventArgs e) { var sd1 = new SimpleDialogBox("path", "Enter directory where PPM files are:", ""); if (sd1.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string dirname = sd1.GetResult().Trim(); _fm.ConvertPPMToJPGButton_ItemClick(dirname); }