Exemple #1
0
        private static void Add(ImageRecognition.Prediction prediction)
        {
            Server.Controllers.RecognitionController.RealTimeAdd(prediction);

            lock (Recognitions)
            {
                var l = (from pic in Recognitions
                         where pic.Title == prediction.Label
                         select pic).FirstOrDefault();

                var q = (from pic in Photos
                         where prediction.Path == pic.Path
                         select pic).FirstOrDefault();

                if (l == null) //first time
                {
                    Recognitions.Add(new Recognition
                    {
                        Title  = prediction.Label,
                        Count  = 1,
                        Photos = new ObservableCollection <Photo> {
                            q
                        }
                    });
                }
                else
                {
                    int index = Recognitions.IndexOf(l);
                    Recognitions[index].Count++;
                    Recognitions[index].Photos.Add(q);
                }
            }
        }
        private void RealTimeAddPrediction(Prediction prediction)
        {
            lock (Recognitions)
            {
                var l = (from pic in Recognitions
                         where pic.Title == prediction.Title
                         select pic).FirstOrDefault();

                var q = (from pic in Photos
                         where pic.Path == prediction.Path
                         select pic).FirstOrDefault();
                App.Current.Dispatcher.Invoke(() =>
                {
                    if (l == null) //first time
                    {
                        Recognitions.Add(new Recognition
                        {
                            Title  = prediction.Title,
                            Count  = 1,
                            Photos = new ObservableCollection <Photo> {
                                q
                            }
                        });
                    }
                    else
                    {
                        int index = Recognitions.IndexOf(l);
                        Recognitions[index].Count++;
                        Recognitions[index].Photos.Add(q);
                    }
                    ImagesCounter++;
                });
            }
        }