public static void FaceMatch() { var client = new Baidu.Aip.Face.Face(API_KEY, SECRET_KEY); var image1 = File.ReadAllBytes(filename1); var image2 = File.ReadAllBytes(filename2); var images = new byte[][] { image1, image2 }; var result = client.FaceMatch(images); MessageBox.Show(result.ToString()); }
public static void FaceMatch() { var client = new Baidu.Aip.Face.Face("Api Key", "Secret Key"); var image1 = File.ReadAllBytes("图片文件路径"); var image2 = File.ReadAllBytes("图片文件路径"); var image3 = File.ReadAllBytes("图片文件路径"); var images = new byte[][] { image1, image2, image3 }; // 人脸对比 var result = client.FaceMatch(images); }
public static void FaceMatch(string img1, string img2, string img3) { var client = new Baidu.Aip.Face.Face(AiKeySecret.ApiKey, AiKeySecret.SecretKey); var image1 = File.ReadAllBytes(img1); var image2 = File.ReadAllBytes(img2); var image3 = File.ReadAllBytes(img3); var images = new byte[][] { image1, image2, image3 }; // 人脸对比 var result = client.FaceMatch(images); }
public static String GetFaceMatch(string imgpath1, string imgpath2) { var client = new Baidu.Aip.Face.Face(API_KEY, SECRET_KEY); var image1 = File.ReadAllBytes(imgpath1); var image2 = File.ReadAllBytes(imgpath2); var images = new byte[][] { image1, image2 }; // 人脸对比 var result = client.FaceMatch(images); return(result.ToString()); }
public void Face() { var client = new Baidu.Aip.Face.Face("uGU69Iudv3GFAePr1ZOZWGzp", "U7oZ4EatcctoEKXOFCbpSzDyIHEZUW3p"); byte[] bytes = new byte[_imageStream.Length]; _imageStream.Read(bytes, 0, bytes.Length); // 设置当前流的位置为流的开始 _imageStream.Seek(0, SeekOrigin.Begin); var images = new byte[][] { bytes, bytes }; // 人脸对比 var result = client.FaceMatch(images); }
private void faceMatching() { if (videoSource == null) { MessageBox.Show("请先连接摄像头!"); return; } Bitmap bitmap = new Bitmap(videoSourcePlayer1.GetCurrentVideoFrame()); string fileName = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ff") + ".jpg"; bitmap.Save(@"" + ConfigurationManager.AppSettings["cachePath"] + fileName, ImageFormat.Png); bitmap.Dispose(); var client = new Baidu.Aip.Face.Face(apiKey, apiSecret); var image1 = File.ReadAllBytes(@"" + ConfigurationManager.AppSettings["cachePath"] + fileName); var image2 = File.ReadAllBytes(@"" + ConfigurationManager.AppSettings["imgPath"]); var images = new byte[][] { image1, image2 }; var result = client.FaceMatch(images); JToken num; try { num = result["result"][0]; } catch (Exception) { textBox1.Text = "未检测到人脸"; openApplication(); return; } StringBuilder sb = new StringBuilder(); foreach (JProperty jp in num) { if (jp.Name == "score") { if (Convert.ToDouble(jp.Value) > Convert.ToDouble(ConfigurationManager.AppSettings["threshold"])) { res = jp.Value.ToString(); this.textBox1.Text = res; MiniMizeAppication(ConfigurationManager.AppSettings["broswer"]); } else { openApplication(); } } } }
private void Border_MouseDown(object sender, MouseButtonEventArgs e) { try { vce.Play(); RenderTargetBitmap bmp = new RenderTargetBitmap( (int)vce.ActualWidth, (int)vce.ActualHeight, 96, 96, PixelFormats.Default); bmp.Render(vce); BitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); using (MemoryStream ms = new MemoryStream()) { encoder.Save(ms); byte[] a = ms.ToArray(); byte[] b = Convert.FromBase64String(He.TextDecrypt(File.ReadAllText(He.lsd.NAME + ".FaceData"), FanyiBox.MD5.EncryptToMD5string(He.lsd.NAME + ".FaceData"))); vce.Stop(); var client = new Baidu.Aip.Face.Face("75bl82qIt9Rtly6Na6wqYUmm", "pMO9ZSQSsZFNvMMnXy5L3GaQbpWG6Fyw"); var images = new byte[][] { a, b }; var result = double.Parse(client.FaceMatch(images).First.First.Last.Last.First.ToString()); if (result >= 90) { if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + He.lsd.NAME + "@qq.com.st")) { He.Settings = (SettingsData)JSON.JsonToObject(Encoding.Default.GetString(Convert.FromBase64String(He.TextDecrypt(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + He.lsd.NAME + "@qq.com.st"), FanyiBox.MD5.EncryptToMD5string(He.lsd.NAME + "@qq.com.st")))), He.Settings); } else { He.SaveSettings(He.lsd.NAME + "@qq.com"); } (Resources["OnLoaded1"] as Storyboard).Begin(); tr.Start(); } else { txb.Text = "识别失败"; } } } catch { txb.Text = "识别失败"; } }
private void btnanew_Click(object sender, RoutedEventArgs e) { try { vce.Play(); SaveControlImage(b, "bp.jpg"); vce.Stop(); var client = new Baidu.Aip.Face.Face("zrvhwm0GTemGprS7VX8MsOAY", "2PGAdCX0eO0G3IHlGNmeEu65zhWeHK5a"); var image1 = File.ReadAllBytes("b.jpg"); var image2 = File.ReadAllBytes("bp.jpg"); var images = new byte[][] { image1, image2 }; var result = double.Parse(client.FaceMatch(images).First.First.Last.Last.First.ToString()); if (result >= 90) { Title = "识别成功"; } else { Title = "识别失败"; } } catch { Title = "识别失败"; } }
private void btnanew_Click(object sender, RoutedEventArgs e) { try { vce.Play(); SaveControlImage(b, "bp.jpg"); vce.Stop(); var client = new Baidu.Aip.Face.Face("API KEY", "Secret Key"); var image1 = File.ReadAllBytes("b.jpg"); var image2 = File.ReadAllBytes("bp.jpg"); var images = new byte[][] { image1, image2 }; var result = double.Parse(client.FaceMatch(images).First.First.Last.Last.First.ToString()); if (result >= 90) { Title = "识别成功"; } else { Title = "识别失败"; } } catch { Title = "识别失败"; } }
private void btnanew_Click(object sender, RoutedEventArgs e) { try { vce.Play(); SaveControlImage(b, "bp.jpg"); vce.Stop(); //这的KEY可以到百度申请,链接:https://console.bce.baidu.com/ai/?fromai=1#/ai/face/app/list var client = new Baidu.Aip.Face.Face("apiKey", "secretKey"); var image1 = File.ReadAllBytes("b.jpg"); var image2 = File.ReadAllBytes("bp.jpg"); var images = new byte[][] { image1, image2 }; var result = double.Parse(client.FaceMatch(images).First.First.Last.Last.First.ToString()); if (result >= 90) { Title = "识别成功"; } else { Title = "识别失败"; } } catch { Title = "识别失败"; } }