Skip to content

Instantly share code, notes, and snippets.

@elbruno
Last active August 7, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/21d114935e603cb28cee00ddce36725a to your computer and use it in GitHub Desktop.
Save elbruno/21d114935e603cb28cee00ddce36725a to your computer and use it in GitHub Desktop.
Unity3DDetectImage.cs
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