teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

9

意図的に内容を抹消する行為にあたるため

2021/07/12 02:30

投稿

pofinpouty
pofinpouty

スコア20

title CHANGED
@@ -1,1 +1,1 @@
1
- teratailで質問。削除予定
1
+ ARFoundation +image tracking 外部にある画像を認識したい
body CHANGED
@@ -1,1 +1,34 @@
1
+ ARFoundation +ARKitでimage trackingのを試しています。
2
+ [image trackingサンプル](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/manual/image-tracking.html)
3
+ サンプルだとこのように「Reference image library」に直接画像を設定することによりマーカー認識できるようになると思うのですが、これを外部から設定できるようにしたいです。
4
+ [画像読み込み方法の参考](https://qiita.com/k7a/items/df6dd8ea66cbc5a1e21d)
5
+ こちらを参考にまずはResources.Loadの方法で画像を読み込めるようにAsset > Rerources > sample(画像)としました。
6
+ Reference image libraryのスクリプトを直接編集することができないため、実行時に参照ライブラリに画像を追加できるという「Dynamic Library」のスクリプトに記述しました。
7
+ 以下コードです。
8
+ ```
9
+ void Start(){
10
+ ARTrackedImageManager mARTrackedImageManager = gameObject.GetComponent<ARTrackedImageManager>();
11
+ //MutableRuntimeReferenceImageLibrary myRuntimeReferenceImageLibrary = mARTrackedImageManager.CreateRuntimeLibrary() as MutableRuntimeReferenceImageLibrary;
12
+ var texture = Resources.Load("sample") as Texture2D;
13
+ Debug.Log("Texture name:"+ texture.name);
14
+
15
+ if (mARTrackedImageManager.referenceLibrary is MutableRuntimeReferenceImageLibrary myRuntimeReferenceImageLibrary)
16
+ {
17
+ myRuntimeReferenceImageLibrary.ScheduleAddImageWithValidationJob(texture, "sample", 0.5f);
18
+ if(myRuntimeReferenceImageLibrary != null)
19
+ {
20
+ Debug.Log("myRuntimeReferenceImageLibrary:" + myRuntimeReferenceImageLibrary.count);
21
+ Debug.Log("supportedTextureFormatCount:" + myRuntimeReferenceImageLibrary.supportedTextureFormatCount);
22
+ mARTrackedImageManager.referenceLibrary = myRuntimeReferenceImageLibrary;
23
+ }
24
+ Debug.Log("入らない");
25
+ //mARTrackedImageManager.maxNumberOfMovingImages = 1;
26
+ //mARTrackedImageManager.trackedImagePrefab = m_TrackedImagePrefab;
27
+ mARTrackedImageManager.enabled = true;
28
+
29
+ }
30
+ }
31
+ ```
32
+ エラーは起きていないのですが、「myRuntimeReferenceImageLibrary.count」が0のままで、
1
- ~~u~~削除予定削除予定削除予定削除予定削除予定削除予定削除予定削除予定
33
+ Resourcesフォルダに格納したsample画像が読み込まれておりません…
34
+ texture.nameは取れているので読み込みできていると思っていたのですが、どのようにしたら実現できるのでしょうか?

8

2021/07/12 02:30

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- ARFoundation +image tracking 外部にある画像を認識したい
1
+ teratailで質問。削除予定
body CHANGED
@@ -1,37 +1,1 @@
1
- ARFoundation +ARKitでimage trackingのを試しています。
2
- [image trackingサンプル](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/manual/image-tracking.html)
3
- サンプルだとこのように「Reference image library」に直接画像を設定することによりマーカー認識できるようになると思うのですが、これを外部から設定できるようにしたいです。
4
- [画像読み込み方法の参考](https://qiita.com/k7a/items/df6dd8ea66cbc5a1e21d)
5
- こちらを参考にまずはResources.Loadの方法で画像を読み込めるようにAsset > Rerources > sample(画像)としました。
6
- Reference image libraryのスクリプトを直接編集することができないため、実行時に参照ライブラリに画像を追加できるという「Dynamic Library」のスクリプトに記述しました。
7
- 以下コードです。
8
- ```
9
-
10
- void Start(){
11
- ARTrackedImageManager mARTrackedImageManager = gameObject.GetComponent<ARTrackedImageManager>();
12
- //MutableRuntimeReferenceImageLibrary myRuntimeReferenceImageLibrary = mARTrackedImageManager.CreateRuntimeLibrary() as MutableRuntimeReferenceImageLibrary;
13
- var texture = Resources.Load("sample") as Texture2D;
14
- Debug.Log("Texture name:"+ texture.name);
15
-
16
- if (mARTrackedImageManager.referenceLibrary is MutableRuntimeReferenceImageLibrary myRuntimeReferenceImageLibrary)
17
- {
18
- myRuntimeReferenceImageLibrary.ScheduleAddImageWithValidationJob(texture, "sample", 0.5f);
19
- if(myRuntimeReferenceImageLibrary != null)
20
- {
21
- Debug.Log("myRuntimeReferenceImageLibrary:" + myRuntimeReferenceImageLibrary.count);
22
- Debug.Log("supportedTextureFormatCount:" + myRuntimeReferenceImageLibrary.supportedTextureFormatCount);
23
- mARTrackedImageManager.referenceLibrary = myRuntimeReferenceImageLibrary;
24
- }
25
- Debug.Log("入らない");
26
- //mARTrackedImageManager.maxNumberOfMovingImages = 1;
27
- //mARTrackedImageManager.trackedImagePrefab = m_TrackedImagePrefab;
28
- mARTrackedImageManager.enabled = true;
29
-
30
- }
31
- }
32
-
33
- ```
34
-
35
- エラーは起きていないのですが、「myRuntimeReferenceImageLibrary.count」が0のままで、
36
- Resourcesフォルダに格納したsample画像が読み込まれておりません…
1
+ ~~u~~削除予定削除予定削除予定削除予定削除予定削除予定削除予定削除予定
37
- texture.nameは取れているので読み込みできていると思っていたのですが、どのようにしたら実現できるのでしょうか?

7

2021/07/10 04:52

投稿

pofinpouty
pofinpouty

スコア20

title CHANGED
File without changes
body CHANGED
@@ -2,256 +2,36 @@
2
2
  [image trackingサンプル](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/manual/image-tracking.html)
3
3
  サンプルだとこのように「Reference image library」に直接画像を設定することによりマーカー認識できるようになると思うのですが、これを外部から設定できるようにしたいです。
4
4
  [画像読み込み方法の参考](https://qiita.com/k7a/items/df6dd8ea66cbc5a1e21d)
5
- こちらを参考にまずはResources.Loadで画像を表示できるようにAsset > Rerources > sample(画像)としたのですがうく動作ません
5
+ こちらを参考にまずはResources.Loadの方法で画像を読み込めるようにAsset > Rerources > sample(画像)としまし
6
-
7
6
  Reference image libraryのスクリプトを直接編集することができないため、実行時に参照ライブラリに画像を追加できるという「Dynamic Library」のスクリプトに記述しました。
8
- 以下コードです。コメントの内容はサンプルの英語を直訳しただけなので気にしないでください…
7
+ 以下コードです。
9
8
  ```
10
9
 
11
- namespace UnityEngine.XR.ARFoundation.Samples
12
- {
13
- /// <summary>
14
- ///実行時に参照ライブラリに画像を追加します
15
- /// Adds images to the reference library at runtime.
16
- /// </summary>
17
- [RequireComponent(typeof(ARTrackedImageManager))]
18
- public class DynamicLibrary : MonoBehaviour
19
- {
20
- public Texture2D value;
21
-
22
- void awake(){
10
+ void Start(){
11
+ ARTrackedImageManager mARTrackedImageManager = gameObject.GetComponent<ARTrackedImageManager>();
12
+ //MutableRuntimeReferenceImageLibrary myRuntimeReferenceImageLibrary = mARTrackedImageManager.CreateRuntimeLibrary() as MutableRuntimeReferenceImageLibrary;
13
+ var texture = Resources.Load("sample") as Texture2D;
14
+ Debug.Log("Texture name:"+ texture.name);
23
15
 
24
- value = Resources.Load("sample") as Texture2D;
25
-
26
- }
27
- [Serializable]
28
- public class ImageData
29
- {
30
- //画像のソーステクスチャ。読み取り可能としてマークする必要があります。
31
- [SerializeField, Tooltip("The source texture for the image. Must be marked as readable.")]
16
+ if (mARTrackedImageManager.referenceLibrary is MutableRuntimeReferenceImageLibrary myRuntimeReferenceImageLibrary)
32
- //2D画像の変数生成
33
- Texture2D m_Texture;
34
-
35
-
36
- //2D画像の変数生成
37
- public Texture2D texture
38
17
  {
39
- get => m_Texture;
40
- set => m_Texture = value;
41
- }
42
-
43
- [SerializeField, Tooltip("The name for this image.")]
18
+ myRuntimeReferenceImageLibrary.ScheduleAddImageWithValidationJob(texture, "sample", 0.5f);
44
- //画像の名前
45
- string m_Name;
46
-
47
- public string name
19
+ if(myRuntimeReferenceImageLibrary != null)
48
20
  {
49
- get => m_Name;
21
+ Debug.Log("myRuntimeReferenceImageLibrary:" + myRuntimeReferenceImageLibrary.count);
22
+ Debug.Log("supportedTextureFormatCount:" + myRuntimeReferenceImageLibrary.supportedTextureFormatCount);
50
- set => m_Name = value;
23
+ mARTrackedImageManager.referenceLibrary = myRuntimeReferenceImageLibrary;
51
24
  }
52
-
53
- [SerializeField, Tooltip("The width, in meters, of the image in the real world.")]
54
- //実世界での画像の幅(メートル単位)
55
- float m_Width;
56
-
57
- public float width
58
- {
59
- get => m_Width;
60
- set => m_Width = value;
25
+ Debug.Log("入らない");
61
- }
62
-
63
- public AddReferenceImageJobState jobState { get; set; }
26
+ //mARTrackedImageManager.maxNumberOfMovingImages = 1;
64
- }
65
- //実行時に画像ライブラリに追加する画像のセット
66
- [SerializeField, Tooltip("The set of images to add to the image library at runtime")]
67
- ImageData[] m_Images;
68
-
69
- /// <summary>
70
- ///実行時に画像ライブラリに追加する画像のセット
71
- /// The set of images to add to the image library at runtime
27
+ //mARTrackedImageManager.trackedImagePrefab = m_TrackedImagePrefab;
72
- /// </summary>
73
- public ImageData[] images
74
- {
75
- get => m_Images;
76
- set => m_Images = value;
77
- }
78
-
79
- enum State
80
- {
81
- NoImagesAdded,
82
- AddImagesRequested,
83
- AddingImages,
84
- Done,
85
- Error
86
- }
87
-
88
- State m_State;
89
-
90
- string m_ErrorMessage = "";
91
-
92
- StringBuilder m_StringBuilder = new StringBuilder();
93
-
94
- void OnGUI()
95
- {
96
- //ボタンと文字の大きさ
97
- var fontSize = 50;
98
- GUI.skin.button.fontSize = fontSize;
99
- GUI.skin.label.fontSize = fontSize;
100
-
101
- float margin = 100;
102
-
103
- //開始エリア
104
- GUILayout.BeginArea(new Rect(margin, margin, Screen.width - margin * 2, Screen.height - margin * 2));
105
-
106
- switch (m_State)
107
- {
108
- case State.NoImagesAdded:
109
- {
110
- if (GUILayout.Button("Add images"))
111
- {
112
- m_State = State.AddImagesRequested;
28
+ mARTrackedImageManager.enabled = true;
113
- }
114
-
115
- break;
116
- }
117
- case State.AddingImages:
118
- {
119
- m_StringBuilder.Clear();
120
- //追加行
121
- m_StringBuilder.AppendLine("Add image status:");
122
- foreach (var image in m_Images)
123
- {
124
- m_StringBuilder.AppendLine($"\t{image.name}: {(image.jobState.status.ToString())}");
125
- }
126
- GUILayout.Label(m_StringBuilder.ToString());
127
- break;
128
- }
129
- case State.Done:
130
- {
131
- GUILayout.Label("All images added");
132
- break;
133
- }
134
- case State.Error:
135
- {
136
- GUILayout.Label(m_ErrorMessage);
137
- break;
138
- }
139
- }
140
-
141
- GUILayout.EndArea();
142
- }
143
-
144
- void SetError(string errorMessage)
145
- {
146
- m_State = State.Error;
147
- m_ErrorMessage = $"Error: {errorMessage}";
148
- }
149
-
150
- void Update()
151
- {
152
-
153
- switch (m_State)
154
- {
155
29
 
156
- case State.AddImagesRequested:
157
- {
158
-
159
- if (m_Images == null)
160
- {
161
-
162
- SetError("No images to add.");
163
- break;
164
- }
165
-
166
- var manager = GetComponent<ARTrackedImageManager>();
167
- if (manager == null)
168
- {
169
-
170
- SetError($"No {nameof(ARTrackedImageManager)} available.");
171
- break;
172
- }
173
-
174
- //生の画像バイトを追加するか、テクスチャを受け入れる拡張メソッド(以下で使用)を使用できます。ただし、テクスチャを使用するには、そのインポート設定でテクスチャへの読み取り/書き込みアクセスが有効になっている必要があります。
175
- // You can either add raw image bytes or use the extension method (used below) which accepts
176
- // a texture. To use a texture, however, its import settings must have enabled read/write
177
- // access to the texture.
178
- foreach (var image in m_Images)
179
- {
180
- Debug.Log("ここでエラー");
181
- if (!image.texture.isReadable)//////
182
- {
183
-
184
- SetError($"Image {image.name} must be readable to be added to the image library.");
185
- break;
186
- }
187
-
188
- }
189
-
190
- if (manager.referenceLibrary is MutableRuntimeReferenceImageLibrary mutableLibrary)
191
- {
192
-
193
- try
194
- {
195
- foreach (var image in m_Images)
196
- {
197
- //注:返されたJobHandleに対して何もする必要はありませんが、画像がライブラリに追加された時期を知りたい
198
- //場合は、数フレームかかる可能性があるため便利です。
199
- // Note: You do not need to do anything with the returned JobHandle, but it can be
200
- // useful if you want to know when the image has been added to the library since it may
201
- // take several frames.
202
- image.jobState = mutableLibrary.ScheduleAddImageWithValidationJob(image.texture, image.name, image.width);
203
-
204
- }
205
-
206
- m_State = State.AddingImages;
207
- }
208
- catch (InvalidOperationException e)
209
- {
210
-
211
- SetError($"ScheduleAddImageJob threw exception: {e.Message}");
212
- }
213
- }
214
- else
215
- {
216
-
217
- SetError($"The reference image library is not mutable.");
218
- }
219
-
220
- break;
221
- }
222
- case State.AddingImages:
223
- {
224
-
225
- //完了を確認する
226
- // Check for completion
227
- var done = true;
228
- foreach (var image in m_Images)
229
- {
230
- if (!image.jobState.jobHandle.IsCompleted)
231
- {
232
- done = false;
233
- break;
234
- }
235
- }
236
-
237
- if (done)
238
- {
239
- m_State = State.Done;
240
- }
241
-
242
- break;
243
- }
244
30
  }
245
31
  }
246
-  }
247
-
248
32
 
249
33
  ```
250
34
 
251
- エラーの内容が
252
- NullReferenceException: Object reference not set to an instance of an object.
253
- at UnityEngine.XR.ARFoundation.Samples.DynamicLibrary.Update () [0x00000]
35
+ エラーは起きていないのですが、「myRuntimeReferenceImageLibrary.count」が0のままで、
254
- in <00000000000000000000000000000000>:0
255
-
256
- となっており、うまく読み込めていないのかと思っております…
257
- 通常は何行目がエラーか出るみいなのです、私の場合はでておりません
36
+ Resourcesフォルダに格納しsample画像読み込まれておりません
37
+ texture.nameは取れているので読み込みできていると思っていたのですが、どのようにしたら実現できるのでしょうか?

6

2021/07/08 11:00

投稿

pofinpouty
pofinpouty

スコア20

title CHANGED
File without changes
body CHANGED
@@ -246,4 +246,12 @@
246
246
   }
247
247
 
248
248
 
249
- ```
249
+ ```
250
+
251
+ エラーの内容が
252
+ NullReferenceException: Object reference not set to an instance of an object.
253
+ at UnityEngine.XR.ARFoundation.Samples.DynamicLibrary.Update () [0x00000]
254
+ in <00000000000000000000000000000000>:0
255
+
256
+ となっており、うまく読み込めていないのかと思っております…
257
+ 通常は何行目がエラーか出るみたいなのですが、私の場合はでておりません。

5

2021/07/07 22:57

投稿

pofinpouty
pofinpouty

スコア20

title CHANGED
@@ -1,1 +1,1 @@
1
- ARFoundation +image tracking 外部にある画像を認識し、テキストを表示したい
1
+ ARFoundation +image tracking 外部にある画像を認識したい
body CHANGED
@@ -1,11 +1,249 @@
1
1
  ARFoundation +ARKitでimage trackingのを試しています。
2
- [ク内容](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/manual/image-tracking.html)
2
+ [image trackingサプル](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/manual/image-tracking.html)
3
- サンプルだとこのように「reference image library」に直接画像を設定することによりマーカー認識できるようになると思うのですが、これを外部から設定(開発環境がmacなのfinderからできるのが理想です)したいです。
3
+ サンプルだとこのように「Reference image library」に直接画像を設定することによりマーカー認識できるようになると思うのですが、これを外部から設定できるようにしたいです。
4
+ [画像読み込み方法の参考](https://qiita.com/k7a/items/df6dd8ea66cbc5a1e21d)
4
- スクリプトの中身(もしかしてreference image libraryのスクリプトではない…?を確認したのですがどのよたら実現できるのかわかりませんでした…
5
+ こちらを参考にまずはResources.Loadで画像を表示できるようにAsset > Rerources > sample(画像したのですがうまく動作しません
5
- その辺はちゃんと理解していく必要があるのですが、ご教示願いたいです。
6
6
 
7
- **追記**
8
- 試したこととして
9
- ![![メージ説明](133a92a8b8cde8e1191e599d247d9185.png)](e9fab14f3de3923cbc34da70cf1153f9.png)
7
+ Reference image libraryのスクリプトを直接編集することができないため、実行時に参照ラブラリに画像を追加できるという「Dynamic Library」のスクリプトに記述しました。
8
+ 以下コードです。コメントの内容はサンプルの英語を直訳しただけなので気にしないでください…
9
+ ```
10
10
 
11
+ namespace UnityEngine.XR.ARFoundation.Samples
12
+ {
13
+ /// <summary>
14
+ ///実行時に参照ライブラリに画像を追加します
15
+ /// Adds images to the reference library at runtime.
16
+ /// </summary>
17
+ [RequireComponent(typeof(ARTrackedImageManager))]
18
+ public class DynamicLibrary : MonoBehaviour
19
+ {
20
+ public Texture2D value;
21
+
22
+ void awake(){
23
+
24
+ value = Resources.Load("sample") as Texture2D;
25
+
26
+ }
27
+ [Serializable]
28
+ public class ImageData
29
+ {
30
+ //画像のソーステクスチャ。読み取り可能としてマークする必要があります。
31
+ [SerializeField, Tooltip("The source texture for the image. Must be marked as readable.")]
32
+ //2D画像の変数生成
33
+ Texture2D m_Texture;
34
+
35
+
36
+ //2D画像の変数生成
37
+ public Texture2D texture
38
+ {
39
+ get => m_Texture;
40
+ set => m_Texture = value;
41
+ }
42
+
43
+ [SerializeField, Tooltip("The name for this image.")]
44
+ //画像の名前
45
+ string m_Name;
46
+
47
+ public string name
48
+ {
49
+ get => m_Name;
50
+ set => m_Name = value;
51
+ }
52
+
53
+ [SerializeField, Tooltip("The width, in meters, of the image in the real world.")]
54
+ //実世界での画像の幅(メートル単位)
55
+ float m_Width;
56
+
57
+ public float width
58
+ {
59
+ get => m_Width;
60
+ set => m_Width = value;
61
+ }
62
+
63
+ public AddReferenceImageJobState jobState { get; set; }
64
+ }
65
+ //実行時に画像ライブラリに追加する画像のセット
66
+ [SerializeField, Tooltip("The set of images to add to the image library at runtime")]
67
+ ImageData[] m_Images;
68
+
69
+ /// <summary>
70
+ ///実行時に画像ライブラリに追加する画像のセット
71
+ /// The set of images to add to the image library at runtime
72
+ /// </summary>
73
+ public ImageData[] images
74
+ {
75
+ get => m_Images;
76
+ set => m_Images = value;
77
+ }
78
+
79
+ enum State
80
+ {
81
+ NoImagesAdded,
82
+ AddImagesRequested,
83
+ AddingImages,
84
+ Done,
85
+ Error
86
+ }
87
+
88
+ State m_State;
89
+
90
+ string m_ErrorMessage = "";
91
+
92
+ StringBuilder m_StringBuilder = new StringBuilder();
93
+
94
+ void OnGUI()
95
+ {
96
+ //ボタンと文字の大きさ
97
+ var fontSize = 50;
98
+ GUI.skin.button.fontSize = fontSize;
99
+ GUI.skin.label.fontSize = fontSize;
100
+
101
+ float margin = 100;
102
+
103
+ //開始エリア
104
+ GUILayout.BeginArea(new Rect(margin, margin, Screen.width - margin * 2, Screen.height - margin * 2));
105
+
106
+ switch (m_State)
107
+ {
108
+ case State.NoImagesAdded:
109
+ {
110
+ if (GUILayout.Button("Add images"))
111
+ {
112
+ m_State = State.AddImagesRequested;
113
+ }
114
+
115
+ break;
116
+ }
117
+ case State.AddingImages:
118
+ {
119
+ m_StringBuilder.Clear();
120
+ //追加行
121
+ m_StringBuilder.AppendLine("Add image status:");
122
+ foreach (var image in m_Images)
123
+ {
124
+ m_StringBuilder.AppendLine($"\t{image.name}: {(image.jobState.status.ToString())}");
125
+ }
126
+ GUILayout.Label(m_StringBuilder.ToString());
127
+ break;
128
+ }
129
+ case State.Done:
130
+ {
131
+ GUILayout.Label("All images added");
132
+ break;
133
+ }
134
+ case State.Error:
135
+ {
136
+ GUILayout.Label(m_ErrorMessage);
137
+ break;
138
+ }
139
+ }
140
+
141
+ GUILayout.EndArea();
142
+ }
143
+
144
+ void SetError(string errorMessage)
145
+ {
146
+ m_State = State.Error;
147
+ m_ErrorMessage = $"Error: {errorMessage}";
148
+ }
149
+
150
+ void Update()
151
+ {
152
+
153
+ switch (m_State)
154
+ {
155
+
156
+ case State.AddImagesRequested:
157
+ {
158
+
159
+ if (m_Images == null)
160
+ {
161
+
162
+ SetError("No images to add.");
163
+ break;
164
+ }
165
+
166
+ var manager = GetComponent<ARTrackedImageManager>();
167
+ if (manager == null)
168
+ {
169
+
170
+ SetError($"No {nameof(ARTrackedImageManager)} available.");
171
+ break;
172
+ }
173
+
174
+ //生の画像バイトを追加するか、テクスチャを受け入れる拡張メソッド(以下で使用)を使用できます。ただし、テクスチャを使用するには、そのインポート設定でテクスチャへの読み取り/書き込みアクセスが有効になっている必要があります。
175
+ // You can either add raw image bytes or use the extension method (used below) which accepts
176
+ // a texture. To use a texture, however, its import settings must have enabled read/write
177
+ // access to the texture.
178
+ foreach (var image in m_Images)
179
+ {
180
+ Debug.Log("ここでエラー");
181
+ if (!image.texture.isReadable)//////
182
+ {
183
+
11
- trackedimagemanagerのスクリプトのupdateinfoメソッドに、finderのパスを記述してテキストの内容を表示しようとしましたがダメでした…
184
+ SetError($"Image {image.name} must be readable to be added to the image library.");
185
+ break;
186
+ }
187
+
188
+ }
189
+
190
+ if (manager.referenceLibrary is MutableRuntimeReferenceImageLibrary mutableLibrary)
191
+ {
192
+
193
+ try
194
+ {
195
+ foreach (var image in m_Images)
196
+ {
197
+ //注:返されたJobHandleに対して何もする必要はありませんが、画像がライブラリに追加された時期を知りたい
198
+ //場合は、数フレームかかる可能性があるため便利です。
199
+ // Note: You do not need to do anything with the returned JobHandle, but it can be
200
+ // useful if you want to know when the image has been added to the library since it may
201
+ // take several frames.
202
+ image.jobState = mutableLibrary.ScheduleAddImageWithValidationJob(image.texture, image.name, image.width);
203
+
204
+ }
205
+
206
+ m_State = State.AddingImages;
207
+ }
208
+ catch (InvalidOperationException e)
209
+ {
210
+
211
+ SetError($"ScheduleAddImageJob threw exception: {e.Message}");
212
+ }
213
+ }
214
+ else
215
+ {
216
+
217
+ SetError($"The reference image library is not mutable.");
218
+ }
219
+
220
+ break;
221
+ }
222
+ case State.AddingImages:
223
+ {
224
+
225
+ //完了を確認する
226
+ // Check for completion
227
+ var done = true;
228
+ foreach (var image in m_Images)
229
+ {
230
+ if (!image.jobState.jobHandle.IsCompleted)
231
+ {
232
+ done = false;
233
+ break;
234
+ }
235
+ }
236
+
237
+ if (done)
238
+ {
239
+ m_State = State.Done;
240
+ }
241
+
242
+ break;
243
+ }
244
+ }
245
+ }
246
+  }
247
+
248
+
249
+ ```

4

2021/07/07 22:53

投稿

pofinpouty
pofinpouty

スコア20

title CHANGED
@@ -1,1 +1,1 @@
1
- ARFoundation +image tracking マーカーの参照先を外部フォルダにしたい
1
+ ARFoundation +image tracking 外部にある画像を認識、テキストを表示したい
body CHANGED
File without changes

3

試したことを追記

2021/06/30 03:08

投稿

pofinpouty
pofinpouty

スコア20

title CHANGED
File without changes
body CHANGED
@@ -2,4 +2,10 @@
2
2
  [リンク内容](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/manual/image-tracking.html)
3
3
  サンプルだとこのように「reference image library」に直接画像を設定することによりマーカー認識できるようになると思うのですが、これを外部から設定(開発環境がmacなのでfinderからできるのが理想です)したいです。
4
4
  スクリプトの中身(もしかしてreference image libraryのスクリプトではない…?)を確認したのですがどのようにしたら実現できるのかわかりませんでした…
5
- その辺はちゃんと理解していく必要があるのですが、ご教示願いたいです。
5
+ その辺はちゃんと理解していく必要があるのですが、ご教示願いたいです。
6
+
7
+ **追記**
8
+ 試したこととして
9
+ ![![イメージ説明](133a92a8b8cde8e1191e599d247d9185.png)](e9fab14f3de3923cbc34da70cf1153f9.png)
10
+
11
+ trackedimagemanagerのスクリプトのupdateinfoメソッドに、finderのパスを記述してテキストの内容を表示しようとしましたがダメでした…

2

2021/06/29 23:48

投稿

pofinpouty
pofinpouty

スコア20

title CHANGED
@@ -1,1 +1,1 @@
1
- ARFoundation +ARKit マーカーの参照先を外部フォルダにしたい
1
+ ARFoundation +image tracking マーカーの参照先を外部フォルダにしたい
body CHANGED
File without changes

1

2021/06/29 03:11

投稿

pofinpouty
pofinpouty

スコア20

title CHANGED
@@ -1,1 +1,1 @@
1
- ARFoundation +ARKit マーカーの設定先を
1
+ ARFoundation +ARKit マーカーの参照先を外部フォルダにしたい
body CHANGED
File without changes