Exemplo n.º 1
0
        public Patient UploadAndDetectFaces(byte[] array)
        {
            try
            {
                Stream str = new MemoryStream(array);
                IEnumerable <FaceAttributeType> faceAttributes =
                    new FaceAttributeType[]
                {
                    FaceAttributeType.Gender, FaceAttributeType.Age, FaceAttributeType.Smile,
                    FaceAttributeType.Glasses, FaceAttributeType.FacialHair
                };

                Face[] faces   = faceServiceClient.DetectAsync(str, false, false, faceAttributes).Result;
                var    face    = faces.FirstOrDefault();
                var    patient = new Patient()
                {
                    Age    = (int)face.FaceAttributes.Age,
                    Gender = face.FaceAttributes.Gender.ToLowerInvariant() == "male" ? Gender.Male : Gender.Female
                };

                return(patient);
            }
            catch
            {
                return(PatientGenerator.Create().FirstOrDefault());
            }
        }
Exemplo n.º 2
0
 public Patient Post(string data)
 {
     try
     {
         //string realBase = base64.Substring(base64.IndexOf(',') + 1);
         //realBase = realBase.Trim('\0');
         //byte[] bytes = System.Convert.FromBase64String(base64);
         var base64Data = Regex.Match(data, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value;
         var binData    = Convert.FromBase64String(base64Data);
         var service    = new FaceServiceHelper();
         var info       = service.UploadAndDetectFaces(binData);
         return(info);
     }
     catch (Exception e)
     {
         return(PatientGenerator.Create().FirstOrDefault());
     }
 }
Exemplo n.º 3
0
 public IActionResult Index()
 {
     return(View(PatientGenerator.Create()));
 }