/// <summary>
        /// 提取人脸特征
        /// </summary>
        /// <param name="pEngine">引擎Handle</param>
        /// <param name="imageInfo">图像数据</param>
        /// <param name="multiFaceInfo">人脸检测结果</param>
        /// <returns>保存人脸特征结构体指针</returns>
        public static IntPtr ExtractFaceFeature(IntPtr pEngine, ImageInfo imageInfo, ASF_MultiFaceInfo multiFaceInfo, out ASF_SingleFaceInfo singleFaceInfo)
        {
            singleFaceInfo = new ASF_SingleFaceInfo();
            if (multiFaceInfo.faceRects == null)
            {
                ASF_FaceFeature emptyFeature  = new ASF_FaceFeature();
                IntPtr          pEmptyFeature = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_FaceFeature>());
                UtilToolMemory.StructureToPtr(emptyFeature, pEmptyFeature);
                return(pEmptyFeature);
            }
            singleFaceInfo.faceRect   = UtilToolMemory.PtrToStructure <MRECT>(multiFaceInfo.faceRects);
            singleFaceInfo.faceOrient = UtilToolMemory.PtrToStructure <int>(multiFaceInfo.faceOrients);
            IntPtr pSingleFaceInfo = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_SingleFaceInfo>());

            UtilToolMemory.StructureToPtr(singleFaceInfo, pSingleFaceInfo);

            IntPtr pFaceFeature = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_FaceFeature>());
            int    retCode      = ASFFunctions.ASFFaceFeatureExtract(pEngine, imageInfo.width, imageInfo.height, imageInfo.format, imageInfo.imgData, pSingleFaceInfo, pFaceFeature);

            Console.WriteLine("FR Extract Feature result:" + retCode);

            if (retCode != 0)
            {
                //释放指针
                UtilToolMemory.Free(pSingleFaceInfo);
                UtilToolMemory.Free(pFaceFeature);
                ASF_FaceFeature emptyFeature  = new ASF_FaceFeature();
                IntPtr          pEmptyFeature = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_FaceFeature>());
                UtilToolMemory.StructureToPtr(emptyFeature, pEmptyFeature);
                return(pEmptyFeature);
            }

            //人脸特征feature过滤
            ASF_FaceFeature faceFeature = UtilToolMemory.PtrToStructure <ASF_FaceFeature>(pFaceFeature);

            byte[] feature = new byte[faceFeature.featureSize];
            UtilToolMemory.Copy(faceFeature.feature, feature, 0, faceFeature.featureSize);

            ASF_FaceFeature localFeature = new ASF_FaceFeature();

            localFeature.feature = UtilToolMemory.Malloc(feature.Length);
            UtilToolMemory.Copy(feature, 0, localFeature.feature, feature.Length);
            localFeature.featureSize = feature.Length;
            IntPtr pLocalFeature = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_FaceFeature>());

            UtilToolMemory.StructureToPtr(localFeature, pLocalFeature);

            //释放指针
            UtilToolMemory.Free(pSingleFaceInfo);
            UtilToolMemory.Free(pFaceFeature);

            return(pLocalFeature);
        }
        /// <summary>
        /// 获取图片信息
        /// </summary>
        /// <param name="image">图片</param>
        /// <returns>成功或失败</returns>
        public static ImageInfo ReadImage(Image image)
        {
            ImageInfo         imageInfo = new ImageInfo();
            Image <Bgr, byte> my_Image  = null;
            Bitmap            bitmap    = null;

            try
            {
                bitmap = new Bitmap(image);
                if (bitmap == null)
                {
                    return(null);
                }
                my_Image         = new Image <Bgr, byte>(bitmap);
                imageInfo.format = ASF_ImagePixelFormat.ASVL_PAF_RGB24_B8G8R8;
                imageInfo.width  = my_Image.Width;
                imageInfo.height = my_Image.Height;

                imageInfo.imgData = UtilToolMemory.Malloc(my_Image.Bytes.Length);
                UtilToolMemory.Copy(my_Image.Bytes, 0, imageInfo.imgData, my_Image.Bytes.Length);

                return(imageInfo);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (my_Image != null)
                {
                    my_Image.Dispose();
                }
                if (bitmap != null)
                {
                    bitmap.Dispose();
                }
            }
            return(null);
        }
        /// <summary>
        /// 获取图片IR信息
        /// </summary>
        /// <param name="image">图片</param>
        /// <returns>成功或失败</returns>
        public static ImageInfo ReadBMP_IR(Bitmap bitmap)
        {
            ImageInfo          imageInfo  = new ImageInfo();
            Image <Bgr, byte>  my_Image   = null;
            Image <Gray, byte> gray_image = null;

            try
            {
                //图像灰度转化
                my_Image          = new Image <Bgr, byte>(bitmap);
                gray_image        = my_Image.Convert <Gray, byte>(); //灰度化函数
                imageInfo.format  = ASF_ImagePixelFormat.ASVL_PAF_GRAY;
                imageInfo.width   = gray_image.Width;
                imageInfo.height  = gray_image.Height;
                imageInfo.imgData = UtilToolMemory.Malloc(gray_image.Bytes.Length);
                UtilToolMemory.Copy(gray_image.Bytes, 0, imageInfo.imgData, gray_image.Bytes.Length);

                return(imageInfo);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (my_Image != null)
                {
                    my_Image.Dispose();
                }
                if (gray_image != null)
                {
                    gray_image.Dispose();
                }
            }

            return(null);
        }
        /// <summary>
        /// 提取单人脸特征
        /// </summary>
        /// <param name="pEngine">人脸识别引擎</param>
        /// <param name="image">图片</param>
        /// <param name="singleFaceInfo">单人脸信息</param>
        /// <returns>单人脸特征</returns>
        public static IntPtr ExtractFaceFeature(IntPtr pEngine, Image image, ASF_SingleFaceInfo singleFaceInfo)
        {
            ImageInfo imageInfo = UtilTool.ReadImage(image);

            if (imageInfo == null)
            {
                ASF_FaceFeature emptyFeature  = new ASF_FaceFeature();
                IntPtr          pEmptyFeature = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_FaceFeature>());
                UtilToolMemory.StructureToPtr(emptyFeature, pEmptyFeature);
                return(pEmptyFeature);
            }
            IntPtr pSingleFaceInfo = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_SingleFaceInfo>());

            UtilToolMemory.StructureToPtr(singleFaceInfo, pSingleFaceInfo);

            IntPtr pFaceFeature = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_FaceFeature>());
            int    retCode      = -1;

            try
            {
                retCode = ASFFunctions.ASFFaceFeatureExtract(pEngine, imageInfo.width, imageInfo.height, imageInfo.format, imageInfo.imgData, pSingleFaceInfo, pFaceFeature);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("FR Extract Feature result:" + retCode);

            if (retCode != 0)
            {
                //释放指针
                UtilToolMemory.Free(pSingleFaceInfo);
                UtilToolMemory.Free(pFaceFeature);
                UtilToolMemory.Free(imageInfo.imgData);

                ASF_FaceFeature emptyFeature  = new ASF_FaceFeature();
                IntPtr          pEmptyFeature = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_FaceFeature>());
                UtilToolMemory.StructureToPtr(emptyFeature, pEmptyFeature);
                return(pEmptyFeature);
            }

            //人脸特征feature过滤
            ASF_FaceFeature faceFeature = UtilToolMemory.PtrToStructure <ASF_FaceFeature>(pFaceFeature);

            byte[] feature = new byte[faceFeature.featureSize];
            UtilToolMemory.Copy(faceFeature.feature, feature, 0, faceFeature.featureSize);

            ASF_FaceFeature localFeature = new ASF_FaceFeature();

            localFeature.feature = UtilToolMemory.Malloc(feature.Length);
            UtilToolMemory.Copy(feature, 0, localFeature.feature, feature.Length);
            localFeature.featureSize = feature.Length;
            IntPtr pLocalFeature = UtilToolMemory.Malloc(UtilToolMemory.SizeOf <ASF_FaceFeature>());

            UtilToolMemory.StructureToPtr(localFeature, pLocalFeature);

            //释放指针
            UtilToolMemory.Free(pSingleFaceInfo);
            UtilToolMemory.Free(pFaceFeature);
            UtilToolMemory.Free(imageInfo.imgData);

            return(pLocalFeature);
        }