/// <summary>
        ///
        /// </summary>
        /// <param name="hadFaceInfo"></param>
        /// <param name="ageInfo"></param>
        /// <param name="genderInfo"></param>
        /// <param name="face3DAngleInfo"></param>
        /// <param name="rgbLiveInfo"></param>
        /// <param name="irLiveInfo"></param>
        /// <param name="maskInfo"></param>
        /// <param name="lanMaskInfo"></param>
        /// <param name="hadRgbLive"></param>
        /// <param name="hadRIrLive"></param>
        /// <param name="i"></param>
        /// <param name="faceInfo"></param>
        private static void SetFaceInfo(bool hadFaceInfo, ASF_AgeInfo ageInfo, ASF_GenderInfo genderInfo, ASF_Face3DAngle face3DAngleInfo, ASF_LivenessInfo rgbLiveInfo
                                        , ASF_LivenessInfo irLiveInfo, ASF_MaskInfo maskInfo, ASF_LandMarkInfo lanMaskInfo, bool hadRgbLive, bool hadRIrLive, int i, FaceInfo faceInfo)
        {
            if (hadFaceInfo)
            {
                if (ageInfo.Num > i)
                {
                    faceInfo.Age = MemoryUtil.PtrToStructure <int>(ageInfo.AgeArray + MemoryUtil.SizeOf <int>() * i);
                }
                else
                {
                    faceInfo.Age = -1;
                }
                if (genderInfo.Num > i)
                {
                    faceInfo.Gender = MemoryUtil.PtrToStructure <int>(genderInfo.GenderArray + MemoryUtil.SizeOf <int>() * i);
                }
                else
                {
                    faceInfo.Gender = -1;
                }

                if (maskInfo.Num > i)
                {
                    faceInfo.Mask = MemoryUtil.PtrToStructure <int>(maskInfo.MaskArray + MemoryUtil.SizeOf <int>() * i);
                }
                else
                {
                    faceInfo.Mask = -1;
                }
                if (lanMaskInfo.Num > i)
                {
                    var faceLandmark = MemoryUtil.PtrToStructure <ASF_FaceLandmark>(lanMaskInfo.Point + MemoryUtil.SizeOf <ASF_FaceLandmark>() * i);
                    faceInfo.FaceLandPoint = new PointF(faceLandmark.X, faceLandmark.Y);
                }
                else
                {
                    faceInfo.FaceLandPoint = new PointF(-1f, -1f);
                }
                if (face3DAngleInfo.Num > i)
                {
                    faceInfo.Face3DAngle.Status = 0;
                    //roll为侧倾角,pitch为俯仰角,yaw为偏航角
                    faceInfo.Face3DAngle.Roll  = MemoryUtil.PtrToStructure <float>(face3DAngleInfo.Roll + MemoryUtil.SizeOf <float>() * i);
                    faceInfo.Face3DAngle.Pitch = MemoryUtil.PtrToStructure <float>(face3DAngleInfo.Pitch + MemoryUtil.SizeOf <float>() * i);
                    faceInfo.Face3DAngle.Yaw   = MemoryUtil.PtrToStructure <float>(face3DAngleInfo.Yaw + MemoryUtil.SizeOf <float>() * i);
                }
                else
                {
                    faceInfo.Face3DAngle.Status = -1;
                }
            }
            else
            {
                faceInfo.Age                = -1;
                faceInfo.Gender             = -1;
                faceInfo.Face3DAngle.Status = -1;
                faceInfo.Mask               = -1;
                faceInfo.FaceLandPoint      = new PointF(-1f, -1f);
            }
            if (hadRgbLive &&
                rgbLiveInfo.Num == 1)
            {
                faceInfo.RgbLive = MemoryUtil.PtrToStructure <int>(rgbLiveInfo.IsLive);
            }
            else
            {
                faceInfo.RgbLive = -2;
            }
            if (hadRIrLive &&
                irLiveInfo.Num == 1)
            {
                faceInfo.IrLive = MemoryUtil.PtrToStructure <int>(irLiveInfo.IsLive);
            }
            else
            {
                faceInfo.IrLive = -2;
            }
        }
예제 #2
0
 public static extern MResult ASFGetMask(IntPtr hEngine, out ASF_MaskInfo maskInfo);
 /// <summary>
 ///
 /// </summary>
 /// <param name="pEngine"></param>
 /// <param name="needFaceInfo"></param>
 /// <param name="needRgbLive"></param>
 /// <param name="multiFaceInfo"></param>
 /// <param name="hadFaceInfo"></param>
 /// <param name="ageInfo"></param>
 /// <param name="genderInfo"></param>
 /// <param name="face3DAngleInfo"></param>
 /// <param name="rgbLiveInfo"></param>
 /// <param name="hadRgbLive"></param>
 /// <param name="pMultiFaceInfo"></param>
 /// <param name="aSF_MaskInfo"></param>
 /// <param name="lanMaskInfo"></param>
 /// <returns></returns>
 private static int[] ReadyFaceinStruct(IntPtr pEngine, bool needFaceInfo, bool needRgbLive, ASF_MultiFaceInfo multiFaceInfo,
                                        ref bool hadFaceInfo, ref ASF_AgeInfo ageInfo, ref ASF_GenderInfo genderInfo, ref ASF_Face3DAngle face3DAngleInfo,
                                        ref ASF_LivenessInfo rgbLiveInfo, ref bool hadRgbLive, IntPtr pMultiFaceInfo, ref ASF_MaskInfo aSF_MaskInfo, ref ASF_LandMarkInfo lanMaskInfo)
 {
     if (pMultiFaceInfo != IntPtr.Zero)
     {
         if (needFaceInfo &&
             multiFaceInfo.FaceNum > 0)
         {
             hadFaceInfo     = true;
             ageInfo         = AgeEstimation(pEngine);
             genderInfo      = GenderEstimation(pEngine);
             face3DAngleInfo = Face3DAngleDetection(pEngine);
             aSF_MaskInfo    = MaskEstimation(pEngine);
             lanMaskInfo     = FaceLandEstimation(pEngine);
         }
         if (needRgbLive &&
             multiFaceInfo.FaceNum == 1)
         {
             hadRgbLive  = true;
             rgbLiveInfo = LivenessInfo_RGB(pEngine);
         }
         MemoryUtil.Free(ref pMultiFaceInfo);
     }
     int[] orienArry;
     if (multiFaceInfo.FaceNum > 0)
     {
         orienArry = new int[multiFaceInfo.FaceNum];
         Marshal.Copy(multiFaceInfo.FaceOrients, orienArry, 0, multiFaceInfo.FaceNum);
     }
     else
     {
         orienArry = new int[] { };
     }
     return(orienArry);
 }