public ShapeModelLearningProgressEventArgs(
     int iterationsCompleted,
     ShapeModel shapeModel,
     ShapeFittingInfo fittingInfo)
 {
     this.IterationsCompleted = iterationsCompleted;
     this.ShapeModel = shapeModel;
     this.FittingInfo = fittingInfo;
 }
예제 #2
0
        private void OnLoadShapeModelButtonClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();
            openDialog.InitialDirectory = @"C:\Users\boya\Source\BayesianShapePrior\ShapeModelLearner\bin\Release";
            if (openDialog.ShowDialog().Value)
            {
                try
                {
                    this.shapeModel = ShapeModel.Load(openDialog.FileName);
                }
                catch (Exception)
                {
                    MessageBox.Show("Something went wrong while loading a model from " + openDialog.FileName);
                    return;
                }

                this.loadMaskToCompleteButton.IsEnabled = true;

                this.traitSetupPanel.Children.Clear();
                this.traitSliders.Clear();
                for (int i = 0; i < this.shapeModel.TraitCount; ++i)
                {
                    Slider slider = new Slider();
                    slider.Value = i == this.shapeModel.TraitCount - 1 ? 1 : 0;
                    slider.Minimum = -3;
                    slider.Maximum = 3;
                    slider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight;
                    slider.TickFrequency = 0.25;
                    slider.ValueChanged += OnSliderValueChanged;

                    traitSliders.Add(slider);
                    this.traitSetupPanel.Children.Add(slider);

                    Label sliderValueLabel = new Label();
                    sliderValueLabel.DataContext = slider;
                    sliderValueLabel.SetBinding(Label.ContentProperty, new Binding("Value"));
                    sliderValueLabel.Margin = new Thickness(5, 5, 5, 15);
                    this.traitSetupPanel.Children.Add(sliderValueLabel);
                }

                this.Sample();
            }
        }
        public void SetBeliefs(ShapeModel shapeModel)
        {
            this.SetPriorBeliefs(shapeModel.GridWidth, shapeModel.GridHeight, shapeModel.TraitCount, shapeModel.ShapePartCount, shapeModel.ObservationNoiseProb);

            this.shapeLocationMeanPrior.ObservedValue = shapeModel.ShapeLocationMean;
            this.shapeLocationPrecisionPrior.ObservedValue = shapeModel.ShapeLocationPrecision;
            this.shapePartOffsetWeightPriors.ObservedValue = shapeModel.ShapePartOffsetWeights;
            this.shapePartLogScaleWeightPriors.ObservedValue = shapeModel.ShapePartLogScaleWeights;
            this.shapePartAngleWeightPriors.ObservedValue = shapeModel.ShapePartAngleWeights;
            this.shapePartOffsetPrecisionPriors.ObservedValue = shapeModel.ShapePartOffsetPrecisions;
            this.shapePartLogScalePrecisionPriors.ObservedValue = shapeModel.ShapePartLogScalePrecisions;
            this.shapePartAnglePrecisionPriors.ObservedValue = shapeModel.ShapePartAnglePrecisions;
        }
예제 #4
0
 private Bitmap GetFittingMask(ShapeModel shapeModel, ShapeFittingInfo fittingInfo)
 {
     Vector[] meanLocations = Util.ArrayInit(fittingInfo.ShapePartLocations[0].Count, i => Vector.FromArray(Util.ArrayInit(2, j => fittingInfo.ShapePartLocations[0][i][j].GetMean())));
     PositiveDefiniteMatrix[] meanOrientations = Util.ArrayInit(fittingInfo.ShapePartOrientations[0].Count, j => fittingInfo.ShapePartOrientations[0][j].GetMean());
     return ImageHelpers.DrawShape(shapeModel.GridWidth, shapeModel.GridHeight, meanLocations, meanOrientations);
 }