Created
August 5, 2019 20:23
-
-
Save OlafenwaMoses/bc1475b9a043d63285cb733d0093d3d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
namespace appone | |
{ | |
class Response { | |
public bool success {get;set;} | |
public Object[] predictions {get;set;} | |
} | |
class Object { | |
public string label {get;set;} | |
public float confidence {get;set;} | |
public int y_min {get;set;} | |
public int x_min {get;set;} | |
public int y_max {get;set;} | |
public int x_max {get;set;} | |
} | |
class App { | |
static HttpClient client = new HttpClient(); | |
public static async Task detectFace(string image_path){ | |
var request = new MultipartFormDataContent(); | |
var image_data = File.OpenRead(image_path); | |
request.Add(new StreamContent(image_data),"image",Path.GetFileName(image_path)); | |
var output = await client.PostAsync("http://localhost:80/v1/vision/detection",request); | |
var jsonString = await output.Content.ReadAsStringAsync(); | |
Response response = JsonConvert.DeserializeObject<Response>(jsonString); | |
foreach (var user in response.predictions){ | |
Console.WriteLine(user.label); | |
} | |
Console.WriteLine(jsonString); | |
} | |
static void Main(string[] args){ | |
detectFace("test-image.jpg").Wait(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment