private void GetPic(object _bitmap) { //var image = Convert.ToBase64String(Common.GetFilebyte(_bitmap as Image)); lock (obj) { var faceDetectResponse = client.FaceDetect(_bitmap as Image); if (faceDetectResponse.facemodels.Count == 0) { return; } Image bitmap = null; float avalue = 0; int imgIndex = 0; FaceModel facemodel = null; for (int i = 0; i < faceDetectResponse.facemodels.Count; i++) { var model = faceDetectResponse.facemodels[i]; float o = client.FaceContrast(facetrue1, model.base64feature).similar; if (o > avalue) { avalue = o; facemodel = model; } //bitmap = Common.DrawImage(_bitmap as Image, model.facerectanglex, model.facerectangley, model.facerectanglewidth, model.facerectangleheight); } bitmap = Common.DrawImage(_bitmap as Image, facemodel.facerectanglex, facemodel.facerectangley, facemodel.facerectanglewidth, facemodel.facerectangleheight); Send(bitmap, avalue); } }
private void btnCompar_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(face1true) || string.IsNullOrEmpty(face2true)) { MessageBox.Show("缺少人脸信息"); return; } FaceClient client = new FaceClient("8c1be718fa976083a6940009f36c056e"); var contrast = client.FaceContrast(face1true, face2true); if (contrast != null) { lblCompar.Text = "相似度" + (contrast.similar * 100).ToString("0.00") + "%"; } }