Exemplo n.º 1
0
        /// <summary>
        /// 获取年龄信息
        /// </summary>
        /// <returns></returns>
        public int GetAge()
        {
            var faceinfo = DetectFaces();

            if (faceinfo.faceOrient == IntPtr.Zero || faceinfo.faceRect == IntPtr.Zero)
            {
                return(0);
            }

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

            if (processResult != (int)ResultCode.成功)
            {
                return(0);
            }

            AgeInfo age       = new AgeInfo();
            var     ageResult = ASFAPI.ASFGetAge(hEngine, ref age);

            if (ageResult != (int)ResultCode.成功)
            {
                return(0);
            }

            int[] ageArray = new int[age.num];
            Marshal.Copy(age.ageArray, ageArray, 0, ageArray.Length);
            return(ageArray[0]);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取年龄信息
        /// </summary>
        /// <returns></returns>
        public int GetAge()
        {
            var faceinfo = DetectFaces();

            ASFAPI.ASFProcess(hEngine, bitmapImage.Width, bitmapImage.Height, bitmapImage.Format, bitmapImage.ImageData, faceinfo, (int)(EngineMode.年龄识别));
            AgeInfo age = new AgeInfo();

            ASFAPI.ASFGetAge(hEngine, ref age);
            int[] ageArray = new int[age.num];
            Marshal.Copy(age.ageArray, ageArray, 0, ageArray.Length);
            return(ageArray[0]);
        }
Exemplo n.º 3
0
 public static extern int ASFGetAge(IntPtr hEngine, ref AgeInfo ageInfo);