質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
UWP

UWPは、Universal Windows Platformの略。様々なデバイス向けに提供されているアプリケーションを共通のフレームワーク上で動作可能にする仕組みで、Windows10で導入されました。

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Visual Studio

Microsoft Visual StudioはMicrosoftによる統合開発環境(IDE)です。多種多様なプログラミング言語に対応しています。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Q&A

解決済

1回答

562閲覧

顔認識がUnity上では成功するが、HoloLens上では失敗する理由

jun_taki

総合スコア9

UWP

UWPは、Universal Windows Platformの略。様々なデバイス向けに提供されているアプリケーションを共通のフレームワーク上で動作可能にする仕組みで、Windows10で導入されました。

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Visual Studio

Microsoft Visual StudioはMicrosoftによる統合開発環境(IDE)です。多種多様なプログラミング言語に対応しています。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

0グッド

0クリップ

投稿2018/01/02 16:52

編集2018/01/03 03:53

###前提・実現したいこと
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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

見ていただいた方はありがとうございました。
自己解決いたしました。

Unityのplayer settingで"internet client"にチェックを入れていなかったことと、".net2.0"を選択していなかったことが原因でした。

投稿2018/01/03 09:13

jun_taki

総合スコア9

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問