Example #1
0
        private async Task SetupVisualization(Windows.Foundation.Size framePizelSize, ImageStream StreamImage, string Genero, string Edad, List <Tuple <string, string, FaceRectangle> > ListaCaraS)
        {
            this.VisualizationCanvas.Children.Clear();


            Image imagenCamaraWeb = new Image();

            imagenCamaraWeb.Width  = 640;
            imagenCamaraWeb.Height = 360;
            imagenCamaraWeb.HorizontalAlignment = HorizontalAlignment.Center;
            imagenCamaraWeb.VerticalAlignment   = VerticalAlignment.Center;
            imagenCamaraWeb.Stretch             = Stretch.Fill;

            BitmapImage imagen           = new BitmapImage();
            var         StreamImageNuevo = StreamImage.AsStream();

            await imagen.SetSourceAsync(StreamImageNuevo.AsRandomAccessStream());

            imagenCamaraWeb.Source = imagen;

            this.VisualizationCanvas.Children.Add(imagenCamaraWeb);

            foreach (var elemento in ListaCaraS)
            {
                double actualWidth  = this.VisualizationCanvas.ActualWidth;
                double actualHeight = this.VisualizationCanvas.ActualHeight;

                if (elemento.Item3 != null && actualWidth != 0 && actualHeight != 0)
                {
                    double widthScale  = framePizelSize.Width / actualWidth;
                    double heightScale = framePizelSize.Height / actualHeight;

                    int       i    = 0;
                    var       face = elemento.Item3;
                    Rectangle box  = new Rectangle();

                    box.Width           = (int)face.Width / (int)widthScale;
                    box.Height          = (int)(face.Height / heightScale);
                    box.Fill            = this.fillBrush;
                    box.Stroke          = this.lineBrush;
                    box.StrokeThickness = this.lineThickness;
                    box.Margin          = new Thickness((uint)(face.Left / widthScale), (uint)(face.Top / heightScale), 0, 0);

                    this.VisualizationCanvas.Children.Add(box);

                    TextBlock texto = new TextBlock();
                    texto.Text       = Genero + " / " + Edad;
                    texto.Margin     = new Thickness((uint)(face.Left / widthScale), (uint)(face.Top / heightScale) - 15, 0, 0);
                    texto.Foreground = this.lineBrush;
                    this.VisualizationCanvas.Children.Add(texto);
                }
            }

            listaCaras.Clear();
        }