public void UpdateFace(int faceUKey, bool check) { var db = new FacesDBDataContext(_connectionString); var face = db.Faces.Where(x => x.FaceUKey == faceUKey).Single(); face.Selected = check; db.SubmitChanges(); _faceUKeyLookup[faceUKey].Selected = check; }
public int AddPerson(String firstName, String lastName) { var db = new FacesDBDataContext(_connectionString); if (db.Persons .Where(x => x.FirstName.ToUpper() == firstName.ToUpper() && x.LastName.ToUpper() == lastName.ToUpper()) .Count() > 0) throw new ApplicationException("That name already exists."); int id = db.GetID("Persons", 1); var person = new Person() { PersonID = id, FirstName = firstName.Trim(), LastName = lastName.Trim() }; db.Persons.InsertOnSubmit(person); db.SubmitChanges(); _Persons.Add((api.Person) new PersonImpl(firstName.Trim(), lastName.Trim(), id), new List<api.Face>()); return id; }
internal void SaveMatchResults(List<MatchRun> results) { var db = new FacesDBDataContext(_connectionString); foreach (var res in results) { res.MatchRunID = db.GetID("MatchRuns", 1); db.MatchRuns.InsertOnSubmit(res); } db.SubmitChanges(); System.Diagnostics.Debug.WriteLine("Inserting " + results.Count() + " records."); }
public int CreateTrainingRun (String name, String trainingDropZone, int numDimensions, double threshhold, String faceSet, string detectionSettingName, int rows, int cols, Manager.ImageMode mode, Manager.Model model) { var db = new FacesDBDataContext(_connectionString); int faceSetID = db.FaceSets.Where(x => x.Name.Equals(faceSet)).Single().FaceSetID; int detectionSettingID = db.DetectionSettings.Where(x => x.Description.Equals(detectionSettingName)).Single().SettingID; List<Face> tFaces = (from fsm in db.FaceSetMappings join f in db.Faces on fsm.FaceUKey equals f.FaceUKey where fsm.FaceSetID == faceSetID select f).ToList(); String fileNameRoot = trainingDropZone + "\\" + name; String csvFilePath = fileNameRoot + ".csv"; String firstFacePath = null; using (StreamWriter writer = new StreamWriter(csvFilePath)) { foreach (var f in tFaces) { String facePath = _m.GetFacePath(f.PictureID, f.FaceID, false, (api.FaceState)f.FaceStateID); if (firstFacePath == null) firstFacePath = facePath; int? personId = f.PersonID; if (personId == null) personId = -1; String line = facePath + ";" + personId; writer.WriteLine(line); } writer.Flush(); writer.Close(); } if (rows == 0) { var img = System.Drawing.Image.FromFile(firstFacePath); rows = img.Height; cols = img.Width; } System.Diagnostics.Debug.WriteLine("CSV file written to " + csvFilePath); int realNComponents = CAPI.TrainModel(fileNameRoot, false, numDimensions, rows, cols, (int) mode, (int) model); int nextId = db.GetID("TrainingRuns", 1); db.TrainingRuns.InsertOnSubmit(new TrainingRun() { Date = DateTime.Now, Name = name, TrainingRunID = nextId, NumDimensions = realNComponents, Threshold = threshhold, ImageModeID = (int)mode, FaceSetID = faceSetID, ScannerSettingID = detectionSettingID, Rows = rows, Cols = cols, ModelID = (int)model }); db.SubmitChanges(); return tFaces.Count(); }
public void AssignPersonToFace(int personId, int pictureId, int faceId) { var db = new FacesDBDataContext(_connectionString); var face = db.Faces.Where(x => x.PictureID == pictureId && x.FaceID == faceId).Single(); face.PersonID = personId; db.SubmitChanges(); InitCaches(); // todo: don't be so lazy. }
public void CreateFaceSet(String name, List<int> fukeys) { var db = new FacesDBDataContext(_connectionString); CreateFaceSet(db, name, fukeys); db.SubmitChanges(); InitCaches(); }
public void Import(List<Person> newPersons, List<Face> newFaces, String name) { var db = new FacesDBDataContext(_connectionString); db.Persons.InsertAllOnSubmit(newPersons); db.Faces.InsertAllOnSubmit(newFaces); CreateFaceSet(db, name, newFaces); db.SubmitChanges(); InitCaches(); }