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 pnlbg_Click(object sender, EventArgs e) { Panel pnl = sender as Panel; if (pnl != null) { //byte[] bts = Common.GetFilebyte(pnl.BackgroundImage); picSource.Image = pnl.BackgroundImage; FaceClient client = new FaceClient("8c1be718fa976083a6940009f36c056e"); var face = client.FaceDetect(picSource.Image);//获取特征值 //var face = client.FaceDetectAgeAndSex(picSource.Image);//获取特征值 if (face != null && face.facemodels.Count > 0) { byte[] bts = Common.GetFilebyte(pnl.BackgroundImage); Image img = Image.FromStream(new MemoryStream(bts)); foreach (var model in face.facemodels) { string strInfo = string.Format("左眼坐标(X:{0},Y{1}) 右眼坐标(X:{2},Y{3})", model.lefteye.x, model.lefteye.y , model.righteye.x, model.righteye.y); //string strInfo = string.Format("性别:{0},年龄{1}", model.ageandsex.sex == "Female" ? "女" : "男", model.ageandsex.age.ToString("0.00")); img = Common.DrawImage(img, model.facerectanglex, model.facerectangley, model.facerectanglewidth, model.facerectangleheight); } picCheck.Image = img; } } }
private void btn2Select_Click(object sender, EventArgs e) { string filename = SelectPicture(); if (!string.IsNullOrEmpty(filename)) { FaceClient client = new FaceClient("8c1be718fa976083a6940009f36c056e"); byte[] bt = GetFilebyte(filename); var face = client.FaceDetect(bt);//获取特征值 pic2.Image = Image.FromStream(new MemoryStream(bt)); if (face != null && face.facemodels.Count > 0) { face2true = face.facemodels[0].base64feature; } else { MessageBox.Show("未读取到人脸信息"); pic2.Image = null; face2true = string.Empty; } } else { pic2.Image = null; face2true = string.Empty; } }
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) { Send(_bitmap as Image); return; } Image bitmap = null; foreach (var model in faceDetectResponse.facemodels) { bitmap = Common.DrawImage(_bitmap as Image, model.facerectanglex, model.facerectangley, model.facerectanglewidth, model.facerectangleheight); } Send(bitmap); } }
private void loadImage(string filename) { if (!string.IsNullOrEmpty(filename)) { FaceClient client = new FaceClient("8c1be718fa976083a6940009f36c056e"); byte[] bt = Common.GetFilebyte(filename); var face = client.FaceDetect(bt);//获取特征值 //var face = client.FaceDetectAgeAndSex(bt); picSource.Image = Image.FromStream(new MemoryStream(bt)); if (face != null && face.facemodels.Count > 0) { Image img = Image.FromStream(new MemoryStream(bt)); foreach (var model in face.facemodels) { img = Common.DrawImage(img, model.facerectanglex, model.facerectangley, model.facerectanglewidth, model.facerectangleheight); } picCheck.Image = img; } else { MessageBox.Show("未读取到人脸信息"); } } }