예제 #1
0
        /// <summary>
        /// Slider value changed, this method updates the morphed image according to the alpha value of the slider
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            double sliderValue  = mySlider.Value;
            float  updatedAlpha = (float)sliderValue;
            //MorphImage m = new MorphImage(_preprocessor.CurrImageI.Mat, _preprocessor.NextImageI.Mat, _preprocessor.ffpCurr, _preprocessor.ffpNext, updatedAlpha);
            MorphImage m = new MorphImage(_preprocessor.curr, _preprocessor.next, _preprocessor.ffpCurr, _preprocessor.ffpNext, updatedAlpha);

            morphImage.Source = m.GetMorphedImage();
        }
예제 #2
0
        private void MorphButton_Click(object sender, RoutedEventArgs e)
        {
            //MorphImage m = new MorphImage(_preprocessor.CurrImageI.Mat, _preprocessor.NextImageI.Mat, _preprocessor.ffpCurr, _preprocessor.ffpNext, defaultAlpha);

            try
            {
                MorphImage m = new MorphImage(_preprocessor.curr, _preprocessor.next, _preprocessor.ffpCurr, _preprocessor.ffpNext, defaultAlpha);
                morphImage.Source = m.GetMorphedImage();
                mySlider.Value    = 0.5;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Something went wrong: {ex}");
            }
        }
예제 #3
0
        /// <summary>
        /// Displays the PreviewWindow showing the current and next image, and if possible the morphed image
        /// </summary>
        /// <param name="imageDetails"></param>
        /// <param name="images"></param>
        public PreviewWindow(ImageDetails imageDetails, ObservableCollection <ImageDetails> images)
        {
            try
            {
                this.Images = images;
                this.curr   = imageDetails;

                activeButtonEnumCurr = ActiveButtonEnum.None;
                activeButtonEnumNext = ActiveButtonEnum.None;

                DisplayImages();


                if (next != null)
                {
                    RefreshDisplayedImages();
                }
                InitializeComponent();

                if (displayMorphOk)
                {
                    MorphImage m = new MorphImage(_preprocessor.curr, _preprocessor.next, _preprocessor.ffpCurr, _preprocessor.ffpNext, 0.5f);
                    morphImage.Source = m.GetMorphedImage();
                    mySlider.Value    = 0.5;
                }
                else
                {
                    InitializeComponent();
                    var uriSource = new Uri(@"/FaceMorph;component/data/MyDefaultImage.png", UriKind.Relative);
                    morphImage.Source = new BitmapImage(uriSource);
                }
                //InitializeFacesInfoList();
            }

            catch (Exception ex)
            {
                //Write ex.Message to a file
                using (StreamWriter outfile = new StreamWriter(@".\error.txt"))
                {
                    outfile.Write(ex.Message.ToString());
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Changes active pictures
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ChangeActivePicturesButton_Clicked(object sender, RoutedEventArgs e)
        {
            string buttonName = ((Button)sender).Uid;
            int    currIdOld, currIdNew;

            switch (buttonName)
            {
            case "left":
                if (0 >= curr.Id)
                {
                    MessageBox.Show("no next image");
                }
                else
                {
                    currIdOld = curr.Id;
                    currIdNew = currIdOld - 1;
                    ImageDetails newCurrImageDetails = Images.ElementAt(currIdNew);
                    ImageDetails newNextImageDetails = Images.ElementAt(currIdNew + 1);
                    this.curr = newCurrImageDetails;
                    this.next = newNextImageDetails;

                    currImage.Source = BitmapSourceConvert.ToBitmapSource(new Image <Bgr, byte>(curr.Title));
                    nextImage.Source = BitmapSourceConvert.ToBitmapSource(new Image <Bgr, byte>(next.Title));

                    RefreshDisplayedImages();

                    if (displayMorphOk)
                    {
                        DisplayImagesCorrectCB();
                    }
                }
                break;

            case "right":
                currIdOld = curr.Id;
                currIdNew = currIdOld + 1;
                if (Images.Count <= currIdNew + 1)
                {
                    MessageBox.Show("no next image");
                }
                else
                {
                    ImageDetails newCurrImageDetails = Images.ElementAt(currIdNew);
                    ImageDetails newNextImageDetails = Images.ElementAt(currIdNew + 1);
                    this.curr = newCurrImageDetails;
                    this.next = newNextImageDetails;

                    currImage.Source = BitmapSourceConvert.ToBitmapSource(new Image <Bgr, byte>(curr.Title));
                    nextImage.Source = BitmapSourceConvert.ToBitmapSource(new Image <Bgr, byte>(next.Title));

                    RefreshDisplayedImages();
                    //DisplayImages();
                    if (displayMorphOk)
                    {
                        DisplayImagesCorrectCB();
                    }
                }

                break;

            default:
                throw new MissingFieldException();
            }

            if (displayMorphOk)
            {
                MorphImage m = new MorphImage(_preprocessor.curr, _preprocessor.next, _preprocessor.ffpCurr, _preprocessor.ffpNext, 0.5f);
                morphImage.Source = m.GetMorphedImage();
                mySlider.Value    = 0.5;
            }
            else
            {
                var uriSource = new Uri(@"/FaceMorph;component/data/MyDefaultImage.png", UriKind.Relative);
                morphImage.Source = new BitmapImage(uriSource);
            }

            DisplayImages();
        }