예제 #1
0
        /// <summary>
        /// 引擎资源释放
        /// </summary>
        /// <returns></returns>
        public int UninitFaceEngine()
        {
            if (this.dEngine == IntPtr.Zero)
            {
                return(-1);
            }

            int ret = AFDFunction.AFD_FSDK_UninitialFaceEngine(this.dEngine);

            if (ret == 0)
            {
                this.dEngine = IntPtr.Zero;
            }

            return(ret);
        }
예제 #2
0
        /// <summary>
        /// 初始化人脸检测引擎
        /// </summary>
        /// <returns></returns>
        public int InitFaceEngine()
        {
            if (this.dEngine != IntPtr.Zero)
            {
                return(0);
            }

            IntPtr detectEngine = IntPtr.Zero;
            int    retCode      = AFDFunction.AFD_FSDK_InitialFaceEngine(this.AppID, this.AfdKey, pMem, detectSize, ref detectEngine, (int)AFD_FSDK_OrientPriority.AFD_FSDK_OPF_0_HIGHER_EXT, nScale, nMaxFaceNum);

            if (retCode == 0)
            {
                this.dEngine = detectEngine;
            }
            return(retCode);
        }
예제 #3
0
        /// <summary>
        /// 人脸检测
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public AFD_FSDK_FACERES DetectFace(Bitmap image)
        {
            if (this.dEngine == IntPtr.Zero)
            {
                return(default(AFD_FSDK_FACERES));
            }

            //入参
            IntPtr offInputPtr = MakeImageInput_ASVLOFFSCREEN(image);
            //返参
            AFD_FSDK_FACERES faceRes    = new AFD_FSDK_FACERES();
            IntPtr           faceResPtr = Marshal.AllocHGlobal(Marshal.SizeOf(faceRes));

            int detectResult = AFDFunction.AFD_FSDK_StillImageFaceDetection(this.dEngine, offInputPtr, ref faceResPtr);

            if (detectResult == 0)
            {
                faceRes = (AFD_FSDK_FACERES)Marshal.PtrToStructure(faceResPtr, typeof(AFD_FSDK_FACERES));
            }
            return(faceRes);
        }