Any suggestions on how to get info of the image with a mask through microsoft's cognitive service face recognition?
When I upload an image with headwear or eyeglasses then cognitive service return the image information but when I pick an image with mask, Cognitive service doesn't return any information. That means my implementation of cognitive service is not able to recognise the image with the mask. If anybody have faced this issue and resolved it then please suggest me a solution.
`
public string subscriptionKey = "88c**************************f7"; public string uriBase = "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect"; //Method to pick an image from the gallery async void btnPick_Clicked(object sender, System.EventArgs e) { try { if (!CrossMedia.Current.IsPickPhotoSupported) { return; } var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions { PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium }); if (file == null) return; imgSelected.Source = ImageSource.FromStream(() => { var stream = file.GetStream(); return stream; }); MakeAnalysisRequest(file.Path); } catch (Exception ex) { string test = ex.Message; } } //convert Convert image to byte array public byte[] GetImageAsByteArray(string imageFilePath) { using (FileStream fileStream = new FileStream(imageFilePath, FileMode.Open, FileAccess.Read)) { BinaryReader binaryReader = new BinaryReader(fileStream); return binaryReader.ReadBytes((int)fileStream.Length); } } //Method to get image information from the detection Url public async void MakeAnalysisRequest(string imageFilePath) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey); string requestParameters = "returnFaceId=true&returnFaceLandmarks=false" + "&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses," + "emotion,hair,makeup,occlusion,accessories,blur,exposure,noise"; string uri = uriBase + "?" + requestParameters; HttpResponseMessage response; byte[] byteData = GetImageAsByteArray(imageFilePath); using (ByteArrayContent content = new ByteArrayContent(byteData)) { content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response = await client.PostAsync(uri, content); string contentString = await response.Content.ReadAsStringAsync(); //*************************************************** //Here it return null in case of mask else its working fine //*************************************************** List<ResponseModel> faceDetails = JsonConvert.DeserializeObject<List<ResponseModel>>(contentString); if (faceDetails.Count != 0) { lblTotalFace.Text = "Total Faces : " + faceDetails.Count; lblGender.Text = "Gender : " + faceDetails[0].faceAttributes.gender; lblAge.Text = "Total Age : " + faceDetails[0].faceAttributes.age; Console.WriteLine(faceDetails[0].faceAttributes.accessories.FirstOrDefault(x => x.type == "mask").confidence); } } }
`
@JamesMontemagno Please suggest.
Thanks in advance..!!