public void AddFileWithoutFace(string imageFile) { string imageFileLower = imageFile.ToLower(); FaceEncodingInfo faceEncodingInfo = GetFromDB(imageFileLower); if (faceEncodingInfo != null) { throw new Exception($"{imageFile} уже есть в базе!"); } faceEncodingInfo = new FaceEncodingInfo(imageFileLower); _faceCollection.Upsert(faceEncodingInfo); }
public void AddFaceInfo(string imageFile, double[] doubleInfo, int left, int right, int top, int bottom) { string imageFileLower = imageFile.ToLower(); FaceEncodingInfo faceEncodingInfo = GetFromDB(imageFileLower); //if (faceEncodingInfo != null) // throw new Exception($"{imageFile} уже есть в базе!"); if (faceEncodingInfo == null) { faceEncodingInfo = new FaceEncodingInfo(imageFileLower); } FingerAndLocation fingerAndLocation = new FingerAndLocation(); fingerAndLocation.FingerPrint = doubleInfo; fingerAndLocation.Left = left; fingerAndLocation.Right = right; fingerAndLocation.Top = top; fingerAndLocation.Bottom = bottom; var fingerAndLocations = _fingerCollection.Find(f => f.Equals(fingerAndLocation)); if (fingerAndLocations.Any()) { fingerAndLocation.Id = fingerAndLocations.Single().Id; } else { _fingerCollection.Insert(fingerAndLocation); } //if (!faceEncodingInfo.FingerAndLocations.Any(fe => fe.Equals(fingerAndLocation))) if (!faceEncodingInfo.FingerAndLocations.Any(fe => fe.Bottom == fingerAndLocation.Bottom && fe.Left == fingerAndLocation.Left && fe.Right == fingerAndLocation.Right && fe.Top == fingerAndLocation.Top && fe.FingerPrint.SequenceEqual(fingerAndLocation.FingerPrint))) { faceEncodingInfo.FingerAndLocations.Add(fingerAndLocation); } _faceCollection.Upsert(faceEncodingInfo); //var info = _faceCollection.Include(x => x.FingerAndLocations).FindById(imageFile); //if (info.FingerAndLocations.First().Left != faceEncodingInfo.FingerAndLocations.First().Left) // throw new Exception("Данные не сохранились!"); }
public bool UpsertFaceInfo(FaceEncodingInfo info) { return(_faceCollection.Upsert(info)); }