private void UpdateWords(IEnumerable <QCARManagerImpl.WordData> newWordData, IEnumerable <QCARManagerImpl.WordResultData> wordResults) { this.mNewWords.Clear(); this.mLostWords.Clear(); foreach (QCARManagerImpl.WordData data in newWordData) { if (!this.mTrackedWords.ContainsKey(data.id)) { string text = Marshal.PtrToStringUni(data.stringValue); WordImpl word = new WordImpl(data.id, text, data.size); WordResultImpl impl2 = new WordResultImpl(word); this.mTrackedWords.Add(data.id, impl2); this.mNewWords.Add(impl2); } } List <int> list = new List <int>(); foreach (QCARManagerImpl.WordResultData data2 in wordResults) { list.Add(data2.id); } foreach (int num in this.mTrackedWords.Keys.ToList <int>()) { if (!list.Contains(num)) { this.mLostWords.Add(this.mTrackedWords[num].Word); this.mTrackedWords.Remove(num); } } if (this.mWordPrefabCreationMode == WordPrefabCreationMode.DUPLICATE) { this.UnregisterLostWords(); this.AssociateWordResultsWithBehaviours(); } }
private void UpdateWordResultPoses(Camera arCamera, IEnumerable <QCARManagerImpl.WordResultData> wordResults) { QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if (behaviour == null) { Debug.LogError("QCAR Behaviour could not be found"); } else { Rect viewportRectangle = behaviour.GetViewportRectangle(); bool videoBackGroundMirrored = behaviour.VideoBackGroundMirrored; CameraDevice.VideoModeData videoMode = behaviour.GetVideoMode(); foreach (QCARManagerImpl.WordResultData data2 in wordResults) { WordResultImpl impl = (WordResultImpl)this.mTrackedWords[data2.id]; Vector3 position = arCamera.transform.TransformPoint(data2.pose.position); Quaternion orientation = data2.pose.orientation; Quaternion quaternion2 = (arCamera.transform.rotation * orientation) * Quaternion.AngleAxis(270f, Vector3.left); impl.SetPose(position, quaternion2); impl.SetStatus(data2.status); OrientedBoundingBox cameraFrameObb = new OrientedBoundingBox(data2.orientedBoundingBox.center, data2.orientedBoundingBox.halfExtents, data2.orientedBoundingBox.rotation); impl.SetObb(QCARRuntimeUtilities.CameraFrameToScreenSpaceCoordinates(cameraFrameObb, viewportRectangle, videoBackGroundMirrored, videoMode)); } if (this.mWordPrefabCreationMode == WordPrefabCreationMode.DUPLICATE) { this.UpdateWordBehaviourPoses(); } } }
private void UpdateWords(IEnumerable <QCARManagerImpl.WordData> newWordData, IEnumerable <QCARManagerImpl.WordResultData> wordResults) { mNewWords.Clear(); mLostWords.Clear(); //add new words to list of tracked words and to list of new words foreach (var wd in newWordData) { if (!mTrackedWords.ContainsKey(wd.id)) { var word = new WordImpl(wd.id, Marshal.PtrToStringUni(wd.stringValue), wd.size); var wordResult = new WordResultImpl(word); mTrackedWords.Add(wd.id, wordResult); mNewWords.Add(wordResult); } } //remove lost words from list of tracked words, add them to list of lost words var trackedKeys = new List <int>(); //tracked keys in current frame foreach (var wr in wordResults) { trackedKeys.Add(wr.id); } var allKeys = mTrackedWords.Keys.ToList(); //keys tracked in previous frame foreach (var id in allKeys) { if (!trackedKeys.Contains(id)) { mLostWords.Add(mTrackedWords[id].Word); mTrackedWords.Remove(id); } } // update word behaviours if enabled: if (mWordPrefabCreationMode == WordPrefabCreationMode.DUPLICATE) { // unregister lost words from behaviours UnregisterLostWords(); // associate word results with behaviours: AssociateWordResultsWithBehaviours(); } }
private void UpdateWords(IEnumerable<QCARManagerImpl.WordData> newWordData, IEnumerable<QCARManagerImpl.WordResultData> wordResults) { mNewWords.Clear(); mLostWords.Clear(); //add new words to list of tracked words and to list of new words foreach (var wd in newWordData) { if (!mTrackedWords.ContainsKey(wd.id)) { var word = new WordImpl(wd.id, Marshal.PtrToStringUni(wd.stringValue), wd.size); var wordResult = new WordResultImpl(word); mTrackedWords.Add(wd.id, wordResult); mNewWords.Add(wordResult); } } //remove lost words from list of tracked words, add them to list of lost words var trackedKeys = new List<int>(); //tracked keys in current frame foreach (var wr in wordResults) trackedKeys.Add(wr.id); var allKeys = mTrackedWords.Keys.ToList(); //keys tracked in previous frame foreach (var id in allKeys) { if (!trackedKeys.Contains(id)) { mLostWords.Add(mTrackedWords[id].Word); mTrackedWords.Remove(id); } } // update word behaviours if enabled: if (mWordPrefabCreationMode == WordPrefabCreationMode.DUPLICATE) { // unregister lost words from behaviours UnregisterLostWords(); // associate word results with behaviours: AssociateWordResultsWithBehaviours(); } }