/// <summary> /// Displays facial feature points /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FFPCheckbox_Clicked(object sender, RoutedEventArgs e) { Mat tmp = new Mat(); string buttonName = ((RadioButton)sender).Uid; switch (buttonName) { case "ffpRBCurr": if (_preprocessor.ffpCurr != null) { currImageI.Mat.CopyTo(tmp); this.currFFPImg = tmp.ToImage <Bgr, byte>(); FaceInvoke.DrawFacemarks(currFFPImg, _preprocessor.ffpCurr, new MCvScalar(255, 0, 0)); currImage.Source = BitmapSourceConvert.ToBitmapSource(currFFPImg); activeButtonEnumCurr = ActiveButtonEnum.FFP; } break; case "ffpRBNext": if (_preprocessor.ffpCurr != null) { nextImageI.Mat.CopyTo(tmp); this.nextFFPImg = tmp.ToImage <Bgr, byte>(); FaceInvoke.DrawFacemarks(nextFFPImg, _preprocessor.ffpNext, new MCvScalar(255, 0, 0)); nextImage.Source = BitmapSourceConvert.ToBitmapSource(nextFFPImg); activeButtonEnumNext = ActiveButtonEnum.FFP; } break; default: throw new MissingFieldException(); } }
/// <summary> /// Displays delaunay triangulation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DelaunayCheckBox_Clicked(object sender, RoutedEventArgs e) { Mat tmp = new Mat(); string buttonName = ((RadioButton)sender).Uid; switch (buttonName) { case "delaunayRBCurr": if (_preprocessor.delaunayTrianglesCurr != null) { currImageI.Mat.CopyTo(tmp); this.currDelaunayImg = tmp.ToImage <Bgr, byte>(); foreach (Triangle2DF triangle in _preprocessor.delaunayTrianglesCurr) { System.Drawing.Point[] vertices = Array.ConvertAll <PointF, System.Drawing.Point>(triangle.GetVertices(), System.Drawing.Point.Round); using (VectorOfPoint vp = new VectorOfPoint(vertices)) { CvInvoke.Polylines(currDelaunayImg, vp, true, new Bgr(255, 255, 255).MCvScalar); } } currImage.Source = BitmapSourceConvert.ToBitmapSource(currDelaunayImg); activeButtonEnumCurr = ActiveButtonEnum.Delaunay; } break; case "delaunayRBNext": if (_preprocessor.delaunayTrianglesNext != null) { nextImageI.Mat.CopyTo(tmp); this.nextDelaunayImg = tmp.ToImage <Bgr, byte>(); foreach (Triangle2DF triangle in _preprocessor.delaunayTrianglesNext) { System.Drawing.Point[] vertices = Array.ConvertAll <PointF, System.Drawing.Point>(triangle.GetVertices(), System.Drawing.Point.Round); using (VectorOfPoint vp = new VectorOfPoint(vertices)) { CvInvoke.Polylines(nextDelaunayImg, vp, true, new Bgr(255, 255, 255).MCvScalar); } } nextImage.Source = BitmapSourceConvert.ToBitmapSource(nextDelaunayImg); activeButtonEnumNext = ActiveButtonEnum.Delaunay; } break; default: throw new MissingFieldException(); } }
/// <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()); } } }
/// <summary> /// shows images unaltered /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NoneRB_Clicked(object sender, RoutedEventArgs e) { string buttonName = ((RadioButton)sender).Uid; switch (buttonName) { case "noneRBCurr": currImage.Source = BitmapSourceConvert.ToBitmapSource(currImageI); activeButtonEnumCurr = ActiveButtonEnum.None; break; case "noneRBNext": nextImage.Source = BitmapSourceConvert.ToBitmapSource(nextImageI); activeButtonEnumNext = ActiveButtonEnum.None; break; default: throw new MissingFieldException(); } }