我正在尝试使用从我的Unity应用程序调用的FaceAPI(MS / Azure),使用已编码为PNG的Texture2D,但我一直收到以下错误消息:
{
"error": {
"code": "InvalidImage",
"message": "Decoding error, image format unsupported."
}
}
我已经做了:
这是我用来将POST消息发送到FaceAPI的代码的一部分:
public IEnumerator ReadProfilefromTexture(Texture2D faceTex)
{
string url = faceApiUrl + requestParameters;
var headers = new Dictionary<string, string>
{
{"Ocp-Apim-Subscription-Key",faceApiKey },
{"Content-Type", "application/octet-stream" }
};
byte[] bytes = faceTex.EncodeToPNG();
WWW request = new WWW(url, bytes, headers);
yield return request;
if (!string.IsNullOrEmpty(request.error))
Debug.Log(request.error);
else
Debug.Log(request.text);
}
}
如果你们对我做错了什么有任何线索,请分享。
Tks