private void PopulateProfileMenu() { ToolStripMenuItem pm = new ToolStripMenuItem("Landmark"); PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc(); desc.cuids[0] = PXCMFaceAnalysis.CUID; desc.friendlyName.set(GetCheckedModule()); PXCMBase ft_t = null; if (session.CreateImpl(ref desc, PXCMFaceAnalysis.CUID, out ft_t) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { PXCMFaceAnalysis.Landmark ftl = ft_t.DynamicCast <PXCMFaceAnalysis.Landmark>(PXCMFaceAnalysis.Landmark.CUID); for (uint i = 0; ; i++) { PXCMFaceAnalysis.Landmark.ProfileInfo pinfo; if (ftl.QueryProfile(i, out pinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) { break; } ToolStripMenuItem pm1 = new ToolStripMenuItem((pinfo.labels & PXCMFaceAnalysis.Landmark.Label.LABEL_SIZE_MASK).ToString() + " Points", null, new EventHandler(Profile_Item_Click)); pm.DropDownItems.Add(pm1); } ft_t.Dispose(); } if (pm.DropDownItems.Count > 0) { (pm.DropDownItems[0] as ToolStripMenuItem).Checked = true; } MainMenu.Items.RemoveAt(3); MainMenu.Items.Insert(3, pm); }
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); }
public override void OnFaceLandmarkSetup(ref PXCMFaceAnalysis.Landmark.ProfileInfo finfo) { PXCMFaceAnalysis.Landmark ftl = QueryFace().DynamicCast <PXCMFaceAnalysis.Landmark>(PXCMFaceAnalysis.Landmark.CUID); ftl.QueryProfile(profileIndex, out finfo); }
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; }