Beispiel #1
0
        /// <summary>
        /// 获取性别信息
        /// </summary>
        /// <returns></returns>
        public string GetGender()
        {
            var faceinfo = DetectFaces();

            ASFAPI.ASFProcess(hEngine, bitmapImage.Width, bitmapImage.Height, bitmapImage.Format, bitmapImage.ImageData, faceinfo, (int)(EngineMode.性别识别));
            GenderInfo gender = new GenderInfo();

            ASFAPI.ASFGetGender(hEngine, ref gender);
            int[] genderArray = new int[gender.num];
            Marshal.Copy(gender.genderArray, genderArray, 0, genderArray.Length);
            switch (genderArray[0])
            {
            case 0:
                return("男");

            case 1:
                return("女");

            default:
                return("未知");
            }
        }
Beispiel #2
0
        /// <summary>
        /// 获取性别信息
        /// </summary>
        /// <returns></returns>
        public string GetGender()
        {
            var faceinfo = DetectFaces();

            if (faceinfo.faceOrient == IntPtr.Zero || faceinfo.faceRect == IntPtr.Zero)
            {
                return("未知");
            }

            var processResult = ASFAPI.ASFProcess(hEngine, bitmapImage.Width, bitmapImage.Height, bitmapImage.Format, bitmapImage.ImageData, faceinfo, (int)(EngineMode.性别识别));

            if (processResult != (int)ResultCode.成功)
            {
                return("未知");
            }

            GenderInfo gender       = new GenderInfo();
            var        genderResult = ASFAPI.ASFGetGender(hEngine, ref gender);

            if (genderResult != (int)ResultCode.成功 || gender.num <= 0)
            {
                return("未知");
            }

            int[] genderArray = new int[gender.num];
            Marshal.Copy(gender.genderArray, genderArray, 0, genderArray.Length);
            switch (genderArray[0])
            {
            case 0:
                return("男");

            case 1:
                return("女");

            default:
                return("未知");
            }
        }
Beispiel #3
0
 public static extern int ASFGetGender(IntPtr hEngine, ref GenderInfo genderInfo);