Last active
August 7, 2020 15:39
-
-
Save elbruno/21d114935e603cb28cee00ddce36725a to your computer and use it in GitHub Desktop.
Unity3DDetectImage.cs
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
string DetectImage(byte[] image, string imageUrl) | |
{ | |
string body = string.Empty; | |
using (var request = UnityWebRequest.Post(imageUrl, "")) | |
{ | |
request.SetRequestHeader("Content-Type", "application/octet-stream"); | |
request.uploadHandler = new UploadHandlerRaw(image); | |
request.SendWebRequest(); | |
while (request.isDone == false) | |
{ | |
var wfs = new WaitForSeconds(1); | |
} | |
if (request.isNetworkError || request.isHttpError) | |
{ | |
Debug.Log(request.error); | |
} | |
else | |
{ | |
body = request.downloadHandler.text; | |
} | |
} | |
return body; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment