Created
May 29, 2019 14:48
-
-
Save OlafenwaMoses/8623c7fd751866c66d62f58ea0d73287 to your computer and use it in GitHub Desktop.
This file contains hidden or 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)); | |
//REMEMBER TO REPLACE IP '165.22.72.67' below with the IP of your Ubuntu server | |
var output = await client.PostAsync("http://165.22.72.67: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("office.png").Wait(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment