Esempio n. 1
0
        public override bool OnNewFrame()
        {
            faceAnalysis = QueryFace();
            faceAnalysis.QueryFace(fidx, out faceId, out timeStamp);

            //Get face location
            faceLocation        = (PXCMFaceAnalysis.Detection)faceAnalysis.DynamicCast(PXCMFaceAnalysis.Detection.CUID);
            locationStatus      = faceLocation.QueryData(faceId, out faceLocationData);
            detectionConfidence = faceLocationData.confidence.ToString();

            //Get face attributes (smile, age group, gender, eye blink, etc)
            faceAttributes = (PXCMFaceAnalysis.Attribute)faceAnalysis.DynamicCast(PXCMFaceAnalysis.Attribute.CUID);
            faceAttributes.QueryProfile(PXCMFaceAnalysis.Attribute.Label.LABEL_EYE_CLOSED, 0, out attributeProfile);
            attributeProfile.threshold = 50; //Must be here!
            faceAttributes.SetProfile(PXCMFaceAnalysis.Attribute.Label.LABEL_EYE_CLOSED, ref attributeProfile);
            attributeStatus = faceAttributes.QueryData(PXCMFaceAnalysis.Attribute.Label.LABEL_EYE_CLOSED, faceId, out blink);

            ShowAttributesOnForm();

            //Do the application events
            try
            {
                Application.DoEvents(); //TODO: This should be avoided using a different thread, but how?
            }
            catch (AccessViolationException e)
            {
                //TODO: Handle exception!
            }
            return(true);
        }
Esempio n. 2
0
        public override bool OnNewFrame()
        {
            faceAnalysis = QueryFace();
            faceAnalysis.QueryFace(fidx, out faceId, out timeStamp);

            //Get face location
            faceLocation = (PXCMFaceAnalysis.Detection)faceAnalysis.DynamicCast(PXCMFaceAnalysis.Detection.CUID);
            locationStatus = faceLocation.QueryData(faceId, out faceLocationData);
            detectionConfidence = faceLocationData.confidence.ToString();

            //Get face attributes (smile, age group, gender, eye blink, etc)
            faceAttributes = (PXCMFaceAnalysis.Attribute)faceAnalysis.DynamicCast(PXCMFaceAnalysis.Attribute.CUID);
            faceAttributes.QueryProfile(PXCMFaceAnalysis.Attribute.Label.LABEL_EYE_CLOSED, 0, out attributeProfile);
            attributeProfile.threshold = 50; //Must be here!
            faceAttributes.SetProfile(PXCMFaceAnalysis.Attribute.Label.LABEL_EYE_CLOSED, ref attributeProfile);
            attributeStatus = faceAttributes.QueryData(PXCMFaceAnalysis.Attribute.Label.LABEL_EYE_CLOSED, faceId, out blink);

            //Get face landmarks (eye, mouth, nose position)
            faceLandmark = (PXCMFaceAnalysis.Landmark)faceAnalysis.DynamicCast(PXCMFaceAnalysis.Landmark.CUID);
            faceLandmark.QueryProfile(1, out landmarkProfile);
            faceLandmark.SetProfile(ref landmarkProfile);
            landmarkStatus = faceLandmark.QueryLandmarkData(faceId, PXCMFaceAnalysis.Landmark.Label.LABEL_7POINTS, faceLandmarkData);

            ShowAttributesOnForm();

            //Do the application events
            try
            {
                Application.DoEvents(); //TODO: This should be avoided using a different thread, but how?
            }
            catch (AccessViolationException e)
            {
                //TODO: Handle exception!
            }
            return true;
        }