Ejemplo n.º 1
0
        private Rectangle MakeRectangle(FeatureCoordinate coord1, FeatureCoordinate coord2)
        {
            var x      = (int)coord1.X;
            var y      = (int)coord1.Y;
            var width  = (int)coord2.X - x;
            var height = (int)coord2.Y - y;

            return(new Rectangle(x, y, width, height));
        }
        private void AddFacialLandmark(Face face, FeatureCoordinate feature, double renderedImageXTransform, double renderedImageYTransform, Color color)
        {
            double    dotSize = 3;
            Rectangle b       = new Rectangle {
                Fill = new SolidColorBrush(color), Width = dotSize, Height = dotSize, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top
            };

            b.Margin = new Thickness(((feature.X - face.FaceRectangle.Left) * renderedImageXTransform) - dotSize / 2, ((feature.Y - face.FaceRectangle.Top) * renderedImageYTransform) - dotSize / 2, 0, 0);
            this.hostGrid.Children.Add(b);
        }
Ejemplo n.º 3
0
        private static PointF convertPointFormation(
            FeatureCoordinate _landmark,
            FaceRectangle _rectangle)
        {
            PointF retPoint = new PointF();

            retPoint.X = (float)((_landmark.X - _rectangle.Left) / _rectangle.Width);
            retPoint.Y = (float)((_landmark.Y - _rectangle.Top) / _rectangle.Height);
            return(retPoint);
        }
Ejemplo n.º 4
0
        public ExFace(Face face)
        {
            _landmarkPointList = new List <Point>();
            _face = face;
            var landmark = face.FaceLandmarks;

            foreach (PropertyInfo propertyInfo in landmark.GetType().GetProperties())
            {
                FeatureCoordinate coordinate = propertyInfo.GetValue(face.FaceLandmarks) as FeatureCoordinate;
                //Console.WriteLine("X = {0},  Y = {1}", coordinate.X, coordinate.Y);
                //Console.WriteLine("---------------------" + propertyInfo.GetValue(landmark));
                _landmarkPointList.Add(new Point((int)coordinate.X, (int)coordinate.Y));
            }
        }
Ejemplo n.º 5
0
        public void DrawLandmark(string name, FeatureCoordinate coordinate)
        {
            var landmark = new LandmarkControl(name);

            landmark.Loaded += (s, e) =>
            {
                Canvas.SetLeft(landmark,
                               this.ScaleXPhotoValueToCanvas((int)coordinate.X) - (landmark.ActualWidth / 2));

                Canvas.SetTop(landmark,
                              this.ScaleYPhotoValueToCanvas((int)coordinate.Y) - (landmark.ActualHeight / 2));
            };

            this.canvasLandmarks.Children.Add(landmark);
        }
Ejemplo n.º 6
0
 // Return a Rectangle (used for drawing landmarks)
 private Rectangle GetRectangle(FeatureCoordinate fl)
 {
     return(new Rectangle((int)fl.X - 1, (int)fl.Y - 1, 2, 2));
 }
Ejemplo n.º 7
0
 static double DistanceSquare(FeatureCoordinate p, FeatureCoordinate q)
 {
     return(Math.Pow(p.X - q.X, 2) + Math.Pow(p.Y - q.Y, 2));
 }
Ejemplo n.º 8
0
 private static double GetDistance(FeatureCoordinate start, FeatureCoordinate end)
 {
     return(Math.Sqrt(Math.Pow((end.X - start.X), 2) + Math.Pow((end.Y - start.Y), 2)));
 }