public static void InitEngines()
        {
            //读取配置文件
            AppSettingsReader reader   = new AppSettingsReader();
            string            appId    = (string)reader.GetValue("APP_ID", typeof(string));
            string            sdkKey64 = (string)reader.GetValue("SDKKEY64", typeof(string));
            string            sdkKey32 = (string)reader.GetValue("SDKKEY32", typeof(string));

            var is64CPU = Environment.Is64BitProcess;

            if (is64CPU)
            {
                if (string.IsNullOrWhiteSpace(appId) || string.IsNullOrWhiteSpace(sdkKey64))
                {
                    MessageBox.Show("请在App.config配置文件中先配置APP_ID和SDKKEY64!");
                    return;
                }
            }
            else
            {
                if (string.IsNullOrWhiteSpace(appId) || string.IsNullOrWhiteSpace(sdkKey32))
                {
                    MessageBox.Show("请在App.config配置文件中先配置APP_ID和SDKKEY32!");
                    return;
                }
            }

            //激活引擎    如出现错误,1.请先确认从官网下载的sdk库已放到对应的bin中,2.当前选择的CPU为x86或者x64
            int retCode = 0;

            try
            {
                retCode = ASIDCardFunctions.ArcSoft_FIC_Activate(appId, is64CPU ? sdkKey64 : sdkKey32);
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("无法加载 DLL") > -1)
                {
                    MessageBox.Show("请将sdk相关DLL放入bin对应的x86或x64下的文件夹中!");
                }
                else
                {
                    MessageBox.Show("激活引擎失败!");
                }
                return;
            }
            Console.WriteLine("Activate Result:" + retCode);

            //初始化引擎
            retCode = ASIDCardFunctions.ArcSoft_FIC_InitialEngine(ref pEngine);
            Console.WriteLine("InitEngine Result:" + retCode);
            if (retCode != 0)
            {
                MessageBox.Show(string.Format("引擎初始化失败!错误码为:{0}\n", retCode));
                return;
            }
        }
Exemple #2
0
        /// <summary>
        /// 证件照特征提取
        /// </summary>
        /// <param name="hFICEngine">FIC 引擎Handle</param>
        /// <param name="isVideo">人脸数据类型 1-视频 0-静态图片</param>
        /// <param name="bitmap">人脸图像原始数据</param>
        /// <returns>人脸特征提取结果</returns>
        public static int IdCardDataFeatureExtraction(IntPtr hFICEngine, Image image)
        {
            lock (locks)
            {
                if (image.Width % 4 != 0)
                {
                    image = ImageUtil.ScaleImage(image, image.Width - (image.Width % 4), image.Height);
                }
                //Bitmap bitmap = new Bitmap(image);
                ASVLOFFSCREEN offInput = ImageUtil.ReadBmp(image);

                IntPtr offInputPtr = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASVLOFFSCREEN>());
                MemoryUtil.StructureToPtr(offInput, offInputPtr);

                IntPtr faceResPtr = MemoryUtil.Malloc(MemoryUtil.SizeOf <AFIC_FSDK_FACERES>());
                int    result     = ASIDCardFunctions.ArcSoft_FIC_IdCardDataFeatureExtraction(hFICEngine, offInputPtr);
                MemoryUtil.Free(offInput.ppu8Plane[0]);
                MemoryUtil.Free(offInputPtr);
                MemoryUtil.Free(faceResPtr);
                return(result);
            }
        }
Exemple #3
0
        /// <summary>
        /// 人脸特征提取
        /// </summary>
        /// <param name="hFICEngine">FIC 引擎Handle</param>
        /// <param name="isVideo">人脸数据类型 1-视频 0-静态图片</param>
        /// <param name="bitmap">人脸图像原始数据</param>
        /// <returns>人脸检测结果</returns>
        public static int FaceDataFeatureExtraction(IntPtr hFICEngine, bool isVideo, Bitmap bitmap, ref AFIC_FSDK_FACERES faceRes)
        {
            lock (locks)
            {
                int result = -1;
                if (bitmap != null)
                {
                    ASVLOFFSCREEN offInput = ImageUtil.ReadBmp(bitmap);

                    IntPtr offInputPtr = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASVLOFFSCREEN>());
                    MemoryUtil.StructureToPtr(offInput, offInputPtr);

                    IntPtr faceResPtr = MemoryUtil.Malloc(MemoryUtil.SizeOf <AFIC_FSDK_FACERES>());
                    result  = ASIDCardFunctions.ArcSoft_FIC_FaceDataFeatureExtraction(hFICEngine, isVideo, offInputPtr, faceResPtr);
                    faceRes = MemoryUtil.PtrToStructure <AFIC_FSDK_FACERES>(faceResPtr);
                    MemoryUtil.Free(offInput.ppu8Plane[0]);
                    MemoryUtil.Free(offInputPtr);
                    MemoryUtil.Free(faceResPtr);
                }
                return(result);
            }
        }
Exemple #4
0
 /// <summary>
 /// 人证比对
 /// </summary>
 /// <param name="pSimilarScore">FIC 引擎Handle</param>
 /// <param name="pResult">人脸数据类型 1-视频 0-静态图片</param>
 /// <param name="hFICEngine">引擎Handle</param>
 /// <param name="threshold">引擎Handle</param>
 /// <returns>人脸比对结果</returns>
 public static int FaceIdCardCompare(ref float pSimilarScore, ref int pResult, IntPtr hFICEngine, float threshold = 0.82f)
 {
     return(ASIDCardFunctions.ArcSoft_FIC_FaceIdCardCompare(hFICEngine, threshold, ref pSimilarScore, ref pResult));
 }