I am currently attempting to use C# to submit an image to my Custom Vision Prediction API. I am new to C# and I am having some issues following the tutorial available on the Microsoft Azure website (https://learn.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/use-prediction-api#next-steps).
This tutorial ends with the program returning a JSON-formatted string using this code:
byte[] byteData = GetImageAsByteArray(imageFilePath);
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response = await client.PostAsync(url, content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
With an example of the output being:
{
"Id": "7796df8e-acbc-45fc-90b4-1b0c81b73639",
"Project": "8622c779-471c-4b6e-842c-67a11deffd7b",
"Iteration": "59ec199d-f3fb-443a-b708-4bca79e1b7f7",
"Created": "2019-03-20T16:47:31.322Z",
"Predictions": [
{
"TagId": "d9cb3fa5-1ff3-4e98-8d47-2ef42d7fb373",
"TagName": "cat",
"Probability": 1
},
{
"TagId": "9a8d63fb-b6ed-4462-bcff-77ff72084d99",
"TagName": "dog",
"Probability": 0.1087869
}
]
}
Is it possible to change the code so that it only returns the predictions part of the array? I am aware that there is going to be a solution, but as I mentioned earlier I am very new to C#, have never used JSON before and I haven't managed to find anything online to help solve my problem - but if someone already has, please let me know!
I hope you will be able to help me solve this problem!
Thanks,