###前提・実現したいこと
HoloLensで撮影し、Microsoft AzureのFaceAPIで写っている人の名前を表示するアプリを作成しています。
Unity上ではURLから画像を読み込み、名前を表示することに成功しています。
###発生している問題・エラーメッセージ
Unity上では動くコードでもHoloLens実機デプロイ時には顔認識が失敗してしまいます。
具体的には、人の名前ではなくエラー用の「特定できませんでした」が表示されます。
(恐らく以下のURLのようなことが原因だと思われますが、解決できていません)
https://www.slideshare.net/TakahiroMiyaura/unityhololensuwp
###該当のソースコード
(個人情報があるため、xxxxなどで隠してある部分があります)
使用言語:C#
using UnityEngine; using System.Collections; using System.IO; using System; using System.Collections.Generic; using UnityEngine.UI; public class DisplayURL : MonoBehaviour { public static string faceId; public static string personId; public static string _url1 = "https://southeastasia.api.cognitive.microsoft.com/face/v1.0/detect"; public static string _url2 = "https://southeastasia.api.cognitive.microsoft.com/face/v1.0/identify"; public static string _key = "xxxxxxxx"; public static string name; public string f_url; string responseData1, responseData2; public Text text; // Use this for initialization public void Start() { //画像URL f_url = "https://i.gyazo.com/xxxxxxxxxxxxxxxxxx.jpg"; StartCoroutine(GetFaceFromImages()); } IEnumerator GetFaceFromImages() { string body1 = String.Format("{{'url':'{0}'}}", f_url); byte[] bytes1 = System.Text.Encoding.UTF8.GetBytes(body1); var headers1 = new Dictionary<string, string>() { { "Ocp-Apim-Subscription-Key", _key }, { "Content-Type", "application/json" } }; WWW www1 = new WWW(_url1, bytes1, headers1); yield return www1; responseData1 = www1.text; JSONObject sdbUserGet = new JSONObject(responseData1); for (int i = 0; i < sdbUserGet.Count; ++i) { JSONObject jsonPos = sdbUserGet[i]; JSONObject jsonFaceId = jsonPos.GetField("faceId"); faceId = jsonFaceId.str; } string body2 = String.Format("{{'personGroupId':'xxxxxxxxx', 'faceIds':['{0}'], 'maxNumOfCandidatesReturned':1, 'confidenceThreshold':0.5}}", faceId); byte[] bytes2 = System.Text.Encoding.UTF8.GetBytes(body2); var headers2 = new Dictionary<string, string>() { { "Ocp-Apim-Subscription-Key", _key }, { "Content-Type", "application/json" } }; WWW www2 = new WWW(_url2, bytes2, headers2); yield return www2; responseData2 = www2.text; // Save the response as JSON string JSONObject udbUserGet = new JSONObject(responseData2); for (int i = 0; i < udbUserGet.Count; ++i) { JSONObject jsonPos1 = udbUserGet[i]; JSONObject jsonCandidates = jsonPos1.GetField("candidates"); string json = jsonCandidates.ToString(); JSONObject wdbUserGet = new JSONObject(json); for (int j = 0; j < wdbUserGet.Count; ++j) { JSONObject jsonPos2 = wdbUserGet[j]; JSONObject jsonPersonId = jsonPos2.GetField("personId"); personId = jsonPersonId.str; } } Debug.Log(personId); if (personId == "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx") { name = "xxxxxxxxxxxxx"; } else if (personId == "xxxxxxxxxxxxxxxxxxxxxxxxxxx") { name = "xxxxxxxxxxxxxxxx"; } else { name = "特定できませんでした"; } text.text = "氏名:" + name; }
###試したこと
実機でのデプロイ
###補足情報(言語/FW/ツール等のバージョンなど)
Unityのバージョン:2017.1.0p5(Personal)64bit
visual studio 2017のバージョン:15.4.1
.netのバージョン:4.7.02053
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。