private void Start(object sender) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { ClassObserv.Clear(); Observ.Clear(); SelectedClassObserv.Clear(); DirectoryInfo dirInfo = new DirectoryInfo(fbd.SelectedPath); FileInfo[] files = dirInfo.GetFiles("*.jpg"); List <string> imagesNotInBase = new List <string>(); var tmp = DataBaseContext.DataBaseInfo.Include(p => p.Image); foreach (var item in files) { foreach (var it in tmp.Where(p => p.Path == item.FullName && p.Image.ImageBlob.SequenceEqual(File.ReadAllBytes(item.FullName)))) { PredictionResult findPred = new PredictionResult(it.Path, it.ClassLabel); OnPredictionCome(findPred, null, true); } if (!tmp.Any(p => p.Path == item.FullName && p.Image.ImageBlob.SequenceEqual(File.ReadAllBytes(item.FullName)))) { imagesNotInBase.Add(item.FullName); } } Recognition(imagesNotInBase); } }
private void Clear(object sender) { foreach (var item in DataBaseContext.DataBaseInfo) { DataBaseContext.DataBaseInfo.Remove(item); } foreach (var item in DataBaseContext.ClassLabelsInfo) { DataBaseContext.ClassLabelsInfo.Remove(item); } DataBaseContext.SaveChanges(); ClassObserv.Clear(); Observ.Clear(); SelectedClassObserv.Clear(); }