Пример #1
0
 public bool QueryFaceLandmarkData(Int32 face, PXCMFaceAnalysis.Landmark.Label label, int idx, out PXCMFaceAnalysis.Landmark.LandmarkData data)
 {
     if (initialized)
     {
         return(QueryFaceLandmarkDataC(instance, face, label, idx, out data));
     }
     data = new PXCMFaceAnalysis.Landmark.LandmarkData();
     return(false);
 }
Пример #2
0
        private void DisplayLocation(PXCMFaceAnalysis ft)
        {
            for (uint i = 0; ; i++)
            {
                int fid; ulong ts;
                if (ft.QueryFace(i, out fid, out ts) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }

                //retrieve face location data
                PXCMFaceAnalysis.Detection.Data rData;
                var ftd     = ft.DynamicCast <PXCMFaceAnalysis.Detection>(PXCMFaceAnalysis.Detection.CUID);
                var rStatus = ftd.QueryData(fid, out rData);

                //Retrieve face landmark data
                PXCMFaceAnalysis.Landmark.ProfileInfo pinfo;
                var ftl = ft.DynamicCast <PXCMFaceAnalysis.Landmark>(PXCMFaceAnalysis.Landmark.CUID);
                ftl.QueryProfile(out pinfo);
                var lData   = new PXCMFaceAnalysis.Landmark.LandmarkData[(int)(pinfo.labels & PXCMFaceAnalysis.Landmark.Label.LABEL_SIZE_MASK)];
                var lStatus = ftl.QueryLandmarkData(fid, pinfo.labels, lData);

                //if (rStatus >= pxcmStatus.PXCM_STATUS_NO_ERROR && lStatus >= pxcmStatus.PXCM_STATUS_NO_ERROR)
                if (rStatus < pxcmStatus.PXCM_STATUS_NO_ERROR || lStatus < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    if (FaceNotAvailable != null)
                    {
                        FaceNotAvailable();
                    }
                }
                else
                {
                    //build facedata
                    FaceData faceData = new FaceData();
                    faceData.Rect   = new Rect(rData.rectangle.x, rData.rectangle.y, rData.rectangle.w, rData.rectangle.h);
                    faceData.Points = lData.Select(p => new System.Windows.Point(p.position.x, p.position.y)).ToList();
                    if (FaceAvailable != null)
                    {
                        FaceAvailable(faceData);
                    }
                }
            }
        }
        public List<Face> QueryFaces()
        {
            List<Face> faces = new List<Face>();

            PXCMFaceAnalysis faceAnalysis = QueryFace();
            PXCMFaceAnalysis.Detection faceLocation = (PXCMFaceAnalysis.Detection)faceAnalysis.DynamicCast(PXCMFaceAnalysis.Detection.CUID);
            PXCMFaceAnalysis.Landmark faceLandmark = (PXCMFaceAnalysis.Landmark)faceAnalysis.DynamicCast(PXCMFaceAnalysis.Landmark.CUID);

            for (uint fidx = 0; ; fidx++)
            {
                int faceId = 0;
                ulong timeStamp;

                pxcmStatus sts = faceAnalysis.QueryFace(fidx, out faceId, out timeStamp);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break; // no more faces

                PXCMFaceAnalysis.Detection.Data faceLocationData;
                pxcmStatus locationStatus = faceLocation.QueryData(faceId, out faceLocationData);
                uint detectionConfidence = faceLocationData.confidence;

                if (locationStatus >= pxcmStatus.PXCM_STATUS_NO_ERROR && faceLocationData.fid != 0)
                {
                    Face face = new Face(faceLocationData);
                    // Face landmarks

                    PXCMFaceAnalysis.Landmark.ProfileInfo landmarkProfile;
                    faceLandmark.QueryProfile(1, out landmarkProfile);
                    faceLandmark.SetProfile(ref landmarkProfile);

                    PXCMFaceAnalysis.Landmark.LandmarkData[] faceLandmarkData = new PXCMFaceAnalysis.Landmark.LandmarkData[7];
                    pxcmStatus landmarkStatus = faceLandmark.QueryLandmarkData(faceId, PXCMFaceAnalysis.Landmark.Label.LABEL_7POINTS, faceLandmarkData);
                    face.AddLandmarks(faceLandmarkData);
                    faces.Add(face);
                }
            }

            return faces;
        }
Пример #4
0
 public bool QueryFaceLandmarkData(Int32 face, PXCMFaceAnalysis.Landmark.Label label, int idx, out PXCMFaceAnalysis.Landmark.LandmarkData data)
 {
     if (instance!=IntPtr.Zero) return QueryFaceLandmarkDataC(instance,face,label,idx,out data);
     data=new PXCMFaceAnalysis.Landmark.LandmarkData();
     return false;
 }
Пример #5
0
 private static extern bool QueryFaceLandmarkDataC(IntPtr pp, Int32 face, PXCMFaceAnalysis.Landmark.Label label, int idx, out PXCMFaceAnalysis.Landmark.LandmarkData data);