基本信息
源码名称:基于Dlib FaceRecognitionDotNet 高精度人脸识别实例-亲测可用【精品】
源码大小:535.13M
文件格式:.rar
开发语言:C#
更新时间:2019-11-20
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 20 元 
   源码介绍

基于Dlib FaceRecognitionDotNet 高精度人脸识别实例-亲测可用【精品】

窗体是本人加的,你们也可以加一个WinForm项目调用即可。


 /// <summary>
        /// 
        /// </summary>
        /// <param name="imageBytes"></param>
        /// <returns></returns>
        public static string FaceRecognitionForIamge(byte[] imageBytes)
        {
            if (imageBytes.Length > 0)
            {
                var bitmap = ToFormat24bpprgb(imageBytes);
                var array2d = bitmap.ToArray2D<RgbPixel>();
                bitmap.Dispose();
                var bytes = array2d.ToBytes();
                var image1 = FaceRecognition.LoadImage(bytes, array2d.Rows, array2d.Columns, 3);
                array2d.Dispose();
                var endodings1 = _FaceRecognition.FaceEncodings(image1).ToArray();
                image1.Dispose();
                if (endodings1.Length > 0)
                {
                    var list = FaceRecognition.CompareFaces(_faceDictionary.Keys.ToList(), endodings1[0], _tolerance).ToList<FaceEncodingData>();
                    
                    foreach (var endoding in endodings1)
                    {
                        endoding.Dispose();
                    }
                    if (list.Count > 0)
                    {
                        //Dictionary<string, double> dic = new Dictionary<string, double>();
                        Dictionary<double, string> dic = new Dictionary<double, string>();
                        for (int i = 0; i < list.Count; i  )
                        {
                            string temp = "";
                            if (!dic.TryGetValue(list[i].distance, out temp))
                            {
                                dic.Add(list[i].distance, _faceDictionary[list[i].faceEncoding]);
                            }
                        }
                        var item = dic.OrderBy(p => p.Key).ToDictionary(p => p.Key, o => o.Value).First();
                        return "人员姓名:" item.Value   "|相似度:"  Math.Round((1 - item.Key) * 100,1);
                    }
                    else
                    {
                        return "不在人脸库";
                    }
                }
                else
                {
                    return "没有检测到人脸";
                }
            }
            else { return "错误"; }
        }