Beispiel #1
0
        /**
         * Displays Landmarks by type, as they are defined in the SDK
         * @param Graphics g for the view
         */
        public override void Work(Graphics g)
        {
            if (!guInit)
            {
                GuiInit();
            }
            if (model.FaceAktuell != null)
            {
                PXCMFaceData.LandmarksData lp = model.FaceAktuell.QueryLandmarks();
                if (lp == null)
                {
                    //Console.WriteLine("LandmarksData null, goddamnit!!");
                    g.DrawString("LandmarksData null, goddamnit!!", font, stringBrush, stringRect);
                    return;
                }
                PXCMFaceData.LandmarkPoint lPoint;
                if (((PXCMFaceData.LandmarkType)crossThreadValue) == PXCMFaceData.LandmarkType.LANDMARK_NOT_NAMED)
                {
                    for (int i = 1; i < 33; i++)
                    {
                        lp.QueryPoint(lp.QueryPointIndex((PXCMFaceData.LandmarkType)i), out lPoint);

                        Point p = new Point();

                        p.X = (int)lPoint.image.x;
                        p.Y = (int)lPoint.image.y;

                        g.DrawEllipse(pen, lPoint.image.x - 2, lPoint.image.y - 2, 4, 4);
                    }
                }
                else
                {
                    lp.QueryPoint(lp.QueryPointIndex((PXCMFaceData.LandmarkType)crossThreadValue), out lPoint);

                    Point p = new Point();

                    p.X = (int)lPoint.image.x;
                    p.Y = (int)lPoint.image.y;

                    g.DrawEllipse(pen, lPoint.image.x - 2, lPoint.image.y - 2, 4, 4);
                }
            }
            g.DrawString(((PXCMFaceData.LandmarkType)crossThreadValue).ToString(), font, stringBrush, stringRect);
        }
Beispiel #2
0
        private void GetFaceLandmarks(PXCMFaceData.Face face, out PointF nose, out PointF leftEye, out PointF rightEye, out bool landmarkDetected)
        {
            nose             = PointF.Empty;
            leftEye          = PointF.Empty;
            rightEye         = PointF.Empty;
            landmarkDetected = false;

            PXCMFaceData.LandmarksData landmarksData = face.QueryLandmarks();

            if (landmarksData != null)
            {
                int counter = 0;
                PXCMFaceData.LandmarkPoint noseTip;
                landmarksData.QueryPoint(29, out noseTip);
                if (noseTip != null && noseTip.confidenceImage != 0)
                {
                    nose = new PointF(noseTip.image.x + LandmarkAllignment, noseTip.image.y + LandmarkAllignment);
                    counter++;
                }

                PXCMFaceData.LandmarkPoint lEye;
                landmarksData.QueryPoint(76, out lEye);
                if (lEye != null && lEye.confidenceImage != 0)
                {
                    leftEye = new PointF(lEye.image.x + LandmarkAllignment, lEye.image.y + LandmarkAllignment);
                    counter++;
                }

                PXCMFaceData.LandmarkPoint rEye;
                landmarksData.QueryPoint(77, out rEye);
                if (rEye != null && rEye.confidenceImage != 0)
                {
                    rightEye = new PointF(rEye.image.x + LandmarkAllignment, rEye.image.y + LandmarkAllignment);
                    counter++;
                }

                if (counter == 3)
                {
                    landmarkDetected = true;
                }
            }
        }
        private static void UpdateFaceGeometry(PXCMFaceData.LandmarksData landmarksData)
        {
            if (landmarksData == null)
            {
                return;
            }

            for (int i = 0; i < landmarksData.QueryNumPoints(); i++)
            {
                PXCMFaceData.LandmarkPoint outPoint;
                if (landmarksData.QueryPoint(i, out outPoint))
                {
                    faceGeometry[i] = new Vector(-outPoint.world.x, outPoint.world.y, -outPoint.world.z);
                }
            }
        }
Beispiel #4
0
        public override void Work(Graphics g)
        {
            if (model.FaceAktuell == null)
            {
                return;
            }
            PXCMFaceData.LandmarksData lp = model.FaceAktuell.QueryLandmarks();
            PXCMFaceData.LandmarkPoint point;

            lp.QueryPoint(47, out point);
            lipUpY[0] = point.world.y;
            lp.QueryPoint(48, out point);
            lipUpY[1] = point.world.y;
            lp.QueryPoint(49, out point);
            lipUpY[2] = point.world.y;

            lp.QueryPoint(52, out point);
            lipLowY[0] = point.world.y;
            lp.QueryPoint(51, out point);
            lipLowY[1] = point.world.y;
            lp.QueryPoint(50, out point);
            lipLowY[2] = point.world.y;

            Console.WriteLine(lipUpY[0] + "  " + lipUpY[1] + "  " + lipUpY[2]);
            Console.WriteLine(lipLowY[0] + "  " + lipLowY[1] + "  " + lipLowY[2]);
            float distance = lipUpY[0] - lipLowY[0]
                             + lipUpY[1] - lipLowY[1]
                             + lipUpY[2] - lipLowY[2];

            Console.WriteLine(distance);

            if (distance < .003f)
            {
                g.DrawString("Lips pressed", font, stringBrush, new PointF(20, 20));
            }
        }
Beispiel #5
0
 private PXCMFaceData.LandmarkPoint GetLandmarkPoint(PXCMFaceData.LandmarksData pxcmLandmarksData, PXCMFaceData.LandmarkType landmarkType)
 {
     PXCMFaceData.LandmarkPoint landmarkPoint = null;
     pxcmLandmarksData.QueryPoint(pxcmLandmarksData.QueryPointIndex(landmarkType), out landmarkPoint);
     return(landmarkPoint);
 }