Ejemplo n.º 1
0
        private async void PostFunc()
        {
            try
            {
                var content = new StringContent(JsonConvert.SerializeObject(DirPath), Encoding.UTF8, "application/json");
                HttpResponseMessage httpResponse;
                try
                {
                    httpResponse = await client.PostAsync(url, content, cts.Token);
                }
                catch (HttpRequestException)
                {
                    await Dispatcher.BeginInvoke(new Action(() =>
                    {
                        MessageBox.Show("NO CONNECTION!", "Info");
                        StopCommandHandler(null, null);
                    }));

                    return;
                }

                if (httpResponse.IsSuccessStatusCode)
                {
                    var item = JsonConvert.DeserializeObject <List <TransferFile> >(httpResponse.Content.ReadAsStringAsync().Result);
                    foreach (var pr in item)
                    {
                        await Dispatcher.BeginInvoke(new Action(() =>
                        {
                            ImgCollection.Add(new ImgInf()
                            {
                                Image = ToBitmapImage(Convert.FromBase64String(pr.Image)),
                                Path = pr.Path,
                                Label = pr.Label,
                                Confidence = pr.Confidence,
                            });

                            LabelInf lbl = LabelsCollection.First(i => i.Label == Convert.ToInt32(pr.Label));
                            lbl.Count++;
                        }));
                    }

                    isProcessing = false;
                }
            }
            catch (OperationCanceledException)
            {
                await Dispatcher.BeginInvoke(new Action(() =>
                {
                    MessageBox.Show("RECOGNITION WAS STOPPED!", "Info");
                }));
            }
        }
Ejemplo n.º 2
0
        private void LbOLC_SelectionChanged(object sender, EventArgs e)
        {
            OneLabelCollection.Clear();
            LabelInf lbl = LbOLC.SelectedItem as LabelInf;

            if (lbl != null)
            {
                var q = from i in ImgCollection
                        where i.Label == lbl.Label
                        select i.Image;

                foreach (BitmapImage b in q)
                {
                    OneLabelCollection.Add(new OneLabel()
                    {
                        Image = b
                    });
                }
            }
        }