private void Administration_ProgressChanged(object sender, GettingTokensProgressReportModel e) { Progress.ImagesProcessed = e.ImagesProcessed; Progress.PercentageComplete = e.ImagesProcessed / Progress.MaxProgress; if (Progress.ImagesProcessed == Progress.MaxProgress) { Progress.Status = "Obrađeno!"; } NotifyOfPropertyChange(() => Progress); }
public GettingTokensProgressBarViewModel(ref GettingTokensProgressReportModel progress, dynamic settings, AdministrationViewModel administration) { Progress = progress; PopupAnimation = settings.PopupAnimation; Placement = settings.Placement; HorizontalOffset = settings.HorizontalOffset; VerticalOffset = settings.VerticalOffset; Width = settings.Width; Height = settings.Height; administration.ProgressChanged += Administration_ProgressChanged; }
public void GetTokens() { Progress = new GettingTokensProgressReportModel(); Progress.MaxProgress = Plants.Sum(x => x.LeafImages.Count);; Progress.ImagesProcessed = 0; Progress.Status = "Obrađivanje..."; dynamic settings = SetSettingsForProgressReportPopup(); Task.Run(() => { foreach (var plant in Plants) { foreach (var leafImage in plant.LeafImages) { ImageProcessor imageProcessor = new ImageProcessor(leafImage); imageProcessor.EdgeDetect(Threshold); imageProcessor.Thinning(); imageProcessor.CheckLines(MinLine); imageProcessor.MarkPoints(Distance); imageProcessor.CalcAngels(); List <LeafToken> leafTokens = imageProcessor.GetTokens(); double[] input = new double[NumberOfInputNodes]; for (int i = 0; i < NumberOfInputNodes; i++) { input[i] = i < leafTokens.Count - 1 ? leafTokens[i].Sin : 0; } double[] output = new double[Plants.Count]; for (int i = 0; i < Plants.Count; i++) { output[i] = i == plant.Id ? 1.0 : 0.0; } DataPoint dataPoint = new DataPoint(input, output); _dataSet.Data.Add(dataPoint); Progress.ImagesProcessed++; NotifyOfPropertyChange(() => Progress); ProgressChanged?.Invoke(this, Progress); } } SaveData(); NotifyOfPropertyChange(() => CanTrainNetwork); }); WindowManager window = new WindowManager(); window.ShowDialog(new GettingTokensProgressBarViewModel(ref _progress, settings, this)); }