Esempio n. 1
0
        private async void PredictCommand_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                DisplayStandByGraphic("Predicting...");

                _predictor.Locator = Context.FaceDetection == FaceDetectionOption.Hog ? _hogLocator : _haarLocator;
                var rs = new List <Result>();
                await Task.Run(() =>
                {
                    // Tensorflow session was created in a different thread.
                    _predictor.GetDefault();
                    rs = _predictor.Fit(Context.PicturePath);
                });

                if (rs.Count == 0)
                {
                    MessageBox.Show("not found");
                    return;
                }

                _annotator.Option = Context.Annotation;
                var rsImg = _annotator.Annotate(Context.PicturePath, rs);
                ImageUtils.DisplayImage(rsImg, "Result");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButton.OK);
            }
            finally
            {
                DisplayDefaultGraphic();
            }
        }