// Use this for initialization void Start() { Debug.Log("Hello"); string fp0 = "C:\\Users\\bobic\\Desktop\\SLIKE\\img3.jpg"; string fp1 = "C:\\Users\\bobic\\Desktop\\SLIKE\\img01.jpg"; byte[] imgD0 = File.ReadAllBytes(fp0); //byte[] imgD1 = File.ReadAllBytes(fp1); DBService dbsr = new DBService("real_data.db"); dbsr.AssertDatabaseExists(); FARequest frf = new FARequest(APIConstants.APIKEY, APIConstants.APISECRET); frf.image_file1 = imgD0; //frf.image_file2 = imgD1; Debug.Log(FAUtils.getIdConfidenceForCompare(imgD0, dbsr)); /* * var obj = GameObject.Find("HttpUtil"); * HTTPUtils htp=obj.GetComponent<HTTPUtils>(); * htp.POST(APIConstants.APIURL_COMPARE, frf); * while (!htp) { } * double data;*/ // frf.image_file1 }
//private static readonly string POSTAddUserURL = "http://db.url.com/api/addUser"; public WWW POST(string url, FARequest req) { isSignal = false; WWW www; WWWForm form = new WWWForm(); //form.AddField("api_key",APIConstants.APIKEY); // form.AddField("api_secret", APIConstants.APISECRET); form.AddBinaryData("image_file1", req.image_file1, "img00.jpeg"); //Debug.Log(req.image_file1); form.AddBinaryData("image_file2", req.image_file2, "img01.jpeg"); //Debug.Log(req.image_file2); www = new WWW(APIConstants.getUrlWKeys(), form.data, form.headers); StartCoroutine(WaitForRequest(www)); return(www); }
public static int getIdConfidenceForCompare(byte[] image, DBService dbService) { // string fp0 = "C:\\Users\\bobic\\Desktop\\SLIKE\\img00.jpg"; ///string fp1 = "C:\\Users\\bobic\\Desktop\\SLIKE\\img01.jpg"; // byte[] imgD0 = File.ReadAllBytes(fp0); //byte[] imgD1 = File.ReadAllBytes(fp1); FARequest frf = new FARequest(APIConstants.APIKEY, APIConstants.APISECRET); frf.image_file1 = image; //frf.image_file2; int id = 0; List <Patient> lst = Patient.GetAll(dbService); Patient mk = Patient.GetInfo(dbService, 3); var obj = GameObject.Find("HttpUtil"); HTTPUtils htp = obj.GetComponent <HTTPUtils>(); Debug.Log(lst.Count + 1); byte[] imgD1 = File.ReadAllBytes(mk.PicPath); frf.image_file2 = imgD1; WWW util = htp.POST(APIConstants.APIURL_COMPARE, frf); while (!util.isDone) { } for (int i = 0; i < 10000; i++) { ; } double data = htp.confData; Debug.Log(data); if (data > APIConstants.Threshold) { return(mk.Id); } return(mk.Id); }