private Rectangle createRectangleAroundFace(FaceAnnotation face)
        {
            Rectangle rectangle;

            var firstPointX = face.FdBoundingPoly.Vertices[0].X;
            var firstPointY = face.FdBoundingPoly.Vertices[0].Y;
            var width       = face.FdBoundingPoly.Vertices[1].X - face.FdBoundingPoly.Vertices[0].X;
            var height      = face.FdBoundingPoly.Vertices[2].Y - face.FdBoundingPoly.Vertices[1].Y;

            rectangle = new Rectangle(firstPointX.Value, firstPointY.Value, width.Value, height.Value);

            return(rectangle);
        }
Beispiel #2
0
        private void annotateWithFace(Bitmap bmp, FaceAnnotation face)
        {
            Graphics     graphics = Graphics.FromImage(bmp);
            List <Point> point    = new List <Point>();

            foreach (var item in face.BoundingPoly.Vertices)
            {
                point.Add(new Point(item.X.Value, item.Y.Value));
            }

            point.Add(point[0]);
            graphics.DrawLines(Pens.Aqua, point.ToArray());

            graphics.Dispose();
        }
Beispiel #3
0
        private string GetFaceAttributes(FaceAnnotation fa)
        {
            var props = fa
                        .GetType()
                        .GetProperties()
                        .Where(prop => prop.PropertyType == typeof(Likelihood))
                        .Select(p => new { p.Name, Likelihood = (Likelihood)p.GetValue(fa) })
                        .Where(x => x.Likelihood > Likelihood.Unlikely)
                        .ToDictionary(x => x.Name, x => x.Likelihood.ToString());

            return(new
            {
                Properties = props, fa.PanAngle, fa.TiltAngle, fa.RollAngle
            }.Dump());
        }
        public void annotateWithFace(WriteableBitmap bmp, FaceAnnotation face)
        {
            Rectangle    box   = new Rectangle();
            List <Point> point = new List <Point>();


            foreach (var item in face.BoundingPoly.Vertices)
            {
                point.Add(new Point(item.X.Value, item.Y.Value));
            }


            point.Add(point[0]);

            box.Height = Math.Sqrt(Math.Pow((point[2].X - point[1].X), 2.0) + Math.Pow((point[2].Y - point[1].Y), 2.0));
            box.Width  = Math.Sqrt(Math.Pow((point[1].X - point[0].X), 2.0) + Math.Pow((point[1].Y - point[0].Y), 2.0));
            box.Fill   = this.fillBrush;
            box.Stroke = lineBrush;


            //this.PreviewFrameImage.Children.Add(box);
        }
Beispiel #5
0
        public FaceAnnotationModel(FaceAnnotation faceAnnotation)
        {
            Vertices = new List <VertexModel>();
            foreach (var vertex in faceAnnotation.BoundingPoly.Vertices)
            {
                Vertices.Add(new VertexModel(vertex));
            }

            Landmarks = new List <LandmarkModel>();
            foreach (var landmark in faceAnnotation.Landmarks)
            {
                Landmarks.Add(new LandmarkModel(landmark));
            }

            DetectionConfidence    = faceAnnotation.DetectionConfidence != null ? faceAnnotation.DetectionConfidence.Value : 0;
            AngerLikelihood        = faceAnnotation.AngerLikelihood;
            JoyLikelihood          = faceAnnotation.JoyLikelihood;
            SorrowLikelihood       = faceAnnotation.SorrowLikelihood;
            HeadWearLikelihood     = faceAnnotation.HeadwearLikelihood;
            BlurredLikelihood      = faceAnnotation.BlurredLikelihood;
            UnderexposedLikelihood = faceAnnotation.UnderExposedLikelihood;
            SupriseLikelihood      = faceAnnotation.SurpriseLikelihood;
        }