public override bool GetRegionOfInterest(out Rect detectionRegion, out Rect trackingRegion) { QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if (behaviour == null) { Debug.LogError("QCAR Behaviour could not be found"); detectionRegion = new Rect(); trackingRegion = new Rect(); return(false); } Rect viewportRectangle = behaviour.GetViewportRectangle(); bool videoBackGroundMirrored = behaviour.VideoBackGroundMirrored; CameraDevice.VideoModeData videoMode = CameraDevice.Instance.GetVideoMode(behaviour.CameraDeviceMode); IntPtr detectionROI = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RectangleIntData))); IntPtr trackingROI = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RectangleIntData))); QCARWrapper.Instance.TextTrackerGetRegionOfInterest(detectionROI, trackingROI); RectangleIntData camSpaceRectData = (RectangleIntData)Marshal.PtrToStructure(detectionROI, typeof(RectangleIntData)); RectangleIntData data3 = (RectangleIntData)Marshal.PtrToStructure(trackingROI, typeof(RectangleIntData)); Marshal.FreeHGlobal(detectionROI); Marshal.FreeHGlobal(trackingROI); detectionRegion = this.ScreenSpaceRectFromCamSpaceRectData(camSpaceRectData, viewportRectangle, videoBackGroundMirrored, videoMode); trackingRegion = this.ScreenSpaceRectFromCamSpaceRectData(data3, viewportRectangle, videoBackGroundMirrored, videoMode); return(true); }
public override bool SetRegionOfInterest(Rect detectionRegion, Rect trackingRegion) { Vector2 vector; Vector2 vector2; Vector2 vector3; Vector2 vector4; QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if (behaviour == null) { Debug.LogError("QCAR Behaviour could not be found"); return(false); } Rect viewportRectangle = behaviour.GetViewportRectangle(); bool videoBackGroundMirrored = behaviour.VideoBackGroundMirrored; CameraDevice.VideoModeData videoMode = CameraDevice.Instance.GetVideoMode(behaviour.CameraDeviceMode); QCARRuntimeUtilities.SelectRectTopLeftAndBottomRightForLandscapeLeft(detectionRegion, videoBackGroundMirrored, out vector, out vector2); QCARRuntimeUtilities.SelectRectTopLeftAndBottomRightForLandscapeLeft(trackingRegion, videoBackGroundMirrored, out vector3, out vector4); QCARRenderer.Vec2I veci = QCARRuntimeUtilities.ScreenSpaceToCameraFrameCoordinates(vector, viewportRectangle, videoBackGroundMirrored, videoMode); QCARRenderer.Vec2I veci2 = QCARRuntimeUtilities.ScreenSpaceToCameraFrameCoordinates(vector2, viewportRectangle, videoBackGroundMirrored, videoMode); QCARRenderer.Vec2I veci3 = QCARRuntimeUtilities.ScreenSpaceToCameraFrameCoordinates(vector3, viewportRectangle, videoBackGroundMirrored, videoMode); QCARRenderer.Vec2I veci4 = QCARRuntimeUtilities.ScreenSpaceToCameraFrameCoordinates(vector4, viewportRectangle, videoBackGroundMirrored, videoMode); if (QCARWrapper.Instance.TextTrackerSetRegionOfInterest(veci.x, veci.y, veci2.x, veci2.y, veci3.x, veci3.y, veci4.x, veci4.y, (int)this.CurrentUpDirection) == 0) { Debug.LogError(string.Format("Could not set region of interest: ({0}, {1}, {2}, {3}) - ({4}, {5}, {6}, {7})", new object[] { detectionRegion.x, detectionRegion.y, detectionRegion.width, detectionRegion.height, trackingRegion.x, trackingRegion.y, trackingRegion.width, trackingRegion.height })); return(false); } return(true); }
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 Awake() { if (QCARRuntimeUtilities.IsQCAREnabled()) { if (QCARRuntimeUtilities.IsPlayMode()) { QCARUnity.CheckInitializationError(); } bool flag = false; QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if ((behaviour != null) && behaviour.enabled) { behaviour.enabled = false; flag = true; } if (TrackerManager.Instance.GetTracker <TextTracker>() == null) { TrackerManager.Instance.InitTracker <TextTracker>(); } if (flag) { behaviour.enabled = true; } } }
private void OnDestroy() { QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if (behaviour != null) { behaviour.UnregisterTrackerEventHandler(this); } }
/// <summary> /// When this game object is destroyed, it unregisters itself as event handler /// </summary> void OnDestroy() { QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.UnregisterQCARInitErrorCallback(OnQCARInitializationError); } }
private void Start() { QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if (behaviour != null) { behaviour.RegisterTrackerEventHandler(this, true); } }
public void Start() { QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.RegisterTrackerEventHandler(this); } }
// Deinitialize the tracker when the Behaviour is destroyed. void OnDestroy() { // unregister from the QCARBehaviour QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.UnregisterTrackerEventHandler(this); } }
void Awake() { // Check for an initialization error on start. QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.RegisterQCARInitErrorCallback(OnQCARInitializationError); } }
public override void Bind() { this.View.mCameraFlashSettings.TappedOn += OnTappedToTurnOnFlash; this.View.mCloseButton.TappedOn += OnTappedOnCloseButton; this.View.mAboutLabel.TappedOn += OnTappedOnAboutButton; QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.RegisterOnPauseCallback(OnPause); } }
public override void UnBind() { this.View.mCameraFlashSettings.TappedOn -= OnTappedToTurnOnFlash; this.View.mCloseButton.TappedOn -= OnTappedOnCloseButton; this.View.UnLoadView(); QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.UnregisterOnPauseCallback(OnPause); } }
private void OnDestroy() { if (QCARManager.Instance.Initialized && this.mOnInitializedCalled) { this.Deinitialize(); } QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if (behaviour != null) { behaviour.UnregisterTrackerEventHandler(this); } }
private void Start() { if (KeepAliveAbstractBehaviour.Instance.KeepCloudRecoBehaviourAlive) { UnityEngine.Object.DontDestroyOnLoad(base.gameObject); } QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if (behaviour != null) { behaviour.RegisterTrackerEventHandler(this, false); } }
private void OnDestroy() { QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if (behaviour != null) { behaviour.UnregisterTrackerEventHandler(this); } TextTracker tracker = TrackerManager.Instance.GetTracker <TextTracker>(); if (tracker != null) { tracker.WordList.UnloadAllLists(); } }
void Awake() { mPopUpMsg = GetComponent <SampleInitErrorHandler>(); if (!mPopUpMsg) { mPopUpMsg = gameObject.AddComponent <SampleInitErrorHandler>(); } // Check for an initialization error on start. QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.RegisterQCARInitErrorCallback(OnQCARInitializationError); } }
void OnDestroy() { InputController.BackButtonTapped -= OnBackButtonTapped; InputController.SingleTapped -= OnSingleTapped; InputController.DoubleTapped -= OnDoubleTapped; m_UIEventHandler.CloseView -= OnTappedOnCloseButton; m_UIEventHandler.GoToAboutPage -= OnAboutPageTapped; m_UIEventHandler.UnBind(); QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.UnregisterQCARInitErrorCallback(OnQCARInitializationError); } }
public override void Bind() { this.View.mCameraFlashSettings.TappedOn += OnTappedToTurnOnFlash; this.View.mAutoFocusSetting.TappedOn += OnTappedToTurnOnAutoFocus; this.View.mCloseButton.TappedOn += OnTappedOnCloseButton; this.View.mCameraFacing.TappedOnOption += OnTappedToTurnCameraFacing; this.View.mAboutLabel.TappedOn += OnTappedOnAboutButton; this.View.mExtendedTracking.TappedOn += OnTappedOnTracking; // register qcar started callback QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.RegisterQCARStartedCallback(EnableContinuousAutoFocus); qcarBehaviour.RegisterOnPauseCallback(OnPause); } }
/// <summary> /// sets various parameters on the Oculus scripts /// </summary> private static void SetOVRParameters(GameObject arCameraGameObject) { #if ENABLE_VUFORIA_OCULUS_INTEGRATION QCARAbstractBehaviour qcarBehaviour = arCameraGameObject.GetComponent <QCARAbstractBehaviour>(); // set black background color OVRCameraController ovrCameraController = arCameraGameObject.GetComponent <OVRCameraController>(); ovrCameraController.BackgroundColor = Color.black; ovrCameraController.FlipCorrectionInY = true; // set up cameras as Oculus expects them to be: qcarBehaviour.PrimaryCamera.depth = 1; OVRCamera leftOVRCamera = qcarBehaviour.PrimaryCamera.GetComponent <OVRCamera>(); leftOVRCamera.RightEye = false; qcarBehaviour.SecondaryCamera.depth = 0; OVRCamera rightOVRCamera = qcarBehaviour.SecondaryCamera.GetComponent <OVRCamera>(); rightOVRCamera.RightEye = true; #endif }
public override bool Init(CameraDevice.CameraDirection cameraDirection) { if (QCARRuntimeUtilities.IsPlayMode()) { cameraDirection = CameraDevice.CameraDirection.CAMERA_BACK; } if (this.InitCameraDevice((int)cameraDirection) == 0) { return(false); } this.mCameraDirection = cameraDirection; this.mCameraReady = true; if (this.CameraReady) { QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour)); if (behaviour != null) { behaviour.ResetClearBuffers(); behaviour.ConfigureVideoBackground(true); } } return(true); }
public override void UnBind() { this.View.mExtendedTracking.TappedOn -= OnTappedToTurnOnTraking; this.View.mCameraFlashSettings.TappedOn -= OnTappedToTurnOnFlash; this.View.mAutoFocusSetting.TappedOn -= OnTappedToTurnOnAutoFocus; this.View.mCameraFacing.TappedOnOption -= OnTappedToTurnCameraFacing; this.View.mDataSet.TappedOnOption -= OnTappedOnDataSet; this.View.mCloseButton.TappedOn -= OnTappedOnCloseButton; this.View.mAboutLabel.TappedOn -= OnTappedOnAboutButton; sExtendedTrackingIsEnabled = false; // unregister qcar started callback QCARAbstractBehaviour qcarBehaviour = (QCARAbstractBehaviour)FindObjectOfType(typeof(QCARAbstractBehaviour)); if (qcarBehaviour) { qcarBehaviour.UnregisterQCARStartedCallback(EnableContinuousAutoFocus); qcarBehaviour.UnregisterOnPauseCallback(OnPause); } this.View.UnLoadView(); mView = null; }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeInspector(); QCARAbstractBehaviour target = (QCARAbstractBehaviour)base.target; base.DrawDefaultInspector(); target.SetWorldCenterMode((QCARAbstractBehaviour.WorldCenterMode)EditorGUILayout.EnumPopup("World Center Mode", target.WorldCenterModeSetting, new GUILayoutOption[0])); bool allowSceneObjects = !EditorUtility.IsPersistent(base.target); if (target.WorldCenterModeSetting == QCARAbstractBehaviour.WorldCenterMode.SPECIFIC_TARGET) { TrackableBehaviour behaviour2 = (TrackableBehaviour)EditorGUILayout.ObjectField("World Center", target.WorldCenter, typeof(TrackableBehaviour), allowSceneObjects, new GUILayoutOption[0]); if (behaviour2 is WordAbstractBehaviour) { behaviour2 = null; EditorWindow.focusedWindow.ShowNotification(new GUIContent("Word behaviours cannot be selected as world center.")); } target.SetWorldCenter(behaviour2); } if (GUI.changed) { EditorUtility.SetDirty(target); } }