Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
 private void OnPredictionCome(PredictionResult pr, EventArgs e, bool isInBase = false)
 {
     Dispatcherr.BeginInvoke(DispatcherPriority.Background, new Action(() =>
     {
         Observ.Add(new RecognitionModel(pr.Path, pr.ClassLabel));
         int index = -1;
         foreach (var tmp in ClassObserv)
         {
             if (tmp.Item1.Equals(pr.ClassLabel))
             {
                 index = ClassObserv.IndexOf(tmp);
                 break;
             }
         }
         if (index != -1)
         {
             ClassObserv[index] = new Tuple <string, int>(ClassObserv[index].Item1, ClassObserv[index].Item2 + 1);
         }
         else
         {
             ClassObserv.Add(new Tuple <string, int>(pr.ClassLabel, 1));
         }
         if (!isInBase)
         {
             var newElem = new RecognitionModel(pr.Path, pr.ClassLabel);
             DataBaseContext.DataBaseInfo.Add(newElem);
             DataBaseContext.SaveChanges();
             if (DataBaseContext.ClassLabelsInfo.Find(newElem.ClassLabel) == null)
             {
                 DataBaseContext.ClassLabelsInfo.Add(new ClassInfo(newElem.ClassLabel, newElem));
             }
             else
             {
                 DataBaseContext.ClassLabelsInfo.Find(newElem.ClassLabel).RecogModel.Add(newElem);
             }
             DataBaseContext.SaveChanges();
         }
     }));
 }